Skip to content

Commit

Permalink
arch/tile: Add driver to enable access to the user dynamic network.
Browse files Browse the repository at this point in the history
This network (the "UDN") connects all the cpus on the chip in a
wormhole-routed dynamic network.  Subrectangles of the chip can
be allocated by a "create" ioctl on /dev/hardwall, and then to access the
UDN in that rectangle, tasks must perform an "activate" ioctl on that
same file object after affinitizing themselves to a single cpu in
the region.  Sending a wormhole-routed message that tries to leave
that subrectangle causes all activated tasks to receive a SIGILL
(just as they would if they tried to access the UDN without first
activating themselves to a hardwall rectangle).

The original submission of this code to LKML had the driver
instantiated under /proc/tile/hardwall.  Now we just use a character
device for this, conventionally /dev/hardwall.  Some futures planning
for the TILE-Gx chip suggests that we may want to have other types of
devices that share the general model of "bind a task to a cpu, then
'activate' a file descriptor on a pseudo-device that gives access to
some hardware resource".  As such, we are using a device rather
than, for example, a syscall, to set up and activate this code.

As part of this change, the compat_ptr() declaration was fixed and used
to pass the compat_ioctl argument to the normal ioctl.  So far we limit
compat code to 2GB, so the difference between zero-extend and sign-extend
(the latter being correct, eventually) had been overlooked.

Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
  • Loading branch information
Chris Metcalf committed Jul 6, 2010
1 parent fb702b9 commit 9f9c038
Show file tree
Hide file tree
Showing 7 changed files with 874 additions and 6 deletions.
4 changes: 4 additions & 0 deletions arch/tile/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ config VMALLOC_RESERVE
hex
default 0x1000000

config HARDWALL
bool "Hardwall support to allow access to user dynamic network"
default y

endmenu # Tilera-specific configuration

menu "Bus options"
Expand Down
2 changes: 1 addition & 1 deletion arch/tile/include/asm/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ struct compat_shmid64_ds {

static inline void __user *compat_ptr(compat_uptr_t uptr)
{
return (void __user *)(unsigned long)uptr;
return (void __user *)(long)(s32)uptr;
}

static inline compat_uptr_t ptr_to_compat(void __user *uptr)
Expand Down
56 changes: 56 additions & 0 deletions arch/tile/include/asm/hardwall.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2010 Tilera Corporation. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, version 2.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
* NON INFRINGEMENT. See the GNU General Public License for
* more details.
*
* Provide methods for the HARDWALL_FILE for accessing the UDN.
*/

#ifndef _ASM_TILE_HARDWALL_H
#define _ASM_TILE_HARDWALL_H

#include <linux/ioctl.h>

#define HARDWALL_IOCTL_BASE 0xa2

/*
* The HARDWALL_CREATE() ioctl is a macro with a "size" argument.
* The resulting ioctl value is passed to the kernel in conjunction
* with a pointer to a little-endian bitmask of cpus, which must be
* physically in a rectangular configuration on the chip.
* The "size" is the number of bytes of cpu mask data.
*/
#define _HARDWALL_CREATE 1
#define HARDWALL_CREATE(size) \
_IOC(_IOC_READ, HARDWALL_IOCTL_BASE, _HARDWALL_CREATE, (size))

#define _HARDWALL_ACTIVATE 2
#define HARDWALL_ACTIVATE \
_IO(HARDWALL_IOCTL_BASE, _HARDWALL_ACTIVATE)

#define _HARDWALL_DEACTIVATE 3
#define HARDWALL_DEACTIVATE \
_IO(HARDWALL_IOCTL_BASE, _HARDWALL_DEACTIVATE)

#ifndef __KERNEL__

/* This is the canonical name expected by userspace. */
#define HARDWALL_FILE "/dev/hardwall"

#else

/* Hook for /proc/tile/hardwall. */
struct seq_file;
int proc_tile_hardwall_show(struct seq_file *sf, void *v);

#endif

#endif /* _ASM_TILE_HARDWALL_H */
17 changes: 14 additions & 3 deletions arch/tile/include/asm/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* NOTE: we don't include <linux/ptrace.h> or <linux/percpu.h> as one
* normally would, due to #include dependencies.
*/
#include <linux/types.h>
#include <asm/ptrace.h>
#include <asm/percpu.h>

Expand All @@ -29,7 +30,6 @@

struct task_struct;
struct thread_struct;
struct list_head;

typedef struct {
unsigned long seg;
Expand Down Expand Up @@ -74,6 +74,9 @@ struct async_tlb {
unsigned long address; /* what address faulted? */
};

#ifdef CONFIG_HARDWALL
struct hardwall_info;
#endif

struct thread_struct {
/* kernel stack pointer */
Expand All @@ -100,6 +103,12 @@ struct thread_struct {
/* Any other miscellaneous processor state bits */
unsigned long proc_status;
#endif
#ifdef CONFIG_HARDWALL
/* Is this task tied to an activated hardwall? */
struct hardwall_info *hardwall;
/* Chains this task into the list at hardwall->list. */
struct list_head hardwall_list;
#endif
#if CHIP_HAS_TILE_DMA()
/* Async DMA TLB fault information */
struct async_tlb dma_async_tlb;
Expand Down Expand Up @@ -194,8 +203,6 @@ static inline void release_thread(struct task_struct *dead_task)

extern int kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);

/* Helper routines for setting home cache modes at exec() time. */


/*
* Return saved (kernel) PC of a blocked thread.
Expand Down Expand Up @@ -240,6 +247,10 @@ struct siginfo;
extern void arch_coredump_signal(struct siginfo *, struct pt_regs *);
#define arch_coredump_signal arch_coredump_signal

/* Info on this processor (see fs/proc/cpuinfo.c) */
struct seq_operations;
extern const struct seq_operations cpuinfo_op;

/* Provide information about the chip model. */
extern char chip_model[64];

Expand Down
1 change: 1 addition & 0 deletions arch/tile/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ obj-y := backtrace.o entry.o init_task.o irq.o messaging.o \
setup.o signal.o single_step.o stack.o sys.o time.o traps.o \
intvec_$(BITS).o regs_$(BITS).o tile-desc_$(BITS).o

obj-$(CONFIG_HARDWALL) += hardwall.o
obj-$(CONFIG_TILEGX) += futex_64.o
obj-$(CONFIG_COMPAT) += compat.o compat_signal.o
obj-$(CONFIG_SMP) += smpboot.o smp.o tlb.o
Expand Down
Loading

0 comments on commit 9f9c038

Please sign in to comment.