powerpc-genirq: port cell iic and spider-pic to genirq
Subsystems (2)
PATCH 1/1 powerpc-genirq: port cell iic and spider-pic to genirq
This patch is a quick hack at porting the cell iic and spider-pic to genirq. It applies on top of other cell patches not yet in mainline. It needs more work though, for example, we need to handle proper retrigger of interrupts that have been masked etc...
It also hacks together some cascade handling that need to be reworked, mostly when my irq number allocator/remapper is ready (I currently hijack spider irq 32 which doesn't exist to do the iic->spider cascade). It needs some work to properly handle the RAS interrupts on cell as well. One feature it adds that wasn't there is better handling of stacked priorities (that should be done for xics as well btw). That is, when an irq is completed (eoi), the processor priority is restored to the previous priority that got interrupted rather than 0xff systematically, thus avoiding the potential for infinite stacking of interrupts.
---
Patch depends on Ingo/Thomas genirq patchset. It's not to be merged right away, It's being posted here for comments as I may have further rework.
arch/powerpc/platforms/cell/interrupt.c +54 -55
@@ -57,64 +57,51 @@ struct iic_regs {struct iic {struct iic_regs __iomem *regs;u8 target_id; +u8 eoi_stack[16 ]; +int eoi_ptr; }; static DEFINE_PER_CPU(struct iic, iic); -void iic_local_enable (void ) +static void iic_mask (unsigned int irq) { -struct iic *iic = &__get_cpu_var (iic); -u64 tmp; - -/* -* There seems to be a bug that is present in DD2.x CPUs -* and still only partially fixed in DD3.1. -* This bug causes a value written to the priority register -* not to make it there, resulting in a system hang unless we -* write it again. -* Masking with 0xf0 is done because the Cell BE does not -* implement the lower four bits of the interrupt priority, -* they always read back as zeroes, although future CPUs -* might implement different bits. -*/ -do { -out_be64 (&iic->regs->prio,0xff ); - tmp =in_be64 (&iic->regs->prio); - }while ((tmp &0xf0 ) !=0xf0 ); -} - -void iic_local_disable (void ) -{ -out_be64 (&__get_cpu_var (iic).regs->prio,0x0 ); } -static unsigned int iic_startup (unsigned int irq) +static void iic_unmask (unsigned int irq) { -return 0 ; } -static void iic_enable (unsigned int irq) +static void iic_eoi (unsigned int irq) { -iic_local_enable (); -} - -static void iic_disable (unsigned int irq) -{ -} - -static void iic_end (unsigned int irq) -{ -iic_local_enable (); +struct iic *iic = &__get_cpu_var (iic); +out_be64 (&iic->regs->prio, iic->eoi_stack[--iic->eoi_ptr]); +BUG_ON (iic->eoi_ptr <0 ); } -static struct hw_interrupt_type iic_pic = { +static struct irq_chip iic_chip = { .typename =" CELL-IIC " , - .startup = iic_startup, - .enable = iic_enable, - .disable = iic_disable, - .end = iic_end, + .mask = iic_mask, + .unmask = iic_unmask, + .eoi = iic_eoi, }; +/* XXX All of this has to be reworked completely. We need to assign a real +* interrupt numbers to the external interrupts and remove all the hard coded +* interrupt maps (rely on the device-tree whenever possible). +* +* Basically, my scheme is to define the "pendings" bits to be the HW interrupt +* number (ignoring the data and flags here). That means we can sort-of split +* external sources based on priority, and we can use request_irq() on pretty +* much anything. +* +* For spider or axon, they have their own interrupt space. spider will just have +* local "hardward" interrupts 0...xx * node stride. The node stride is not +* necessary (separate interrupt chips will have separate HW number space), but +* will allow to be compatible with existing device-trees. +* +* All of thise little world will get a standard remapping scheme to map those HW +* numbers into the linux flat irq number space. +*/ static int iic_external_get_irq (struct iic_pending_bits pending) {int irq;
@@ -138,9 +125,10 @@ static int iic_external_get_irq(struct i*/ if (pending.class !=2 )break ; - irq =IIC_EXT_OFFSET - +spider_get_irq (node) - + node *IIC_NODE_STRIDE ; +/* TODO: We might want to silently ignore cascade interrupts +* when no cascade handler exist yet +*/ + irq =IIC_EXT_CASCADE + node *IIC_NODE_STRIDE ;break ; case 0x01 ... 0x04: case 0x07 ... 0x0a:
@@ -172,6 +160,8 @@ int iic_get_irq(struct pt_regs *regs) iic = &__get_cpu_var (iic); *(unsigned long *) &pending =in_be64 ((unsigned long __iomem *) &iic->regs->pending_destr); + iic->eoi_stack[++iic->eoi_ptr] = pending.prio; +BUG_ON (iic->eoi_ptr >15 ); irq =-1 ;if (pending.flags &IIC_VALID ) {
@@ -192,7 +182,7 @@ int iic_get_irq(struct pt_regs *regs)/* hardcoded part to be compatible with older firmware */ -static int setup_iic_hardcoded (void ) +static int __init setup_iic_hardcoded (void ) {struct device_node *np;int nodeid, cpu;
@@ -232,7 +222,7 @@ static int setup_iic_hardcoded(void)return 0 ; } -static int setup_iic (void ) +static int __init setup_iic (void ) {struct device_node *dn;unsigned long *regs;
@@ -268,11 +258,13 @@ static int setup_iic(void) iic = &per_cpu (iic, np[0 ]); iic->regs =ioremap (regs[0 ],sizeof (struct iic_regs )); iic->target_id = ((np[0 ] &2 ) <<3 ) + ((np[0 ] &1 ) ?0xf :0xe ); + iic->eoi_stack[0 ] =0xff ;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->target_id = ((np[1 ] &2 ) <<3 ) + ((np[1 ] &1 ) ?0xf :0xe ); + iic->eoi_stack[0 ] =0xff ;printk ("IIC for CPU %d at %lx mapped to %p\n" , np[1 ], regs[2 ], iic->regs); found++;
@@ -324,10 +316,10 @@ static void iic_request_ipi(int ipi, conint irq; irq =iic_ipi_to_irq (ipi); +/* IPIs are marked SA_INTERRUPT as they must run with irqs * disabled */ -get_irq_desc (irq)->chip = &iic_pic; -get_irq_desc (irq)->status |=IRQ_PER_CPU ; +set_irq_chip_and_handler (irq, &iic_chip, handle_percpu_irq);request_irq (irq, iic_ipi_action,SA_INTERRUPT , name,NULL ); }
@@ -341,20 +333,26 @@ void iic_request_IPIs(void) }#endif /* CONFIG_SMP */ -static void iic_setup_spe_handlers (void ) +static void __init iic_setup_builtin_handlers (void ) {int be, isrc; -/* Assume two threads per BE are present */ +/* XXX FIXME: Assume two threads per BE are present */ for (be=0 ; be <num_present_cpus () /2 ; be++) { +int irq; + +/* setup SPE chip and handlers */ for (isrc =0 ; isrc <IIC_CLASS_STRIDE *3 ; isrc++) { -int irq =IIC_NODE_STRIDE * be +IIC_SPE_OFFSET + isrc; -get_irq_desc (irq)->chip = &iic_pic; + irq =IIC_NODE_STRIDE * be +IIC_SPE_OFFSET + isrc; +set_irq_chip_and_handler (irq, &iic_chip, handle_fasteoi_irq); } +/* setup cascade chip */ + irq =IIC_EXT_CASCADE + be *IIC_NODE_STRIDE ; +set_irq_chip_and_handler (irq, &iic_chip, handle_fasteoi_irq); } } -void iic_init_IRQ (void ) +void __init iic_init_IRQ (void ) {int cpu, irq_offset;struct iic *iic;
@@ -368,5 +366,6 @@ void iic_init_IRQ(void)if (iic->regs)out_be64 (&iic->regs->prio,0xff ); } -iic_setup_spe_handlers (); +iic_setup_builtin_handlers (); + }
arch/powerpc/Kconfig.debug +19 -1
@@ -131,12 +131,30 @@ config PPC_EARLY_DEBUG_G5 help Select this to enable early debugging for Apple G5 machines. -config PPC_EARLY_DEBUG_RTAS +config PPC_EARLY_DEBUG_RTAS_PANEL bool "RTAS Panel" depends on PPC_RTAS help Select this to enable early debugging via the RTAS panel. +config PPC_EARLY_DEBUG_RTAS_CONSOLE + bool "RTAS Console" + depends on PPC_RTAS + help + Select this to enable early debugging via the RTAS console. + +config PPC_EARLY_DEBUG_RTAS_PUTCHAR_TOKEN + hex " RTAS token for put-term-char function" if PPC_EARLY_DEBUG_RTAS_CONSOLE + default "0x27" + help + Enter the value for the put-term-char rtas token on your machine + +config PPC_EARLY_DEBUG_RTAS_GETCHAR_TOKEN + hex " RTAS token for get-term-char function" if PPC_EARLY_DEBUG_RTAS_CONSOLE + default "0x28" + help + Enter the value for the get-term-char rtas token on your machine + config PPC_EARLY_DEBUG_MAPLE bool "Maple real mode" depends on PPC_MAPLE
arch/powerpc/kernel/rtas.c +58 -1
69 lines not on this page · raw message
arch/powerpc/kernel/udbg.c +6 -2
@@ -34,9 +34,13 @@ void __init udbg_early_init(void)#elif defined(CONFIG_PPC_EARLY_DEBUG_G5 )/* For use on Apple G5 machines */ udbg_init_pmac_realmode (); -#elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS ) +#elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS_PANEL )/* RTAS panel debug */ -udbg_init_rtas (); +udbg_init_rtas_panel (); +#elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS_CONSOLE ) +/* RTAS console debug */ +udbg_init_rtas_console (CONFIG_PPC_EARLY_DEBUG_RTAS_PUTCHAR_TOKEN , +CONFIG_PPC_EARLY_DEBUG_RTAS_GETCHAR_TOKEN );#elif defined(CONFIG_PPC_EARLY_DEBUG_MAPLE )/* Maple real mode debug */ udbg_init_maple_realmode ();
arch/powerpc/platforms/cell/interrupt.h +1 -3
@@ -38,6 +38,7 @@enum {IIC_EXT_OFFSET =0x00 ,/* Start of south bridge IRQs */ +IIC_EXT_CASCADE =0x20 ,/* There is no interrupt 32 on spider */ IIC_NUM_EXT =0x40 ,/* Number of south bridge IRQs */ IIC_SPE_OFFSET =0x40 ,/* Start of SPE interrupts */ IIC_CLASS_STRIDE =0x10 ,/* SPE IRQs per class */
@@ -51,13 +52,10 @@ extern int iic_get_irq(struct pt_regs *extern void iic_cause_IPI (int cpu,int mesg);extern void iic_request_IPIs (void );extern void iic_setup_cpu (void ); -extern void iic_local_enable (void ); -extern void iic_local_disable (void );extern u8 iic_get_target_id (int cpu);extern void spider_init_IRQ (void ); -extern int spider_get_irq (int node);#endif #endif /* ASM_CELL_PIC_H */
arch/powerpc/platforms/cell/setup.c +9 -4
@@ -77,11 +77,14 @@ static void cell_progress(char *s, unsigprintk ("*** %04x : %s\n" , hex, s ? s :"" ); } -static void __init cell_setup_arch (void ) +static void __init cell_init_irq (void ) { - ppc_md.init_IRQ = iic_init_IRQ; - ppc_md.get_irq = iic_get_irq; +iic_init_IRQ (); +spider_init_IRQ (); +} +static void __init cell_setup_arch (void ) +{#ifdef CONFIG_SMP smp_init_cell ();#endif
@@ -97,7 +100,6 @@ static void __init cell_setup_arch(void)/* Find and initialize PCI host bridges */ init_pci_config_tokens ();find_and_init_phbs (); -spider_init_IRQ ();cell_pervasive_init ();#ifdef CONFIG_DUMMY_CONSOLE conswitchp = &dummy_con;
@@ -158,6 +160,9 @@ define_machine(cell) { .calibrate_decr = generic_calibrate_decr, .check_legacy_ioport = cell_check_legacy_ioport, .progress = cell_progress, + .init_IRQ = cell_init_irq, + .get_irq = iic_get_irq, + #ifdef CONFIG_KEXEC .machine_kexec = default_machine_kexec, .machine_kexec_prepare = default_machine_kexec_prepare,
arch/powerpc/platforms/cell/spider-pic.c +75 -96
226 lines not on this page · raw message
include/asm-powerpc/udbg.h +3 -1
@@ -41,7 +41,9 @@ extern void __init udbg_init_debug_lpar(extern void __init udbg_init_pmac_realmode (void );extern void __init udbg_init_maple_realmode (void );extern void __init udbg_init_iseries (void ); -extern void __init udbg_init_rtas (void ); +extern void __init udbg_init_rtas_panel (void ); +extern void __init udbg_init_rtas_console (unsigned int put_token, +unsigned int get_token);#endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_UDBG_H */