spufs: The SPU file system
Subsystems (4)
PATCH 1/7 spufs: The SPU file system
This is a work-in-progress version of the SPU file system.
Since the previous version, a lot of features have been added and a number of bugs has been fixed. We now support doing read() on the /run file to start executing code on an SPU. Some files have been added to give access to more hardware features, especially the signal notification channels.
Most importantly, we now have a working context save and restore functionality for SPEs, which is written by Mark Nutter and will eventually lead to having a scheduler for SPUs in the kernel. Since this has grown the file system a lot, I now split it up into a few smaller patches.
Within the next weeks, we will do some larger reworks on the code base, so this version is probably the last one that is binary compatible to the earlier releases.
If you have specific requirements that are not met by spufs in its present incarnation, now would be a good time to tell us.
--
Documentation/filesystems/spufs.txt | 107 +++++ arch/ppc/kernel/ppc_ksyms.c | 1 arch/ppc64/kernel/Makefile | 1 arch/ppc64/kernel/spu_base.c | 733 ++++++++++++++++++++++++++++++++++++ arch/ppc64/mm/hash_utils.c | 1 fs/Kconfig | 10 fs/Makefile | 1 fs/spufs/Makefile | 3 fs/spufs/context.c | 67 +++ fs/spufs/file.c | 716 +++++++++++++++++++++++++++++++++++ fs/spufs/inode.c | 435 +++++++++++++++++++++ fs/spufs/spufs.h | 65 +++ include/asm-ppc64/spu.h | 473 +++++++++++++++++++++++ mm/memory.c | 2 14 files changed, 2614 insertions(+), 1 deletion(-)
Documentation/filesystems/spufs.txt +107 -0
@@ -0,0 +1,107 @@ + *** The SPU file system *** + +Spufs is used to run code on the Synergistic Processing Units +of the Cell Processor (a.k.a Broadband Engine). + +The file system provides a name space similar to posix shared +memory or message queues. Users that have write permissions +on the file system can create directories in the spufs root. + +Every directory represents an SPU context, which is currently +mapped to a physical SPU, but that is going to change to a +virtualization scheme in future updates. + +An SPU context directory contains a predefined set of files +used for manipulating the state of the logical SPU. Users +can change permissions on those files, but not actually +add or remove files without removing the complete directory. + +The current set of files is: + +/mem the contents of the local store memory of the SPU. + This can be accessed like a regular shared memory + file and contains both code and data in the address + space of the SPU. + The implemented file operations currently are read(), + write() and mmap(). We will need our own address + space operations as soon as we allow the SPU context + to be scheduled away from the physical SPU into + page cache. + +/run A stub file that lets us do the spu_run() call. + spu_run suspends the current thread from the host + CPU and transfers the flow of execution to the SPU. + The spu_run call returns to the calling thread when a + state is entered that can not be handled by the kernel, + e.g. an error in the SPU code or an exit() from it. + When a signal is pending for the host CPU thread, the + ioctl is interrupted and the SPU stopped in order to + call the signal handler. + Currently, there are three different methods how + spu_run can be entered with the /run file: + - The spu_run() syscall (see other patch) + - ioctl(), as used in previous versions + - read(), to return only the status, while the npc + is updated in kernel or through the /npc file. + Very likely, the concept of the /run file will change + in the near future and it will be replaced with + something completely different. + +/mbox The first SPU to CPU communication mailbox. This file + is read-only and can be read in units of 32 bits. + The file can only be used in non-blocking mode and + it even poll() will not block on it. + When no data is available in the mailbox, read() returns + EAGAIN. + +/ibox The second SPU to CPU communication mailbox. This file + is similar to the first mailbox file, but can be read + in blocking I/O mode, and the poll familiy of system + calls can be used to wait for it. + +/wbox The CPU to SPU communation mailbox. It is write-only + can can be written in units of 32 bits. If the mailbox + is full, write() will block and poll can be used to + wait for it becoming empty again. + +/mbox_stat +/ibox_stat +/wbox_stat + Read-only files that contain the length of the current + queue, i.e. how many words can be read from mbox or + ibox or how many words can be written to wbox without + blocking. + The files can be read only in 4-byte units and return + a big-endian binary integer number. + +/npc The next program counter of the SPU. The representation + is an ASCII string with the numeric value of the + next instruction to be executed. It can be used in + read/write mode. + +/signal1 +/signal2 + The two signal notification channels of an SPU. These + are read-write files that operate on a 32 bit word, + similar to the npc file. + Writing to one of these files triggers an interrupt on + the SPU. The value writting to the signal files can + be read from the SPU through a channel read or from + host user space through the file. + After the value has been read by the SPU, it is reset + to zero. + +/signal1_type +/signal2_type + These two files change the behavior of the signal1 and + signal2 notification files. The contain a numerical + ASCII string which is read as either "1" or "0". + In mode 0 (overwrite), the hardware replaces the contents + of the signal channel with the data that is written to it. + in mode 1 (logical OR), the hardware accumulates the bits + that are subsequently written to it. + +There are also a number of files that are only there for +debugging purposes and give low-level access to hardware +registers of an SPE. These will certainly go away and +should not be considered official interfaces.
arch/ppc64/kernel/Makefile +1 -0
@@ -53,6 +53,7 @@ obj-$(CONFIG_HVCS) += hvcserver.o obj-$(CONFIG_IBMVIO) += vio.o obj-$(CONFIG_XICS) += xics.o obj-$(CONFIG_MPIC) += mpic.o +obj-$(CONFIG_SPU_FS) += spu_base.o obj-$(CONFIG_PPC_PMAC) += pmac_setup.o pmac_feature.o pmac_pci.o \ pmac_time.o pmac_nvram.o pmac_low_i2c.o
arch/ppc64/kernel/spu_base.c +733 -0
733 lines not on this page · raw message
arch/ppc64/mm/hash_utils.c +1 -0
@@ -354,6 +354,7 @@ int hash_page(unsigned long ea, unsignedreturn ret; } +EXPORT_SYMBOL_GPL (hash_page);void flush_hash_page (unsigned long context,unsigned long ea,pte_t pte,int local)
fs/Kconfig +10 -0
@@ -845,6 +845,16 @@ config HUGETLBFS config HUGETLB_PAGE def_bool HUGETLBFS +config SPU_FS + tristate "SPU file system" + default m + depends on PPC_BPA + help + The SPU file system is used to access Synergistic Processing + Units on machines implementing the Broadband Processor + Architecture. + + config RAMFS bool default y
fs/Makefile +1 -0
@@ -98,3 +98,4 @@ obj-$(CONFIG_BEFS_FS) += befs/ obj-$(CONFIG_HOSTFS) += hostfs/ obj-$(CONFIG_HPPFS) += hppfs/ obj-$(CONFIG_DEBUG_FS) += debugfs/ +obj-$(CONFIG_SPU_FS) += spufs/
fs/spufs/Makefile +3 -0
@@ -0,0 +1,3 @@ +obj-$(CONFIG_SPU_FS) += spufs.o + +spufs-y += inode.o file.o context.o
fs/spufs/context.c +67 -0
67 lines not on this page · raw message
fs/spufs/file.c +716 -0
716 lines not on this page · raw message
fs/spufs/inode.c +435 -0
435 lines not on this page · raw message
fs/spufs/spufs.h +65 -0
65 lines not on this page · raw message
include/asm-ppc64/spu.h +473 -0
473 lines not on this page · raw message
mm/memory.c +2 -0
@@ -2062,6 +2062,8 @@ int __handle_mm_fault(struct mm_struct *return VM_FAULT_OOM ; } +EXPORT_SYMBOL_GPL (__handle_mm_fault); +#ifndef __PAGETABLE_PUD_FOLDED/* * Allocate page upper directory.
arch/ppc/kernel/ppc_ksyms.c +0 -1
@@ -324,7 +324,6 @@ EXPORT_SYMBOL(__res);EXPORT_SYMBOL (next_mmu_context);EXPORT_SYMBOL (set_context); -EXPORT_SYMBOL_GPL (__handle_mm_fault);/* For MOL */ EXPORT_SYMBOL (disarm_decr);#ifdef CONFIG_PPC_STD_MMU extern long mol_trampoline;
Hi Arnd,
Quoted 13 lines
This is a work-in-progress version of the SPU file system.
fs/spufs/file.c 2005-08-25 22:27:19.503976592 -0400 renamed from fs/spufs/file.c 1969-12-31 19:00:00.000000000 -0500 +8
-0@@ -0,0 +1,716 @@ +/* + * SPU file system -- file contents +/* low-level mailbox write */ +size_t spu_wbox_write(struct spu *spu, u32 data) +{ + int ret; + + spin_lock_irq(&spu->register_lock);
fs/spufs/file.c 2005-08-25 22:27:19.503976592 -0400 line 18
Quoted 10 lines
fs/spufs/file.c 2005-08-25 22:27:19.503976592 -0400 renamed from fs/spufs/file.c 1969-12-31 19:00:00.000000000 -0500 +10
-0+ + if (in_be32(&spu->problem->mb_stat_R) & 0x00ff00) { + /* we have space to write wbox_data to */ + out_be32(&spu->problem->spu_mb_W, data); + ret = 4; + } else { + /* make sure we get woken up by the interrupt when space + becomes available */ + out_be64(&spu->priv1->int_mask_class2_RW, + in_be64(&spu->priv1->int_mask_class2_RW) | 0x10);
I am confused. The code is architecture specific and does device I/O. Why do you want to put this in fs/ and not drivers/?
Pekka
Quoted 2 lines · Pekka Enberg
I am confused. The code is architecture specific and does device I/O. Why do you want to put this in
fs/and notdrivers/?
I never really thought of it as a device driver but rather an architecture extension, so it started out in arch/ppc64/kernel. Since most of the code is interacting with VFS, it is now in fs/spufs. I don't really care about the location, but I among the possible places to put the code (with the unified arch/powerpc tree), I'd suggest (best first)
1) arch/powerpc/platforms/cell
2) arch/powerpc/spe
3) fs/spufs
4) drivers/spe
1) would be the place where I want to have the low-level code (currently arch/ppc64/kernel/spu_base.c) anyway, so it makes sense to have everything in there that I maintain.
2) might work better if we at a later point have multiple platform types in arch/powerpc that use SPEs, e.g if we want to keep Playstation code separate from generic Cell.
Arnd <><
Quoted 6 lines · Arnd Bergmann
I never really thought of it as a device driver but rather an architecture extension, so it started out in
arch/ppc64/kernel. Since most of the code is interacting with VFS, it is now in fs/spufs. I don't really care about the location, but I among the possible places to put the code (with the unifiedarch/powerpctree), I'd suggest (best first)
Quoted 8 lines
1)
arch/powerpc/platforms/cell
2)arch/powerpc/spe
3) fs/spufs
4)drivers/spe1) would be the place where I want to have the low-level code (currently
arch/ppc64/kernel/spu_base.c) anyway, so it makes sense to have everything in there that I maintain.
I am happy with 1, 2, and 4. You could, of course, abstract away the general purpose parts of spufs (for example, if we had other similar architecture extensions that could share the code) and put them in 3 but that would probably just introduce unnecessary complexity.
Pekka
Quoted 17 lines · Arnd Bergmann
Quoted 2 lines · Pekka Enberg
I am confused. The code is architecture specific and does device I/O. Why do you want to put this in
fs/and notdrivers/?I never really thought of it as a device driver but rather an architecture extension, so it started out in
arch/ppc64/kernel. Since most of the code is interacting with VFS, it is now in fs/spufs. I don't really care about the location, but I among the possible places to put the code (with the unifiedarch/powerpctree), I'd suggest (best first)1)
arch/powerpc/platforms/cell
2)arch/powerpc/spe
3) fs/spufs
4)drivers/spe
Quoted 7 lines
1) would be the place where I want to have the low-level code (currently
arch/ppc64/kernel/spu_base.c) anyway, so it makes sense to have everything in there that I maintain.
2) might work better if we at a later point have multiple platform types inarch/powerpcthat use SPEs, e.g if we want to keep Playstation code separate from generic Cell.
I think putting it in 'arch/powerpc/platforms/cell' is fine for now. We'll be better able to judge if we need to and how to split off platform specifics when we have code for more cell platforms.
-Geoff