sparc32: genirq support
PATCH 5/5 sparc32: genirq support
The conversion of sparc32 to genirq is based on original work done by David S. Miller.
generic
Introduce use of GENERIC_HARDIRQS
Allocate 64 IRQs - which is enough even for SS2000 Use a table of irq_bucket to maintain uses IRQs
irq_bucket is also used to chain several irq's that must be called when the same intrrupt is asserted
Use irq_link to link a interrupt source to the irq All plafforms must now supply their own build_device_irq method Use show_interrupts from sparc64
handler_irq rewriten to use generic irq support
floppy
Read FLOPPY_IRQ from plat_From device
Use generic request_irq to register the floppy interrupt Rewrote sparc_floppy_irq to use the generic irq support
pcic:
Introduce irq_chip
Store mask in chip_data for use in mask/unmask functions Add build_device_irq for pcic
Use pcic_build_device_irq in pci_time_init allocate virtual irqs in pcic_fill_irq
sun4c:
Introduce irq_chip
Store mask in chip_data for use in mask/unmask functions Add build_device_irq for sun4c
Use sun4c_build_device_irq in sun4c_init_timers
sun4m:
Introduce irq_chip
Introduce dedicated mask/unmask methods
Introduce sun4m_handler_data that allow easy access to necessary
data in the mask/unmask functions
Add a helper method to enable profile_timer (used from smp) Added sun4m_build_device_irq
Use sun4m_build_device_irq in sun4m_init_timers
TODO:
There is no replacement for smp_rotate that always scheduled next CPU as interrupt target upon an interrupt
sun4d:
Introduce irq_chip
Introduce dedicated mask/unmask methods Introduce sun4d_handler_data that allow easy access to necessary data in mask/unmask fuctions
Rename sbus_tid to board_to_cpu
Rewrote sun4d_handler_irq to use generic irq support
TODO:
The original implmentation of enable/disable had:
if (irq < NR_IRQS)
return;
The new implmentation does not distingush between SBUS and cpu interrupts.
I am no sure what is right here. I assume we need to do something for the cpu interrupts.
I have (not yet at least) sun4d hardware available, and my understanding of this platfrom is limited. So I would be a bit suprised if this works.
leon:
Introduce irq_chip
Store mask in chip_data for use in mask/unmask functions Add build_device_irq for leon
Use leon_build_device_irq in leon_init_timers
--- arch/sparc/Kconfig | 5 +- arch/sparc/include/asm/floppy_32.h | 41 +++- arch/sparc/include/asm/irq_32.h | 8 +- arch/sparc/include/asm/system_32.h | 5 - arch/sparc/kernel/Makefile | 4 - arch/sparc/kernel/irq.h | 44 ++-- arch/sparc/kernel/irq_32.c | 501 ++++++++--------------------------- arch/sparc/kernel/kernel.h | 1 + arch/sparc/kernel/leon_kernel.c | 62 ++++- arch/sparc/kernel/pcic.c | 82 ++++-- arch/sparc/kernel/sun4c_irq.c | 144 ++++++----- arch/sparc/kernel/sun4d_irq.c | 477 ++++++++++++---------------------- arch/sparc/kernel/sun4m_irq.c | 174 +++++++------ arch/sparc/kernel/sun4m_smp.c | 16 +- 14 files changed, 625 insertions(+), 939 deletions(-)
arch/sparc/Kconfig +3 -2
@@ -25,6 +25,9 @@ config SPARC select HAVE_DMA_ATTRS select HAVE_DMA_API_DEBUG select HAVE_ARCH_JUMP_LABEL + select HAVE_GENERIC_HARDIRQS + select GENERIC_HARDIRQS_NO_DEPRECATED + config SPARC32 def_bool !64BIT
@@ -50,8 +53,6 @@ config SPARC64 select RTC_DRV_STARFIRE select HAVE_PERF_EVENTS select PERF_USE_VMALLOC - select HAVE_GENERIC_HARDIRQS - select GENERIC_HARDIRQS_NO_DEPRECATED config ARCH_DEFCONFIG string
arch/sparc/include/asm/floppy_32.h +30 -11
71 lines not on this page · raw message
arch/sparc/include/asm/irq_32.h +7 -1
@@ -6,11 +6,17 @@#ifndef _SPARC_IRQ_H#define _SPARC_IRQ_H -#define NR_IRQS 16 +/* +* Allocated number of logical irq numbers. +* sun4d boxes (ss2000e) should be OK with ~32. +* Be on the safe side and make room for 64 +*/ +#define NR_IRQS 64#include <linux/interrupt.h> #define irq_canonicalize (irq) (irq)extern void __init init_IRQ (void ); +#endif
arch/sparc/include/asm/system_32.h +0 -5
@@ -15,11 +15,6 @@#include <linux/irqflags.h> -static inline unsigned int probe_irq_mask (unsigned long val) -{ -return 0 ; -} -/* * Sparc (general) CPU types */
arch/sparc/kernel/Makefile +0 -4
@@ -71,10 +71,6 @@ obj-$(CONFIG_SPARC64) += pcr.o obj-$(CONFIG_SPARC64) += nmi.o obj-$(CONFIG_SPARC64_SMP) += cpumap.o -# sparc32 do not use GENERIC_HARDIRQS but uses the generic devres implementation -obj-$(CONFIG_SPARC32) += devres.o -devres-y := ../../../kernel/irq/devres.o - obj-y += dma.o obj-$(CONFIG_SPARC32_PCI) += pcic.o
arch/sparc/kernel/irq.h +20 -24
65 lines not on this page · raw message
arch/sparc/kernel/irq_32.c +115 -386
598 lines not on this page · raw message
arch/sparc/kernel/kernel.h +1 -0
@@ -37,6 +37,7 @@ extern void sun4c_init_IRQ(void);extern unsigned int lvl14_resolution;extern void sun4m_init_IRQ (void ); +extern void sun4m_unmask_profile_irq (void );extern void sun4m_clear_profile_irq (int cpu);/* sun4d_irq.c */
arch/sparc/kernel/leon_kernel.c +48 -14
103 lines not on this page · raw message
arch/sparc/kernel/pcic.c +56 -26
166 lines not on this page · raw message
arch/sparc/kernel/sun4c_irq.c +84 -60
192 lines not on this page · raw message
arch/sparc/kernel/sun4d_irq.c +168 -309
599 lines not on this page · raw message
arch/sparc/kernel/sun4m_irq.c +92 -82
254 lines not on this page · raw message
arch/sparc/kernel/sun4m_smp.c +1 -15
@@ -150,20 +150,6 @@ void __init smp4m_smp_done(void)/* Ok, they are spinning and ready to go. */ } -/* At each hardware IRQ, we get this called to forward IRQ reception -* to the next processor. The caller must disable the IRQ level being -* serviced globally so that there are no double interrupts received. -* -* XXX See sparc64 irq.c. -*/ -void smp4m_irq_rotate (int cpu) -{ -int next =cpu_data (cpu).next; - -if (next != cpu) -set_irq_udt (next); -} - static struct smp_funcall { smpfunc_t func; unsigned long arg1;
@@ -277,7 +263,7 @@ static void __cpuinit smp_setup_percpu_timer(void)load_profile_irq (cpu, lvl14_resolution);if (cpu = boot_cpu_id) -enable_pil_irq (14 ); +sun4m_unmask_profile_irq (); }static void __init smp4m_blackbox_id (unsigned *addr)
Signature · 1 line
1.6.0.6
Quoted 9 lines · Sam Ravnborg
arch/sparc/kernel/pcic.c +3
-2-static void pcic_load_profile_irq (int cpu,unsigned int limit) +static unsigned int pcic_startup_irq (struct irq_data *data) { -printk ("PCIC: unimplemented code: FILE=%s LINE=%d" , __FILE__, __LINE__); +irq_link (data->irq); +pcic_unmask_irq (data);
arch/sparc/kernel/pcic.c static inline unsigned long get_irqmask(int irq_nr) · line 876
Quoted 10 lines
arch/sparc/kernel/pcic.c +4
-2+return 0 ; } -static void pcic_enable_pil_irq (unsigned int pil) + +static void pcic_load_profile_irq (int cpu,unsigned int limit) { -writel (get_irqmask (pil), pcic0.pcic_regs+PCI_SYS_INT_TARGET_MASK_CLEAR ); +printk ("PCIC: unimplemented code: FILE=%s LINE=%d" , __FILE__, __LINE__); }
So, continuing on my previous line of nitpicking :) you could also rearrange these two a bit, so they don't clutter up the diff like this.
arch/sparc/kernel/sun4d_irq.c void sun4d_handler_irq(int pil, struct pt_regs *regs) · line 224
Quoted 12 lines
arch/sparc/kernel/sun4d_irq.c +4
-3-int sun4d_request_irq (unsigned int irq, +static void sun4d_mask_irq(struct irq_data *data) -static void sun4d_disable_irq (unsigned int irq) +static void sun4d_unmask_irq(struct irq_data *data) -static void sun4d_enable_irq(unsigned int irq) +/* XXX Do we need shutdown too for sun4d? */ +static unsigned int sun4d_startup_irq(struct irq_data *data)
Also possibly rearrange these two pairs, so that the sun4d_mask_irq/sun4d_disable_irq and sun4d_unmask_irq/sun4d_enable_irq diffs are shown, which would seem to be logical, if I read this right.
arch/sparc/kernel/sun4m_irq.c static unsigned long irq_mask[0x50] = { · line 215
Quoted 10 lines
arch/sparc/kernel/sun4m_irq.c +2
-3-static unsigned long sun4m_get_irqmask(unsigned int irq) +static void sun4m_mask_irq(struct irq_data *data) -static void sun4m_disable_irq(unsigned int irq_nr) +static void sun4m_unmask_irq(struct irq_data *data) -static void sun4m_enable_irq(unsigned int irq_nr)
Here too, you probably want us to see the diff sun4m_disable_irq vs. sun4m_mask_irq, and then sun4m_enable_irq vs. sun4m_unmask_irq, rather than this.
Signature · 1 line
2. That which causes joy or happiness.
Quoted 13 lines · Josip Rodin
Quoted 11 lines · Sam Ravnborg
arch/sparc/kernel/pcic.c +4
-2-static void pcic_load_profile_irq (int cpu,unsigned int limit) +static unsigned int pcic_startup_irq (struct irq_data *data) { -printk ("PCIC: unimplemented code: FILE=%s LINE=%d" , __FILE__, __LINE__); +irq_link (data->irq); +pcic_unmask_irq (data); +return 0 ; }
Quoted 10 lines
arch/sparc/kernel/pcic.c static inline unsigned long get_irqmask(int irq_nr) · line 876
Quoted 7 lines
arch/sparc/kernel/pcic.c +3
-2-static void pcic_enable_pil_irq (unsigned int pil) + +static void pcic_load_profile_irq (int cpu,unsigned int limit) { -writel (get_irqmask (pil), pcic0.pcic_regs+PCI_SYS_INT_TARGET_MASK_CLEAR ); +printk ("PCIC: unimplemented code: FILE=%s LINE=%d" , __FILE__, __LINE__); }So, continuing on my previous line of nitpicking :) you could also rearrange these two a bit, so they don't clutter up the diff like this.
I will try to split the changes in two patches. There are several smaller things that can go in in first patch.
I will prepare a v4 soon.
Sam
David Miller
maintainerFrom: Sam Ravnborg <[email protected]>
Date: Tue, 22 Feb 2011 19:22:19 +0100
Quoted 1 line
I will prepare a v4 soon.
The first 4 patches are in the tree, so you only need to resubmit this patch rather than the whole bunch.
I really look forward to applying v4, thanks Sam!
Quoted 5 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Tue, 22 Feb 2011 19:22:19 +0100
Quoted 10 lines
Quoted 3 lines
I will prepare a v4 soon.
The first 4 patches are in the tree, so you only need to resubmit this patch rather than the whole bunch.
I really look forward to applying v4, thanks Sam!
I think it is very good as well, it will save us a lot of problems in the future! However LEON needs VIRQ to map 1:1 to real IRQs. I figured that it does not hurt the SUNs if we map 1:1 as long as it is possible. The reason is that LEON drivers must have the possibility to do request_irq on IRQ and IRQ+1 and IRQ+2 and so on. Due to how the Plug&Play information is designed we can only know the first IRQ of a device, a device may have 2 IRQs (always IRQ and IRQ+1 in that case). And since VIRQ->REAL_IRQ but not VIRQ+1->REAL_IRQ+1 this will break.
Please see my patches sent to the list (not the APBUART patches), perhaps Sam can include the single patch into the PATCH5? The other patches for the exteneded IRQ controller and irq_shutdown must be applied afterwards.
Thanks,
Daniel
David Miller
maintainerFrom: Daniel Hellstrom <[email protected]>
Date: Wed, 16 Mar 2011 16:53:18 +0100
Quoted 10 lines
I think it is very good as well, it will save us a lot of problems in the future! However LEON needs VIRQ to map 1:1 to real IRQs. I figured that it does not hurt the SUNs if we map 1:1 as long as it is possible. The reason is that LEON drivers must have the possibility to do
request_irqon IRQ and IRQ+1 and IRQ+2 and so on. Due to how the Plug&Play information is designed we can only know the first IRQ of a device, a device may have 2 IRQs (always IRQ and IRQ+1 in that case). And sinceVIRQ->REAL_IRQbut not VIRQ+1->REAL_IRQ+1 this will break.
Quoted 4 lines
Please see my patches sent to the list (not the APBUART patches), perhaps Sam can include the single patch into the PATCH5? The other patches for the exteneded IRQ controller and
irq_shutdownmust be applied afterwards.
I disagree with the validity of your conclusion.
The physical interrupts can be anything.
What you need to do on LEON is convert this linear sequence of physical IRQs to a set of virtual IRQs and make the drivers receive this information.
The method by which the IRQs are communicated to the kernel is absolutely arbitrary, and has no bearing on how this stuff must or must not work.
Therefore, there is absolutely no 1:1 requirement, and I am strongly against supporting such a mapping. It makes the whole VIRQ exercise pointless.
Make the drivers LEON drivers and able to receive a set of IRQs from the kernel, instead of depending upon linearity.
Quoted 30 lines · David Miller
From: Daniel Hellstrom <[email protected]>
Date: Wed, 16 Mar 2011 16:53:18 +0100Quoted 10 lines
I think it is very good as well, it will save us a lot of problems in the future! However LEON needs VIRQ to map 1:1 to real IRQs. I figured that it does not hurt the SUNs if we map 1:1 as long as it is possible. The reason is that LEON drivers must have the possibility to do
request_irqon IRQ and IRQ+1 and IRQ+2 and so on. Due to how the Plug&Play information is designed we can only know the first IRQ of a device, a device may have 2 IRQs (always IRQ and IRQ+1 in that case). And sinceVIRQ->REAL_IRQbut not VIRQ+1->REAL_IRQ+1 this will break.Quoted 6 lines
Please see my patches sent to the list (not the APBUART patches), perhaps Sam can include the single patch into the PATCH5? The other patches for the exteneded IRQ controller and
irq_shutdownmust be applied afterwards.I disagree with the validity of your conclusion.
The physical interrupts can be anything.
What you need to do on LEON is convert this linear sequence of physical IRQs to a set of virtual IRQs and make the drivers receive this information.
Quoted 9 lines
The method by which the IRQs are communicated to the kernel is absolutely arbitrary, and has no bearing on how this stuff must or must not work.
Therefore, there is absolutely no 1:1 requirement, and I am strongly against supporting such a mapping. It makes the whole VIRQ exercise pointless.
I agree, but the problem is that due to hardware limitation the LEON IRQ layers or bootloader can not know this. Please see my reply to "[PATCH 1/2 v2] sparc32,leon: APBUART driver must use ..."
Quoted 5 lines
Make the drivers LEON drivers and able to receive a set of IRQs from the kernel, instead of depending upon linearity.
That is no problem, I can have that done by today. The problem is the bootloader or the IRQ layer of sparc32-leon.