bcm2836 (Raspberry Pi 2) interrupt controller updates for 4.5
Subsystems (3)
cover bcm2836 (Raspberry Pi 2) interrupt controller updates for 4.5
While the 2836 interrupt controller technically works, it would be nice to merge these improvements to it, adding SMP booting, fixing the timers, and fixing an apparently-spurious error message.
Patches 1, 2 were seen before in the full Pi 2 series I sent recently, now with their summary prefixes fixed and a minor style cleanup to #2. Patches 3, 4 are new, but trivial.
Andrea Merello (3):
irqchip: bcm2836: Add SMP support for the 2836
irqchip: bcm2836: tolerate IRQs while no flag is set in ISR
irqchip: bcm2836: make code more readable
Eric Anholt (1):
irqchip: bcm2836: Fix initialization of the LOCAL_IRQ_CNT*IRQ timers
drivers/irqchip/irq-bcm2836.c | 55 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-)
Signature · 1 line
2.6.2
PATCH 1/4 irqchip: bcm2836: Fix initialization of the LOCAL_IRQ_CNT*IRQ timers
The irqchip's register area includes the the setup for the timer's scaling factors, and for the platform we want a fixed configuration of these registers.
--- drivers/irqchip/irq-bcm2836.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/irqchip/irq-bcm2836.c +26 -0
@@ -21,6 +21,9 @@#include <linux/irqdomain.h> #include <asm/exception.h> +#define LOCAL_CONTROL 0x000 +#define LOCAL_PRESCALER 0x008 +/* * The low 2 bits identify the CPU that the GPU IRQ goes to, and the * next 2 bits identify the CPU that the GPU FIQ goes to.
@@ -237,6 +240,27 @@ bcm2836_arm_irqchip_smp_init(void)#endif } +/* +* The LOCAL_IRQ_CNT* timer firings are based off of the external +* oscillator with some scaling. The firmware sets up CNTFRQ to +* report 19.2Mhz, but doesn't set up the scaling registers. +*/ +static void bcm2835_init_local_timer_frequency (void ) +{ +/* +* Set the timer to source from the 19.2Mhz crystal clock (bit +* 8 unset), and only increment by 1 instead of 2 (bit 9 +* unset). +*/ +writel (0 , intc.base +LOCAL_CONTROL ); + +/* +* Set the timer prescaler to 1:1 (timer freq = input freq * +* 2**31 / prescaler) +*/ +writel (0x80000000 , intc.base +LOCAL_PRESCALER ); +} +static int __init bcm2836_arm_irqchip_l1_intc_of_init (struct device_node *node,struct device_node *parent) {
@@ -246,6 +270,8 @@ static int __init bcm2836_arm_irqchip_l1_intc_of_init(struct device_node *node, node->full_name); } +bcm2835_init_local_timer_frequency (); + intc.domain =irq_domain_add_linear (node,LAST_IRQ +1 , &bcm2836_arm_irqchip_intc_ops,NULL );
Signature · 1 line
2.6.2
tip-bot for Eric Anholt
merge bot[tip:irq/core] irqchip/bcm2836: Fix initialization of the LOCAL_IRQ_CNT timers
irqchip/bcm2836: Fix initialization of the LOCAL_IRQ_CNT timers
Commit-ID: 401667bb8a2e0825090c5e6c15b899c1c36a4773 Gitweb: http://git.kernel.org/tip/401667bb8a2e0825090c5e6c15b899c1c36a4773 Author: Eric Anholt <[email protected]> AuthorDate: Sat, 26 Dec 2015 13:47:21 -0800 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 29 Dec 2015 11:40:45 +0100
irqchip/bcm2836: Fix initialization of the LOCAL_IRQ_CNT timers
The irqchip's register area includes the the setup for the timer's scaling factors, and for the platform we want a fixed configuration of these registers.
--- drivers/irqchip/irq-bcm2836.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
drivers/irqchip/irq-bcm2836.c +26 -0
@@ -21,6 +21,9 @@#include <linux/irqdomain.h> #include <asm/exception.h> +#define LOCAL_CONTROL 0x000 +#define LOCAL_PRESCALER 0x008 +/* * The low 2 bits identify the CPU that the GPU IRQ goes to, and the * next 2 bits identify the CPU that the GPU FIQ goes to.
@@ -237,6 +240,27 @@ bcm2836_arm_irqchip_smp_init(void)#endif } +/* +* The LOCAL_IRQ_CNT* timer firings are based off of the external +* oscillator with some scaling. The firmware sets up CNTFRQ to +* report 19.2Mhz, but doesn't set up the scaling registers. +*/ +static void bcm2835_init_local_timer_frequency (void ) +{ +/* +* Set the timer to source from the 19.2Mhz crystal clock (bit +* 8 unset), and only increment by 1 instead of 2 (bit 9 +* unset). +*/ +writel (0 , intc.base +LOCAL_CONTROL ); + +/* +* Set the timer prescaler to 1:1 (timer freq = input freq * +* 2**31 / prescaler) +*/ +writel (0x80000000 , intc.base +LOCAL_PRESCALER ); +} +static int __init bcm2836_arm_irqchip_l1_intc_of_init (struct device_node *node,struct device_node *parent) {
@@ -246,6 +270,8 @@ static int __init bcm2836_arm_irqchip_l1_intc_of_init(struct device_node *node, node->full_name); } +bcm2835_init_local_timer_frequency (); + intc.domain =irq_domain_add_linear (node,LAST_IRQ +1 , &bcm2836_arm_irqchip_intc_ops,NULL );
PATCH 2/4 irqchip: bcm2836: Add SMP support for the 2836
In reply to Eric AnholtFrom: Andrea Merello <[email protected]>
The firmware sets the secondaries spinning waiting for a non-NULL value to show up in the last IPI mailbox.
The original SMP port from the downstream tree was done by Andrea, and Eric cleaned it up/rewrote it a few times from there.
---
v2: Merge into another CONFIG_SMP block.
drivers/irqchip/irq-bcm2836.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/irqchip/irq-bcm2836.c +23 -2
@@ -53,14 +53,16 @@/* Same status bits as above, but for FIQ. */ #define LOCAL_FIQ_PENDING0 0x070/* -* Mailbox0 write-to-set bits. There are 16 mailboxes, 4 per CPU, and +* Mailbox write-to-set bits. There are 16 mailboxes, 4 per CPU, and * these bits are organized by mailbox number and then CPU number. We * use mailbox 0 for IPIs. The mailbox's interrupt is raised while * any bit is set. */ #define LOCAL_MAILBOX0_SET0 0x080 -/* Mailbox0 write-to-clear bits. */ +#define LOCAL_MAILBOX3_SET0 0x08c +/* Mailbox write-to-clear bits. */ #define LOCAL_MAILBOX0_CLR0 0x0c0 +#define LOCAL_MAILBOX3_CLR0 0x0cc#define LOCAL_IRQ_CNTPSIRQ 0#define LOCAL_IRQ_CNTPNSIRQ 1
@@ -220,6 +222,24 @@ static struct notifier_block bcm2836_arm_irqchip_cpu_notifier = { .notifier_call = bcm2836_arm_irqchip_cpu_notify, .priority = 100, }; + +int __init bcm2836_smp_boot_secondary (unsigned int cpu, +struct task_struct *idle) +{ +unsigned long secondary_startup_phys = + (unsigned long )virt_to_phys ((void *)secondary_startup); + +dsb (); +writel (secondary_startup_phys, + intc.base +LOCAL_MAILBOX3_SET0 +16 * cpu); + +return 0 ; +} + +static const struct smp_operations bcm2836_smp_ops__initconst = { + .smp_boot_secondary = bcm2836_smp_boot_secondary, +}; +#endif static const struct irq_domain_ops bcm2836_arm_irqchip_intc_ops = {
@@ -237,6 +257,7 @@ bcm2836_arm_irqchip_smp_init(void)register_cpu_notifier (&bcm2836_arm_irqchip_cpu_notifier);set_smp_cross_call (bcm2836_arm_irqchip_send_ipi); +smp_set_ops (&bcm2836_smp_ops);#endif }
Signature · 1 line
2.6.2
tip-bot for Andrea Merello
merge bot[tip:irq/core] irqchip/bcm2836: Add SMP support for the 2836
irqchip/bcm2836: Add SMP support for the 2836
Commit-ID: 41f4988cc287e5f836d3f6620c9f900bc9b560e9 Gitweb: http://git.kernel.org/tip/41f4988cc287e5f836d3f6620c9f900bc9b560e9 Author: Andrea Merello <[email protected]> AuthorDate: Sat, 26 Dec 2015 13:47:22 -0800 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 29 Dec 2015 11:40:45 +0100
irqchip/bcm2836: Add SMP support for the 2836
The firmware sets the secondaries spinning waiting for a non-NULL value to show up in the last IPI mailbox.
The original SMP port from the downstream tree was done by Andrea, and Eric cleaned it up/rewrote it a few times from there.
--- drivers/irqchip/irq-bcm2836.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/irqchip/irq-bcm2836.c +23 -2
@@ -53,14 +53,16 @@/* Same status bits as above, but for FIQ. */ #define LOCAL_FIQ_PENDING0 0x070/* -* Mailbox0 write-to-set bits. There are 16 mailboxes, 4 per CPU, and +* Mailbox write-to-set bits. There are 16 mailboxes, 4 per CPU, and * these bits are organized by mailbox number and then CPU number. We * use mailbox 0 for IPIs. The mailbox's interrupt is raised while * any bit is set. */ #define LOCAL_MAILBOX0_SET0 0x080 -/* Mailbox0 write-to-clear bits. */ +#define LOCAL_MAILBOX3_SET0 0x08c +/* Mailbox write-to-clear bits. */ #define LOCAL_MAILBOX0_CLR0 0x0c0 +#define LOCAL_MAILBOX3_CLR0 0x0cc#define LOCAL_IRQ_CNTPSIRQ 0#define LOCAL_IRQ_CNTPNSIRQ 1
@@ -220,6 +222,24 @@ static struct notifier_block bcm2836_arm_irqchip_cpu_notifier = { .notifier_call = bcm2836_arm_irqchip_cpu_notify, .priority = 100, }; + +int __init bcm2836_smp_boot_secondary (unsigned int cpu, +struct task_struct *idle) +{ +unsigned long secondary_startup_phys = + (unsigned long )virt_to_phys ((void *)secondary_startup); + +dsb (); +writel (secondary_startup_phys, + intc.base +LOCAL_MAILBOX3_SET0 +16 * cpu); + +return 0 ; +} + +static const struct smp_operations bcm2836_smp_ops__initconst = { + .smp_boot_secondary = bcm2836_smp_boot_secondary, +}; +#endif static const struct irq_domain_ops bcm2836_arm_irqchip_intc_ops = {
@@ -237,6 +257,7 @@ bcm2836_arm_irqchip_smp_init(void)register_cpu_notifier (&bcm2836_arm_irqchip_cpu_notifier);set_smp_cross_call (bcm2836_arm_irqchip_send_ipi); +smp_set_ops (&bcm2836_smp_ops);#endif }
Re: [PATCH 2/4] irqchip: bcm2836: Add SMP support for the 2836
In reply to Eric Anholtdrivers/irqchip/irq-bcm2836.c static struct notifier_block bcm2836_arm_irqchip_cpu_notifier = { · line 234
Quoted 9 lines · Eric Anholt
drivers/irqchip/irq-bcm2836.c +9
-0+int __init bcm2836_smp_boot_secondary (unsigned int cpu, +struct task_struct *idle) +{ +unsigned long secondary_startup_phys = + (unsigned long )virt_to_phys ((void *)secondary_startup); + +dsb (); +writel (secondary_startup_phys, + intc.base +LOCAL_MAILBOX3_SET0 +16 * cpu);
Please explain why you need this dsb() - I can't see a reason for it. writel() has a barrier internally prior to writing the register, and therefore I think the above dsb() is entirely redundant.
Signature · 3 lines
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
Re: [PATCH 2/4] irqchip: bcm2836: Add SMP support for the 2836
Agreed.
This probably comes from the downstream code, I think.. But I agree it's actually redundant.
Thank you for pointing this out.
Quoted 19 lines · Russell King - ARM Linux
drivers/irqchip/irq-bcm2836.c static struct notifier_block bcm2836_arm_irqchip_cpu_notifier = { · line 234
Quoted 9 lines · Eric Anholt
drivers/irqchip/irq-bcm2836.c +9
-0+int __init bcm2836_smp_boot_secondary (unsigned int cpu, +struct task_struct *idle) +{ +unsigned long secondary_startup_phys = + (unsigned long )virt_to_phys ((void *)secondary_startup); + +dsb (); +writel (secondary_startup_phys, + intc.base +LOCAL_MAILBOX3_SET0 +16 * cpu);Please explain why you need this
dsb()- I can't see a reason for it.writel()has a barrier internally prior to writing the register, and therefore I think the abovedsb()is entirely redundant.--
RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.
PATCH 3/4 irqchip: bcm2836: tolerate IRQs while no flag is set in ISR
In reply to Eric AnholtFrom: Andrea Merello <[email protected]>
On my RPi2 I got a lot of:
unexpected IRQ trap at vector 00
This happens because bcm2836_arm_irqchip_handle_irq() is sometimes invoked even if the ISR is clear, and this case is not handled.
This patch explicitly handle this case, fixing the kernel complaints about the bad IRQ lookup.
--- drivers/irqchip/irq-bcm2836.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-bcm2836.c +1 -1
@@ -177,7 +177,7 @@ __exception_irq_entry bcm2836_arm_irqchip_handle_irq(struct pt_regs *regs)writel (1 << ipi, mailbox0);handle_IPI (ipi, regs);#endif - }else { + }else if (stat) {u32 hwirq =ffs (stat) -1 ;handle_IRQ (irq_linear_revmap (intc.domain, hwirq), regs);
Signature · 1 line
2.6.2
tip-bot for Andrea Merello
merge bot[tip:irq/core] irqchip/bcm2836: Tolerate IRQs while no flag is set in ISR
irqchip/bcm2836: Tolerate IRQs while no flag is set in ISR
Commit-ID: a51744ddcc62925ec4d3d3d3a8a13bdd2033af59 Gitweb: http://git.kernel.org/tip/a51744ddcc62925ec4d3d3d3a8a13bdd2033af59 Author: Andrea Merello <[email protected]> AuthorDate: Sat, 26 Dec 2015 13:47:23 -0800 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 29 Dec 2015 11:40:45 +0100
irqchip/bcm2836: Tolerate IRQs while no flag is set in ISR
On my RPi2 I got a lot of:
unexpected IRQ trap at vector 00
This happens because bcm2836_arm_irqchip_handle_irq() is sometimes invoked even if the ISR is clear, and this case is not handled.
This patch explicitly handle this case, fixing the kernel complaints about the bad IRQ lookup.
--- drivers/irqchip/irq-bcm2836.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-bcm2836.c +1 -1
@@ -177,7 +177,7 @@ __exception_irq_entry bcm2836_arm_irqchip_handle_irq(struct pt_regs *regs)writel (1 << ipi, mailbox0);handle_IPI (ipi, regs);#endif - }else { + }else if (stat) {u32 hwirq =ffs (stat) -1 ;handle_IRQ (irq_linear_revmap (intc.domain, hwirq), regs);
PATCH 4/4 irqchip: bcm2836: make code more readable
In reply to Eric AnholtFrom: Andrea Merello <[email protected]>
Avoid using hardcoded magics. We have a #define for this number. No functional changes.
--- drivers/irqchip/irq-bcm2836.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-bcm2836.c +1 -1
@@ -167,7 +167,7 @@ __exception_irq_entry bcm2836_arm_irqchip_handle_irq(struct pt_regs *regs)u32 stat; stat =readl_relaxed (intc.base +LOCAL_IRQ_PENDING0 +4 * cpu); -if (stat &0x10 ) { +if (stat &BIT (LOCAL_IRQ_MAILBOX0 )) {#ifdef CONFIG_SMP void __iomem *mailbox0 = (intc.base +LOCAL_MAILBOX0_CLR0 +16 * cpu);
Signature · 1 line
2.6.2
tip-bot for Andrea Merello
merge bot[tip:irq/core] irqchip/bcm2836: Make code more readable
irqchip/bcm2836: Make code more readable
Commit-ID: 64103f061573e3d7670ba295b07919fb8fc7594c Gitweb: http://git.kernel.org/tip/64103f061573e3d7670ba295b07919fb8fc7594c Author: Andrea Merello <[email protected]> AuthorDate: Sat, 26 Dec 2015 13:47:24 -0800 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 29 Dec 2015 11:40:46 +0100
irqchip/bcm2836: Make code more readable
Avoid using hardcoded magics. We have a #define for this number. No functional changes.
--- drivers/irqchip/irq-bcm2836.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-bcm2836.c +1 -1
@@ -167,7 +167,7 @@ __exception_irq_entry bcm2836_arm_irqchip_handle_irq(struct pt_regs *regs)u32 stat; stat =readl_relaxed (intc.base +LOCAL_IRQ_PENDING0 +4 * cpu); -if (stat &0x10 ) { +if (stat &BIT (LOCAL_IRQ_MAILBOX0 )) {#ifdef CONFIG_SMP void __iomem *mailbox0 = (intc.base +LOCAL_MAILBOX0_CLR0 +16 * cpu);