sparc32: genirq conversion (buggy)
PATCH 4/4 sparc32: genirq conversion (buggy)
The actual genirq conversion.
Please ignore sun4c + sun4d stuff for now.
Sam
---
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/irq_32.h +7 -1
@@ -6,7 +6,13 @@#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>
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 +6 -25
@@ -30,10 +30,15 @@ extern struct sun4m_irq_global __iomem *sun4m_irq_global;*/ struct sparc_irq_config {void (*init_timers)(irq_handler_t ); -int (*build_device_irq)(struct platform_device *op,int interrupt); +unsigned int (*build_device_irq)(struct platform_device *op, +unsigned int interrupt); +unsigned int profile_irq; };extern struct sparc_irq_config sparc_irq_config; +unsigned int irq_alloc (unsigned int real_irq,unsigned int pil); +void irq_link (unsigned int irq); +void handler_irq (unsigned int pil,struct pt_regs *regs);/* Dave Redman ([email protected]) * changed these to function pointers.. it saves cycles and will allow
@@ -43,33 +48,9 @@ extern struct sparc_irq_config sparc_irq_config;* Changed these to btfixup entities... It saves cycles :) */ -BTFIXUPDEF_CALL(void, disable_irq, unsigned int) -BTFIXUPDEF_CALL(void, enable_irq, unsigned int) -BTFIXUPDEF_CALL(void, disable_pil_irq, unsigned int) -BTFIXUPDEF_CALL(void, enable_pil_irq, unsigned int) BTFIXUPDEF_CALL(void, clear_clock_irq, void) BTFIXUPDEF_CALL(void, load_profile_irq, int, unsigned int) -static inline void __disable_irq (unsigned int irq) -{ -BTFIXUP_CALL (disable_irq)(irq); -} - -static inline void __enable_irq (unsigned int irq) -{ -BTFIXUP_CALL (enable_irq)(irq); -} - -static inline void disable_pil_irq (unsigned int irq) -{ -BTFIXUP_CALL (disable_pil_irq)(irq); -} - -static inline void enable_pil_irq (unsigned int irq) -{ -BTFIXUP_CALL (enable_pil_irq)(irq); -} -static inline void clear_clock_irq (void ) {BTFIXUP_CALL (clear_clock_irq)();
arch/sparc/kernel/irq_32.c +118 -368
566 lines not on this page · raw message
arch/sparc/kernel/pcic.c +0 -42
55 lines not on this page · raw message
arch/sparc/kernel/sun4c_irq.c +82 -55
177 lines not on this page · raw message
arch/sparc/kernel/sun4d_irq.c +133 -276
510 lines not on this page · raw message
arch/sparc/kernel/sun4m_irq.c +82 -79
228 lines not on this page · raw message
arch/sparc/kernel/sun4m_smp.c +1 -1
@@ -277,7 +277,7 @@ static void __cpuinit smp_setup_percpu_timer(void)load_profile_irq (cpu, lvl14_resolution);if (cpu = boot_cpu_id) -enable_pil_irq (14 ); +enable_irq (sparc_irq_config.profile_irq); }static void __init smp4m_blackbox_id (unsigned *addr)
David Miller
maintainerFrom: Sam Ravnborg <[email protected]>
Date: Sun, 13 Feb 2011 20:29:52 +0100
Quoted 3 lines
arch/sparc/kernel/irq_32.c +3
-0+unsigned int irq_alloc (unsigned int real_irq,unsigned int pil) +{ +unsigned int i;
...
Quoted 4 lines
arch/sparc/kernel/irq_32.c +4
-0+for (i =1 ; i <NR_IRQS ; i++) { +if (irq_table[i].irq = real_irq && irq_table[i].irq = pil) +return i; + }
...
arch/sparc/kernel/irq_32.c static void irq_panic(irq_handler_t handler) · line 158
Quoted 5 lines
arch/sparc/kernel/irq_32.c +5
-0+ irq_table[i].irq = i; + irq_table[i].pil = pil; + +return i; +}
Well, what is it? Are we storing "real_irq" in irq_table[].irq or "i"? I think it's supposed to be "real_irq" and that's one of the reasons your implementation isn't working :-)
Quoted 12 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Sun, 13 Feb 2011 20:29:52 +0100Quoted 3 lines
(quoted diff) +3
-0+unsigned int irq_alloc(unsigned int real_irq, unsigned int pil) +{ + unsigned int i;...
Quoted 4 lines
(quoted diff) +4
-0+ for (i = 1; i < NR_IRQS; i++) { + if (irq_table[i].irq = real_irq && irq_table[i].irq = pil) + return i; + }...
Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +5
-0+ irq_table[i].irq = i; + irq_table[i].pil = pil; + + return i; +}Well, what is it? Are we storing "
real_irq" in irq_table[].irq or "i"? I think it's supposed to be "real_irq" and that's one of the reasons your implementation isn't working :-)
Good catch. I changed the above as I require irq in handler_irq() to lookup the relevant irq_desc. But I obviously scrwed up.
From handler_irq():
unsigned int irq;
irq = p->irq;
desc = irq_to_desc(irq);
if (!(desc->status & IRQ_DISABLED))
desc->handle_irq(irq, desc);So I fixed this - but result is the same - we hang in calibrate_dealy().
Sam
My fix looks like this:
arch/sparc/kernel/irq_32.c +3 -1
@@ -123,6 +123,7 @@ static void irq_panic(irq_handler_t handler)struct irq_bucket {struct irq_bucket *next; +unsigned int real_irq;unsigned int irq;unsigned int pil; };
@@ -138,7 +139,7 @@ unsigned int irq_alloc(unsigned int real_irq, unsigned int pil)unsigned int i;for (i =1 ; i <NR_IRQS ; i++) { -if (irq_table[i].irq = real_irq && irq_table[i].irq = pil) +if (irq_table[i].real_irq = real_irq && irq_table[i].pil = pil)return i; }
@@ -151,6 +152,7 @@ unsigned int irq_alloc(unsigned int real_irq, unsigned int pil)printk (KERN_ERR "IRQ: Out of virtual IRQs.\n" );return 0 ; } + irq_table[i].real_irq = real_irq; irq_table[i].irq = i; irq_table[i].pil = pil;
David Miller
maintainerFrom: Sam Ravnborg <[email protected]>
Date: Sun, 13 Feb 2011 22:06:51 +0100
Quoted 1 line
So I fixed this - but result is the same - we hang in
calibrate_dealy().
Well, the next problem I noticed is that you only enable the timer IRQ on the cpu on which request_irq() executes, what about all of the other cpus in the system?
Quoted 8 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Sun, 13 Feb 2011 22:06:51 +0100Quoted 1 line
So I fixed this - but result is the same - we hang in
calibrate_dealy().Well, the next problem I noticed is that you only enable the timer IRQ on the cpu on which
request_irq()executes, what about all of the other cpus in the system?
Trying to investigate this I actually found a bug:
@@ -267,7 +268,7 @@ static unsigned int sun4m_build_device_irq(struct platform_device *o
}
handler_data->mask = sun4m_imask[real_irq];
- handler_data->percpu = irq < OBP_INT_LEVEL_ONBOARD;
+ handler_data->percpu = real_irq < OBP_INT_LEVEL_ONBOARD;
set_irq_chip(irq, &sun4m_irq);
set_irq_data(irq, handler_data);percpu is a bool used in the enable/disable handlers to determine if this is a system wide or a percpu specific irq.
Before the above change the timer interrupt was considered a cpu specific irq - resulting in the wrong register being set.
With the above change I got one step further - now I see a "Watchdog Reset". I am yet to investigate why.
Quoted 1 line
what about all of the other cpus in the system?
I really do not know :-(
This code is as much as I could a copy of the original implementation (except a floppy hack).
In the original implmentation we did the same via __enable_irq().
And as the timer interrupt is enabled in the system wide interrupt register - I think this is OK.
But I do not (yet) see how to cope with softint's.
As they are unused for now they can wait.
Sam
David Miller
maintainerFrom: Sam Ravnborg <[email protected]>
Date: Sun, 13 Feb 2011 22:48:44 +0100
Quoted 1 line
In the original implmentation we did the same via
__enable_irq().
And we did so Via a function that's invoked by every cpu as it is booted.
Right?
Quoted 8 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Sun, 13 Feb 2011 22:48:44 +0100Quoted 1 line
In the original implmentation we did the same via
__enable_irq().And we did so Via a function that's invoked by every cpu as it is booted.
Right?
To the best of my knowledge - no.
In irq_32.c:request_irq() we had:
__enable_irq(irq); // irq is what we consider real_irq
In irq.h: we had:BTFIXUPDEF_CALL(void, enable_irq, unsigned int)
static inline void __enable_irq(unsigned int irq)
{
BTFIXUP_CALL(enable_irq)(irq);
}In sun4m_irq.c we had:
void __init sun4m_init_IRQ(void)
{
...
BTFIXUPSET_CALL(enable_irq, sun4m_enable_irq, BTFIXUPCALL_NORM);So unless the btfix stuff does trick I do not understand then I do not see this iterate over all cpu's.
I guess there is something obvious I have missed :-(
One thing I have left-out on the sun4m side is a call to smp4m_irq_rotate() that for each interrupt let the next be the interrupt target.
But I do not see that interrupts are globally enabled.
Note: I got one step further. It helped that I
called irq_ack(), irq_enable() around my desc->handle_irq(irq, desc);
But desc->handle_irq in NULL.
That will be for another day - it is getting late.
Thanks for all the help so far!
Sam
David Miller
maintainerFrom: Sam Ravnborg <[email protected]>
Date: Sun, 13 Feb 2011 23:30:18 +0100
Quoted 11 lines · David Miller
Quoted 8 lines
From: Sam Ravnborg <[email protected]>
Date: Sun, 13 Feb 2011 22:48:44 +0100Quoted 1 line
In the original implmentation we did the same via
__enable_irq().And we did so Via a function that's invoked by every cpu as it is booted.
Right?
To the best of my knowledge - no.
I was thinking of:
ofarch/sparc/kernel/sun4m_smp.c:smp_setup_percpu_timer()
which enables it explicitly via enable_pil_irq(14).
Oh, it's a global IRQ, so we should be Ok nevermind. :-)