cell: patches for 2.6.18
cover cell: patches for 2.6.18
Here are the cell patches I promised to submit ages ago for inclusion in 2.6.18. I refreshed them to apply on the union of 2.6.17 and powerpc.git.
Arnd <><
--
PATCH 1/20 cell: add RAS support
From: Benjamin Herrenschmidt <[email protected]>
This is a first version of support for the Cell BE "Reliability, Availability and Serviceability" features.
It doesn't yet handle some of the RAS interrupts (the ones described in iic_is/iic_irr), I'm still working on a proper way to expose these. They are essentially a cascaded controller by themselves (sic !) though I may just handle them locally to the iic driver. I need also to sync with David Erb on the way he hooked in the performance monitor interrupt.
So that's all for 2.6.17 and I'll do more work on that with my rework of the powerpc interrupt layer that I'm hacking on at the moment.
arch/powerpc/kernel/head_64.S +29 -0
@@ -316,6 +316,21 @@ label##_pSeries: \ mtspr SPRN_SPRG1,r13; /* save r13 */ \ EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common) +#define HSTD_EXCEPTION_PSERIES(n, label) \ + . = n; \ + .globl label##_pSeries; \ +label##_pSeries: \ + HMT_MEDIUM; \ + mtspr SPRN_SPRG1,r20; /* save r20 */ \ + mfspr r20,SPRN_HSRR0; /* copy HSRR0 to SRR0 */ \ + mtspr SPRN_SRR0,r20; \ + mfspr r20,SPRN_HSRR1; /* copy HSRR0 to SRR0 */ \ + mtspr SPRN_SRR1,r20; \ + mfspr r20,SPRN_SPRG1; /* restore r20 */ \ + mtspr SPRN_SPRG1,r13; /* save r13 */ \ + EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common) + + #define STD_EXCEPTION_ISERIES(n, label, area) \ .globl label##_iSeries; \ label##_iSeries: \
@@ -544,8 +559,17 @@ system_call_pSeries: STD_EXCEPTION_PSERIES(0xf20, altivec_unavailable) +#ifdef CONFIG_CBE_RAS + HSTD_EXCEPTION_PSERIES(0x1200, cbe_system_error) +#endif /* CONFIG_CBE_RAS */ STD_EXCEPTION_PSERIES(0x1300, instruction_breakpoint) +#ifdef CONFIG_CBE_RAS + HSTD_EXCEPTION_PSERIES(0x1600, cbe_maintenance) +#endif /* CONFIG_CBE_RAS */ STD_EXCEPTION_PSERIES(0x1700, altivec_assist) +#ifdef CONFIG_CBE_RAS + HSTD_EXCEPTION_PSERIES(0x1800, cbe_thermal) +#endif /* CONFIG_CBE_RAS */ . = 0x3000
@@ -827,6 +851,11 @@ machine_check_common: #else STD_EXCEPTION_COMMON(0x1700, altivec_assist, .unknown_exception) #endif +#ifdef CONFIG_CBE_RAS + STD_EXCEPTION_COMMON(0x1200, cbe_system_error, .cbe_system_error_exception) + STD_EXCEPTION_COMMON(0x1600, cbe_maintenance, .cbe_maintenance_exception) + STD_EXCEPTION_COMMON(0x1800, cbe_thermal, .cbe_thermal_exception) +#endif /* CONFIG_CBE_RAS */ /* * Here we have detected that the kernel stack pointer is bad.
arch/powerpc/platforms/cell/Kconfig +4 -0
@@ -16,4 +16,8 @@ config SPUFS_MMAP select MEMORY_HOTPLUG default y +config CBE_RAS + bool "RAS features for bare metal Cell BE" + default y + endmenu
arch/powerpc/platforms/cell/Makefile +2 -1
@@ -1,5 +1,6 @@ obj-y += interrupt.o iommu.o setup.o spider-pic.o -obj-y += pervasive.o +obj-y += cbe_regs.o pervasive.o +obj-$(CONFIG_CBE_RAS) += ras.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SPU_FS) += spu-base.o spufs/
arch/powerpc/platforms/cell/pervasive.c +21 -83
164 lines not on this page · raw message
arch/powerpc/platforms/cell/ras.c new file +112 -0
112 lines not on this page · raw message
arch/powerpc/platforms/cell/ras.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef RAS_H +#define RAS_H + +extern void cbe_system_error_exception (struct pt_regs *regs); +extern void cbe_maintenance_exception (struct pt_regs *regs); +extern void cbe_thermal_exception (struct pt_regs *regs); +extern void cbe_ras_init (void ); + +#endif /* RAS_H */
arch/powerpc/platforms/cell/setup.c +9 -1
@@ -52,7 +52,9 @@#include "interrupt.h" #include "iommu.h" +#include "cbe_regs.h" #include "pervasive.h" +#include "ras.h" #ifdef DEBUG #define DBG(fmt...) udbg_printf(fmt)
@@ -82,6 +84,12 @@ static void __init cell_setup_arch(void) ppc_md.init_IRQ = iic_init_IRQ; ppc_md.get_irq = iic_get_irq; +cbe_regs_init (); + +#ifdef CONFIG_CBE_RAS +cbe_ras_init (); +#endif +#ifdef CONFIG_SMP smp_init_cell ();#endif
@@ -98,7 +106,7 @@ static void __init cell_setup_arch(void)init_pci_config_tokens ();find_and_init_phbs ();spider_init_IRQ (); -cell_pervasive_init (); +cbe_pervasive_init ();#ifdef CONFIG_DUMMY_CONSOLE conswitchp = &dummy_con;#endif
include/asm-powerpc/reg.h +2 -0
@@ -386,6 +386,8 @@#define SRR1_WAKEMT 0x00280000/* mtctrl */ #define SRR1_WAKEDEC 0x00180000/* Decrementer interrupt */ #define SRR1_WAKETHERM 0x00100000/* Thermal management interrupt */ +#define SPRN_HSRR0 0x13A/* Save/Restore Register 0 */ +#define SPRN_HSRR1 0x13B/* Save/Restore Register 1 */ #ifndef SPRN_SVR #define SPRN_SVR 0x11E/* System Version Register */
arch/powerpc/platforms/cell/pervasive.h +4 -33
@@ -25,38 +25,9 @@#ifndef PERVASIVE_H #define PERVASIVE_H -struct pmd_regs { -u8 pad_0x0000_0x0800[0x0800 -0x0000 ];/* 0x0000 */ - -/* Thermal Sensor Registers */ -u64 ts_ctsr1;/* 0x0800 */ -u64 ts_ctsr2;/* 0x0808 */ -u64 ts_mtsr1;/* 0x0810 */ -u64 ts_mtsr2;/* 0x0818 */ -u64 ts_itr1;/* 0x0820 */ -u64 ts_itr2;/* 0x0828 */ -u64 ts_gitr;/* 0x0830 */ -u64 ts_isr;/* 0x0838 */ -u64 ts_imr;/* 0x0840 */ -u64 tm_cr1;/* 0x0848 */ -u64 tm_cr2;/* 0x0850 */ -u64 tm_simr;/* 0x0858 */ -u64 tm_tpr;/* 0x0860 */ -u64 tm_str1;/* 0x0868 */ -u64 tm_str2;/* 0x0870 */ -u64 tm_tsr;/* 0x0878 */ - -/* Power Management */ -u64 pm_control;/* 0x0880 */ -#define PMD_PAUSE_ZERO_CONTROL 0x10000 -u64 pm_status;/* 0x0888 */ - -/* Time Base Register */ -u64 tbr;/* 0x0890 */ - -u8 pad_0x0898_0x1000 [0x1000 -0x0898 ];/* 0x0898 */ -}; - -void __init cell_pervasive_init (void ); +extern void cbe_pervasive_init (void ); +extern void cbe_system_error_exception (struct pt_regs *regs); +extern void cbe_maintenance_exception (struct pt_regs *regs); +extern void cbe_thermal_exception (struct pt_regs *regs);#endif
arch/powerpc/platforms/cell/cbe_regs.h new file +129 -0
129 lines not on this page · raw message
arch/powerpc/platforms/cell/interrupt.c +9 -28
@@ -33,29 +33,10 @@#include <asm/ptrace.h> #include "interrupt.h" - -struct iic_pending_bits { -u32 data; -u8 flags; -u8 class; -u8 source; -u8 prio; -}; - -enum iic_pending_flags { -IIC_VALID =0x80 , -IIC_IPI =0x40 , -}; - -struct iic_regs { -struct iic_pending_bits pending; -struct iic_pending_bits pending_destr; -u64 generate; -u64 prio; -}; +#include "cbe_regs.h" struct iic { -struct iic_regs __iomem *regs; +struct cbe_iic_thread_regs __iomem *regs;u8 target_id; };
@@ -115,7 +96,7 @@ static struct hw_interrupt_type iic_pic .end = iic_end, }; -static int iic_external_get_irq (struct iic_pending_bits pending) +static int iic_external_get_irq (struct cbe_iic_pending_bits pending) {int irq;unsigned char node, unit;
@@ -168,15 +149,15 @@ int iic_get_irq(struct pt_regs *regs) {struct iic *iic;int irq; -struct iic_pending_bits pending; +struct cbe_iic_pending_bits pending; iic = &__get_cpu_var (iic); *(unsigned long *) &pending =in_be64 ((unsigned long __iomem *) &iic->regs->pending_destr); irq =-1 ; -if (pending.flags &IIC_VALID ) { -if (pending.flags &IIC_IPI ) { +if (pending.flags &CBE_IIC_IRQ_VALID ) { +if (pending.flags &CBE_IIC_IRQ_IPI ) { irq =IIC_IPI_OFFSET + (pending.prio >>4 );/* if (irq > 0x80)
@@ -226,7 +207,7 @@ static int setup_iic_hardcoded(void) regs +=0x20 ;printk (KERN_INFO "IIC for CPU %d at %lx\n" , cpu, regs); - iic->regs =ioremap (regs,sizeof (struct iic_regs )); + iic->regs =ioremap (regs,sizeof (struct cbe_iic_thread_regs )); iic->target_id = (nodeid <<4 ) + ((cpu &1 ) ?0xf :0xe ); }
@@ -267,12 +248,12 @@ static int setup_iic(void) } iic = &per_cpu (iic, np[0 ]); - iic->regs =ioremap (regs[0 ],sizeof (struct iic_regs )); + iic->regs =ioremap (regs[0 ],sizeof (struct cbe_iic_thread_regs )); iic->target_id = ((np[0 ] &2 ) <<3 ) + ((np[0 ] &1 ) ?0xf :0xe );printk ("IIC for CPU %d at %lx mapped to %p\n" , np[0 ], regs[0 ], iic->regs); iic = &per_cpu (iic, np[1 ]); - iic->regs =ioremap (regs[2 ],sizeof (struct iic_regs )); + iic->regs =ioremap (regs[2 ],sizeof (struct cbe_iic_thread_regs )); iic->target_id = ((np[1 ] &2 ) <<3 ) + ((np[1 ] &1 ) ?0xf :0xe );printk ("IIC for CPU %d at %lx mapped to %p\n" , np[1 ], regs[2 ], iic->regs);
arch/powerpc/kernel/prom.c +43 -0
46 lines not on this page · raw message
arch/powerpc/platforms/cell/cbe_regs.c new file +128 -0
128 lines not on this page · raw message
include/asm-powerpc/prom.h +3 -0
@@ -238,5 +238,8 @@ void of_parse_dma_window(struct device_nextern void kdump_move_device_tree (void ); +/* CPU OF node matching */ +struct device_node *of_get_cpu_node (int cpu,unsigned int *thread); +#endif /* __KERNEL__ */ #endif /* _POWERPC_PROM_H */
arch/powerpc/configs/cell_defconfig +1 -0
@@ -133,6 +133,7 @@ CONFIG_CELL_IIC=y # CONFIG_SPU_FS=m CONFIG_SPUFS_MMAP=y +CONFIG_CBE_RAS=y # # Kernel options
--
Re: [Cbe-oss-dev] [patch 01/20] cell: add RAS support
Quoted 4 lines · On Mon, Jun 19, 2006 at 08:33:16PM +0200, [email protected] wrote:
From: Benjamin Herrenschmidt <[email protected]>
This is a first version of support for the Cell BE "Reliability, Availability and Serviceability" features.
Does it really make sense to do this under a config option? I don't see why anyone would not want to know that their machine is about to melt.
-Olof
Re: [Cbe-oss-dev] [patch 01/20] cell: add RAS support
Quoted 7 lines · Olof Johansson
Quoted 3 lines
This is a first version of support for the Cell BE "Reliability, Availability and Serviceability" features.
Does it really make sense to do this under a config option? I don't see why anyone would not want to know that their machine is about to melt.
You can only have that when running on bare metal. Machines that run on a hypervisor can't run that code.
It probably makes sense to auto-select that option for CONFIG_CELL_BLADE though.
Arnd <><
Re: [Cbe-oss-dev] [patch 01/20] cell: add RAS support
Quoted 10 lines · Arnd Bergmann
Quoted 7 lines · Olof Johansson
Quoted 3 lines
This is a first version of support for the Cell BE "Reliability, Availability and Serviceability" features.
Does it really make sense to do this under a config option? I don't see why anyone would not want to know that their machine is about to melt.
You can only have that when running on bare metal. Machines that run on a hypervisor can't run that code.
Well, it's harmless to build it in even on hypervisor systems, right?
Quoted 2 lines
It probably makes sense to auto-select that option for
CONFIG_CELL_BLADEthough.
Sounds like a reasonable trade-off.
-Olof
Re: [Cbe-oss-dev] [patch 01/20] cell: add RAS support
Quoted 7 lines · Olof Johansson
Quoted 6 lines · Arnd Bergmann
Quoted 5 lines · Olof Johansson
Quoted 3 lines
This is a first version of support for the Cell BE "Reliability, Availability and Serviceability" features.
Does it really make sense to do this under a config option? I don't
Quoted 8 lines
see
Quoted 1 line
Quoted 1 line
why anyone would not want to know that their machine is about to
melt.
Quoted 3 lines
Quoted 1 line
You can only have that when running on bare metal. Machines that run on a hypervisor can't run that code.
Well, it's harmless to build it in even on hypervisor systems, right?
Harmless if you have a lot of RAM...
Quoted 5 lines
Quoted 1 line
It probably makes sense to auto-select that option for
CONFIG_CELL_BLADEQuoted 1 line
though.
Sounds like a reasonable trade-off.
If its always built in, then I guess we don't need the conditionals in cell/setup.c:
+#ifdef CONFIG_CBE_RAS
+ cbe_ras_init();
+#endif
-Geoff
Re: [Cbe-oss-dev] [patch 01/20] cell: add RAS support
In reply to Olof JohanssonQuoted 8 lines · Olof Johansson
Quoted 4 lines · On Mon, Jun 19, 2006 at 08:33:16PM +0200, [email protected] wrote:
From: Benjamin Herrenschmidt <[email protected]>
This is a first version of support for the Cell BE "Reliability, Availability and Serviceability" features.
Does it really make sense to do this under a config option? I don't see why anyone would not want to know that their machine is about to melt.
Well, it's not quite clear yet wether that thing works at all at this point :) It shuld be a config option (becasue those things don't make sense on LPAR cells) but maybe not a selectable one ...
Ben.
PATCH 2/20 cell: fix interrupt priority handling
In reply to [email protected]Checking the priority field to test for irq validity is completely bogus and breaks with future external interrupt controllers.
---
arch/powerpc/platforms/cell/interrupt.c +1 -2
@@ -117,8 +117,7 @@ static int iic_external_get_irq(struct c* One of these units can be connected * to an external interrupt controller. */ -if (pending.prio >0x3f || - pending.class !=2 ) +if (pending.class !=2 )break ; irq =IIC_EXT_OFFSET +spider_get_irq (node)
--
PATCH 3/20 cell: update defconfig
In reply to [email protected]Enable some of the most requested features in defconfig and refresh with the latest powerpc.git Kconfig files.
---
arch/powerpc/configs/cell_defconfig +17 -12
@@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Linux kernel version: 2.6.16 -# Thu Mar 23 20:48:09 2006 +# Linux kernel version: 2.6.17 +# Mon Jun 19 17:23:03 2006 # CONFIG_PPC64=y CONFIG_64BIT=y
@@ -11,6 +11,7 @@ CONFIG_GENERIC_HARDIRQS=y CONFIG_RWSEM_XCHGADD_ALGORITHM=y CONFIG_GENERIC_HWEIGHT=y CONFIG_GENERIC_CALIBRATE_DELAY=y +CONFIG_GENERIC_FIND_NEXT_BIT=y CONFIG_PPC=y CONFIG_EARLY_PRINTK=y CONFIG_COMPAT=y
@@ -55,7 +56,7 @@ CONFIG_SYSCTL=y # CONFIG_AUDIT is not set CONFIG_IKCONFIG=y CONFIG_IKCONFIG_PROC=y -# CONFIG_CPUSETS is not set +CONFIG_CPUSETS=y # CONFIG_RELAY is not set CONFIG_INITRAMFS_SOURCE="" CONFIG_CC_OPTIMIZE_FOR_SIZE=y
@@ -116,6 +117,7 @@ CONFIG_PPC_MULTIPLATFORM=y # CONFIG_PPC_PMAC is not set # CONFIG_PPC_MAPLE is not set CONFIG_PPC_CELL=y +CONFIG_PPC_SYSTEMSIM=y # CONFIG_U3_DART is not set CONFIG_PPC_RTAS=y # CONFIG_RTAS_ERROR_LOGGING is not set
@@ -153,20 +155,24 @@ CONFIG_FORCE_MAX_ZONEORDER=13 CONFIG_KEXEC=y # CONFIG_CRASH_DUMP is not set CONFIG_IRQ_ALL_CPUS=y -# CONFIG_NUMA is not set +CONFIG_NUMA=y +CONFIG_NODES_SHIFT=4 CONFIG_ARCH_SELECT_MEMORY_MODEL=y -CONFIG_ARCH_FLATMEM_ENABLE=y CONFIG_ARCH_SPARSEMEM_ENABLE=y CONFIG_SELECT_MEMORY_MODEL=y # CONFIG_FLATMEM_MANUAL is not set # CONFIG_DISCONTIGMEM_MANUAL is not set CONFIG_SPARSEMEM_MANUAL=y CONFIG_SPARSEMEM=y +CONFIG_NEED_MULTIPLE_NODES=y CONFIG_HAVE_MEMORY_PRESENT=y # CONFIG_SPARSEMEM_STATIC is not set CONFIG_SPARSEMEM_EXTREME=y -# CONFIG_MEMORY_HOTPLUG is not set +CONFIG_MEMORY_HOTPLUG=y CONFIG_SPLIT_PTLOCK_CPUS=4 +CONFIG_MIGRATION=y +CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID=y +CONFIG_ARCH_MEMORY_PROBE=y # CONFIG_PPC_64K_PAGES is not set CONFIG_SCHED_SMT=y CONFIG_PROC_DEVICETREE=y
@@ -183,6 +189,7 @@ CONFIG_GENERIC_ISA_DMA=y # CONFIG_PPC_INDIRECT_PCI is not set CONFIG_PCI=y CONFIG_PCI_DOMAINS=y +CONFIG_PCIEPORTBUS=y # CONFIG_PCI_DEBUG is not set #
@@ -477,7 +484,7 @@ CONFIG_DM_MULTIPATH=m # CONFIG_NETDEVICES=y # CONFIG_DUMMY is not set -# CONFIG_BONDING is not set +CONFIG_BONDING=y # CONFIG_EQUALIZER is not set # CONFIG_TUN is not set
@@ -625,6 +632,7 @@ CONFIG_SERIAL_NONSTANDARD=y # CONFIG_N_HDLC is not set # CONFIG_SPECIALIX is not set # CONFIG_SX is not set +# CONFIG_RIO is not set # CONFIG_STALDRV is not set #
@@ -767,6 +775,7 @@ CONFIG_I2C_ALGOBIT=y # Multimedia devices # # CONFIG_VIDEO_DEV is not set +CONFIG_VIDEO_V4L2=y # # Digital Video Broadcasting Devices
@@ -1055,11 +1064,7 @@ CONFIG_DEBUGGER=y # CONFIG_XMON is not set CONFIG_IRQSTACKS=y # CONFIG_BOOTX_TEXT is not set -# CONFIG_PPC_EARLY_DEBUG_LPAR is not set -# CONFIG_PPC_EARLY_DEBUG_G5 is not set -# CONFIG_PPC_EARLY_DEBUG_RTAS is not set -# CONFIG_PPC_EARLY_DEBUG_MAPLE is not set -# CONFIG_PPC_EARLY_DEBUG_ISERIES is not set +# CONFIG_PPC_EARLY_DEBUG is not set # # Security options
--
PATCH 4/20 cell: register SPUs as sysdevs
In reply to [email protected]From: Jeremy Kerr <[email protected]>
SPUs are registered as system devices, exposing attributes through sysfs. Since the sysdev includes a kref, we can remove the one in struct spu (it isn't used at the moment anyway).
Currently only the interrupt source and numa node attributes are added.
arch/powerpc/platforms/cell/spu_base.c +54 -0
@@ -649,6 +649,46 @@ out:return ret; } +struct sysdev_class spu_sysdev_class = { +set_kset_name ("spu" ) +}; + +static ssize_t spu_show_isrc (struct sys_device *sysdev,char *buf) +{ + struct spu *spu = container_of(sysdev, struct spu, sysdev); +return sprintf (buf,"%d\n" , spu->isrc); + +} +static SYSDEV_ATTR(isrc, 0400, spu_show_isrc, NULL); + +extern int attach_sysdev_to_node (struct sys_device *dev,int nid); + +static int spu_create_sysdev (struct spu *spu) +{ +int ret; + + spu->sysdev.id = spu->number; + spu->sysdev.cls = &spu_sysdev_class; + ret =sysdev_register (&spu->sysdev); +if (ret) { +printk (KERN_ERR "Can't register SPU %d with sysfs\n" , + spu->number); +return ret; + } + +sysdev_create_file (&spu->sysdev, &attr_isrc); +sysfs_add_device_to_node (&spu->sysdev, spu->nid); + +return 0 ; +} + +static void spu_destroy_sysdev (struct spu *spu) +{ +sysdev_remove_file (&spu->sysdev, &attr_isrc); +sysfs_remove_device_from_node (&spu->sysdev, spu->nid); +sysdev_unregister (&spu->sysdev); +} +static int __init create_spu (struct device_node *spe) {struct spu *spu;
@@ -695,6 +735,10 @@ static int __init create_spu(struct deviif (ret) goto out_unmap; + ret =spu_create_sysdev (spu); +if (ret) + goto out_free_irqs; +list_add (&spu->list, &spu_list);mutex_unlock (&spu_mutex);
@@ -703,6 +747,9 @@ static int __init create_spu(struct devi spu->problem, spu->priv1, spu->priv2, spu->number); goto out; +out_free_irqs: +spu_free_irqs (spu); + out_unmap:mutex_unlock (&spu_mutex);spu_unmap (spu);
@@ -716,6 +763,7 @@ static void destroy_spu(struct spu *spu) {list_del_init (&spu->list); +spu_destroy_sysdev (spu);spu_free_irqs (spu);spu_unmap (spu);kfree (spu);
@@ -728,6 +776,7 @@ static void cleanup_spu_base(void)list_for_each_entry_safe (spu, tmp, &spu_list, list)destroy_spu (spu);mutex_unlock (&spu_mutex); +sysdev_class_unregister (&spu_sysdev_class); }module_exit (cleanup_spu_base);
@@ -736,6 +785,11 @@ static int __init init_spu_base(void)struct device_node *node;int ret; +/* create sysdev class for spus */ + ret =sysdev_class_register (&spu_sysdev_class); +if (ret) +return ret; + ret = -ENODEV ;for (node =of_find_node_by_type (NULL ,"spe" ); node; node =of_find_node_by_type (node,"spe" )) {
include/asm-powerpc/spu.h +3 -2
@@ -25,8 +25,8 @@#ifdef __KERNEL__#include <linux/config.h> -#include <linux/kref.h> #include <linux/workqueue.h> +#include <linux/sysdev.h> #define LS_SIZE (256 * 1024)#define LS_ADDR_MASK (LS_SIZE - 1)
@@ -123,7 +123,6 @@ struct spu {u64 flags;u64 dar;u64 dsisr; -struct kref kref;size_t ls_size;unsigned int slb_replace;struct mm_struct *mm;
@@ -144,6 +143,8 @@ struct spu {char irq_c0[8 ];char irq_c1[8 ];char irq_c2[8 ]; + +struct sys_device sysdev; };struct spu *spu_alloc (void );
--
PATCH 5/20 cell: always build spu base into the kernel
In reply to [email protected]The spu_base module is rather deeply intermixed with the core kernel, so it makes sense to have that built-in. This will let us extend the base in the future without having to export more core symbols just for it.
arch/powerpc/platforms/cell/Makefile +1 -5
@@ -3,15 +3,11 @@ obj-y += cbe_regs.o pervasive.o obj-$(CONFIG_CBE_RAS) += ras.o obj-$(CONFIG_SMP) += smp.o -obj-$(CONFIG_SPU_FS) += spu-base.o spufs/ - -spu-base-y += spu_base.o spu_priv1.o # needed only when building loadable spufs.ko spufs-modular-$(CONFIG_SPU_FS) += spu_syscalls.o obj-y += $(spufs-modular-m) # always needed in kernel -spufs-builtin-$(CONFIG_SPU_FS) += spu_callbacks.o +spufs-builtin-$(CONFIG_SPU_FS) += spu_callbacks.o spu_base.o spu_priv1.o spufs/ obj-y += $(spufs-builtin-y) $(spufs-builtin-m) -
arch/powerpc/platforms/cell/spufs/Makefile +3 -1
@@ -1,5 +1,7 @@ +obj-y += switch.o + obj-$(CONFIG_SPU_FS) += spufs.o -spufs-y += inode.o file.o context.o switch.o syscalls.o +spufs-y += inode.o file.o context.o syscalls.o spufs-y += sched.o backing_ops.o hw_ops.o run.o # Rules to build switch.o with the help of SPU tool chain
arch/powerpc/platforms/cell/spufs/switch.c +4 -0
@@ -2074,6 +2074,7 @@ int spu_save(struct spu_state *prev, str }return rc; } +EXPORT_SYMBOL_GPL (spu_save);/** * spu_restore - SPU context restore, with harvest and locking.
@@ -2103,6 +2104,7 @@ int spu_restore(struct spu_state *new, s }return rc; } +EXPORT_SYMBOL_GPL (spu_restore);/** * spu_harvest - SPU harvest (reset) operation
@@ -2193,6 +2195,7 @@ void spu_init_csa(struct spu_state *csa)init_priv1 (csa);init_priv2 (csa); } +EXPORT_SYMBOL_GPL (spu_init_csa);void spu_fini_csa (struct spu_state *csa) {
@@ -2203,3 +2206,4 @@ void spu_fini_csa(struct spu_state *csa)vfree (csa->lscsa); } +EXPORT_SYMBOL_GPL (spu_fini_csa);
--
PATCH 6/20 spufs: restore mapping of mssync register
In reply to [email protected]A recent change to the way that the mfc file gets mapped made it impossible to map the SPE Multi-Source Synchronization register into user space, but that may be needed by some applications.
This restores the missing functionality.
---
arch/powerpc/platforms/cell/spufs/file.c +50 -0
@@ -825,6 +825,55 @@ DEFINE_SIMPLE_ATTRIBUTE(spufs_signal2_ty spufs_signal2_type_set, "%llu");#ifdef CONFIG_SPUFS_MMAP +static struct page *spufs_mss_mmap_nopage (struct vm_area_struct *vma, +unsigned long address,int *type) +{ +return spufs_ps_nopage (vma, address, type,0x0000 ); +} + +static struct vm_operations_struct spufs_mss_mmap_vmops = { + .nopage = spufs_mss_mmap_nopage, +}; + +/* +* mmap support for problem state MFC DMA area [0x0000 - 0x0fff]. +* Mapping this area requires that the application have CAP_SYS_RAWIO, +* as these registers require special care when read/writing. +*/ +static int spufs_mss_mmap (struct file *file,struct vm_area_struct *vma) +{ +if (!(vma->vm_flags &VM_SHARED )) +return -EINVAL ; + +if (!capable (CAP_SYS_RAWIO )) +return -EPERM ; + + vma->vm_flags |=VM_RESERVED ; + vma->vm_page_prot =__pgprot (pgprot_val (vma->vm_page_prot) + | _PAGE_NO_CACHE); + + vma->vm_ops = &spufs_mss_mmap_vmops; +return 0 ; +} +#endif + +static int spufs_mss_open (struct inode *inode,struct file *file) +{ +struct spufs_inode_info *i =SPUFS_I (inode); + + file->private_data = i->i_ctx; +return nonseekable_open (inode, file); +} + +static struct file_operations spufs_mss_fops = { + .open = spufs_mss_open, +#ifdef CONFIG_SPUFS_MMAP + .mmap = spufs_mss_mmap, +#endif +}; + + +#ifdef CONFIG_SPUFS_MMAP static struct page *spufs_mfc_mmap_nopage (struct vm_area_struct *vma,unsigned long address,int *type) {
@@ -1292,6 +1341,7 @@ struct tree_descr spufs_dir_contents[] = { "signal2", &spufs_signal2_fops, 0666, }, { "signal1_type", &spufs_signal1_type, 0666, }, { "signal2_type", &spufs_signal2_type, 0666, }, + { "mss", &spufs_mss_fops, 0666, }, { "mfc", &spufs_mfc_fops, 0666, }, { "cntl", &spufs_cntl_fops, 0666, }, { "npc", &spufs_npc_ops, 0666, },
--
PATCH 7/20 spufs: fix deadlock in spu_create error path
In reply to [email protected]From: Michael Ellerman <[email protected]>
spufs_rmdir tries to acquire the spufs root i_mutex, which is already held by spufs_create_thread.
This was tracked as Bug #H9512.
---
arch/powerpc/platforms/cell/spufs/inode.c +15 -11
@@ -157,20 +157,12 @@ static void spufs_prune_dir(struct dentrmutex_unlock (&dir->d_inode->i_mutex); } +/* Caller must hold root->i_mutex */ static int spufs_rmdir (struct inode *root,struct dentry *dir_dentry) { -struct spu_context *ctx; -/* remove all entries */ -mutex_lock (&root->i_mutex);spufs_prune_dir (dir_dentry); -mutex_unlock (&root->i_mutex); -/* We have to give up the mm_struct */ - ctx =SPUFS_I (dir_dentry->d_inode)->i_ctx; -spu_forget (ctx); - -/* XXX Do we need to hold i_mutex here ? */ return simple_rmdir (root, dir_dentry); }
@@ -199,16 +191,23 @@ out:static int spufs_dir_close (struct inode *inode,struct file *file) { +struct spu_context *ctx;struct inode *dir;struct dentry *dentry;int ret; dentry = file->f_dentry; dir = dentry->d_parent->d_inode; + ctx =SPUFS_I (dentry->d_inode)->i_ctx; +mutex_lock (&dir->i_mutex); ret =spufs_rmdir (dir, dentry); +mutex_unlock (&dir->i_mutex);WARN_ON (ret); +/* We have to give up the mm_struct */ +spu_forget (ctx); +return dcache_dir_close (inode, file); }
@@ -324,8 +323,13 @@ long spufs_create_thread(struct nameidat* in error path of *_open(). */ ret =spufs_context_open (dget (dentry),mntget (nd->mnt)); -if (ret <0 ) -spufs_rmdir (nd->dentry->d_inode, dentry); +if (ret <0 ) { +WARN_ON (spufs_rmdir (nd->dentry->d_inode, dentry)); +mutex_unlock (&nd->dentry->d_inode->i_mutex); +spu_forget (SPUFS_I (dentry->d_inode)->i_ctx); +dput (dentry); + goto out; + } out_dput:dput (dentry);
--
Re: [patch 07/20] spufs: fix deadlock in spu_create error path
Quoted 9 lines · On Mon, 2006-06-19 at 20:33 +0200, [email protected] wrote:
plain text document attachment (spufs-rmdir-3.diff)
From: Michael Ellerman <[email protected]>
spufs_rmdirtries to acquire the spufs rooti_mutex, which is already held byspufs_create_thread.This was tracked as Bug #H9512.
Signed-off-by Arnd Bergmann <[email protected]>
I should have signed this off when I sent it .. but FWIW:
Quoted 68 lines
---
Index:
powerpc.git/arch/powerpc/platforms/cell/spufs/inode.c
===================================================================arch/powerpc/platforms/cell/spufs/inode.c +15
-11@@ -157,20 +157,12 @@ static void spufs_prune_dir(struct dentrmutex_unlock (&dir->d_inode->i_mutex); } +/* Caller must hold root->i_mutex */ static int spufs_rmdir (struct inode *root,struct dentry *dir_dentry) { -struct spu_context *ctx; -/* remove all entries */ -mutex_lock (&root->i_mutex);spufs_prune_dir (dir_dentry); -mutex_unlock (&root->i_mutex); -/* We have to give up the mm_struct */ - ctx =SPUFS_I (dir_dentry->d_inode)->i_ctx; -spu_forget (ctx); - -/* XXX Do we need to hold i_mutex here ? */ return simple_rmdir (root, dir_dentry); }@@ -199,16 +191,23 @@ out:static int spufs_dir_close (struct inode *inode,struct file *file) { +struct spu_context *ctx;struct inode *dir;struct dentry *dentry;int ret; dentry = file->f_dentry; dir = dentry->d_parent->d_inode; + ctx =SPUFS_I (dentry->d_inode)->i_ctx; +mutex_lock (&dir->i_mutex); ret =spufs_rmdir (dir, dentry); +mutex_unlock (&dir->i_mutex);WARN_ON (ret); +/* We have to give up the mm_struct */ +spu_forget (ctx); +return dcache_dir_close (inode, file); }@@ -324,8 +323,13 @@ long spufs_create_thread(struct nameidat* in error path of *_open(). */ ret =spufs_context_open (dget (dentry),mntget (nd->mnt)); -if (ret <0 ) -spufs_rmdir (nd->dentry->d_inode, dentry); +if (ret <0 ) { +WARN_ON (spufs_rmdir (nd->dentry->d_inode, dentry)); +mutex_unlock (&nd->dentry->d_inode->i_mutex); +spu_forget (SPUFS_I (dentry->d_inode)->i_ctx); +dput (dentry); + goto out; + } out_dput:dput (dentry);
PATCH 8/20 spufs: set up correct SLB entries for 64k pages
In reply to [email protected]spufs currently knows only 4k pages and 16M hugetlb pages. Make it use the regular methods for deciding on the SLB bits.
---
arch/powerpc/platforms/cell/spu_base.c +8 -3
@@ -71,7 +71,7 @@ static int __spu_trap_data_seg(struct sp {struct spu_priv2 __iomem *priv2 = spu->priv2;struct mm_struct *mm = spu->mm; -u64 esid, vsid; +u64 esid, vsid, llp;pr_debug ("%s\n" , __FUNCTION__);
@@ -91,9 +91,14 @@ static int __spu_trap_data_seg(struct sp } esid = (ea &ESID_MASK ) |SLB_ESID_V ; - vsid = (get_vsid (mm->context.id, ea) <<SLB_VSID_SHIFT ) |SLB_VSID_USER ; +#ifdef CONFIG_HUGETLB_PAGE if (in_hugepage_area (mm->context, ea)) - vsid |=SLB_VSID_L ; + llp = mmu_psize_defs[mmu_huge_psize].sllp; + else +#endif + llp = mmu_psize_defs[mmu_virtual_psize].sllp; + vsid = (get_vsid (mm->context.id, ea) <<SLB_VSID_SHIFT ) | +SLB_VSID_USER | llp;out_be64 (&priv2->slb_index_W, spu->slb_replace);out_be64 (&priv2->slb_vsid_RW, vsid);
arch/powerpc/platforms/cell/spufs/switch.c +8 -6
@@ -718,13 +718,15 @@ static inline void invalidate_slbs(strucstatic inline void get_kernel_slb (u64 ea,u64 slb[2 ]) { - slb[0 ] = (get_kernel_vsid (ea) <<SLB_VSID_SHIFT ) |SLB_VSID_KERNEL ; - slb[1 ] = (ea &ESID_MASK ) |SLB_ESID_V ; +u64 llp; -/* Large pages are used for kernel text/data, but not vmalloc. */ -if (cpu_has_feature (CPU_FTR_16M_PAGE ) - &®ION_ID (ea) ==KERNEL_REGION_ID ) - slb[0 ] |=SLB_VSID_L ; +if (REGION_ID (ea) ==KERNEL_REGION_ID ) + llp = mmu_psize_defs[mmu_linear_psize].sllp; +else + llp = mmu_psize_defs[mmu_virtual_psize].sllp; + slb[0 ] = (get_kernel_vsid (ea) <<SLB_VSID_SHIFT ) | +SLB_VSID_KERNEL | llp; + slb[1 ] = (ea &ESID_MASK ) |SLB_ESID_V ; }static inline void load_mfc_slb (struct spu *spu,u64 slb[2 ],int slbe)
--
PATCH 9/20 spufs: add a phys-id attribute to each SPU context
In reply to [email protected]For performance analysis, it is often interesting to know which physical SPE a thread is currently running on, and, more importantly, if it is running at all.
This patch adds a simple attribute to each SPU directory with that information.
The attribute is read-only and called 'phys-id'. It contains an ascii string with the number of the physical SPU (e.g. "0x5"), or alternatively the string "0xffffffff" (32 bit -1) when it is not running at all at the time that the file is read.
---
arch/powerpc/platforms/cell/spufs/file.c +17 -0
@@ -1328,6 +1328,22 @@ static u64 spufs_srr0_get(void *data)DEFINE_SIMPLE_ATTRIBUTE (spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set, "%llx\n") +static u64 spufs_id_get (void *data) +{ +struct spu_context *ctx = data; +u64 num; + +spu_acquire (ctx); +if (ctx->state ==SPU_STATE_RUNNABLE ) + num = ctx->spu->number; +else + num = (unsigned int )-1 ; +spu_release (ctx); + +return num; +} +DEFINE_SIMPLE_ATTRIBUTE(spufs_id_ops, spufs_id_get, 0, "0x%llx\n") +struct tree_descr spufs_dir_contents[] = { {"mem" , &spufs_mem_fops,0666 , }, {"regs" , &spufs_regs_fops,0666 , },
@@ -1351,5 +1367,6 @@ struct tree_descr spufs_dir_contents[] = { "spu_tag_mask", &spufs_spu_tag_mask_ops, 0666, }, { "event_mask", &spufs_event_mask_ops, 0666, }, { "srr0", &spufs_srr0_ops, 0666, }, + { "phys-id", &spufs_id_ops, 0666, }, {}, };
--
PATCH 10/20 spufs: fix initial state of wbox file
In reply to [email protected]The wbox channel count of an spu is now initialized to four for the saved context. This makes it possible to write to the mailbox right away without waiting for the SPE to become scheduled first.
---
arch/powerpc/platforms/cell/spufs/switch.c +1 -0
@@ -2129,6 +2129,7 @@ static void init_prob(struct spu_state * csa->spu_chnlcnt_RW[28 ] =1 ; csa->spu_chnlcnt_RW[30 ] =1 ; csa->prob.spu_runcntl_RW =SPU_RUNCNTL_STOP ; + csa->prob.mb_stat_R =0x000400 ; }static void init_priv1 (struct spu_state *csa)
--
PATCH 11/20 spufs: use kzalloc in create_spu
In reply to [email protected]From: Jeremy Kerr <[email protected]>
Clean up create_spu() a little by using kzalloc instead of kmalloc + assignments.
---
arch/powerpc/platforms/cell/spu_base.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
arch/powerpc/platforms/cell/spu_base.c +2 -19
@@ -701,7 +701,7 @@ static int __init create_spu(struct devistatic int number; ret = -ENOMEM ; - spu =kmalloc (sizeof (*spu),GFP_KERNEL ); + spu =kzalloc (sizeof (*spu),GFP_KERNEL );if (!spu) goto out;
@@ -713,28 +713,11 @@ static int __init create_spu(struct devi spu->nid =of_node_to_nid (spe);if (spu->nid ==-1 ) spu->nid =0 ; - - spu->stop_code =0 ; - spu->slb_replace =0 ; - spu->mm =NULL ; - spu->ctx =NULL ; - spu->rq =NULL ; - spu->pid =0 ; - spu->class_0_pending =0 ; - spu->flags =0UL ; - spu->dar =0UL ; - spu->dsisr =0UL ;spin_lock_init (&spu->register_lock); -spu_mfc_sdr_set (spu,mfspr (SPRN_SDR1 ));spu_mfc_sr1_set (spu,0x33 ); - - spu->ibox_callback =NULL ; - spu->wbox_callback =NULL ; - spu->stop_callback =NULL ; - spu->mfc_callback =NULL ; -mutex_lock (&spu_mutex); + spu->number = number++; ret =spu_request_irqs (spu);if (ret)
--
PATCH 12/20 spufs: dont try to access SPE channel 1 count
In reply to [email protected]The save/restore sequence for SPE contexts currently attempts to save and restore the channel count for SPE channel 1 (the SPU_WriteEventMask channel. But the CBE architecture (section 9.11.2) clearly states that this channel does not have an associated count. Hardware simply ignores the attempt to write this count, but the simulator generates a warning message.
WARNING: 279721590: SPE7: Attempt to write channel count for CH 1 with no associated count is ignored.
arch/powerpc/platforms/cell/spufs/switch.c +21 -6
@@ -622,12 +622,17 @@ static inline void save_ppuint_mb(structstatic inline void save_ch_part1 (struct spu_state *csa,struct spu *spu) {struct spu_priv2 __iomem *priv2 = spu->priv2; -u64 idx, ch_indices[7 ] = {0UL ,1UL ,3UL ,4UL ,24UL ,25UL ,27UL }; +u64 idx, ch_indices[7 ] = {0UL ,3UL ,4UL ,24UL ,25UL ,27UL };int i;/* Save, Step 42: -* Save the following CH: [0,1,3,4,24,25,27] */ + +/* Save CH 1, without channel count */ +out_be64 (&priv2->spu_chnlcntptr_RW,1 ); + csa->spu_chnldata_RW[1 ] =in_be64 (&priv2->spu_chnldata_RW); + +/* Save the following CH: [0,3,4,24,25,27] */ for (i =0 ; i <7 ; i++) { idx = ch_indices[i];out_be64 (&priv2->spu_chnlcntptr_RW, idx);
@@ -1105,13 +1110,18 @@ static inline void clear_spu_status(strustatic inline void reset_ch_part1 (struct spu_state *csa,struct spu *spu) {struct spu_priv2 __iomem *priv2 = spu->priv2; -u64 ch_indices[7 ] = {0UL ,1UL ,3UL ,4UL ,24UL ,25UL ,27UL }; +u64 ch_indices[7 ] = {0UL ,3UL ,4UL ,24UL ,25UL ,27UL };u64 idx;int i;/* Restore, Step 20: -* Reset the following CH: [0,1,3,4,24,25,27] */ + +/* Reset CH 1 */ +out_be64 (&priv2->spu_chnlcntptr_RW,1 ); +out_be64 (&priv2->spu_chnldata_RW,0UL ); + +/* Reset the following CH: [0,3,4,24,25,27] */ for (i =0 ; i <7 ; i++) { idx = ch_indices[i];out_be64 (&priv2->spu_chnlcntptr_RW, idx);
@@ -1572,12 +1582,17 @@ static inline void restore_decr_wrapped(static inline void restore_ch_part1 (struct spu_state *csa,struct spu *spu) {struct spu_priv2 __iomem *priv2 = spu->priv2; -u64 idx, ch_indices[7 ] = {0UL ,1UL ,3UL ,4UL ,24UL ,25UL ,27UL }; +u64 idx, ch_indices[7 ] = {0UL ,3UL ,4UL ,24UL ,25UL ,27UL };int i;/* Restore, Step 59: -* Restore the following CH: [0,1,3,4,24,25,27] */ + +/* Restore CH 1 without count */ +out_be64 (&priv2->spu_chnlcntptr_RW,1 ); +out_be64 (&priv2->spu_chnldata_RW, csa->spu_chnldata_RW[1 ]); + +/* Restore the following CH: [0,3,4,24,25,27] */ for (i =0 ; i <7 ; i++) { idx = ch_indices[i];out_be64 (&priv2->spu_chnlcntptr_RW, idx);
--
PATCH 13/20 spufs: split the Cell BE support into generic and platform dependant parts
In reply to [email protected]From: Geoff Levand <[email protected]>
Creates new config variables PPC_CELL_NATIVE and PPC_IBM_CELL_BLADE. The existing CONFIG_PPC_CELL is now used to denote the generic Cell processor support.
PPC_CELL = make descends into platforms/cell PPC_CELL_NATIVE = add bare metal support PPC_IBM_CELL_BLADE = add blade device drivers, etc.
Also renames spu_priv1.c to spu_priv1_mmio.c.
arch/powerpc/Kconfig +11 -6
@@ -395,8 +395,18 @@ config PPC_MAPLE For more informations, refer to <http://www.970eval.com> config PPC_CELL - bool "Cell Broadband Processor Architecture" + bool + default n + +config PPC_CELL_NATIVE + bool + select PPC_CELL + default n + +config PPC_IBM_CELL_BLADE + bool " IBM Cell Blade" depends on PPC_MULTIPLATFORM && PPC64 + select PPC_CELL_NATIVE select PPC_RTAS select MMIO_NVRAM select PPC_UDBG_16550
@@ -443,11 +453,6 @@ config MPIC_BROKEN_U3 depends on PPC_MAPLE default y -config CELL_IIC - depends on PPC_CELL - bool - default y - config IBMVIO depends on PPC_PSERIES || PPC_ISERIES bool
arch/powerpc/configs/cell_defconfig +3 -1
@@ -117,6 +117,8 @@ CONFIG_PPC_MULTIPLATFORM=y # CONFIG_PPC_PMAC is not set # CONFIG_PPC_MAPLE is not set CONFIG_PPC_CELL=y +CONFIG_PPC_CELL_NATIVE=y +CONFIG_PPC_IBM_CELL_BLADE=y CONFIG_PPC_SYSTEMSIM=y # CONFIG_U3_DART is not set CONFIG_PPC_RTAS=y
@@ -124,7 +126,6 @@ CONFIG_PPC_RTAS=y CONFIG_RTAS_PROC=y CONFIG_RTAS_FLASH=y CONFIG_MMIO_NVRAM=y -CONFIG_CELL_IIC=y # CONFIG_PPC_MPC106 is not set # CONFIG_PPC_970_NAP is not set # CONFIG_CPU_FREQ is not set
@@ -134,6 +135,7 @@ CONFIG_CELL_IIC=y # Cell Broadband Engine options # CONFIG_SPU_FS=m +CONFIG_SPU_BASE=y CONFIG_SPUFS_MMAP=y CONFIG_CBE_RAS=y
arch/powerpc/platforms/cell/Kconfig +5 -0
@@ -5,11 +5,16 @@ config SPU_FS tristate "SPU file system" default m depends on PPC_CELL + select SPU_BASE help The SPU file system is used to access Synergistic Processing Units on machines implementing the Broadband Processor Architecture. +config SPU_BASE + bool + default n + config SPUFS_MMAP bool depends on SPU_FS && SPARSEMEM
arch/powerpc/platforms/cell/Makefile +11 -9
@@ -1,13 +1,15 @@ -obj-y += interrupt.o iommu.o setup.o spider-pic.o -obj-y += cbe_regs.o pervasive.o -obj-$(CONFIG_CBE_RAS) += ras.o +obj-$(CONFIG_PPC_CELL_NATIVE) += interrupt.o iommu.o setup.o \ + cbe_regs.o spider-pic.o pervasive.o +obj-$(CONFIG_CBE_RAS) += ras.o -obj-$(CONFIG_SMP) += smp.o +ifeq ($(CONFIG_SMP),y) +obj-$(CONFIG_PPC_CELL_NATIVE) += smp.o +endif # needed only when building loadable spufs.ko -spufs-modular-$(CONFIG_SPU_FS) += spu_syscalls.o -obj-y += $(spufs-modular-m) +spufs-modular-$(CONFIG_SPU_FS) += spu_syscalls.o +spu-priv1-$(CONFIG_PPC_CELL_NATIVE) += spu_priv1_mmio.o -# always needed in kernel -spufs-builtin-$(CONFIG_SPU_FS) += spu_callbacks.o spu_base.o spu_priv1.o spufs/ -obj-y += $(spufs-builtin-y) $(spufs-builtin-m) +obj-$(CONFIG_SPU_BASE) += spu_callbacks.o spu_base.o \ + $(spufs-modular-m) \ + $(spu-priv1-y) spufs/
arch/powerpc/platforms/cell/spu_priv1.c deleted +0 -133
133 lines not on this page · raw message
arch/powerpc/platforms/cell/spu_priv1_mmio.c new file +133 -0
133 lines not on this page · raw message
drivers/net/Kconfig +1 -1
@@ -2171,7 +2171,7 @@ config BNX2 config SPIDER_NET tristate "Spider Gigabit Ethernet driver" - depends on PCI && PPC_CELL + depends on PCI && PPC_IBM_CELL_BLADE select FW_LOADER help This driver supports the Gigabit Ethernet chips present on the
--
PATCH 14/20 spufs: further abstract priv1 register access
In reply to [email protected]From: Geoff Levand <[email protected]>
To support muti-platform binaries the spu hypervisor accessor routines must have runtime binding.
I removed the existing statically linked routines in spu.h and spu_priv1_mmio.c and created new accessor routines in spu_priv1.h that operate indirectly through an ops struct spu_priv1_ops. spu_priv1_mmio.c contains the instance of the accessor routines for running on raw hardware.
arch/powerpc/platforms/cell/setup.c +4 -0
@@ -49,6 +49,7 @@#include <asm/ppc-pci.h> #include <asm/irq.h> #include <asm/spu.h> +#include <asm/spu_priv1.h> #include "interrupt.h" #include "iommu.h"
@@ -83,6 +84,9 @@ static void __init cell_setup_arch(void) { ppc_md.init_IRQ = iic_init_IRQ; ppc_md.get_irq = iic_get_irq; +#ifdef CONFIG_SPU_BASE + spu_priv1_ops = &spu_priv1_mmio_ops; +#endif cbe_regs_init ();
arch/powerpc/platforms/cell/spu_base.c +5 -0
@@ -34,10 +34,15 @@#include <asm/prom.h> #include <linux/mutex.h> #include <asm/spu.h> +#include <asm/spu_priv1.h> #include <asm/mmu_context.h> #include "interrupt.h" +const struct spu_priv1_ops *spu_priv1_ops; + +EXPORT_SYMBOL_GPL (spu_priv1_ops); +static int __spu_trap_invalid_dma (struct spu *spu) {pr_debug ("%s\n" , __FUNCTION__);
arch/powerpc/platforms/cell/spu_priv1_mmio.c +63 -41
196 lines not on this page · raw message
arch/powerpc/platforms/cell/spufs/hw_ops.c +1 -0
@@ -32,6 +32,7 @@#include <asm/io.h> #include <asm/spu.h> +#include <asm/spu_priv1.h> #include <asm/spu_csa.h> #include <asm/mmu_context.h> #include "spufs.h"
arch/powerpc/platforms/cell/spufs/switch.c +1 -0
@@ -46,6 +46,7 @@#include <asm/io.h> #include <asm/spu.h> +#include <asm/spu_priv1.h> #include <asm/spu_csa.h> #include <asm/mmu_context.h>
include/asm-powerpc/spu.h +0 -23
@@ -183,29 +183,6 @@ static inline void unregister_spu_syscal#endif /* MODULE */ -/* access to priv1 registers */ -void spu_int_mask_and (struct spu *spu,int class,u64 mask); -void spu_int_mask_or (struct spu *spu,int class,u64 mask); -void spu_int_mask_set (struct spu *spu,int class,u64 mask); -u64 spu_int_mask_get (struct spu *spu,int class); -void spu_int_stat_clear (struct spu *spu,int class,u64 stat); -u64 spu_int_stat_get (struct spu *spu,int class); -void spu_int_route_set (struct spu *spu,u64 route); -u64 spu_mfc_dar_get (struct spu *spu); -u64 spu_mfc_dsisr_get (struct spu *spu); -void spu_mfc_dsisr_set (struct spu *spu,u64 dsisr); -void spu_mfc_sdr_set (struct spu *spu,u64 sdr); -void spu_mfc_sr1_set (struct spu *spu,u64 sr1); -u64 spu_mfc_sr1_get (struct spu *spu); -void spu_mfc_tclass_id_set (struct spu *spu,u64 tclass_id); -u64 spu_mfc_tclass_id_get (struct spu *spu); -void spu_tlb_invalidate (struct spu *spu); -void spu_resource_allocation_groupID_set (struct spu *spu,u64 id); -u64 spu_resource_allocation_groupID_get (struct spu *spu); -void spu_resource_allocation_enable_set (struct spu *spu,u64 enable); -u64 spu_resource_allocation_enable_get (struct spu *spu); - -/* * This defines the Local Store, Problem Area and Privlege Area of an SPU. */
include/asm-powerpc/spu_priv1.h new file +182 -0
182 lines not on this page · raw message
--
PATCH 15/20 spufs: fix spu irq affinity setting
In reply to [email protected]From: Geoff Levand <[email protected]>
This changes the hypervisor abstraction of setting cpu affinity to a higher level to avoid platform dependent interrupt controller routines. I replaced spu_priv1_ops:spu_int_route_set() with a new routine spu_priv1_ops:spu_cpu_affinity_set().
As a by-product, this change eliminated what looked like an existing bug in the set affinity code where spu_int_route_set() mistakenly called int_stat_get().
arch/powerpc/platforms/cell/spu_base.c +0 -8
@@ -522,14 +522,6 @@ int spu_irq_class_1_bottom(struct spu *sreturn ret; } -void spu_irq_setaffinity (struct spu *spu,int cpu) -{ -u64 target =iic_get_target_id (cpu); -u64 route = target <<48 | target <<32 | target <<16 ; -spu_int_route_set (spu, route); -} -EXPORT_SYMBOL_GPL (spu_irq_setaffinity); -static int __init find_spu_node_id (struct device_node *spe) {unsigned int *id;
arch/powerpc/platforms/cell/spu_priv1_mmio.c +6 -2
@@ -24,6 +24,8 @@#include <asm/spu.h> #include <asm/spu_priv1.h> +#include "interrupt.h" +static void int_mask_and (struct spu *spu,int class,u64 mask) {u64 old_mask;
@@ -60,8 +62,10 @@ static u64 int_stat_get(struct spu *spu,return in_be64 (&spu->priv1->int_stat_RW[class]); } -static void int_route_set (struct spu *spu,u64 route) +static void cpu_affinity_set (struct spu *spu,int cpu) { +u64 target =iic_get_target_id (cpu); +u64 route = target <<48 | target <<32 | target <<16 ;out_be64 (&spu->priv1->int_route_RW, route); }
@@ -138,7 +142,7 @@ const struct spu_priv1_ops spu_priv1_mmi .int_mask_get = int_mask_get, .int_stat_clear = int_stat_clear, .int_stat_get = int_stat_get, - .int_route_set = int_route_set, + .cpu_affinity_set = cpu_affinity_set, .mfc_dar_get = mfc_dar_get, .mfc_dsisr_get = mfc_dsisr_get, .mfc_dsisr_set = mfc_dsisr_set,
arch/powerpc/platforms/cell/spufs/sched.c +2 -1
@@ -43,6 +43,7 @@#include <asm/mmu_context.h> #include <asm/spu.h> #include <asm/spu_csa.h> +#include <asm/spu_priv1.h> #include "spufs.h" #define SPU_MIN_TIMESLICE (100 * HZ / 1000)
@@ -363,7 +364,7 @@ int spu_activate(struct spu_context *ctx* We're likely to wait for interrupts on the same * CPU that we are now on, so send them here. */ -spu_irq_setaffinity (spu,raw_smp_processor_id ()); +spu_cpu_affinity_set (spu,raw_smp_processor_id ());put_active_spu (spu);return 0 ; }
include/asm-powerpc/spu_priv1.h +3 -3
@@ -33,7 +33,7 @@ struct spu_priv1_opsu64 (*int_mask_get) (struct spu *spu,int class);void (*int_stat_clear) (struct spu *spu,int class,u64 stat);u64 (*int_stat_get) (struct spu *spu,int class); -void (*int_route_set) (struct spu *spu,u64 route); +void (*cpu_affinity_set) (struct spu *spu,int cpu);u64 (*mfc_dar_get) (struct spu *spu);u64 (*mfc_dsisr_get) (struct spu *spu);void (*mfc_dsisr_set) (struct spu *spu,u64 dsisr);
@@ -88,9 +88,9 @@ spu_int_stat_get (struct spu *spu, int c }static inline void -spu_int_route_set (struct spu *spu,u64 route) +spu_cpu_affinity_set (struct spu *spu,int cpu) { - spu_priv1_ops->int_stat_get (spu, route); + spu_priv1_ops->cpu_affinity_set (spu, cpu); } static inline u64
--
PATCH 16/20 spufs: remove stop_code from struct spu
In reply to [email protected]From: Masato Noguchi <[email protected]>
This patch remove 'stop_code' -- discarded member of struct spu. It is written at initialize and interrupt, but never read in current implementation.
--- arch/powerpc/platforms/cell/spu_base.c | 2 -- arch/powerpc/platforms/cell/spufs/switch.c | 1 - include/asm-powerpc/spu.h | 1 - 3 files changed, 4 deletions(-)
arch/powerpc/platforms/cell/spu_base.c +0 -2
@@ -160,7 +160,6 @@ static int __spu_trap_mailbox(struct spustatic int __spu_trap_stop (struct spu *spu) {pr_debug ("%s\n" , __FUNCTION__); - spu->stop_code =in_be32 (&spu->problem->spu_status_R);if (spu->stop_callback) spu->stop_callback (spu);return 0 ;
@@ -169,7 +168,6 @@ static int __spu_trap_stop(struct spu *sstatic int __spu_trap_halt (struct spu *spu) {pr_debug ("%s\n" , __FUNCTION__); - spu->stop_code =in_be32 (&spu->problem->spu_status_R);if (spu->stop_callback) spu->stop_callback (spu);return 0 ;
arch/powerpc/platforms/cell/spufs/switch.c +0 -1
@@ -2109,7 +2109,6 @@ int spu_restore(struct spu_state *new, sacquire_spu_lock (spu);harvest (NULL , spu); - spu->stop_code =0 ; spu->dar =0 ; spu->dsisr =0 ; spu->slb_replace =0 ;
include/asm-powerpc/spu.h +0 -1
@@ -134,7 +134,6 @@ struct spu {int class_0_pending;spinlock_t register_lock; -u32 stop_code;void (* wbox_callback)(struct spu *spu);void (* ibox_callback)(struct spu *spu);void (* stop_callback)(struct spu *spu);
--
PATCH 17/20 spufs: fix Makefile for "make clean"
In reply to [email protected]From: Masato Noguchi <[email protected]>
added spu_{save,restore}_dump.h to target of 'make clean'
--- arch/powerpc/platforms/cell/spufs/Makefile | 1 + 1 files changed, 1 insertion(+)
arch/powerpc/platforms/cell/spufs/Makefile +1 -0
@@ -15,6 +15,7 @@ SPU_AFLAGS := -c -D__ASSEMBLY__ -I$(srct SPU_LDFLAGS := -N -Ttext=0x0 $(obj)/switch.o: $(obj)/spu_save_dump.h $(obj)/spu_restore_dump.h +clean-files := spu_save_dump.h spu_restore_dump.h # Compile SPU files cmd_spu_cc = $(SPU_CC) $(SPU_CFLAGS) -c -o $@ $<
--
PATCH 18/20 spufs: clear class2 interrupt status before wakeup
In reply to [email protected]From: Masato Noguchi <[email protected]>
SPU interrupt status must be cleared before handle it. Otherwise, kernel may drop some interrupt packet.
Currently, class2 interrupt treated like:
1) call callback to wake up waiting process
2) mask raised mailbox interrupt
3) clear interrupt status
I changed like:
1) mask raised mailbox interrupt
2) clear interrupt status
3) call callback to wake up waiting process
Clearing status before masking will make spurious interrupt. Thus, it is necessary to hold by steps I described above, I think.
--- arch/powerpc/platforms/cell/spu_base.c | 33 ++++++++++++++++++++++++--------- 1 files changed, 24 insertions(+), 9 deletions(-)
arch/powerpc/platforms/cell/spu_base.c +19 -59
@@ -140,55 +140,7 @@ static int __spu_trap_data_map(struct sp spu->dar = ea; spu->dsisr = dsisr;mb (); -if (spu->stop_callback) - spu->stop_callback (spu); -return 0 ; -} - -static int __spu_trap_mailbox (struct spu *spu) -{ -if (spu->ibox_callback) - spu->ibox_callback (spu); - -/* atomically disable SPU mailbox interrupts */ -spin_lock (&spu->register_lock); -spu_int_mask_and (spu,2 , ~0x1 ); -spin_unlock (&spu->register_lock); -return 0 ; -} - -static int __spu_trap_stop (struct spu *spu) -{ -pr_debug ("%s\n" , __FUNCTION__); -if (spu->stop_callback) - spu->stop_callback (spu); -return 0 ; -} - -static int __spu_trap_halt (struct spu *spu) -{ -pr_debug ("%s\n" , __FUNCTION__); -if (spu->stop_callback) - spu->stop_callback (spu); -return 0 ; -} - -static int __spu_trap_tag_group (struct spu *spu) -{ -pr_debug ("%s\n" , __FUNCTION__); - spu->mfc_callback (spu); -return 0 ; -} - -static int __spu_trap_spubox (struct spu *spu) -{ -if (spu->wbox_callback) - spu->wbox_callback (spu); - -/* atomically disable SPU mailbox interrupts */ -spin_lock (&spu->register_lock); -spu_int_mask_and (spu,2 , ~0x10 ); -spin_unlock (&spu->register_lock); + spu->stop_callback (spu);return 0 ; }
@@ -199,8 +151,7 @@ spu_irq_class_0(int irq, void *data, str spu = data; spu->class_0_pending =1 ; -if (spu->stop_callback) - spu->stop_callback (spu); + spu->stop_callback (spu);return IRQ_HANDLED ; }
@@ -278,29 +229,38 @@ spu_irq_class_2(int irq, void *data, strunsigned long mask; spu = data; +spin_lock (&spu->register_lock); stat =spu_int_stat_get (spu,2 ); mask =spu_int_mask_get (spu,2 ); +/* ignore interrupts we're not waiting for */ + stat &= mask; +/* +* mailbox interrupts (0x1 and 0x10) are level triggered. +* mask them now before acknowledging. +*/ +if (stat &0x11 ) +spu_int_mask_and (spu,2 , ~(stat &0x11 )); +/* acknowledge all interrupts before the callbacks */ +spu_int_stat_clear (spu,2 , stat); +spin_unlock (&spu->register_lock);pr_debug ("class 2 interrupt %d, %lx, %lx\n" , irq, stat, mask); - stat &= mask; -if (stat &1 )/* PPC core mailbox */ -__spu_trap_mailbox (spu); + spu->ibox_callback (spu);if (stat &2 )/* SPU stop-and-signal */ -__spu_trap_stop (spu); + spu->stop_callback (spu);if (stat &4 )/* SPU halted */ -__spu_trap_halt (spu); + spu->stop_callback (spu);if (stat &8 )/* DMA tag group complete */ -__spu_trap_tag_group (spu); + spu->mfc_callback (spu);if (stat &0x10 )/* SPU mailbox threshold */ -__spu_trap_spubox (spu); + spu->wbox_callback (spu); -spu_int_stat_clear (spu,2 , stat);return stat ?IRQ_HANDLED :IRQ_NONE ; }
--
PATCH 19/20 spufs: fail spu_create with invalid flags
In reply to [email protected]At this time, all flags are invalid. Since we are planning to actually add valid flags in the future, we better check if any were passed by the user.
arch/powerpc/platforms/cell/spufs/inode.c +4 -0
@@ -304,6 +304,10 @@ long spufs_create_thread(struct nameidat nd->dentry != nd->dentry->d_sb->s_root) goto out; +/* all flags are reserved */ +if (flags) + goto out; + dentry =lookup_create (nd,1 ); ret =PTR_ERR (dentry);if (IS_ERR (dentry))
--
PATCH 20/20 spufs: one more fix for 64k pages
In reply to [email protected]The SPU context save/restore code is currently built for a 4k page size and we provide a _shipped version of it since most people don't have the spu toolchain that is needed to rebuild that code.
This patch hardcodes the data structures to a 64k page alignment, which also guarantees 4k alignment but unfortunately wastes 60k of memory per SPU context that is created in the running system.
We will follow up on this with another patch to reduce that overhead or maybe redo the context save/restore logic to do this part entirely different, but for now it should make experimental systems work with either page size.
---
include/asm-powerpc/spu_csa.h +11 -2
@@ -86,10 +86,18 @@ struct spu_lscsa {struct spu_reg128 event_mask;struct spu_reg128 srr0;struct spu_reg128 stopped_status; -struct spu_reg128 pad[119 ];/* 'ls' must be page-aligned. */ -unsigned char ls[LS_SIZE ]; + +/* +* 'ls' must be page-aligned on all configurations. +* Since we don't want to rely on having the spu-gcc +* installed to build the kernel and this structure +* is used in the SPU-side code, make it 64k-page +* aligned for now. +*/ + unsigned char ls[LS_SIZE] __attribute__((aligned(65536))); }; +#ifndef __SPU__/* * struct spu_problem_collapsed - condensed problem state area, w/o pads. */
@@ -250,6 +258,7 @@ extern int spu_restore(struct spu_stateextern int spu_switch (struct spu_state *prev,struct spu_state *new,struct spu *spu); +#endif /* !__SPU__ */ #endif /* __KERNEL__ */ #endif /* !__ASSEMBLY__ */ #endif /* _SPU_CSA_H_ */
arch/powerpc/platforms/cell/spufs/Makefile +6 -3
@@ -10,8 +10,10 @@ SPU_CC := $(SPU_CROSS)gcc SPU_AS := $(SPU_CROSS)gcc SPU_LD := $(SPU_CROSS)ld SPU_OBJCOPY := $(SPU_CROSS)objcopy -SPU_CFLAGS := -O2 -Wall -I$(srctree)/include -I$(objtree)/include2 -SPU_AFLAGS := -c -D__ASSEMBLY__ -I$(srctree)/include -I$(objtree)/include2 +SPU_CFLAGS := -O2 -Wall -I$(srctree)/include \ + -I$(objtree)/include2 -D__KERNEL__ +SPU_AFLAGS := -c -D__ASSEMBLY__ -I$(srctree)/include \ + -I$(objtree)/include2 -D__KERNEL__ SPU_LDFLAGS := -N -Ttext=0x0 $(obj)/switch.o: $(obj)/spu_save_dump.h $(obj)/spu_restore_dump.h
@@ -48,7 +50,8 @@ cmd_hexdump = ( \ echo " * Hex-dump auto generated from $*.c." ; \ echo " * Do not edit!" ; \ echo " */" ; \ - echo "static unsigned int $*_code[] __page_aligned = {" ; \ + echo "static unsigned int $*_code[] " \ + "__attribute__((__aligned__(128))) = {" ; \ hexdump -v -e '"0x" 4/1 "%02x" "," "\n"' $< ; \ echo "};" ; \ ) > $@
arch/powerpc/platforms/cell/spufs/spu_restore_dump.h_shipped +897 -225
1,126 lines not on this page · raw message
arch/powerpc/platforms/cell/spufs/spu_save_dump.h_shipped +737 -185
926 lines not on this page · raw message
--