genirq endian fixes; bcm7120/brcmstb IRQ updates
Subsystems (12)
v2 cover genirq endian fixes; bcm7120/brcmstb IRQ updates
I don't know if this will make everyone 100% happy but hopefully we're inching slightly closer to a solution...
V1->V2:
- Rework big endian support per the discussion on the list
- Get rid of the global compile-time irq_reg_{readl,writel} accessors and make them private to generic-chip.c, so that on multiplatform kernels, different irqchip drivers can specify different MMIO behavior
- Rebase on Linus's head of tree
Patch 06/15 still feels a bit like premature optimization to me. Perhaps we can drop it if nobody reports a measurable performance advantage in any known configuration?
Kevin Cernekee (15):
irqchip: Replace irq_reg_{readl,writel} with {readl,writel}
sh: Eliminate unused irq_reg_{readl,writel} accessors
genirq: Generic chip: Move irq_reg_{readl,writel} accessors into
generic-chip.c
genirq: Generic chip: Change irq_reg_{readl,writel} arguments
genirq: Generic chip: Add big endian I/O accessors
genirq: Generic chip: Optimize for fixed-endian systems
irqchip: brcmstb-l2: Eliminate dependency on ARM code
irqchip: bcm7120-l2: Eliminate bad IRQ check
irqchip: Remove ARM dependency for bcm7120-l2 and brcmstb-l2
irqchip: bcm7120-l2: Make sure all register accesses use base+offset
irqchip: bcm7120-l2: Fix missing nibble in gc->unused mask
irqchip: bcm7120-l2: Use gc->mask_cache to simplify suspend/resume
functions
irqchip: bcm7120-l2: Extend driver to support 64+ bit controllers
irqchip: Decouple bcm7120-l2 from brcmstb-l2
irqchip: bcm7120-l2: Enable big endian register accesses on BE kernels
.../interrupt-controller/brcm,bcm7120-l2-intc.txt | 26 +++- arch/arm/mach-bcm/Kconfig | 1 + arch/sh/boards/mach-se/7343/irq.c | 3 - arch/sh/boards/mach-se/7722/irq.c | 3 - drivers/irqchip/Kconfig | 8 +- drivers/irqchip/Makefile | 4 +- drivers/irqchip/irq-atmel-aic.c | 40 ++--- drivers/irqchip/irq-atmel-aic5.c | 63 ++++---- drivers/irqchip/irq-bcm7120-l2.c | 169 +++++++++++++-------- drivers/irqchip/irq-brcmstb-l2.c | 7 +- drivers/irqchip/irq-sunxi-nmi.c | 4 +- drivers/irqchip/irq-tb10x.c | 4 +- include/linux/irq.h | 8 +- kernel/irq/Kconfig | 5 + kernel/irq/Makefile | 1 + kernel/irq/generic-chip.c | 51 +++++-- 16 files changed, 237 insertions(+), 160 deletions(-)
Signature · 6 lines
2.1.1 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 1/15 irqchip: Replace irq_reg_{readl,writel} with {readl,writel}
Nobody is overriding these definitions anyway, so get rid of the wrappers.
--- drivers/irqchip/irq-atmel-aic.c | 40 ++++++++++++------------- drivers/irqchip/irq-atmel-aic5.c | 65 +++++++++++++++++++--------------------- drivers/irqchip/irq-sunxi-nmi.c | 4 +-- drivers/irqchip/irq-tb10x.c | 4 +-- 4 files changed, 55 insertions(+), 58 deletions(-)
drivers/irqchip/irq-atmel-aic.c +20 -20
@@ -65,11 +65,11 @@ aic_handle(struct pt_regs *regs)u32 irqnr;u32 irqstat; - irqnr =irq_reg_readl (gc->reg_base +AT91_AIC_IVR ); - irqstat =irq_reg_readl (gc->reg_base +AT91_AIC_ISR ); + irqnr =readl (gc->reg_base +AT91_AIC_IVR ); + irqstat =readl (gc->reg_base +AT91_AIC_ISR );if (!irqstat) -irq_reg_writel (0 , gc->reg_base +AT91_AIC_EOICR ); +writel (0 , gc->reg_base +AT91_AIC_EOICR );else handle_domain_irq (aic_domain, irqnr, regs); }
@@ -80,7 +80,7 @@ static int aic_retrigger(struct irq_data *d)/* Enable interrupt on AIC5 */ irq_gc_lock (gc); -irq_reg_writel (d->mask, gc->reg_base +AT91_AIC_ISCR ); +writel (d->mask, gc->reg_base +AT91_AIC_ISCR );irq_gc_unlock (gc);return 0 ;
@@ -92,12 +92,12 @@ static int aic_set_type(struct irq_data *d, unsigned type)unsigned int smr;int ret; - smr =irq_reg_readl (gc->reg_base +AT91_AIC_SMR (d->hwirq)); + smr =readl (gc->reg_base +AT91_AIC_SMR (d->hwirq)); ret =aic_common_set_type (d, type, &smr);if (ret)return ret; -irq_reg_writel (smr, gc->reg_base +AT91_AIC_SMR (d->hwirq)); +writel (smr, gc->reg_base +AT91_AIC_SMR (d->hwirq));return 0 ; }
@@ -108,8 +108,8 @@ static void aic_suspend(struct irq_data *d)struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);irq_gc_lock (gc); -irq_reg_writel (gc->mask_cache, gc->reg_base +AT91_AIC_IDCR ); -irq_reg_writel (gc->wake_active, gc->reg_base +AT91_AIC_IECR ); +writel (gc->mask_cache, gc->reg_base +AT91_AIC_IDCR ); +writel (gc->wake_active, gc->reg_base +AT91_AIC_IECR );irq_gc_unlock (gc); }
@@ -118,8 +118,8 @@ static void aic_resume(struct irq_data *d)struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);irq_gc_lock (gc); -irq_reg_writel (gc->wake_active, gc->reg_base +AT91_AIC_IDCR ); -irq_reg_writel (gc->mask_cache, gc->reg_base +AT91_AIC_IECR ); +writel (gc->wake_active, gc->reg_base +AT91_AIC_IDCR ); +writel (gc->mask_cache, gc->reg_base +AT91_AIC_IECR );irq_gc_unlock (gc); }
@@ -128,8 +128,8 @@ static void aic_pm_shutdown(struct irq_data *d)struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);irq_gc_lock (gc); -irq_reg_writel (0xffffffff , gc->reg_base +AT91_AIC_IDCR ); -irq_reg_writel (0xffffffff , gc->reg_base +AT91_AIC_ICCR ); +writel (0xffffffff , gc->reg_base +AT91_AIC_IDCR ); +writel (0xffffffff , gc->reg_base +AT91_AIC_ICCR ); irq_gc_unlock(gc); }#else
@@ -148,24 +148,24 @@ static void __init aic_hw_init(struct irq_domain *domain)* will not Lock out nIRQ */ for (i =0 ; i <8 ; i++) -irq_reg_writel (0 , gc->reg_base +AT91_AIC_EOICR ); +writel (0 , gc->reg_base +AT91_AIC_EOICR );/* * Spurious Interrupt ID in Spurious Vector Register. * When there is no current interrupt, the IRQ Vector Register * reads the value stored in AIC_SPU */ -irq_reg_writel (0xffffffff , gc->reg_base +AT91_AIC_SPU ); +writel (0xffffffff , gc->reg_base +AT91_AIC_SPU );/* No debugging in AIC: Debug (Protect) Control Register */ -irq_reg_writel (0 , gc->reg_base +AT91_AIC_DCR ); +writel (0 , gc->reg_base +AT91_AIC_DCR );/* Disable and clear all interrupts initially */ -irq_reg_writel (0xffffffff , gc->reg_base +AT91_AIC_IDCR ); -irq_reg_writel (0xffffffff , gc->reg_base +AT91_AIC_ICCR ); +writel (0xffffffff , gc->reg_base +AT91_AIC_IDCR ); +writel (0xffffffff , gc->reg_base +AT91_AIC_ICCR );for (i =0 ; i <32 ; i++) -irq_reg_writel (i, gc->reg_base +AT91_AIC_SVR (i)); +writel (i, gc->reg_base +AT91_AIC_SVR (i)); } static int aic_irq_domain_xlate(struct irq_domain *d,
@@ -195,10 +195,10 @@ static int aic_irq_domain_xlate(struct irq_domain *d, gc = dgc->gc[idx];irq_gc_lock (gc); - smr =irq_reg_readl (gc->reg_base +AT91_AIC_SMR (*out_hwirq)); + smr =readl (gc->reg_base +AT91_AIC_SMR (*out_hwirq)); ret =aic_common_set_priority (intspec[2 ], &smr);if (!ret) -irq_reg_writel (smr, gc->reg_base +AT91_AIC_SMR (*out_hwirq)); +writel (smr, gc->reg_base +AT91_AIC_SMR (*out_hwirq));irq_gc_unlock (gc);return ret;
drivers/irqchip/irq-atmel-aic5.c +31 -34
146 lines not on this page · raw message
drivers/irqchip/irq-sunxi-nmi.c +2 -2
@@ -50,12 +50,12 @@ static struct sunxi_sc_nmi_reg_offs sun6i_reg_offs = {static inline void sunxi_sc_nmi_write (struct irq_chip_generic *gc,u32 off,u32 val) { -irq_reg_writel (val, gc->reg_base + off); +writel (val, gc->reg_base + off); }static inline u32 sunxi_sc_nmi_read (struct irq_chip_generic *gc,u32 off) { -return irq_reg_readl (gc->reg_base + off); +return readl (gc->reg_base + off); }static void sunxi_sc_nmi_handle_irq (unsigned int irq,struct irq_desc *desc)
drivers/irqchip/irq-tb10x.c +2 -2
@@ -43,12 +43,12 @@static inline void ab_irqctl_writereg (struct irq_chip_generic *gc,u32 reg,u32 val) { -irq_reg_writel (val, gc->reg_base + reg); +writel (val, gc->reg_base + reg); }static inline u32 ab_irqctl_readreg (struct irq_chip_generic *gc,u32 reg) { -return irq_reg_readl (gc->reg_base + reg); +return readl (gc->reg_base + reg); }static int tb10x_irq_set_type (struct irq_data *data,unsigned int flow_type)
Signature · 1 line
2.1.1
PATCH v2 2/15 sh: Eliminate unused irq_reg_{readl,writel} accessors
In reply to Kevin CernekeeDefining these macros way down in arch/sh/.../irq.c doesn't cause kernel/irq/generic-chip.c to use them. As far as I can tell this code has no effect.
--- arch/sh/boards/mach-se/7343/irq.c | 3 --- arch/sh/boards/mach-se/7722/irq.c | 3 --- 2 files changed, 6 deletions(-)
arch/sh/boards/mach-se/7343/irq.c +0 -3
@@ -14,9 +14,6 @@#define DRV_NAME "SE7343-FPGA"#define pr_fmt (fmt) DRV_NAME ": " fmt -#define irq_reg_readl ioread16 -#define irq_reg_writel iowrite16 -#include <linux/init.h> #include <linux/irq.h> #include <linux/interrupt.h>
arch/sh/boards/mach-se/7722/irq.c +0 -3
@@ -11,9 +11,6 @@#define DRV_NAME "SE7722-FPGA"#define pr_fmt (fmt) DRV_NAME ": " fmt -#define irq_reg_readl ioread16 -#define irq_reg_writel iowrite16 -#include <linux/init.h> #include <linux/irq.h> #include <linux/interrupt.h>
Signature · 1 line
2.1.1
Re: [PATCH V2 02/15] sh: Eliminate unused irq_reg_{readl,writel} accessors
Quoted 5 lines · On Wednesday 29 October 2014 19:17:55 Kevin Cernekee wrote:
Defining these macros way down in
arch/sh/.../irq.cdoesn't causekernel/irq/generic-chip.cto use them. As far as I can tell this code has no effect.Signed-off-by Kevin Cernekee <[email protected]>
Actually it overrides the 32-bit accessors with 16-bit accessors, which does seem intentional and certainly has an effect.
Arnd
Quoted 18 lines
arch/sh/boards/mach-se/7343/irq.c | 3 --- arch/sh/boards/mach-se/7722/irq.c | 3 --- 2 files changed, 6 deletions(-)arch/sh/boards/mach-se/7343/irq.c +0
-3@@ -14,9 +14,6 @@#define DRV_NAME "SE7343-FPGA"#define pr_fmt (fmt) DRV_NAME ": " fmt -#define irq_reg_readl ioread16 -#define irq_reg_writel iowrite16 -#include <linux/init.h> #include <linux/irq.h> #include <linux/interrupt.h>
Re: [PATCH V2 02/15] sh: Eliminate unused irq_reg_{readl,writel} accessors
Quoted 9 lines · Arnd Bergmann
Quoted 5 lines · On Wednesday 29 October 2014 19:17:55 Kevin Cernekee wrote:
Defining these macros way down in
arch/sh/.../irq.cdoesn't causekernel/irq/generic-chip.cto use them. As far as I can tell this code has no effect.Signed-off-by Kevin Cernekee <[email protected]>Actually it overrides the 32-bit accessors with 16-bit accessors, which does seem intentional and certainly has an effect.
Not really. Neither arch/sh/boards/mach-se/7343/irq.c nor arch/sh/boards/mach-se/7722/irq.c actually use irq_reg_readl/writel. They simply define it.
Thanks,
tglx
Re: [PATCH V2 02/15] sh: Eliminate unused irq_reg_{readl,writel} accessors
Quoted 7 lines · On Thursday 30 October 2014 11:43:00 Thomas Gleixner wrote:
Quoted 5 lines · Arnd Bergmann
Quoted 4 lines · On Wednesday 29 October 2014 19:17:55 Kevin Cernekee wrote:
Defining these macros way down in
arch/sh/.../irq.cdoesn't causekernel/irq/generic-chip.cto use them. As far as I can tell this code has no effect.
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
Signed-off-by Kevin Cernekee <[email protected]>Actually it overrides the 32-bit accessors with 16-bit accessors, which does seem intentional and certainly has an effect.
Not really. Neither
arch/sh/boards/mach-se/7343/irq.cnorarch/sh/boards/mach-se/7722/irq.cactually use irq_reg_readl/writel. They simply define it.
Ah, that makes things easier. I looked at the commits that introduced them, and even then they were unused. Probably an artifact from an earlier version of the patch which did not get merged.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH V2 02/15] sh: Eliminate unused irq_reg_{readl,writel} accessors
Quoted 13 lines · Arnd Bergmann
Quoted 12 lines · On Thursday 30 October 2014 11:43:00 Thomas Gleixner wrote:
Quoted 9 lines · Arnd Bergmann
Quoted 5 lines · On Wednesday 29 October 2014 19:17:55 Kevin Cernekee wrote:
Defining these macros way down in
arch/sh/.../irq.cdoesn't causekernel/irq/generic-chip.cto use them. As far as I can tell this code has no effect.Signed-off-by Kevin Cernekee <[email protected]>Actually it overrides the 32-bit accessors with 16-bit accessors, which does seem intentional and certainly has an effect.
Quoted 7 lines
Quoted 3 lines
Not really. Neither
arch/sh/boards/mach-se/7343/irq.cnorarch/sh/boards/mach-se/7722/irq.cactually use irq_reg_readl/writel. They simply define it.Ah, that makes things easier. I looked at the commits that introduced them, and even then they were unused. Probably an artifact from an earlier version of the patch which did not get merged.
I suspect that the intention was to put them into the machine's <irq.h> so that generic-chip.c would pick them up. The sh irq.c files do call ioread16/iowrite16 themselves, and like bcm7120-l2, they utilize irq_gc_mask_{set,clr}_bit from generic-chip.c.
This may be something for the maintainers (Paul?) to double-check, but if the submission worked as-is, maybe overriding the I/O accessors wasn't actually needed. Or maybe there are subtle and unfortunate side effects on adjacent registers.
PATCH v2 3/15 genirq: Generic chip: Move irq_reg_{readl,writel} accessors into generic-chip.c
In reply to Kevin CernekeeThis allows us to implement per-irqchip behavior when necessary, instead of hardcoding the behavior for all irqchip drivers at compile time.
--- include/linux/irq.h | 7 ------- kernel/irq/generic-chip.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 7 deletions(-)
include/linux/irq.h +0 -7
@@ -639,13 +639,6 @@ void arch_teardown_hwirq(unsigned int irq);void irq_init_desc (unsigned int irq);#endif -#ifndef irq_reg_writel -# define irq_reg_writel (val, addr) writel(val, addr) -#endif -#ifndef irq_reg_readl -# define irq_reg_readl (addr) readl(addr) -#endif -/** * struct irq_chip_regs - register offsets for struct irq_gci * @enable: Enable register offset to reg_base
kernel/irq/generic-chip.c +10 -0
@@ -17,6 +17,16 @@static LIST_HEAD (gc_list);static DEFINE_RAW_SPINLOCK (gc_lock); +static void irq_reg_writel (u32 val,void __iomem *addr) +{ +writel (val, addr); +} + +static u32 irq_reg_readl (void __iomem *addr) +{ +return readl (addr); +} +/** * irq_gc_noop - NOOP function * @d: irq_data
Signature · 1 line
2.1.1
Re: [PATCH V2 03/15] genirq: Generic chip: Move irq_reg_{readl,writel} accessors into generic-chip.c
Quoted 14 lines · Kevin Cernekee
This allows us to implement per-irqchip behavior when necessary, instead of hardcoding the behavior for all irqchip drivers at compile time.
Signed-off-by Kevin Cernekee <[email protected]>--- include/linux/irq.h | 7 ------- kernel/irq/generic-chip.c | 10 ++++++++++ 2 files changed, 10 insertions(+), 7 deletions(-)include/linux/irq.h +0
-0
include/linux/irq.h void arch_teardown_hwirq(unsigned int irq); · line 648
Quoted 10 lines
include/linux/irq.h +0
-7@@ -639,13 +639,6 @@ void arch_teardown_hwirq(unsigned int irq);void irq_init_desc (unsigned int irq);#endif -#ifndef irq_reg_writel -# define irq_reg_writel (val, addr) writel(val, addr) -#endif -#ifndef irq_reg_readl -# define irq_reg_readl (addr) readl(addr) -#endif -
Brilliant patch that.
# git grep -l irq_reg_readl drivers/irqchip/ drivers/irqchip/irq-atmel-aic.c drivers/irqchip/irq-atmel-aic5.c drivers/irqchip/irq-sunxi-nmi.c drivers/irqchip/irq-tb10x.c
Thanks,
tglx
Re: [PATCH V2 03/15] genirq: Generic chip: Move irq_reg_{readl,writel} accessors into generic-chip.c
Quoted 18 lines · On Thursday 30 October 2014 09:43:02 Thomas Gleixner wrote:
Quoted 5 lines
include/linux/irq.h +0
-0include/linux/irq.h void arch_teardown_hwirq(unsigned int irq); · line 648
Quoted 10 lines
include/linux/irq.h +0
-7@@ -639,13 +639,6 @@ void arch_teardown_hwirq(unsigned int irq);void irq_init_desc (unsigned int irq);#endif -#ifndef irq_reg_writel -# define irq_reg_writel (val, addr) writel(val, addr) -#endif -#ifndef irq_reg_readl -# define irq_reg_readl (addr) readl(addr) -#endif -Brilliant patch that.
Quoted 5 lines
# git grep -l irq_reg_readl drivers/irqchip/ drivers/irqchip/irq-atmel-aic.c drivers/irqchip/irq-atmel-aic5.c drivers/irqchip/irq-sunxi-nmi.c drivers/irqchip/irq-tb10x.c
Patch 1/15 changes these all. I think it's still broken because patch 2/15 is wrong, but it's not /that/ obviously broken.
Arnd
Re: [PATCH V2 03/15] genirq: Generic chip: Move irq_reg_{readl,writel} accessors into generic-chip.c
Quoted 19 lines · Arnd Bergmann
Quoted 18 lines · On Thursday 30 October 2014 09:43:02 Thomas Gleixner wrote:
Quoted 5 lines
include/linux/irq.h +0
-0include/linux/irq.h void arch_teardown_hwirq(unsigned int irq); · line 648
Quoted 10 lines
include/linux/irq.h +0
-7@@ -639,13 +639,6 @@ void arch_teardown_hwirq(unsigned int irq);void irq_init_desc (unsigned int irq);#endif -#ifndef irq_reg_writel -# define irq_reg_writel (val, addr) writel(val, addr) -#endif -#ifndef irq_reg_readl -# define irq_reg_readl (addr) readl(addr) -#endif -Brilliant patch that.
Quoted 8 lines
Quoted 5 lines
# git grep -l irq_reg_readl drivers/irqchip/ drivers/irqchip/irq-atmel-aic.c drivers/irqchip/irq-atmel-aic5.c drivers/irqchip/irq-sunxi-nmi.c drivers/irqchip/irq-tb10x.cPatch 1/15 changes these all. I think it's still broken because patch 2/15 is wrong, but it's not /that/ obviously broken.
Oops. Missed that.
Re: [PATCH V2 03/15] genirq: Generic chip: Move irq_reg_{readl,writel} accessors into generic-chip.c
Quoted 26 lines · Thomas Gleixner
Quoted 25 lines · Arnd Bergmann
Quoted 23 lines · On Thursday 30 October 2014 09:43:02 Thomas Gleixner wrote:
Quoted 5 lines
include/linux/irq.h +0
-0include/linux/irq.h void arch_teardown_hwirq(unsigned int irq); · line 648
Quoted 10 lines
include/linux/irq.h +0
-7@@ -639,13 +639,6 @@ void arch_teardown_hwirq(unsigned int irq);void irq_init_desc (unsigned int irq);#endif -#ifndef irq_reg_writel -# define irq_reg_writel (val, addr) writel(val, addr) -#endif -#ifndef irq_reg_readl -# define irq_reg_readl (addr) readl(addr) -#endif -Brilliant patch that.
# git grep -l irq_reg_readl drivers/irqchip/ drivers/irqchip/irq-atmel-aic.c drivers/irqchip/irq-atmel-aic5.c drivers/irqchip/irq-sunxi-nmi.c drivers/irqchip/irq-tb10x.c
Quoted 4 lines
Quoted 2 lines
Patch 1/15 changes these all. I think it's still broken because patch 2/15 is wrong, but it's not /that/ obviously broken.
Oops. Missed that.
But looking at: drivers/irqchip/irq-sunxi-nmi.c
It's using the generic chip. So while the generic chip uses the accessor function, the driver implementation which implements extra functionality will use something hardcoded. While it does not break the current setup, it's wrong nevertheless.
Thanks,
tglx
PATCH v2 4/15 genirq: Generic chip: Change irq_reg_{readl,writel} arguments
In reply to Kevin CernekeeInstead of taking a raw register virtual address, we will take an irq_chip_generic struct and a register offset. This makes it possible to implement different behavior on different irqchips.
--- kernel/irq/generic-chip.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-)
kernel/irq/generic-chip.c +16 -14
@@ -17,14 +17,16 @@static LIST_HEAD (gc_list);static DEFINE_RAW_SPINLOCK (gc_lock); -static void irq_reg_writel (u32 val,void __iomem *addr) +static void irq_reg_writel (struct irq_chip_generic *gc, +u32 val,int reg_offset) { -writel (val, addr); +writel (val, gc->reg_base + reg_offset); } -static u32 irq_reg_readl (void __iomem *addr) +static u32 irq_reg_readl (struct irq_chip_generic *gc, +int reg_offset) { -return readl (addr); +return readl (gc->reg_base + reg_offset); }/**
@@ -49,7 +51,7 @@ void irq_gc_mask_disable_reg(struct irq_data *d)u32 mask = d->mask;irq_gc_lock (gc); -irq_reg_writel (mask, gc->reg_base + ct->regs.disable); +irq_reg_writel (gc, mask, ct->regs.disable); *ct->mask_cache &= ~mask;irq_gc_unlock (gc); }
@@ -69,7 +71,7 @@ void irq_gc_mask_set_bit(struct irq_data *d)irq_gc_lock (gc); *ct->mask_cache |= mask; -irq_reg_writel (*ct->mask_cache, gc->reg_base + ct->regs.mask); +irq_reg_writel (gc, *ct->mask_cache, ct->regs.mask);irq_gc_unlock (gc); }EXPORT_SYMBOL_GPL (irq_gc_mask_set_bit);
@@ -89,7 +91,7 @@ void irq_gc_mask_clr_bit(struct irq_data *d)irq_gc_lock (gc); *ct->mask_cache &= ~mask; -irq_reg_writel (*ct->mask_cache, gc->reg_base + ct->regs.mask); +irq_reg_writel (gc, *ct->mask_cache, ct->regs.mask);irq_gc_unlock (gc); }EXPORT_SYMBOL_GPL (irq_gc_mask_clr_bit);
@@ -108,7 +110,7 @@ void irq_gc_unmask_enable_reg(struct irq_data *d)u32 mask = d->mask;irq_gc_lock (gc); -irq_reg_writel (mask, gc->reg_base + ct->regs.enable); +irq_reg_writel (gc, mask, ct->regs.enable); *ct->mask_cache |= mask;irq_gc_unlock (gc); }
@@ -124,7 +126,7 @@ void irq_gc_ack_set_bit(struct irq_data *d)u32 mask = d->mask;irq_gc_lock (gc); -irq_reg_writel (mask, gc->reg_base + ct->regs.ack); +irq_reg_writel (gc, mask, ct->regs.ack);irq_gc_unlock (gc); }EXPORT_SYMBOL_GPL (irq_gc_ack_set_bit);
@@ -140,7 +142,7 @@ void irq_gc_ack_clr_bit(struct irq_data *d)u32 mask = ~d->mask;irq_gc_lock (gc); -irq_reg_writel (mask, gc->reg_base + ct->regs.ack); +irq_reg_writel (gc, mask, ct->regs.ack);irq_gc_unlock (gc); }
@@ -155,8 +157,8 @@ void irq_gc_mask_disable_reg_and_ack(struct irq_data *d)u32 mask = d->mask;irq_gc_lock (gc); -irq_reg_writel (mask, gc->reg_base + ct->regs.mask); -irq_reg_writel (mask, gc->reg_base + ct->regs.ack); +irq_reg_writel (gc, mask, ct->regs.mask); +irq_reg_writel (gc, mask, ct->regs.ack);irq_gc_unlock (gc); }
@@ -171,7 +173,7 @@ void irq_gc_eoi(struct irq_data *d)u32 mask = d->mask;irq_gc_lock (gc); -irq_reg_writel (mask, gc->reg_base + ct->regs.eoi); +irq_reg_writel (gc, mask, ct->regs.eoi);irq_gc_unlock (gc); }
@@ -255,7 +257,7 @@ irq_gc_init_mask_cache(struct irq_chip_generic *gc, enum irq_gc_flags flags) } ct[i].mask_cache = mskptr;if (flags &IRQ_GC_INIT_MASK_CACHE ) - *mskptr =irq_reg_readl (gc->reg_base + mskreg); + *mskptr =irq_reg_readl (gc, mskreg); } }
Signature · 1 line
2.1.1
PATCH v2 5/15 genirq: Generic chip: Add big endian I/O accessors
In reply to Kevin CernekeeUse io{read,write}32be if the caller specified IRQ_GC_BE_IO when creating the irqchip.
--- include/linux/irq.h | 1 + kernel/irq/generic-chip.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-)
include/linux/irq.h +1 -0
@@ -739,6 +739,7 @@ enum irq_gc_flags {IRQ_GC_INIT_NESTED_LOCK =1 <<1 ,IRQ_GC_MASK_CACHE_PER_TYPE =1 <<2 ,IRQ_GC_NO_MASK =1 <<3 , + IRQ_GC_BE_IO = 1 << 4, };/*
kernel/irq/generic-chip.c +13 -2
@@ -17,16 +17,27 @@static LIST_HEAD (gc_list);static DEFINE_RAW_SPINLOCK (gc_lock); +static int is_big_endian (struct irq_chip_generic *gc) +{ +return !!(gc->domain->gc->gc_flags &IRQ_GC_BE_IO ); +} +static void irq_reg_writel (struct irq_chip_generic *gc,u32 val,int reg_offset) { -writel (val, gc->reg_base + reg_offset); +if (is_big_endian (gc)) +iowrite32be (val, gc->reg_base + reg_offset); +else +writel (val, gc->reg_base + reg_offset); }static u32 irq_reg_readl (struct irq_chip_generic *gc,int reg_offset) { -return readl (gc->reg_base + reg_offset); +if (is_big_endian (gc)) +return ioread32be (gc->reg_base + reg_offset); +else +return readl (gc->reg_base + reg_offset); }/**
Signature · 1 line
2.1.1
Re: [PATCH V2 05/15] genirq: Generic chip: Add big endian I/O accessors
Quoted 8 lines · On Wednesday 29 October 2014 19:17:58 Kevin Cernekee wrote:
static
LIST_HEAD(gc_list);
staticDEFINE_RAW_SPINLOCK(gc_lock);kernel/irq/generic-chip.c +4
-0+static int is_big_endian (struct irq_chip_generic *gc) +{ +return !!(gc->domain->gc->gc_flags &IRQ_GC_BE_IO ); +}
kernel/irq/generic-chip.c line 32
Quoted 10 lines
kernel/irq/generic-chip.c +5
-1+static void irq_reg_writel (struct irq_chip_generic *gc,u32 val,int reg_offset) { -writel (val, gc->reg_base + reg_offset); +if (is_big_endian (gc)) +iowrite32be (val, gc->reg_base + reg_offset); +else +writel (val, gc->reg_base + reg_offset); }
What I had in mind was to use indirect function calls instead, like
#ifndef irq_reg_writel
static inline void irq_reg_writel_le(u32 val, void __iomem *addr)
{
return writel(val, addr);
}#endif
#ifndef irq_reg_writel_be
static inline void irq_reg_writel_be(u32 val, void __iomem *addr)
{
return iowrite32_be(val, addr);
}#endif
static inline void irq_reg_writel(struct irq_chip_generic *gc, u32 val, int reg_offset)
{
if (IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP) &&
!IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP_BE))
return irq_reg_writel_le(val, gc->reg_base + reg_offset);
if (IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP) &&
!IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP_BE))
return irq_reg_writel_be(val, gc->reg_base + reg_offset);
return gc->writel(val, gc->reg_base + reg_offset);
}This would take the condition out of the callers.
Arnd
Re: [PATCH V2 05/15] genirq: Generic chip: Add big endian I/O accessors
Quoted 34 lines · Arnd Bergmann
Quoted 8 lines · On Wednesday 29 October 2014 19:17:58 Kevin Cernekee wrote:
static
LIST_HEAD(gc_list);
staticDEFINE_RAW_SPINLOCK(gc_lock);kernel/irq/generic-chip.c +4
-0+static int is_big_endian (struct irq_chip_generic *gc) +{ +return !!(gc->domain->gc->gc_flags &IRQ_GC_BE_IO ); +}kernel/irq/generic-chip.c line 32
Quoted 10 lines
kernel/irq/generic-chip.c +5
-1+static void irq_reg_writel (struct irq_chip_generic *gc,u32 val,int reg_offset) { -writel (val, gc->reg_base + reg_offset); +if (is_big_endian (gc)) +iowrite32be (val, gc->reg_base + reg_offset); +else +writel (val, gc->reg_base + reg_offset); }What I had in mind was to use indirect function calls instead, like
#ifndef
irq_reg_writel
static inline voidirq_reg_writel_le(u32 val, void __iomem *addr){ return writel(val, addr); }#endif
#ifndef
irq_reg_writel_be
static inline voidirq_reg_writel_be(u32 val, void __iomem *addr){ return iowrite32_be(val, addr); }
Quoted 6 lines
#endif
static inline void
irq_reg_writel(struct irq_chip_generic *gc, u32 val, int reg_offset){ if (IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP) &&
That's inside of the generic irq chip, so CONFIG_GENERIC_IRQ_CHIP is always set when this is compiled.
Quoted 5 lines
!IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP_BE))
return irq_reg_writel_le(val, gc->reg_base + reg_offset);
if (IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP) &&
!IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP_BE))s/!// ?
Quoted 1 line
return irq_reg_writel_be(val, gc->reg_base + reg_offset);
I don't think the above will cover all combinations.
..._CHIP_BE ...CHIP_LE
N N ; Default behaviour: readl/writel
Y N ; ioread/write32be
N Y ; Default behaviour: readl/writel
Y Y ; Runtime selected
Quoted 4 lines
return gc->writel(val, gc->reg_base + reg_offset); }This would take the condition out of the callers.
So you trade a conditional for an indirect call. Not sure what's more expensive. The indirect call is definitely a smaller text footprint, so we should opt for this.
Thanks,
tglx
Re: [PATCH V2 05/15] genirq: Generic chip: Add big endian I/O accessors
Quoted 38 lines · On Thursday 30 October 2014 13:30:04 Thomas Gleixner wrote:
Quoted 37 lines · Arnd Bergmann
Quoted 8 lines · On Wednesday 29 October 2014 19:17:58 Kevin Cernekee wrote:
static
LIST_HEAD(gc_list);
staticDEFINE_RAW_SPINLOCK(gc_lock);kernel/irq/generic-chip.c +4
-0+static int is_big_endian (struct irq_chip_generic *gc) +{ +return !!(gc->domain->gc->gc_flags &IRQ_GC_BE_IO ); +}kernel/irq/generic-chip.c line 32
Quoted 10 lines
kernel/irq/generic-chip.c +5
-1+static void irq_reg_writel (struct irq_chip_generic *gc,u32 val,int reg_offset) { -writel (val, gc->reg_base + reg_offset); +if (is_big_endian (gc)) +iowrite32be (val, gc->reg_base + reg_offset); +else +writel (val, gc->reg_base + reg_offset); }What I had in mind was to use indirect function calls instead, like
#ifndef
irq_reg_writel
static inline voidirq_reg_writel_le(u32 val, void __iomem *addr){ return writel(val, addr); }#endif
#ifndef
irq_reg_writel_be
static inline voidirq_reg_writel_be(u32 val, void __iomem *addr){ return iowrite32_be(val, addr); }#endif
Quoted 6 lines
Quoted 3 lines
static inline void
irq_reg_writel(struct irq_chip_generic *gc, u32 val, int reg_offset){ if (IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP) &&That's inside of the generic irq chip, so
CONFIG_GENERIC_IRQ_CHIPis always set when this is compiled.
The part that I mentioned in the other mail and omitted here is that I'd then build the kernel/irq/generic-chip.c file when one or both of CONFIG_GENERIC_IRQ_CHIP or CONFIG_GENERIC_IRQ_CHIP_BE is set.
The alternative would be to introduce CONFIG_GENERIC_IRQ_CHIP_LE along with CONFIG_GENERIC_IRQ_CHIP_BE, which might be cleaner, but requires all existing 39 'select GENERIC_IRQ_CHIP' statements to be changed to 'GENERIC_IRQ_CHIP_LE'.
Either way would work.
Quoted 7 lines
Quoted 5 lines
!IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP_BE)) return irq_reg_writel_le(val, gc->reg_base + reg_offset); if (IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP) && !IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP_BE))s/!// ?
typo: I put the ! in the wrong line, sorry.
Quoted 6 lines
Quoted 1 line
return irq_reg_writel_be(val, gc->reg_base + reg_offset);I don't think the above will cover all combinations.
..._CHIP_BE ...CHIP_LE
N N ; Default behaviour: readl/writel
that would not be allowed with my approach. It should probably cause a compile-error if we introduce all three symbols.
Quoted 6 lines
Y N ; ioread/write32be
N Y ; Default behaviour: readl/writel
Y Y ; Runtime selected
Quoted 8 lines
Quoted 4 lines
return gc->writel(val, gc->reg_base + reg_offset); }This would take the condition out of the callers.
So you trade a conditional for an indirect call. Not sure what's more expensive. The indirect call is definitely a smaller text footprint, so we should opt for this.
It depends on the register pressure in the caller and on the pipeline of the CPU. My guess was that indirect call is generally more efficient, but you are right that this is not obvious, and I have no reliable data to back up my guess.
If we do the conditional, we could also just add an extra byte swap, instead of choosing between two function calls.
Arnd
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 6/15 genirq: Generic chip: Optimize for fixed-endian systems
In reply to Kevin CernekeeAllow the compiler to inline an LE MMIO access if the configuration only supports LE registers, or a BE MMIO access if the configuration only supports BE registers. If the configuration supports both (possibly a multiplatform kernel) then make the decision at runtime.
--- kernel/irq/Kconfig | 5 +++++ kernel/irq/Makefile | 1 + kernel/irq/generic-chip.c | 10 +++++++++- 3 files changed, 15 insertions(+), 1 deletion(-)
kernel/irq/Kconfig +5 -0
@@ -51,6 +51,11 @@ config GENERIC_IRQ_CHIP bool select IRQ_DOMAIN +# Same as above, but use big-endian MMIO accesses +config GENERIC_IRQ_CHIP_BE + bool + select IRQ_DOMAIN + # Generic irq_domain hw <--> linux irq number translation config IRQ_DOMAIN bool
kernel/irq/Makefile +1 -0
@@ -1,6 +1,7 @@ obj-y := irqdesc.o handle.o manage.o spurious.o resend.o chip.o dummychip.o devres.o obj-$(CONFIG_GENERIC_IRQ_CHIP) += generic-chip.o +obj-$(CONFIG_GENERIC_IRQ_CHIP_BE) += generic-chip.o obj-$(CONFIG_GENERIC_IRQ_PROBE) += autoprobe.o obj-$(CONFIG_IRQ_DOMAIN) += irqdomain.o obj-$(CONFIG_PROC_FS) += proc.o
kernel/irq/generic-chip.c +9 -1
@@ -9,6 +9,7 @@#include <linux/export.h> #include <linux/irqdomain.h> #include <linux/interrupt.h> +#include <linux/kconfig.h> #include <linux/kernel_stat.h> #include <linux/syscore_ops.h>
@@ -19,7 +20,14 @@ static DEFINE_RAW_SPINLOCK(gc_lock);static int is_big_endian (struct irq_chip_generic *gc) { -return !!(gc->domain->gc->gc_flags &IRQ_GC_BE_IO ); +if (IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP ) && + !IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP_BE )) +return 0 ; +else if (IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP_BE ) && + !IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP )) +return 1 ; +else +return !!(gc->domain->gc->gc_flags &IRQ_GC_BE_IO ); } static void irq_reg_writel(struct irq_chip_generic *gc,
Signature · 1 line
2.1.1
Re: [PATCH V2 06/15] genirq: Generic chip: Optimize for fixed-endian systems
kernel/irq/generic-chip.c static DEFINE_RAW_SPINLOCK(gc_lock); · line 28
Quoted 11 lines · Kevin Cernekee
kernel/irq/generic-chip.c +6
-1@@ -19,7 +20,14 @@ static DEFINE_RAW_SPINLOCK(gc_lock);static int is_big_endian (struct irq_chip_generic *gc) { -return !!(gc->domain->gc->gc_flags &IRQ_GC_BE_IO ); +if (IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP ) && + !IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP_BE )) +return 0 ; +else if (IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP_BE ) && + !IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP )) +return 1 ;
Would XOR make this any easier to read? e.g.:
if (IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP) ^ IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP_BE)) return IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP_BE); else ...
kernel/irq/generic-chip.c static DEFINE_RAW_SPINLOCK(gc_lock); · line 33
Quoted 5 lines
kernel/irq/generic-chip.c +2
-0+else +return !!(gc->domain->gc->gc_flags &IRQ_GC_BE_IO ); } static void irq_reg_writel(struct irq_chip_generic *gc,
Brian
Re: [PATCH V2 06/15] genirq: Generic chip: Optimize for fixed-endian systems
Quoted 10 lines · On Wednesday 29 October 2014 21:16:58 Brian Norris wrote:
kernel/irq/generic-chip.c static DEFINE_RAW_SPINLOCK(gc_lock); · line 28
Quoted 9 lines
static int
is_big_endian(struct irq_chip_generic *gc){kernel/irq/generic-chip.c +6
-1-return !!(gc->domain->gc->gc_flags &IRQ_GC_BE_IO ); +if (IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP ) && + !IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP_BE )) +return 0 ; +else if (IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP_BE ) && + !IS_ENABLED (CONFIG_GENERIC_IRQ_CHIP )) +return 1 ;
Quoted 8 lines
Would XOR make this any easier to read? e.g.:
if (IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP) ^ IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP_BE)) return IS_ENABLED(CONFIG_GENERIC_IRQ_CHIP_BE); else ...
I think that would only be easier to read for the compiler, not for for a human. ;-)
Arnd
PATCH v2 7/15 irqchip: brcmstb-l2: Eliminate dependency on ARM code
In reply to Kevin CernekeeThe irq-brcmstb-l2 driver has a single dependency on the ARM code, the do_bad_IRQ macro. Expand this macro in-place so that the driver can be built on non-ARM platforms.
--- drivers/irqchip/irq-brcmstb-l2.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/irqchip/irq-brcmstb-l2.c +4 -3
@@ -19,6 +19,7 @@#include <linux/slab.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/spinlock.h> #include <linux/of.h> #include <linux/of_irq.h> #include <linux/of_address.h>
@@ -30,8 +31,6 @@#include <linux/irqchip.h> #include <linux/irqchip/chained_irq.h> -#include <asm/mach/irq.h> -#include "irqchip.h" /* Register offsets in the L2 interrupt controller */
@@ -63,7 +62,9 @@ static void brcmstb_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc) ~(__raw_readl (b->base +CPU_MASK_STATUS ));if (status ==0 ) { -do_bad_IRQ (irq, desc); +raw_spin_lock (&desc->lock); +handle_bad_irq (irq, desc); +raw_spin_unlock (&desc->lock); goto out; }
Signature · 1 line
2.1.1
PATCH v2 8/15 irqchip: bcm7120-l2: Eliminate bad IRQ check
In reply to Kevin CernekeeThis check may be prone to race conditions, e.g.
1) Some external event (e.g. GPIO level) causes an IRQ to become pending
2) Peripheral asserts the L2 IRQ
3) CPU takes an interrupt
4) The event from #1 goes away
5) bcm7120_l2_intc_irq_handle() reads back a 0 status
Unlike the hardware supported by brcmstb-l2, the bcm7120-l2 controller does not latch the IRQ status. Bits can change if the inputs to the controller change. Also, do_bad_IRQ() is an ARM-specific macro.
So let's just nuke it.
--- drivers/irqchip/irq-bcm7120-l2.c | 9 --------- 1 file changed, 9 deletions(-)
drivers/irqchip/irq-bcm7120-l2.c +0 -9
@@ -27,8 +27,6 @@#include "irqchip.h" -#include <asm/mach/irq.h> -/* Register offset in the L2 interrupt controller */ #define IRQEN 0x00#define IRQSTAT 0x04
@@ -51,19 +49,12 @@ static void bcm7120_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc)chained_irq_enter (chip, desc); status =__raw_readl (b->base +IRQSTAT ); - -if (status ==0 ) { -do_bad_IRQ (irq, desc); - goto out; - } -do { irq =ffs (status) -1 ; status &= ~(1 << irq);generic_handle_irq (irq_find_mapping (b->domain, irq)); }while (status); -out:chained_irq_exit (chip, desc); }
Signature · 1 line
2.1.1
Re: [PATCH V2 08/15] irqchip: bcm7120-l2: Eliminate bad IRQ check
Hello.
Quoted 24 lines · Kevin Cernekee
This check may be prone to race conditions, e.g.
1) Some external event (e.g. GPIO level) causes an IRQ to become pending
2) Peripheral asserts the L2 IRQ
3) CPU takes an interrupt
4) The event from #1 goes away
5)bcm7120_l2_intc_irq_handle()reads back a 0 statusUnlike the hardware supported by brcmstb-l2, the bcm7120-l2 controller does not latch the IRQ status. Bits can change if the inputs to the controller change. Also,
do_bad_IRQ()is an ARM-specific macro.So let's just nuke it.
Signed-off-by Kevin Cernekee <[email protected]>Acked-by Florian Fainelli <[email protected]>--- drivers/irqchip/irq-bcm7120-l2.c | 9 --------- 1 file changed, 9 deletions(-)drivers/irqchip/irq-bcm7120-l2.c +0
-0
[...]
drivers/irqchip/irq-bcm7120-l2.c static void bcm7120_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc) · line 52
Quoted 11 lines
drivers/irqchip/irq-bcm7120-l2.c +0
-6@@ -51,19 +49,12 @@ static void bcm7120_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc)chained_irq_enter (chip, desc); status =__raw_readl (b->base +IRQSTAT ); - -if (status ==0 ) { -do_bad_IRQ (irq, desc); - goto out; - } - do {
I think this needs to now become:
while (status) {drivers/irqchip/irq-bcm7120-l2.c static void bcm7120_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc) · line 54
Quoted 2 lines
drivers/irqchip/irq-bcm7120-l2.c +0
-0irq =ffs (status) -1 ; status &= ~(1 << irq);
In case 'status' is 0, 'irq' will be equal to -1. How does the shift by
negative value work?
drivers/irqchip/irq-bcm7120-l2.c static void bcm7120_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc) · line 56
Quoted 2 lines
drivers/irqchip/irq-bcm7120-l2.c +0
-0generic_handle_irq (irq_find_mapping (b->domain, irq)); }while (status);
WBR, Sergei
Re: [PATCH V2 08/15] irqchip: bcm7120-l2: Eliminate bad IRQ check
Quoted 24 lines · Sergei Shtylyov
Quoted 5 lines
drivers/irqchip/irq-bcm7120-l2.c +0
-0[...]
drivers/irqchip/irq-bcm7120-l2.c static void bcm7120_l2_intc_irq_handle(unsigned int · line 53
Quoted 13 lines
drivers/irqchip/irq-bcm7120-l2.c +0
-6@@ -51,19 +49,12 @@ static void bcm7120_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc)chained_irq_enter (chip, desc); status =__raw_readl (b->base +IRQSTAT ); - -if (status ==0 ) { -do_bad_IRQ (irq, desc); - goto out; - } - do {I think this needs to now become:
Quoted 11 lines
while (status) {drivers/irqchip/irq-bcm7120-l2.c static void bcm7120_l2_intc_irq_handle(unsigned int irq, struct irq_desc *desc) · line 54
Quoted 2 lines
drivers/irqchip/irq-bcm7120-l2.c +0
-0irq =ffs (status) -1 ; status &= ~(1 << irq);In case 'status' is 0, 'irq' will be equal to -1. How does the shift by
negative value work?Quoted 2 lines
drivers/irqchip/irq-bcm7120-l2.c +0
-0generic_handle_irq (irq_find_mapping (b->domain, irq)); }while (status);
That's a good point. We need to check for 0 somehow.
This code gets replaced in patch 13/15 anyway, but I'll fix it in the next round.
Thanks!
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 9/15 irqchip: Remove ARM dependency for bcm7120-l2 and brcmstb-l2
In reply to Kevin CernekeeThis can compile for MIPS (or anything else) now.
--- drivers/irqchip/Kconfig | 1 - 1 file changed, 1 deletion(-)
drivers/irqchip/Kconfig +0 -1
@@ -50,7 +50,6 @@ config ATMEL_AIC5_IRQ config BRCMSTB_L2_IRQ bool - depends on ARM select GENERIC_IRQ_CHIP select IRQ_DOMAIN
Signature · 1 line
2.1.1
Re: [PATCH V2 09/15] irqchip: Remove ARM dependency for bcm7120-l2 and brcmstb-l2
Quoted 14 lines · Kevin Cernekee
This can compile for MIPS (or anything else) now.
Signed-off-by Kevin Cernekee <[email protected]>Acked-by Arnd Bergmann <[email protected]>Acked-by Florian Fainelli <[email protected]>--- drivers/irqchip/Kconfig | 1 - 1 file changed, 1 deletion(-)drivers/irqchip/Kconfig +0
-0
drivers/irqchip/Kconfig config ATMEL_AIC5_IRQ · line 53
Quoted 4 lines
drivers/irqchip/Kconfig +0
-1@@ -50,7 +50,6 @@ config ATMEL_AIC5_IRQ config BRCMSTB_L2_IRQ bool - depends on ARM
How about the following?
depends on ARM || MIPS || COMPILE_TEST
[...]
WBR, Sergei
Re: [PATCH V2 09/15] irqchip: Remove ARM dependency for bcm7120-l2 and brcmstb-l2
Quoted 6 lines · On Thursday 30 October 2014 14:10:30 Sergei Shtylyov wrote:
Quoted 6 lines
drivers/irqchip/Kconfig +0
-0@@ -50,7 +50,6 @@ config ATMEL_AIC5_IRQ
Quoted 8 lines
drivers/irqchip/Kconfig config ATMEL_AIC5_IRQ · line 53
Quoted 3 lines
drivers/irqchip/Kconfig +0
-1config BRCMSTB_L2_IRQ bool - depends on ARMHow about the following?
depends on ARM || MIPS ||
COMPILE_TEST
Makes no sense when the driver isn't user-selectable.
Arnd
Re: [PATCH V2 09/15] irqchip: Remove ARM dependency for bcm7120-l2 and brcmstb-l2
Hello.
Quoted 12 lines · Arnd Bergmann
Quoted 11 lines
drivers/irqchip/Kconfig config ATMEL_AIC5_IRQ · line 53
Quoted 9 lines
drivers/irqchip/Kconfig +0
-1@@ -50,7 +50,6 @@ config ATMEL_AIC5_IRQ config BRCMSTB_L2_IRQ bool - depends on ARMHow about the following?
Quoted 3 lines
Quoted 1 line
depends on ARM || MIPS || COMPILE_TESTMakes no sense when the driver isn't user-selectable.
Ah, I was just blind. :-/
Quoted 1 line
Arnd
WBR, Sergei
PATCH v2 10/15 irqchip: bcm7120-l2: Make sure all register accesses use base+offset
In reply to Kevin CernekeeA couple of accesses to IRQEN (base+0x00) just used "base" directly, so they would break if IRQEN ever became nonzero. Make sure that all reads/writes specify the register offset constant.
--- drivers/irqchip/irq-bcm7120-l2.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/irqchip/irq-bcm7120-l2.c +3 -3
@@ -66,10 +66,10 @@ static void bcm7120_l2_intc_suspend(struct irq_data *d)irq_gc_lock (gc);/* Save the current mask and the interrupt forward mask */ - b->saved_mask =__raw_readl (b->base) | b->irq_fwd_mask; + b->saved_mask =__raw_readl (b->base +IRQEN ) | b->irq_fwd_mask;if (b->can_wake) { reg = b->saved_mask | gc->wake_active; -__raw_writel (reg, b->base); +__raw_writel (reg, b->base +IRQEN ); }irq_gc_unlock (gc); }
@@ -81,7 +81,7 @@ static void bcm7120_l2_intc_resume(struct irq_data *d)/* Restore the saved mask */ irq_gc_lock (gc); -__raw_writel (b->saved_mask, b->base); +__raw_writel (b->saved_mask, b->base +IRQEN );irq_gc_unlock (gc); }
Signature · 1 line
2.1.1
Re: [PATCH V2 10/15] irqchip: bcm7120-l2: Make sure all register accesses use base+offset
Quoted 7 lines · On Wednesday 29 October 2014 19:18:03 Kevin Cernekee wrote:
A couple of accesses to IRQEN (
base+0x00) just used "base" directly, so they would break if IRQEN ever became nonzero. Make sure that all reads/writes specify the register offset constant.Signed-off-by Kevin Cernekee <[email protected]>Acked-by Florian Fainelli <[email protected]>
Now you no longer convert them this driver to use irq_reg_{readl,writel}, which breaks support for big-endian ARM.
Arnd
PATCH v2 11/15 irqchip: bcm7120-l2: Fix missing nibble in gc->unused mask
In reply to Kevin CernekeeThis mask should have been 0xffff_ffff, not 0x0fff_ffff.
The change should not have an effect on current users (STB) because bits 31:27 are unused.
--- drivers/irqchip/irq-bcm7120-l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-bcm7120-l2.c +1 -1
@@ -171,7 +171,7 @@ int __init bcm7120_l2_intc_of_init(struct device_node *dn, } gc =irq_get_domain_generic_chip (data->domain,0 ); - gc->unused =0xfffffff & ~data->irq_map_mask; + gc->unused =0xffffffff & ~data->irq_map_mask; gc->reg_base = data->base; gc->private = data; ct = gc->chip_types;
Signature · 1 line
2.1.1
PATCH v2 12/15 irqchip: bcm7120-l2: Use gc->mask_cache to simplify suspend/resume functions
In reply to Kevin CernekeeThe cached value already incorporates irq_fwd_mask, and was saved the last time an IRQ was enabled/disabled.
--- drivers/irqchip/irq-bcm7120-l2.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/irqchip/irq-bcm7120-l2.c +3 -8
@@ -37,7 +37,6 @@ struct bcm7120_l2_intc_data {bool can_wake;u32 irq_fwd_mask;u32 irq_map_mask; -u32 saved_mask; };static void bcm7120_l2_intc_irq_handle (unsigned int irq,struct irq_desc *desc)
@@ -62,14 +61,11 @@ static void bcm7120_l2_intc_suspend(struct irq_data *d) {struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d);struct bcm7120_l2_intc_data *b = gc->private; -u32 reg;irq_gc_lock (gc); -/* Save the current mask and the interrupt forward mask */ - b->saved_mask =__raw_readl (b->base +IRQEN ) | b->irq_fwd_mask;if (b->can_wake) { - reg = b->saved_mask | gc->wake_active; -__raw_writel (reg, b->base +IRQEN ); +__raw_writel (gc->mask_cache | gc->wake_active, + b->base +IRQEN ); }irq_gc_unlock (gc); }
@@ -77,11 +73,10 @@ static void bcm7120_l2_intc_suspend(struct irq_data *d)static void bcm7120_l2_intc_resume (struct irq_data *d) {struct irq_chip_generic *gc =irq_data_get_irq_chip_data (d); -struct bcm7120_l2_intc_data *b = gc->private;/* Restore the saved mask */ irq_gc_lock (gc); -__raw_writel (b->saved_mask, b->base +IRQEN ); +__raw_writel (gc->mask_cache, b->base +IRQEN );irq_gc_unlock (gc); }
Signature · 1 line
2.1.1
PATCH v2 13/15 irqchip: bcm7120-l2: Extend driver to support 64+ bit controllers
In reply to Kevin CernekeeMost implementations of the bcm7120-l2 controller only have a single 32-bit enable word + 32-bit status word. But some instances have added more enable/status pairs in order to support 64+ IRQs (which are all ORed into one parent IRQ input). Make the following changes to allow the driver to support this:
- Extend DT bindings so that multiple words can be specified for the reg property, various masks, etc.
- Add loops to the probe/handle functions to deal with each word separately
- Allocate 1 generic-chip for every 32 IRQs, so we can still use the clr/set helper functions
- Update the documentation
This uses one domain per bcm7120-l2 DT node. If the DT node defines multiple enable/status pairs (i.e. >=64 IRQs) then the driver will create a single IRQ domain with 2+ generic chips. Multiple generic chips are required because the generic-chip code can only handle one enable/status register pair per instance.
--- .../interrupt-controller/brcm,bcm7120-l2-intc.txt | 26 ++-- drivers/irqchip/irq-bcm7120-l2.c | 146 ++++++++++++++------- 2 files changed, 114 insertions(+), 58 deletions(-)
Documentation/devicetree/bindings/interrupt-controller/brcm,bcm7120-l2-intc.txt +18 -8
@@ -13,7 +13,12 @@ Such an interrupt controller has the following hardware design: or if they will output an interrupt signal at this 2nd level interrupt controller, in particular for UARTs -- not all 32-bits within the interrupt controller actually map to an interrupt +- typically has one 32-bit enable word and one 32-bit status word, but on + some hardware may have more than one enable/status pair + +- no atomic set/clear operations + +- not all bits within the interrupt controller actually map to an interrupt The typical hardware layout for this controller is represented below:
@@ -48,7 +53,9 @@ The typical hardware layout for this controller is represented below: Required properties: - compatible: should be "brcm,bcm7120-l2-intc" -- reg: specifies the base physical address and size of the registers +- reg: specifies the base physical address and size of the registers; + multiple pairs may be specified, with the first pair handling IRQ offsets + 0..31 and the second pair handling 32..63 - interrupt-controller: identifies the node as an interrupt controller - #interrupt-cells: specifies the number of cells needed to encode an interrupt source, should be 1.
@@ -59,18 +66,21 @@ Required properties: - brcm,int-map-mask: 32-bits bit mask describing how many and which interrupts are wired to this 2nd level interrupt controller, and how they match their respective interrupt parents. Should match exactly the number of interrupts - specified in the 'interrupts' property. + specified in the 'interrupts' property, multiplied by the number of + enable/status register pairs implemented by this controller. For + multiple parent IRQs with multiple enable/status words, this looks like: + <irq0_w0 irq0_w1 irq1_w0 irq1_w1 ...> Optional properties: - brcm,irq-can-wake: if present, this means the L2 controller can be used as a wakeup source for system suspend/resume. -- brcm,int-fwd-mask: if present, a 32-bits bit mask to configure for the - interrupts which have a mux gate, typically UARTs. Setting these bits will - make their respective interrupts outputs bypass this 2nd level interrupt - controller completely, it completely transparent for the interrupt controller - parent +- brcm,int-fwd-mask: if present, a bit mask to configure the interrupts which + have a mux gate, typically UARTs. Setting these bits will make their + respective interrupt outputs bypass this 2nd level interrupt controller + completely; it is completely transparent for the interrupt controller + parent. This should have one 32-bit word per enable/status pair. Example:
drivers/irqchip/irq-bcm7120-l2.c +96 -50
243 lines not on this page · raw message
Signature · 1 line
2.1.1
PATCH v2 14/15 irqchip: Decouple bcm7120-l2 from brcmstb-l2
In reply to Kevin CernekeeSome chips, such as BCM6328, only require the former driver. Some BCM7xxx STB configurations only require the latter driver. Treat them as two separate entities, and update the mach-bcm dependencies to reflect the change.
--- arch/arm/mach-bcm/Kconfig | 1 + drivers/irqchip/Kconfig | 5 +++++ drivers/irqchip/Makefile | 4 ++-- drivers/irqchip/irq-bcm7120-l2.c | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-)
arch/arm/mach-bcm/Kconfig +1 -0
@@ -125,6 +125,7 @@ config ARCH_BRCMSTB select HAVE_ARM_ARCH_TIMER select BRCMSTB_GISB_ARB select BRCMSTB_L2_IRQ + select BCM7120_L2_IRQ help Say Y if you intend to run the kernel on a Broadcom ARM-based STB chipset.
drivers/irqchip/Kconfig +5 -0
@@ -48,6 +48,11 @@ config ATMEL_AIC5_IRQ select MULTI_IRQ_HANDLER select SPARSE_IRQ +config BCM7120_L2_IRQ + bool + select GENERIC_IRQ_CHIP + select IRQ_DOMAIN + config BRCMSTB_L2_IRQ bool select GENERIC_IRQ_CHIP
drivers/irqchip/Makefile +2 -2
@@ -35,6 +35,6 @@ obj-$(CONFIG_TB10X_IRQC) += irq-tb10x.o obj-$(CONFIG_XTENSA) += irq-xtensa-pic.o obj-$(CONFIG_XTENSA_MX) += irq-xtensa-mx.o obj-$(CONFIG_IRQ_CROSSBAR) += irq-crossbar.o -obj-$(CONFIG_BRCMSTB_L2_IRQ) += irq-brcmstb-l2.o \ - irq-bcm7120-l2.o +obj-$(CONFIG_BCM7120_L2_IRQ) += irq-bcm7120-l2.o +obj-$(CONFIG_BRCMSTB_L2_IRQ) += irq-brcmstb-l2.o obj-$(CONFIG_KEYSTONE_IRQ) += irq-keystone.o
drivers/irqchip/irq-bcm7120-l2.c +1 -1
@@ -247,5 +247,5 @@ out_unmap:kfree (data);return ret; } -IRQCHIP_DECLARE (brcmstb_l2_intc,"brcm,bcm7120-l2-intc" , +IRQCHIP_DECLARE (bcm7120_l2_intc,"brcm,bcm7120-l2-intc" , bcm7120_l2_intc_of_init);
Signature · 1 line
2.1.1
PATCH v2 15/15 irqchip: bcm7120-l2: Enable big endian register accesses on BE kernels
In reply to Kevin CernekeeOn all supported SoCs, the kernel will be built with CONFIG_CPU_BIG_ENDIAN iff the CPU is running in BE mode. Leverage this fact to autodetect the MMIO byte ordering to use in generic-chip.c.
--- drivers/irqchip/Kconfig | 2 ++ drivers/irqchip/irq-bcm7120-l2.c | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-)
drivers/irqchip/Kconfig +2 -0
@@ -51,11 +51,13 @@ config ATMEL_AIC5_IRQ config BCM7120_L2_IRQ bool select GENERIC_IRQ_CHIP + select GENERIC_IRQ_CHIP_BE select IRQ_DOMAIN config BRCMSTB_L2_IRQ bool select GENERIC_IRQ_CHIP + select GENERIC_IRQ_CHIP_BE select IRQ_DOMAIN config DW_APB_ICTL
drivers/irqchip/irq-bcm7120-l2.c +6 -3
@@ -132,7 +132,7 @@ int __init bcm7120_l2_intc_of_init(struct device_node *dn,const __be32 *map_mask;int num_parent_irqs;int ret =0 , len; -unsigned int idx, irq; +unsigned int idx, irq, flags; data =kzalloc (sizeof (*data),GFP_KERNEL );if (!data)
@@ -195,9 +195,12 @@ int __init bcm7120_l2_intc_of_init(struct device_node *dn, goto out_unmap; } + flags =IRQ_GC_INIT_MASK_CACHE ; +if (IS_ENABLED (CONFIG_CPU_BIG_ENDIAN )) + flags |=IRQ_GC_BE_IO ; + ret =irq_alloc_domain_generic_chips (data->domain,IRQS_PER_WORD ,1 , - dn->full_name, handle_level_irq, clr,0 , -IRQ_GC_INIT_MASK_CACHE ); + dn->full_name, handle_level_irq, clr,0 , flags);if (ret) {pr_err ("failed to allocate generic irq chip\n" ); goto out_free_domain;
Signature · 1 line
2.1.1
Re: [PATCH V2 15/15] irqchip: bcm7120-l2: Enable big endian register accesses on BE kernels
drivers/irqchip/irq-bcm7120-l2.c int __init bcm7120_l2_intc_of_init(struct device_node *dn, · line 201
Quoted 6 lines · On Wednesday 29 October 2014 19:18:08 Kevin Cernekee wrote:
drivers/irqchip/irq-bcm7120-l2.c +4
-0+ flags =IRQ_GC_INIT_MASK_CACHE ; +if (IS_ENABLED (CONFIG_CPU_BIG_ENDIAN )) + flags |=IRQ_GC_BE_IO ; +
As I said before, I think you should take this from a DT property instead of making it dependent on the CPU endianess. Otherwise things go horribly wrong e.g. when someone runs a big-endian kernel on one of the ARM based chips.
Arnd