genirq: Handle NOAUTOEN interrupts correctly
Subsystems (5)
cover genirq: Handle NOAUTOEN interrupts correctly
This series addresses a few short comings in the interrupt core code vs. interrupts marked NOAUTOEN and also paves the way for making sure that irq chip callbacks like irq_startup/shutdown/enable/disable are only called when an actual state change is required.
Thanks,
tglx
PATCH 1/2 genirq: Handle NOAUTOEN interrupt setup proper
If an interrupt is marked NOAUTOEN then request_irq() installs the action, but does not enable the interrupt via startup_irq(). The interrupt is enabled via enable_irq() later from the driver. enable_irq() calls irq_enable().
That means that for interrupts which have a irq_startup() callback this callback is never invoked. Neither is irq_domain_activate_irq() invoked for such interrupts.
If an interrupt depends on irq_startup() or irq_domain_activate_irq() then the enable via irq_enable() is not enough.
Add a status flag IRQD_IRQ_STARTED_UP and use this to select the proper mechanism in enable_irq(). Use the flag also to avoid pointless calls into the low level functions.
--- include/linux/irq.h | 6 ++++ kernel/irq/chip.c | 73 +++++++++++++++++++++++++++++++++++++------------ kernel/irq/internals.h | 1 kernel/irq/manage.c | 2 - 4 files changed, 64 insertions(+), 18 deletions(-)
include/linux/irq.h +6 -0
@@ -216,6 +216,7 @@ enum {IRQD_WAKEUP_ARMED = (1 <<19 ),IRQD_FORWARDED_TO_VCPU = (1 <<20 ),IRQD_AFFINITY_MANAGED = (1 <<21 ), + IRQD_IRQ_STARTED_UP = (1 << 22), };#define __irqd_to_state (d) ACCESS_PRIVATE((d)->common, state_use_accessors)
@@ -329,6 +330,11 @@ static inline void irqd_clr_activated(st__irqd_to_state (d) &= ~IRQD_ACTIVATED ; } +static inline bool irqd_is_started_up (struct irq_data *d) +{ +return __irqd_to_state (d) &IRQD_IRQ_STARTED_UP ; +} +#undef __irqd_to_statestatic inline irq_hw_number_t irqd_to_hwirq (struct irq_data *d)
kernel/irq/chip.c +56 -17
112 lines not on this page · raw message
kernel/irq/internals.h +1 -0
@@ -68,6 +68,7 @@ extern void __enable_irq(struct irq_descextern int irq_startup (struct irq_desc *desc,bool resend);extern void irq_shutdown (struct irq_desc *desc); +extern void irq_enable_or_startup (struct irq_desc *desc);extern void irq_enable (struct irq_desc *desc);extern void irq_disable (struct irq_desc *desc);extern void irq_percpu_enable (struct irq_desc *desc,unsigned int cpu);
kernel/irq/manage.c +1 -1
@@ -533,7 +533,7 @@ void __enable_irq(struct irq_desc *desc) goto err_out;/* Prevent probing on this irq: */ irq_settings_set_noprobe (desc); -irq_enable (desc); +irq_enable_or_startup (desc);check_irq_resend (desc);/* fall-through */ }
Re: [patch 1/2] genirq: Handle NOAUTOEN interrupt setup proper
Hi Thomas,
Quoted 35 lines · Thomas Gleixner
If an interrupt is marked NOAUTOEN then
request_irq()installs the action, but does not enable the interrupt viastartup_irq(). The interrupt is enabled viaenable_irq()later from the driver.enable_irq()callsirq_enable().That means that for interrupts which have a
irq_startup()callback this callback is never invoked. Neither isirq_domain_activate_irq()invoked for such interrupts.If an interrupt depends on
irq_startup()orirq_domain_activate_irq()then the enable viairq_enable()is not enough.Add a status flag
IRQD_IRQ_STARTED_UPand use this to select the proper mechanism inenable_irq(). Use the flag also to avoid pointless calls into the low level functions.Signed-off-by Thomas Gleixner <[email protected]>--- include/linux/irq.h | 6 ++++ kernel/irq/chip.c | 73 +++++++++++++++++++++++++++++++++++++------------ kernel/irq/internals.h | 1 kernel/irq/manage.c | 2 - 4 files changed, 64 insertions(+), 18 deletions(-)include/linux/irq.h +1
-0@@ -216,6 +216,7 @@ enum {IRQD_WAKEUP_ARMED = (1 <<19 ),IRQD_FORWARDED_TO_VCPU = (1 <<20 ),IRQD_AFFINITY_MANAGED = (1 <<21 ), + IRQD_IRQ_STARTED_UP = (1 << 22), };#define __irqd_to_state (d) ACCESS_PRIVATE((d)->common, state_use_accessors)
include/linux/irq.h static inline void irqd_clr_activated(st · line 333
Quoted 4 lines
include/linux/irq.h +1
-0@@ -329,6 +330,11 @@ static inline void irqd_clr_activated(st__irqd_to_state (d) &= ~IRQD_ACTIVATED ; } +static inline bool irqd_is_started_up (struct irq_data *d)
nit: since we have set/clr_started, consider making this is_started (without the up)? Or add the _up to clr/set?
Quoted 21 lines
include/linux/irq.h +4
-0+{ +return __irqd_to_state (d) &IRQD_IRQ_STARTED_UP ; +} +#undef __irqd_to_statestatic inline irq_hw_number_t irqd_to_hwirq (struct irq_data *d)kernel/irq/chip.c +8
-0@@ -185,37 +185,71 @@ static void irq_state_set_masked(structirqd_set (&desc->irq_data,IRQD_IRQ_MASKED ); } +static void irq_state_clr_started (struct irq_desc *desc) +{ +irqd_clear (&desc->irq_data,IRQD_IRQ_STARTED_UP ); +} + +static void irq_state_set_started (struct irq_desc *desc) +{ +irqd_set (&desc->irq_data,IRQD_IRQ_STARTED_UP );
kernel/irq/chip.c static void irq_state_set_masked(struct · line 204
Quoted 10 lines
kernel/irq/chip.c +5
-1+} +int irq_startup (struct irq_desc *desc,bool resend) {int ret =0 ; -irq_state_clr_disabled (desc); +if (irqd_is_started_up (&desc->irq_data)) +return 0 ; +
How about:
if (irqd_is_started_up(&desc->irq_data)) {
irq_enable(desc);
return 0;
}Quoted 36 lines
kernel/irq/chip.c +12
-8desc->depth =0 ;irq_domain_activate_irq (&desc->irq_data);if (desc->irq_data.chip->irq_startup) { ret = desc->irq_data.chip->irq_startup (&desc->irq_data); +irq_state_clr_disabled (desc);irq_state_clr_masked (desc); }else {irq_enable (desc); } +irq_state_set_started (desc); +if (resend)check_irq_resend (desc); +return ret; } +static void __irq_disable (struct irq_desc *desc,bool mask); +void irq_shutdown (struct irq_desc *desc) { -irq_state_set_disabled (desc); - desc->depth =1 ; -if (desc->irq_data.chip->irq_shutdown) - desc->irq_data.chip->irq_shutdown (&desc->irq_data); -else if (desc->irq_data.chip->irq_disable) - desc->irq_data.chip->irq_disable (&desc->irq_data); -else - desc->irq_data.chip->irq_mask (&desc->irq_data); +if (irqd_is_started_up (&desc->irq_data)) { + desc->depth =1 ; +if (desc->irq_data.chip->irq_shutdown) { + desc->irq_data.chip->irq_shutdown (&desc->irq_data); +irq_state_set_disabled (desc); +irq_state_set_masked (desc);
kernel/irq/chip.c static void irq_state_set_masked(struct · line 242
Quoted 10 lines
kernel/irq/chip.c +10
-0+ }else { +__irq_disable (desc, true); + } +irq_state_clr_started (desc); + } +/* +* This must be called even if the interrupt was never started up, +* because the activation can happen before the interrupt is +* available for request/startup. It has it's own state tracking so +* it's safe to call it unconditonally.
unconditionally?
kernel/irq/chip.c static void irq_state_set_masked(struct · line 252
Quoted 11 lines
kernel/irq/chip.c +9
-1+*/ irq_domain_deactivate_irq (&desc->irq_data); -irq_state_set_masked (desc); +} + +void irq_enable_or_startup (struct irq_desc *desc) +{ +if (!irqd_is_started_up (&desc->irq_data)) +irq_startup (desc, false); +else +irq_enable (desc);
get rid of this new function...
Quoted 49 lines
kernel/irq/chip.c +12
-7}void irq_enable (struct irq_desc *desc)@@ -228,6 +262,17 @@ void irq_enable(struct irq_desc *desc)irq_state_clr_masked (desc); } +static void __irq_disable (struct irq_desc *desc,bool mask) +{ +irq_state_set_disabled (desc); +if (desc->irq_data.chip->irq_disable) { + desc->irq_data.chip->irq_disable (&desc->irq_data); +irq_state_set_masked (desc); + }else if (mask) { +mask_irq (desc); + } +} +/** * irq_disable - Mark interrupt disabled * @desc: irq descriptor which should be disabled @@ -250,13 +295,7 @@ void irq_enable(struct irq_desc *desc)*/ void irq_disable (struct irq_desc *desc) { -irq_state_set_disabled (desc); -if (desc->irq_data.chip->irq_disable) { - desc->irq_data.chip->irq_disable (&desc->irq_data); -irq_state_set_masked (desc); - }else if (irq_settings_disable_unlazy (desc)) { -mask_irq (desc); - } +__irq_disable (desc,irq_settings_disable_unlazy (desc)); }void irq_percpu_enable (struct irq_desc *desc,unsigned int cpu)kernel/irq/internals.h +1
-0@@ -68,6 +68,7 @@ extern void __enable_irq(struct irq_descextern int irq_startup (struct irq_desc *desc,bool resend);extern void irq_shutdown (struct irq_desc *desc); +extern void irq_enable_or_startup (struct irq_desc *desc);extern void irq_enable (struct irq_desc *desc);extern void irq_disable (struct irq_desc *desc);extern void irq_percpu_enable (struct irq_desc *desc,unsigned int cpu);
kernel/irq/manage.c void __enable_irq(struct irq_desc *desc) · line 536
Quoted 5 lines
kernel/irq/manage.c +1
-1@@ -533,7 +533,7 @@ void __enable_irq(struct irq_desc *desc) goto err_out;/* Prevent probing on this irq: */ irq_settings_set_noprobe (desc); -irq_enable (desc); +irq_enable_or_startup (desc);
and make this irq_startup(desc, false)?
kernel/irq/manage.c void __enable_irq(struct irq_desc *desc) · line 539
Quoted 5 lines
kernel/irq/manage.c +0
-0check_irq_resend (desc);/* fall-through */ }
Otherwise:
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [patch 1/2] genirq: Handle NOAUTOEN interrupt setup proper
Quoted 10 lines · Marc Zyngier
include/linux/irq.h static inline void irqd_clr_activated(st · line 333
Quoted 6 lines · Thomas Gleixner
#define
__irqd_to_state(d)ACCESS_PRIVATE((d)->common, state_use_accessors)include/linux/irq.h +1
-0@@ -329,6 +330,11 @@ static inline void irqd_clr_activated(st__irqd_to_state (d) &= ~IRQD_ACTIVATED ; } +static inline bool irqd_is_started_up (struct irq_data *d)nit: since we have set/clr_started, consider making this
is_started(without the up)? Or add the_upto clr/set?
Sure.
Quoted 33 lines
Quoted 21 lines
include/linux/irq.h +4
-0+{ +return __irqd_to_state (d) &IRQD_IRQ_STARTED_UP ; +} +#undef __irqd_to_statestatic inline irq_hw_number_t irqd_to_hwirq (struct irq_data *d)kernel/irq/chip.c +8
-0@@ -185,37 +185,71 @@ static void irq_state_set_masked(structirqd_set (&desc->irq_data,IRQD_IRQ_MASKED ); } +static void irq_state_clr_started (struct irq_desc *desc) +{ +irqd_clear (&desc->irq_data,IRQD_IRQ_STARTED_UP ); +} + +static void irq_state_set_started (struct irq_desc *desc) +{ +irqd_set (&desc->irq_data,IRQD_IRQ_STARTED_UP );kernel/irq/chip.c static void irq_state_set_masked(struct · line 204
Quoted 10 lines
kernel/irq/chip.c +5
-1+} +int irq_startup (struct irq_desc *desc,bool resend) {int ret =0 ; -irq_state_clr_disabled (desc); +if (irqd_is_started_up (&desc->irq_data)) +return 0 ; +How about:
Quoted 3 lines
if (irqd_is_started_up(&desc->irq_data)) {
irq_enable(desc);
return 0;Why would we do that? I rather have a WARN_ON() there as this should never happen.
Quoted 7 lines
kernel/irq/chip.c static void irq_state_set_masked(struct · line 242
Quoted 5 lines
kernel/irq/chip.c +5
-0+/* +* This must be called even if the interrupt was never started up, +* because the activation can happen before the interrupt is +* available for request/startup. It has it's own state tracking so +* it's safe to call it unconditonally. unconditionally?
Oops.
Quoted 8 lines
Quoted 8 lines
kernel/irq/chip.c +1
-0extern int irq_startup (struct irq_desc *desc,bool resend);extern void irq_shutdown (struct irq_desc *desc); +extern void irq_enable_or_startup (struct irq_desc *desc);extern void irq_enable (struct irq_desc *desc);extern void irq_disable (struct irq_desc *desc);extern void irq_percpu_enable (struct irq_desc *desc,unsigned int cpu);kernel/irq/manage.c +0
-0
Quoted 8 lines
kernel/irq/manage.c void __enable_irq(struct irq_desc *desc) · line 536
Quoted 6 lines
kernel/irq/manage.c +1
-1@@ -533,7 +533,7 @@ void __enable_irq(struct irq_desc *desc) goto err_out;/* Prevent probing on this irq: */ irq_settings_set_noprobe (desc); -irq_enable (desc); +irq_enable_or_startup (desc);and make this
irq_startup(desc, false)?
Ah, now I see where you were heading with that irq_startup() modification. Makes sense, but let me think about it.
Thanks,
tglx
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] genirq: Handle NOAUTOEN interrupt setup proper
In reply to Thomas Gleixnergenirq: Handle NOAUTOEN interrupt setup proper
Commit-ID: 201d7f47f34bd7cb19161d0426f13b141e381f30 Gitweb: http://git.kernel.org/tip/201d7f47f34bd7cb19161d0426f13b141e381f30 Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 31 May 2017 11:58:32 +0200 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 4 Jun 2017 14:35:13 +0200
genirq: Handle NOAUTOEN interrupt setup proper
If an interrupt is marked NOAUTOEN then request_irq() installs the action, but does not enable the interrupt via startup_irq(). The interrupt is enabled via enable_irq() later from the driver. enable_irq() calls irq_enable().
That means that for interrupts which have a irq_startup() callback this callback is never invoked. Neither is irq_domain_activate_irq() invoked for such interrupts.
If an interrupt depends on irq_startup() or irq_domain_activate_irq() then the enable via irq_enable() is not enough.
Add a status flag IRQD_IRQ_STARTED_UP and use this to select the proper mechanism in enable_irq(). Use the flag also to avoid pointless calls into the low level functions.
--- include/linux/irq.h | 6 +++++ kernel/irq/chip.c | 76 +++++++++++++++++++++++++++++++++++++---------------- kernel/irq/manage.c | 12 ++++++--- 3 files changed, 69 insertions(+), 25 deletions(-)
include/linux/irq.h +6 -0
@@ -216,6 +216,7 @@ enum {IRQD_WAKEUP_ARMED = (1 <<19 ),IRQD_FORWARDED_TO_VCPU = (1 <<20 ),IRQD_AFFINITY_MANAGED = (1 <<21 ), + IRQD_IRQ_STARTED = (1 << 22), };#define __irqd_to_state (d) ACCESS_PRIVATE((d)->common, state_use_accessors)
@@ -329,6 +330,11 @@ static inline void irqd_clr_activated(struct irq_data *d)__irqd_to_state (d) &= ~IRQD_ACTIVATED ; } +static inline bool irqd_is_started (struct irq_data *d) +{ +return __irqd_to_state (d) &IRQD_IRQ_STARTED ; +} +#undef __irqd_to_statestatic inline irq_hw_number_t irqd_to_hwirq (struct irq_data *d)
kernel/irq/chip.c +54 -22
110 lines not on this page · raw message
kernel/irq/manage.c +9 -3
@@ -533,9 +533,15 @@ void __enable_irq(struct irq_desc *desc) goto err_out;/* Prevent probing on this irq: */ irq_settings_set_noprobe (desc); -irq_enable (desc); -check_irq_resend (desc); -/* fall-through */ +/* +* Call irq_startup() not irq_enable() here because the +* interrupt might be marked NOAUTOEN. So irq_startup() +* needs to be invoked when it gets enabled the first +* time. If it was already started up, then irq_startup() +* will invoke irq_enable() under the hood. +*/ +irq_startup (desc, true); +break ; }default : desc->depth--;
PATCH 2/2 genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts
In reply to Thomas GleixnerShared interrupts do not go well with disabling auto enable:
1) The sharing interrupt might request it while it's still disabled and then wait for interrupts forever.
2) The interrupt might have been requested by the driver sharing the line before IRQ_NOAUTOEN has been set. So the driver which expects that disabled state after calling request_irq() will not get what it wants. Even worse, when it calls enable_irq() later, it will trigger the unbalanced enable_irq() warning.
--- kernel/irq/chip.c | 7 +++++++ kernel/irq/manage.c | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
kernel/irq/chip.c +7 -0
@@ -942,6 +942,13 @@ void irq_modify_status(unsigned int irq,if (!desc)return ; + +/* +* Warn when a driver sets the no autoenable flag on an already +* active interrupt. +*/ +WARN_ON_ONCE (!desc->depth && (set &IRQF_NOAUTOEN )); +irq_settings_clr_and_set (desc, clr, set); irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
kernel/irq/manage.c +10 -2
@@ -1328,11 +1328,19 @@ static intif (new->flags &IRQF_ONESHOT ) desc->istate |=IRQS_ONESHOT ; -if (irq_settings_can_autoenable (desc)) +if (irq_settings_can_autoenable (desc)) {irq_startup (desc, true); -else + }else { +/* +* Shared interrupts do not go well with disabling +* auto enable. The sharing interrupt might request +* it while it's still disabled and then wait for +* interrupts forever. +*/ +WARN_ON_ONCE (new->flags &IRQF_SHARED );/* Undo nested disables: */ desc->depth =1 ; + }/* Exclude IRQ from balancing if requested */ if (new->flags &IRQF_NOBALANCING ) {
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts
genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts
Commit-ID: 04c848d398797a626608ff48804d809ae6687163 Gitweb: http://git.kernel.org/tip/04c848d398797a626608ff48804d809ae6687163 Author: Thomas Gleixner <[email protected]> AuthorDate: Wed, 31 May 2017 11:58:33 +0200 Committer: Thomas Gleixner <[email protected]> CommitDate: Sun, 4 Jun 2017 14:38:41 +0200
genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts
Shared interrupts do not go well with disabling auto enable:
1) The sharing interrupt might request it while it's still disabled and then wait for interrupts forever.
2) The interrupt might have been requested by the driver sharing the line before IRQ_NOAUTOEN has been set. So the driver which expects that disabled state after calling request_irq() will not get what it wants. Even worse, when it calls enable_irq() later, it will trigger the unbalanced enable_irq() warning.
--- kernel/irq/chip.c | 7 +++++++ kernel/irq/manage.c | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)
kernel/irq/chip.c +7 -0
@@ -935,6 +935,13 @@ void irq_modify_status(unsigned int irq, unsigned long clr, unsigned long set)if (!desc)return ; + +/* +* Warn when a driver sets the no autoenable flag on an already +* active interrupt. +*/ +WARN_ON_ONCE (!desc->depth && (set & _IRQ_NOAUTOEN)); +irq_settings_clr_and_set (desc, clr, set); irqd_clear(&desc->irq_data, IRQD_NO_BALANCING | IRQD_PER_CPU |
kernel/irq/manage.c +10 -2
@@ -1334,11 +1334,19 @@ __setup_irq(unsigned int irq, struct irq_desc *desc, struct irqaction *new)if (new->flags &IRQF_ONESHOT ) desc->istate |=IRQS_ONESHOT ; -if (irq_settings_can_autoenable (desc)) +if (irq_settings_can_autoenable (desc)) {irq_startup (desc, true); -else + }else { +/* +* Shared interrupts do not go well with disabling +* auto enable. The sharing interrupt might request +* it while it's still disabled and then wait for +* interrupts forever. +*/ +WARN_ON_ONCE (new->flags &IRQF_SHARED );/* Undo nested disables: */ desc->depth =1 ; + }/* Exclude IRQ from balancing if requested */ if (new->flags &IRQF_NOBALANCING ) {
Re: [2/2] genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts
In reply to Thomas GleixnerHi Thomas,
Quoted 32 lines · On Wednesday, 31 May 2017 02:58:33 PDT Thomas Gleixner wrote:
Shared interrupts do not go well with disabling auto enable:
1) The sharing interrupt might request it while it's still disabled and then wait for interrupts forever.
2) The interrupt might have been requested by the driver sharing the line before
IRQ_NOAUTOENhas been set. So the driver which expects that disabled state after callingrequest_irq()will not get what it wants. Even worse, when it callsenable_irq()later, it will trigger the unbalancedenable_irq()warning.Reported-by Brian Norris <[email protected]>Signed-off-by Thomas Gleixner <[email protected]>--- kernel/irq/chip.c | 7 +++++++ kernel/irq/manage.c | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-)kernel/irq/manage.c +5
-2@@ -1328,11 +1328,19 @@ static intif (new->flags &IRQF_ONESHOT ) desc->istate |=IRQS_ONESHOT ; -if (irq_settings_can_autoenable (desc)) +if (irq_settings_can_autoenable (desc)) {irq_startup (desc, true); -else + }else { +/* +* Shared interrupts do not go well with disabling +* auto enable. The sharing interrupt might request
kernel/irq/manage.c static int · line 1346
Quoted 10 lines
kernel/irq/manage.c +5
-0+* it while it's still disabled and then wait for +* interrupts forever. +*/ +WARN_ON_ONCE (new->flags &IRQF_SHARED );/* Undo nested disables: */ desc->depth =1 ; + }/* Exclude IRQ from balancing if requested */ if (new->flags &IRQF_NOBALANCING ) {
I'm currently attempting to clean up a hack that we have in the MIPS GIC irqchip driver - we have some interrupts which are really per-CPU, but are currently used with the regular non-per-CPU IRQ APIs. Please search for usage of gic_all_vpes_local_irq_controller (or for the string "HACK") in drivers/ irqchip/irq-mips-gic.c if you wish to find what I'm talking about. The important details are that the interrupts in question are both per-CPU and on many systems are shared (between the CPU timer, performance counters & fast debug channel).
I have been attempting to move towards using the per-CPU APIs instead in order to remove this hack - ie. using setup_percpu_irq() & enable_percpu_irq() in place of plain old setup_irq(). Unfortunately what I've run into is this:
- Per-CPU interrupts get the IRQ_NOAUTOEN flag set by default, in irq_set_percpu_devid_flags(). I can see why this makes sense in the general case, since the alternative is setup_percpu_irq() enabling the interrupt on the CPU that calls it & leaving it disabled on others, which feels a little unclean.
- Your warning above triggers when a shared interrupt has the IRQ_NOAUTOEN flag set. I can see why your warning makes sense if another driver has already enabled the shared interrupt, which would make IRQ_NOAUTOEN ineffective. I'm not sure I follow your comment above the warning though - it sounds like you're trying to describe something else?
For my interrupts which are both per-CPU & shared the combination of these 2 facts mean I end up triggering your warning. My current ideas include:
- I could clear the IRQ_NOAUTOEN flag before calling setup_percpu_irq(). In my cases that should be fine - we call enable_percpu_irq() anyway, and would just enable the IRQ slightly earlier on the CPU which calls setup_percpu_irq() which wouldn't be a problem. It feels a bit yucky though.
- I could adjust your warning such that it only triggers if the shared interrupt is indeed already enabled. This relies on my understanding of the issue described above being correct though, and it doesn't match your comment so I'm unsure I'm imagining the same issue you were warning about.
Do you have any thoughts or suggestions?
Thanks,
Paul
Re: [2/2] genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts
Quoted 25 lines · Paul Burton
I'm currently attempting to clean up a hack that we have in the MIPS GIC irqchip driver - we have some interrupts which are really per-CPU, but are currently used with the regular non-per-CPU IRQ APIs. Please search for usage of
gic_all_vpes_local_irq_controller(or for the string "HACK") indrivers/irqchip/irq-mips-gic.cif you wish to find what I'm talking about. The important details are that the interrupts in question are both per-CPU and on many systems are shared (between the CPU timer, performance counters & fast debug channel).I have been attempting to move towards using the per-CPU APIs instead in order to remove this hack - ie. using
setup_percpu_irq()&enable_percpu_irq()in place of plain oldsetup_irq(). Unfortunately what I've run into is this:- Per-CPU interrupts get the
IRQ_NOAUTOENflag set by default, inirq_set_percpu_devid_flags(). I can see why this makes sense in the general case, since the alternative issetup_percpu_irq()enabling the interrupt on the CPU that calls it & leaving it disabled on others, which feels a little unclean.- Your warning above triggers when a shared interrupt has the
IRQ_NOAUTOENflag set. I can see why your warning makes sense if another driver has already enabled the shared interrupt, which would makeIRQ_NOAUTOENineffective. I'm not sure I follow your comment above the warning though - it sounds like you're trying to describe something else?
Quoted 6 lines
kernel/irq/manage.c static int · line 1339
Quoted 6 lines
kernel/irq/manage.c +6
-0+/* +* Shared interrupts do not go well with disabling +* auto enable. The sharing interrupt might request +* it while it's still disabled and then wait for +* interrupts forever. +*/
Assume the following:
request_irq(X, handler1, NOAUTOEN|SHARED, dev1);
now the second device does:
request_irq(X, handler2, SHARED, dev2):
which will see the first handler installed, so it wont run into the code path which starts up the interrupt. That means as long as dev1 does not explicitely enable the interrupt dev2 will wait for it forever.
Quoted 8 lines
For my interrupts which are both per-CPU & shared the combination of these 2 facts mean I end up triggering your warning. My current ideas include:
- I could clear the
IRQ_NOAUTOENflag before callingsetup_percpu_irq(). In my cases that should be fine - we callenable_percpu_irq()anyway, and would just enable the IRQ slightly earlier on the CPU which callssetup_percpu_irq()which wouldn't be a problem. It feels a bit yucky though.
What's the problem with IRQ_NOAUTOEN and do
setup_percpu_irq();
enable_percpu_irq();on the boot CPU and then later call it when the secondary CPUs come up in cpu bringup code or a hotplug state callback?
Thanks,
tglx
Re: [2/2] genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts
Hi Thomas,
Quoted 42 lines · On Wednesday, 6 September 2017 01:16:48 PDT Thomas Gleixner wrote:
Quoted 30 lines · Paul Burton
I'm currently attempting to clean up a hack that we have in the MIPS GIC irqchip driver - we have some interrupts which are really per-CPU, but are currently used with the regular non-per-CPU IRQ APIs. Please search for usage of
gic_all_vpes_local_irq_controller(or for the string "HACK") indrivers/irqchip/irq-mips-gic.cif you wish to find what I'm talking about. The important details are that the interrupts in question are both per-CPU and on many systems are shared (between the CPU timer, performance counters & fast debug channel).I have been attempting to move towards using the per-CPU APIs instead in order to remove this hack - ie. using
setup_percpu_irq()&enable_percpu_irq()in>
place of plain oldsetup_irq(). Unfortunately what I've run into is this:
- Per-CPU interrupts get theIRQ_NOAUTOENflag set by default, in
irq_set_percpu_devid_flags(). I can see why this makes sense in the general case, since the alternative issetup_percpu_irq()enabling the interrupt on the CPU that calls it & leaving it disabled on others, which
feels a little unclean.- Your warning above triggers when a shared interrupt has the
IRQ_NOAUTOENflag set. I can see why your warning makes sense if another driver has already enabled the shared interrupt, which would make
IRQ_NOAUTOENineffective. I'm not sure I follow your comment above the warning though -
it sounds like you're trying to describe something else?Quoted 1 line
Quoted 6 lines
kernel/irq/manage.c static int · line 1339
Quoted 6 lines
kernel/irq/manage.c +6
-0+/* +* Shared interrupts do not go well with disabling +* auto enable. The sharing interrupt might request +* it while it's still disabled and then wait for +* interrupts forever. +*/ Assume the following:
request_irq(X, handler1, NOAUTOEN|SHARED, dev1);
Quoted 7 lines
now the second device does:
request_irq(X, handler2, SHARED, dev2):which will see the first handler installed, so it wont run into the code path which starts up the interrupt. That means as long as dev1 does not explicitely enable the interrupt dev2 will wait for it forever.
Ok, makes sense.
Quoted 11 lines
Quoted 10 lines
For my interrupts which are both per-CPU & shared the combination of these 2>
facts mean I end up triggering your warning. My current ideas include:
- I could clear theIRQ_NOAUTOENflag before callingsetup_percpu_irq(). Inmy cases that should be fine - we call
enable_percpu_irq()anyway, and would just enable the IRQ slightly earlier on the CPU which callssetup_percpu_irq()which wouldn't be a problem. It feels a bit yucky though.
Quoted 7 lines
What's the problem with
IRQ_NOAUTOENand dosetup_percpu_irq(); enable_percpu_irq();on the boot CPU and then later call it when the secondary CPUs come up in cpu bringup code or a hotplug state callback?
There's no problem with that at all, apart from that it triggers your warning when the boot CPU calls setup_percpu_irq().
Thanks,
Paul
Re: [2/2] genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts
Quoted 11 lines · Paul Burton
Quoted 7 lines · On Wednesday, 6 September 2017 01:16:48 PDT Thomas Gleixner wrote:
What's the problem with
IRQ_NOAUTOENand dosetup_percpu_irq(); enable_percpu_irq();on the boot CPU and then later call it when the secondary CPUs come up in cpu bringup code or a hotplug state callback?
There's no problem with that at all, apart from that it triggers your warning when the boot CPU calls
setup_percpu_irq().
Ok, I misread the whole thing somehow. What you are saying is that you need per cpu interrupts which can be shared ....
Hrmpf, ok. I'll have a look from that side then
Re: [2/2] genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts
Hi Thomas,
Quoted 11 lines · On Wednesday, 6 September 2017 07:14:50 PDT Thomas Gleixner wrote:
Quoted 10 lines · Paul Burton
Quoted 8 lines · On Wednesday, 6 September 2017 01:16:48 PDT Thomas Gleixner wrote:
What's the problem with
IRQ_NOAUTOENand dosetup_percpu_irq(); enable_percpu_irq();on the boot CPU and then later call it when the secondary CPUs come up in
cpu bringup code or a hotplug state callback?
Quoted 7 lines
Quoted 2 lines
There's no problem with that at all, apart from that it triggers your warning when the boot CPU calls
setup_percpu_irq().Ok, I misread the whole thing somehow. What you are saying is that you need per cpu interrupts which can be shared ....
Hrmpf, ok. I'll have a look from that side then
So actually it turns out that getting this to work involves more than just avoiding your warning. I have some code which is mostly working; I'll clean up & send it as an RFC hopefully tomorrow.
Thanks,
Paul
cover Support shared percpu interrupts; clean up MIPS hacks
This series introduces support for percpu shared interrupts and makes use of this support to clean up some hacks that have been used to support such interrupts on MIPS.
- Patch 1 allows users of shared interrupts to opt into IRQ_NOAUTOEN behaviour & avoid warnings from doing so.
- Patch 2 introduces support for shared percpu_devid interrupts.
- Patch 3 introduces a helper allowing users to detect whether an interrupt is a percpu_devid interrupt or not, which is useful during the transition phase where interrupts may be either.
- Patches 4 & 5 removes an ugly custom implementation of shared interrupts between the MIPS cevt-r4k timer driver & users of performance counters, in favor of using standard IRQF_SHARED & multiple handlers.
- Patches 6 & 7 add percpu interrupt support to the MIPS perf & cevt-r4k timer drivers respectively.
- Patch 8 configures the MIPS cop 0 count/compare, fast debug channel & performance counter overflow interrupts as percpu_devid when they are mapped by the irqchip-mips-cpu driver.
- Patch 9 removes a hack from the irqchip-mips-gic driver that was used to enable & disable an interrupt across all CPUs, which is no longer necessary with users of those interrupts using the percpu interrupt APIs correctly. This mirrors patch 8 for systems where we map the CPU local interrupts via the GIC.
There's a little more work necessary before this could go in - the MIPS oprofile code needs adjusting to use the percpu interrupt APIs, as does the fast debug channel driver.
Applies atop next-20170905.
Paul Burton (9):
genirq: Allow shared interrupt users to opt into IRQ_NOAUTOEN
genirq: Support shared per_cpu_devid interrupts
genirq: Introduce irq_is_percpu_devid()
MIPS: Remove perf_irq interrupt sharing fallback
MIPS: Remove perf_irq
MIPS: perf: percpu_devid interrupt support
MIPS: cevt-r4k: percpu_devid interrupt support
irqchip: mips-cpu: Set timer, FDC & perf interrupts percpu_devid
irqchip: mips-gic: Remove gic_all_vpes_local_irq_controller
arch/mips/include/asm/time.h | 1 - arch/mips/kernel/cevt-r4k.c | 77 ++++++++++++----------------- arch/mips/kernel/perf_event_mipsxx.c | 71 +++++++++++---------------- arch/mips/kernel/time.c | 9 ---- arch/mips/kernel/traps.c | 2 +- arch/mips/oprofile/op_impl.h | 2 - arch/mips/oprofile/op_model_loongson3.c | 39 +++++++-------- arch/mips/oprofile/op_model_mipsxx.c | 10 +--- drivers/irqchip/irq-mips-cpu.c | 9 +++- drivers/irqchip/irq-mips-gic.c | 69 +++----------------------- include/linux/interrupt.h | 2 + include/linux/irqdesc.h | 8 +++ kernel/irq/chip.c | 8 +-- kernel/irq/handle.c | 8 ++- kernel/irq/manage.c | 86 +++++++++++++++++++++++++-------- kernel/irq/settings.h | 5 ++ 16 files changed, 189 insertions(+), 217 deletions(-)
Signature · 1 line
2.14.1
RFC PATCH 1/9 genirq: Allow shared interrupt users to opt into IRQ_NOAUTOEN
Shared interrupts which aren't automatically enabled during setup (ie. which have the IRQ_NOAUTOEN flag set) can be problematic if one or more users of the shared interrupt aren't expecting the IRQ_NOAUTOEN behaviour. This led to a warning being added when a combination of IRQ_NOAUTOEN & IRQF_SHARED are used by commit 04c848d39879 ("genirq:
Warn when IRQ_NOAUTOEN is used with shared interrupts").
There are however legitimate cases where a shared interrupt which isn't automatically enabled may make sense. One such case is shared percpu interrupts, which we don't currently support but will with subsequent patches. For percpu interrupts the IRQ_NOAUTOEN flag is automatically set by irq_set_percpu_devid_flags() because it would be inconsistent to automatically enable the interrupt on the CPU that calls setup_percpu_irq() but not on others, and anything else would at best be an expensive operation with few legitimate uses. The use of IRQ_NOAUTOEN means that percpu interrupts cannot currently be shared without running into the warning that commit 04c848d39879 ("genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts") introduced.
This patch allows for the future possibility of shared interrupts that are not automatically enabled, by introducing an IRQF_NOAUTOEN flag which users of a shared interrupt can set to state that they are prepared for the IRQ_NOAUTOEN behaviour. We then require that all actions associated with the shared interrupt share the same value for the IRQF_NOAUTOEN flag, and that if IRQ_NOAUTOEN is set before any actions with IRQF_SHARED are associated with the interrupt then any actions without the IRQF_NOAUTOEN flag set are rejected, with __setup_irq() returning -EINVAL.
In some ways this means that we go further than commit 04c848d39879 ("genirq: Warn when IRQ_NOAUTOEN is used with shared interrupts") did, in that any existing users of shared interrupts with IRQ_NOAUTOEN won't only trigger a warning but will fail to setup their interrupt handler entirely. In others this leaves us with an out for legitimate users which will be able to opt-in to the IRQ_NOAUTOEN behaviour by setting IRQF_NOAUTOEN.
---
include/linux/interrupt.h | 2 ++ kernel/irq/manage.c | 58 ++++++++++++++++++++++++++++++++++++----------- kernel/irq/settings.h | 5 ++++ 3 files changed, 52 insertions(+), 13 deletions(-)
include/linux/interrupt.h +2 -0
@@ -62,6 +62,7 @@* interrupt handler after suspending interrupts. For system * wakeup devices users need to implement wakeup detection in * their interrupt handlers. +* IRQF_NOAUTOEN - Don't automatically enable the interrupt during setup. */ #define IRQF_SHARED 0x00000080#define IRQF_PROBE_SHARED 0x00000100
@@ -75,6 +76,7 @@#define IRQF_NO_THREAD 0x00010000#define IRQF_EARLY_RESUME 0x00020000#define IRQF_COND_SUSPEND 0x00040000 +#define IRQF_NOAUTOEN 0x00080000#define IRQF_TIMER (__IRQF_TIMER | IRQF_NO_SUSPEND | IRQF_NO_THREAD)
kernel/irq/manage.c +45 -13
82 lines not on this page · raw message
kernel/irq/settings.h +5 -0
@@ -147,6 +147,11 @@ static inline bool irq_settings_can_autoenable(struct irq_desc *desc)return !(desc->status_use_accessors & _IRQ_NOAUTOEN); } +static inline void irq_settings_set_noautoenable (struct irq_desc *desc) +{ + desc->status_use_accessors |= _IRQ_NOAUTOEN; +} +static inline bool irq_settings_is_nested_thread (struct irq_desc *desc) {return desc->status_use_accessors & _IRQ_NESTED_THREAD;
Signature · 1 line
2.14.1
RFC PATCH 2/9 genirq: Support shared per_cpu_devid interrupts
In reply to Paul BurtonUp until now per_cpu_devid interrupts have not supported sharing. On MIPS we have some percpu interrupts which are shared in many systems - a single CPU interrupt line may be used to indicate a timer interrupt, performance counter interrupt or fast debug channel interrupt. We have up until now supported this with a series of hacks, wherein drivers call each other's interrupt handlers & our MIPS GIC irqchip driver includes a hack which configures the interrupt(s) for all CPUs. In order to allow this mess to be cleaned up, this patch introduces support for shared per_cpu_devid interrupts.
The major portion of this is supporting per_cpu_devid interrupts in __handle_irq_event_percpu() and then making use of this, via handle_irq_event_percpu(), from handler_percpu_devif_irq() to invoke the handler for all actions associated with the shared interrupt. This does have a few side effects worth noting:
- per_cpu_devid interrupts will now add to the entropy pool via add_interrupt_randomness(), where they previously did not.
- per_cpu_devid interrupts will record timings when IRQS_TIMINGS is set, via record_irq_time(), where they previously did not.
- per_cpu_devid interrupts will handle an IRQ_WAKE_THREAD return from their handlers to wake a thread, where they previously did not.
I'm not aware of any reason the above should be bad side effects, so sharing __handle_irq_event_percpu() for per_cpu_devid interrupts seems like a positive.
The other area that requires work for shared per_cpu_devid interrupts is __free_percpu_irq() which is adjusted to support removing the correct struct irqaction from the list pointed to by the action field of struct irqdesc, where it previously presumed only one action is present. The new behaviour mirrors that of __free_irq().
---
kernel/irq/chip.c | 8 ++------ kernel/irq/handle.c | 8 +++++++- kernel/irq/manage.c | 28 +++++++++++++++++++++------- 3 files changed, 30 insertions(+), 14 deletions(-)
kernel/irq/chip.c +2 -6
@@ -859,7 +859,6 @@ void handle_percpu_irq(struct irq_desc *desc)void handle_percpu_devid_irq (struct irq_desc *desc) {struct irq_chip *chip =irq_desc_get_chip (desc); -struct irqaction *action = desc->action;unsigned int irq =irq_desc_get_irq (desc);irqreturn_t res;
@@ -868,11 +867,8 @@ void handle_percpu_devid_irq(struct irq_desc *desc)if (chip->irq_ack) chip->irq_ack (&desc->irq_data); -if (likely (action)) { -trace_irq_handler_entry (irq, action); - res = action->handler (irq,raw_cpu_ptr (action->percpu_dev_id)); -trace_irq_handler_exit (irq, action, res); - }else { + res =handle_irq_event_percpu (desc); +if (unlikely (res ==IRQ_NONE )) {unsigned int cpu =smp_processor_id ();bool enabled =cpumask_test_cpu (cpu, desc->percpu_enabled);
kernel/irq/handle.c +7 -1
@@ -142,9 +142,15 @@ irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flagsfor_each_action_of_desc (desc, action) {irqreturn_t res; +void *dev_id; + +if (irq_settings_is_per_cpu_devid (desc)) + dev_id =raw_cpu_ptr (action->percpu_dev_id); +else + dev_id = action->dev_id;trace_irq_handler_entry (irq, action); - res = action->handler (irq, action->dev_id); + res = action->handler (irq, dev_id);trace_irq_handler_exit (irq, action, res); if (WARN_ONCE(!irqs_disabled(),"irq %u handler %pF enabled interrupts\n",
kernel/irq/manage.c +21 -7
@@ -1929,7 +1929,7 @@ EXPORT_SYMBOL_GPL(disable_percpu_irq);static struct irqaction *__free_percpu_irq (unsigned int irq,void __percpu *dev_id) {struct irq_desc *desc =irq_to_desc (irq); -struct irqaction *action; +struct irqaction *action, **action_ptr;unsigned long flags;WARN (in_interrupt (),"Trying to free IRQ %d from IRQ context!\n" , irq);
@@ -1939,20 +1939,34 @@ static struct irqaction *__free_percpu_irq(unsigned int irq, void __percpu *dev_raw_spin_lock_irqsave (&desc->lock, flags); - action = desc->action; -if (!action || action->percpu_dev_id != dev_id) { -WARN (1 ,"Trying to free already-free IRQ %d\n" , irq); - goto bad; +/* +* There can be multiple actions per IRQ descriptor, find the right +* one based on the dev_id: +*/ + action_ptr = &desc->action; +for (;;) { + action = *action_ptr; + +if (!action) { +WARN (1 ,"Trying to free already-free IRQ %d\n" , irq); + goto bad; + } + +if (action->percpu_dev_id == dev_id) +break ; + action_ptr = &action->next; } -if (!cpumask_empty (desc->percpu_enabled)) { +if ((action_ptr == &desc->action) && + !action->next && + !cpumask_empty (desc->percpu_enabled)) {WARN (1 ,"percpu IRQ %d still enabled on CPU%d!\n" , irq,cpumask_first (desc->percpu_enabled)); goto bad; }/* Found it - now remove it from the list of entries: */ - desc->action =NULL ; + *action_ptr = action->next;raw_spin_unlock_irqrestore (&desc->lock, flags);
Signature · 1 line
2.14.1
Re: [RFC PATCH v1 2/9] genirq: Support shared per_cpu_devid interrupts
Quoted 16 lines · Paul Burton
Up until now
per_cpu_devidinterrupts have not supported sharing. On MIPS we have some percpu interrupts which are shared in many systems - a single CPU interrupt line may be used to indicate a timer interrupt, performance counter interrupt or fast debug channel interrupt. We have up until now supported this with a series of hacks, wherein drivers call each other's interrupt handlers & our MIPS GIC irqchip driver includes a hack which configures the interrupt(s) for all CPUs. In order to allow this mess to be cleaned up, this patch introduces support for sharedper_cpu_devidinterrupts.The major portion of this is supporting
per_cpu_devidinterrupts in__handle_irq_event_percpu()and then making use of this, viahandle_irq_event_percpu(), fromhandler_percpu_devif_irq()to invoke the handler for all actions associated with the shared interrupt. This does have a few side effects worth noting:
Quoted 8 lines
-
per_cpu_devidinterrupts will now add to the entropy pool viaadd_interrupt_randomness(), where they previously did not.-
per_cpu_devidinterrupts will record timings whenIRQS_TIMINGSis set, viarecord_irq_time(), where they previously did not.-
per_cpu_devidinterrupts will handle anIRQ_WAKE_THREADreturn from their handlers to wake a thread, where they previously did not.
That's broken because it lacks the magic synchronization which is described in the comment in __irq_wake_thread().
Quoted 3 lines
I'm not aware of any reason the above should be bad side effects, so sharing
__handle_irq_event_percpu()forper_cpu_devidinterrupts seems like a positive.
Now you are :)
The other side effect of this is the extra overhead. You add an extra conditional into the main interrupt handling function __handle_irq_event_percpu() and the extra loop and hoops overhead for handle_percpu_devid_irq().
Thanks,
tglx
Re: [RFC PATCH v1 2/9] genirq: Support shared per_cpu_devid interrupts
Quoted 20 lines · Thomas Gleixner
Quoted 19 lines · Paul Burton
Up until now
per_cpu_devidinterrupts have not supported sharing. On MIPS we have some percpu interrupts which are shared in many systems - a single CPU interrupt line may be used to indicate a timer interrupt, performance counter interrupt or fast debug channel interrupt. We have up until now supported this with a series of hacks, wherein drivers call each other's interrupt handlers & our MIPS GIC irqchip driver includes a hack which configures the interrupt(s) for all CPUs. In order to allow this mess to be cleaned up, this patch introduces support for sharedper_cpu_devidinterrupts.The major portion of this is supporting
per_cpu_devidinterrupts in__handle_irq_event_percpu()and then making use of this, viahandle_irq_event_percpu(), fromhandler_percpu_devif_irq()to invoke the handler for all actions associated with the shared interrupt. This does have a few side effects worth noting:-
per_cpu_devidinterrupts will now add to the entropy pool viaadd_interrupt_randomness(), where they previously did not.
Quoted 8 lines
Quoted 5 lines
-
per_cpu_devidinterrupts will record timings whenIRQS_TIMINGSis set, viarecord_irq_time(), where they previously did not.-
per_cpu_devidinterrupts will handle anIRQ_WAKE_THREADreturn from their handlers to wake a thread, where they previously did not.That's broken because it lacks the magic synchronization which is described in the comment in
__irq_wake_thread().
Aside of that to make that work at all would require per cpu threads and not a single systemwide thread.
Thanks,
tglx
Re: [RFC PATCH v1 2/9] genirq: Support shared per_cpu_devid interrupts
Quoted 25 lines · Thomas Gleixner
Quoted 23 lines · Thomas Gleixner
Quoted 22 lines · Paul Burton
Up until now
per_cpu_devidinterrupts have not supported sharing. On MIPS we have some percpu interrupts which are shared in many systems - a single CPU interrupt line may be used to indicate a timer interrupt, performance counter interrupt or fast debug channel interrupt. We have up until now supported this with a series of hacks, wherein drivers call each other's interrupt handlers & our MIPS GIC irqchip driver includes a hack which configures the interrupt(s) for all CPUs. In order to allow this mess to be cleaned up, this patch introduces support for sharedper_cpu_devidinterrupts.The major portion of this is supporting
per_cpu_devidinterrupts in__handle_irq_event_percpu()and then making use of this, viahandle_irq_event_percpu(), fromhandler_percpu_devif_irq()to invoke the handler for all actions associated with the shared interrupt. This does have a few side effects worth noting:-
per_cpu_devidinterrupts will now add to the entropy pool viaadd_interrupt_randomness(), where they previously did not.-
per_cpu_devidinterrupts will record timings whenIRQS_TIMINGSis set, viarecord_irq_time(), where they previously did not.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
-
per_cpu_devidinterrupts will handle anIRQ_WAKE_THREADreturn from their handlers to wake a thread, where they previously did not.That's broken because it lacks the magic synchronization which is described in the comment in
__irq_wake_thread().Aside of that to make that work at all would require per cpu threads and not a single systemwide thread.
also request_threaded_irq() will yell at you if you call it for a percpu interrupt.
Care to rewrite the changelog and make that conditional:
irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags) {
+ bool percpu = irq_settings_is_per_cpu_devid(desc);
irqreturn_t retval = IRQ_NONE;
unsigned int irq = desc->irq_data.irq;
struct irqaction *action;
@@ -142,9 +143,15 @@ irqreturn_t __handle_irq_event_percpu(st
for_each_action_of_desc(desc, action) {
irqreturn_t res;
+ void *dev_id;
+
+ if (!percpu))
+ dev_id = action->dev_id;
+ else
+ dev_id = raw_cpu_ptr(action->percpu_dev_id);
Thanks,
tglx
RFC PATCH 3/9 genirq: Introduce irq_is_percpu_devid()
In reply to Paul BurtonIn preparation for allowing code to handle both percpu_devid interrupts using the percpu interrupt APIs, and non-percpu_devid but still percpu interrupts with the regular interrupt APIs, introduce a new irq_is_percpu_devid() helper function to allow callers to check whether an interrupt has the IRQ_PER_CPU_DEVID flag set.
---
include/linux/irqdesc.h | 8 ++++++++ 1 file changed, 8 insertions(+)
include/linux/irqdesc.h +8 -0
@@ -244,6 +244,14 @@ static inline int irq_is_percpu(unsigned int irq)return desc->status_use_accessors &IRQ_PER_CPU ; } +static inline int irq_is_percpu_devid (unsigned int irq) +{ +struct irq_desc *desc; + + desc =irq_to_desc (irq); +return desc->status_use_accessors &IRQ_PER_CPU_DEVID ; +} +static inline void irq_set_lockdep_class (unsigned int irq,struct lock_class_key *class) {
Signature · 1 line
2.14.1
RFC PATCH 4/9 MIPS: Remove perf_irq interrupt sharing fallback
In reply to Paul BurtonSince commit a1ec0e188330 ("MIPS: perf: Allow sharing IRQ with timer") we have supported registering our performance counter overflow IRQ handler using the IRQF_SHARED flag when cp0_perfcount_irq >= 0 or get_c0_perfcount_int() is implemented & returns a valid interrupt. This was made unconditional for MIPSr2 & beyond by commit 4a91d8fb61e2 ("MIPS: Allow shared IRQ for timer & perf counter") which removed a special case that set cp0_perfcount_irq to -1 if the performance counter overflow & timer interrupts share a CPU interrupt pin, however for pre-r2 systems we retained a fallback wherein we don't register the perf IRQ handler & instead set a perf_irq function pointer which is called by the timer driver.
Commit 4a91d8fb61e2 ("MIPS: Allow shared IRQ for timer & perf counter") seems to suggest that this is necessary because the we can't decode which interrupt happened on pre-r2 systems, but this is not true - in this case __handle_irq_event_percpu() will simply invoke both the timer driver & perf interrupt handlers which is exactly what we want, and they'll simply both perform their work as they do now.
As such we can set cp0_perfcount_irq = cp0_compare_irq for pre-r2 systems and remove the perf_irq fallback in favor of always relying on more standard interrupt sharing using IRQF_SHARED & multiple handlers.
A natural cleanup that ties in with no longer using perf_irq is that we can remove mipsxx_pmu_handle_shared_irq() which we previously pointed perf_irq at, and effectively inline it in mipsxx_pmu_handle_irq().
In the the loongson3 oprofile case the driver had exclusively relied upon perf_irq, and we switch instead to calling request_irq() to register the shared handler just like the mipsxx perf & oprofile code.
---
arch/mips/kernel/perf_event_mipsxx.c | 59 +++++++++++---------------------- arch/mips/kernel/traps.c | 2 +- arch/mips/oprofile/op_model_loongson3.c | 39 +++++++++++----------- arch/mips/oprofile/op_model_mipsxx.c | 10 ++---- 4 files changed, 42 insertions(+), 68 deletions(-)
arch/mips/kernel/perf_event_mipsxx.c +19 -40
@@ -25,7 +25,7 @@#include <asm/irq.h> #include <asm/irq_regs.h> #include <asm/stacktrace.h> -#include <asm/time.h> /* For perf_irq */ +#include <asm/time.h> #define MIPS_MAX_HWEVENTS 4#define MIPS_TCS_PER_COUNTER 2
@@ -167,7 +167,6 @@ static unsigned int counters_total_to_per_cpu(unsigned int counters)static void resume_local_counters (void );static void pause_local_counters (void );static irqreturn_t mipsxx_pmu_handle_irq (int ,void *); -static int mipsxx_pmu_handle_shared_irq (void );static unsigned int mipsxx_pmu_swizzle_perf_idx (unsigned int idx) {
@@ -538,44 +537,25 @@ static void mipspmu_disable(struct pmu *pmu)static atomic_t active_events =ATOMIC_INIT (0 );static DEFINE_MUTEX (pmu_reserve_mutex); -static int (*save_perf_irq)(void );static int mipspmu_get_irq (void ) {int err; -if (mipspmu.irq >=0 ) { -/* Request my own irq handler. */ - err =request_irq (mipspmu.irq, mipsxx_pmu_handle_irq, -IRQF_PERCPU |IRQF_NOBALANCING | -IRQF_NO_THREAD |IRQF_NO_SUSPEND | -IRQF_SHARED , -"mips_perf_pmu" , &mipspmu); -if (err) { -pr_warn ("Unable to request IRQ%d for MIPS performance counters!\n" , - mipspmu.irq); - } - }else if (cp0_perfcount_irq <0 ) { -/* -* We are sharing the irq number with the timer interrupt. -*/ - save_perf_irq = perf_irq; - perf_irq = mipsxx_pmu_handle_shared_irq; - err =0 ; - }else { -pr_warn ("The platform hasn't properly defined its interrupt controller\n" ); - err = -ENOENT ; - } - + err =request_irq (mipspmu.irq, mipsxx_pmu_handle_irq, +IRQF_PERCPU |IRQF_NOBALANCING | +IRQF_NO_THREAD |IRQF_NO_SUSPEND | +IRQF_SHARED , +"mips_perf_pmu" , &mipspmu); +if (err) +pr_warn ("Unable to request IRQ%d for MIPS performance counters!\n" , + mipspmu.irq);return err; }static void mipspmu_free_irq (void ) { -if (mipspmu.irq >=0 ) -free_irq (mipspmu.irq, &mipspmu); -else if (cp0_perfcount_irq <0 ) - perf_irq = save_perf_irq; +free_irq (mipspmu.irq, &mipspmu); }/*
@@ -1403,13 +1383,13 @@ static void resume_local_counters(void) }while (ctr >0 ); } -static int mipsxx_pmu_handle_shared_irq (void ) +static irqreturn_t mipsxx_pmu_handle_irq (int irq,void *dev) {struct cpu_hw_events *cpuc =this_cpu_ptr (&cpu_hw_events);struct perf_sample_data data;unsigned int counters = mipspmu.num_counters;u64 counter; -int handled =IRQ_NONE ; +irqreturn_t handled =IRQ_NONE ;struct pt_regs *regs;if (cpu_has_perf_cntr_intr_bit && !(read_c0_cause () &CAUSEF_PCI ))
@@ -1462,11 +1442,6 @@ static int mipsxx_pmu_handle_shared_irq(void)return handled; } -static irqreturn_t mipsxx_pmu_handle_irq (int irq,void *dev) -{ -return mipsxx_pmu_handle_shared_irq (); -} -/* 24K */ #define IS_BOTH_COUNTERS_24K_EVENT (b) \ ((b) == 0 || (b) == 1 || (b) == 11)
@@ -1736,6 +1711,11 @@ init_hw_perf_events(void)else irq =-1 ; +if (irq <0 ) { +pr_warn ("The platform hasn't properly defined its interrupt controller\n" ); +return -ENOENT ; + } + mipspmu.map_raw_event = mipsxx_pmu_map_raw_event;switch (current_cpu_type ()) {
@@ -1850,9 +1830,8 @@ init_hw_perf_events(void)on_each_cpu (reset_counters, (void *)(long )counters,1 ); -pr_cont ("%s PMU enabled, %d %d-bit counters available to each " -"CPU, irq %d%s\n" , mipspmu.name, counters, counter_bits, irq, - irq <0 ?" (share with timer interrupt)" :"" ); +pr_cont ("%s PMU enabled, %d %d-bit counters available to each CPU, irq %d" , + mipspmu.name, counters, counter_bits, irq);perf_pmu_register (&pmu,"cpu" ,PERF_TYPE_RAW );
arch/mips/kernel/traps.c +1 -1
@@ -2227,7 +2227,7 @@ void per_cpu_trap_init(bool is_boot_cpu) }else { cp0_compare_irq =CP0_LEGACY_COMPARE_IRQ ; cp0_compare_irq_shift =CP0_LEGACY_PERFCNT_IRQ ; - cp0_perfcount_irq =-1 ; + cp0_perfcount_irq = cp0_compare_irq; cp0_fdc_irq =-1 ; }
arch/mips/oprofile/op_model_loongson3.c +20 -19
@@ -40,8 +40,6 @@#define read_c0_perfhi2 () __read_64bit_c0_register($25, 3)#define write_c0_perfhi2 (val) __write_64bit_c0_register($25, 3, val) -static int (*save_perf_irq)(void ); - static struct loongson3_register_config { unsigned int control1; unsigned int control2;
@@ -130,12 +128,13 @@ static void loongson3_cpu_stop(void *args)memset (®,0 ,sizeof (reg)); } -static int loongson3_perfcount_handler (void ) +static irqreturn_t loongson3_perfcount_handler (int irq,void *dev_id) {unsigned long flags;uint64_t counter1, counter2; -uint32_t cause, handled =IRQ_NONE ; +uint32_t cause;struct pt_regs *regs =get_irq_regs (); +irqreturn_t handled =IRQ_NONE ; cause =read_c0_cause ();if (!(cause &CAUSEF_PCI ))
@@ -182,32 +181,34 @@ static int loongson3_dying_cpu(unsigned int cpu)return 0 ; } +struct op_mips_model op_model_loongson3_ops = { + .reg_setup = loongson3_reg_setup, + .cpu_setup = loongson3_cpu_setup, + .init = loongson3_init, + .exit = loongson3_exit, + .cpu_start = loongson3_cpu_start, + .cpu_stop = loongson3_cpu_stop, + .cpu_type ="mips/loongson3" , + .num_counters =2 +}; +static int __init loongson3_init (void ) {on_each_cpu (reset_counters,NULL ,1 );cpuhp_setup_state_nocalls (CPUHP_AP_MIPS_OP_LOONGSON3_STARTING ,"mips/oprofile/loongson3:starting" , loongson3_starting_cpu, loongson3_dying_cpu); - save_perf_irq = perf_irq; - perf_irq = loongson3_perfcount_handler; -return 0 ; +return request_irq (cp0_compare_irq, loongson3_perfcount_handler, +IRQF_PERCPU |IRQF_NOBALANCING | +IRQF_NO_THREAD |IRQF_NO_SUSPEND | +IRQF_SHARED , +"Perfcounter" , &op_model_loongson3_ops); }static void loongson3_exit (void ) { +free_irq (cp0_compare_irq, &op_model_loongson3_ops);on_each_cpu (reset_counters,NULL ,1 );cpuhp_remove_state_nocalls (CPUHP_AP_MIPS_OP_LOONGSON3_STARTING ); - perf_irq = save_perf_irq; } - -struct op_mips_model op_model_loongson3_ops = { - .reg_setup = loongson3_reg_setup, - .cpu_setup = loongson3_cpu_setup, - .init = loongson3_init, - .exit = loongson3_exit, - .cpu_start = loongson3_cpu_start, - .cpu_stop = loongson3_cpu_stop, - .cpu_type ="mips/loongson3" , - .num_counters =2 -};
arch/mips/oprofile/op_model_mipsxx.c +2 -8
@@ -21,7 +21,6 @@#define M_COUNTER_OVERFLOW (1UL << 31) -static int (*save_perf_irq)(void );static int perfcount_irq;/*
@@ -423,9 +422,6 @@ static int __init mipsxx_init(void)return -ENODEV ; } - save_perf_irq = perf_irq; - perf_irq = mipsxx_perfcount_handler; -if (get_c0_perfcount_int) perfcount_irq =get_c0_perfcount_int ();else if (cp0_perfcount_irq >=0 )
@@ -438,7 +434,7 @@ static int __init mipsxx_init(void)IRQF_PERCPU |IRQF_NOBALANCING |IRQF_NO_THREAD |IRQF_NO_SUSPEND |IRQF_SHARED , - "Perfcounter", save_perf_irq); + "Perfcounter", &op_model_mipsxx_ops);return 0 ; }
@@ -448,12 +444,10 @@ static void mipsxx_exit(void)int counters = op_model_mipsxx_ops.num_counters;if (perfcount_irq >=0 ) -free_irq (perfcount_irq, save_perf_irq); +free_irq (perfcount_irq, &op_model_mipsxx_ops); counters =counters_per_cpu_to_total (counters);on_each_cpu (reset_counters, (void *)(long )counters,1 ); - - perf_irq = save_perf_irq; }struct op_mips_model op_model_mipsxx_ops = {
Signature · 1 line
2.14.1
RFC PATCH 5/9 MIPS: Remove perf_irq
In reply to Paul BurtonRemove the perf_irq function pointer which we no longer use. The cevt-r4k clock event driver no longer needs to call it, which simplifies c0_compare_interrupt(), and we drop its definition & declarations.
---
arch/mips/include/asm/time.h | 1 - arch/mips/kernel/cevt-r4k.c | 48 +++++++++----------------------------------- arch/mips/kernel/time.c | 9 --------- arch/mips/oprofile/op_impl.h | 2 -- 4 files changed, 10 insertions(+), 50 deletions(-)
arch/mips/include/asm/time.h +0 -1
@@ -45,7 +45,6 @@ extern unsigned int mips_hpt_frequency;* The performance counter IRQ on MIPS is a close relative to the timer IRQ * so it lives here. */ -extern int (*perf_irq)(void );extern int __weak get_c0_perfcount_int (void );/*
arch/mips/kernel/cevt-r4k.c +10 -38
64 lines not on this page · raw message
arch/mips/kernel/time.c +0 -9
@@ -49,15 +49,6 @@ int update_persistent_clock(struct timespec now)return rtc_mips_set_mmss (now.tv_sec); } -static int null_perf_irq (void ) -{ -return 0 ; -} - -int (*perf_irq)(void ) = null_perf_irq; - -EXPORT_SYMBOL (perf_irq); -/* * time_init() - it does the following things. *
arch/mips/oprofile/op_impl.h +0 -2
@@ -10,8 +10,6 @@ #ifndef OP_IMPL_H #define OP_IMPL_H 1 -extern int (*perf_irq)(void); - /* Per-counter configuration as set via oprofilefs. */ struct op_counter_config { unsigned long enabled;
Signature · 1 line
2.14.1
RFC PATCH 6/9 MIPS: perf: percpu_devid interrupt support
In reply to Paul BurtonThe MIPS CPU performance counter overflow interrupt is really a percpu interrupt, but up until now we have not used the percpu interrupt APIs to configure & control it. In preparation for doing so, introduce support for percpu_devid interrupts in the MIPS perf implementation.
We switch from using request_irq() to using either setup_irq() or setup_percpu_irq() with an explicit struct irqaction such that we can set the flags, handler & name for that struct irqaction once rather than needing to duplicate them in calls to request_irq() and request_percpu_irq().
The IRQF_NOAUTOEN flag is passed because percpu interrupts automatically get IRQ_NOAUTOEN set by irq_set_percpu_devid_flags(). We opt into accepting this behaviour & explicitly enable the interrupt in mipspmu_enable() right after configuring the local performance counters.
---
arch/mips/kernel/perf_event_mipsxx.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-)
arch/mips/kernel/perf_event_mipsxx.c +19 -11
@@ -514,6 +514,11 @@ static void mipspmu_enable(struct pmu *pmu)write_unlock (&pmuint_rwlock);#endif resume_local_counters (); + +if (irq_is_percpu_devid (mipspmu.irq)) +enable_percpu_irq (mipspmu.irq,IRQ_TYPE_NONE ); +else +enable_irq (mipspmu.irq); }/*
@@ -538,24 +543,27 @@ static void mipspmu_disable(struct pmu *pmu)static atomic_t active_events =ATOMIC_INIT (0 );static DEFINE_MUTEX (pmu_reserve_mutex); +static struct irqaction c0_perf_irqaction = { + .handler = mipsxx_pmu_handle_irq, + .flags =IRQF_PERCPU |IRQF_TIMER |IRQF_SHARED |IRQF_NOAUTOEN , + .name ="mips_perf_pmu" , + .percpu_dev_id = &mipspmu, +}; +static int mipspmu_get_irq (void ) { -int err; +if (irq_is_percpu_devid (mipspmu.irq)) +return setup_percpu_irq (mipspmu.irq, &c0_perf_irqaction); - err =request_irq (mipspmu.irq, mipsxx_pmu_handle_irq, -IRQF_PERCPU |IRQF_NOBALANCING | -IRQF_NO_THREAD |IRQF_NO_SUSPEND | -IRQF_SHARED , -"mips_perf_pmu" , &mipspmu); -if (err) -pr_warn ("Unable to request IRQ%d for MIPS performance counters!\n" , - mipspmu.irq); -return err; +return setup_irq (mipspmu.irq, &c0_perf_irqaction); }static void mipspmu_free_irq (void ) { -free_irq (mipspmu.irq, &mipspmu); +if (irq_is_percpu_devid (mipspmu.irq)) +remove_percpu_irq (mipspmu.irq, &c0_perf_irqaction); +else +remove_irq (mipspmu.irq, &c0_perf_irqaction); }/*
Signature · 1 line
2.14.1
Re: [RFC PATCH v1 6/9] MIPS: perf: percpu_devid interrupt support
Quoted 14 lines · Paul Burton
arch/mips/kernel/perf_event_mipsxx.c +9
-1+static struct irqaction c0_perf_irqaction = { + .handler = mipsxx_pmu_handle_irq, + .flags =IRQF_PERCPU |IRQF_TIMER |IRQF_SHARED |IRQF_NOAUTOEN , + .name ="mips_perf_pmu" , + .percpu_dev_id = &mipspmu, +}; +static int mipspmu_get_irq (void ) { -int err; +if (irq_is_percpu_devid (mipspmu.irq)) +return setup_percpu_irq (mipspmu.irq, &c0_perf_irqaction);
arch/mips/kernel/perf_event_mipsxx.c static void mipspmu_disable(struct pmu *pmu) · line 558
Quoted 10 lines
arch/mips/kernel/perf_event_mipsxx.c +1
-9- err =request_irq (mipspmu.irq, mipsxx_pmu_handle_irq, -IRQF_PERCPU |IRQF_NOBALANCING | -IRQF_NO_THREAD |IRQF_NO_SUSPEND | -IRQF_SHARED , -"mips_perf_pmu" , &mipspmu); -if (err) -pr_warn ("Unable to request IRQ%d for MIPS performance counters!\n" , - mipspmu.irq); -return err; +return setup_irq (mipspmu.irq, &c0_perf_irqaction);
request_irq() is really preferred over setup_irq(). setup_irq() exists for historical reasons because back in the days the allocators were not working when early interrupts got initialized. Today that's a non issue, but I never got around to remove the setup_irq() cruft.
Thanks,
tglx
RFC PATCH 7/9 MIPS: cevt-r4k: percpu_devid interrupt support
In reply to Paul BurtonThe MIPS coprocessor 0 count/compare interrupt, used by the cevt-r4k driver, is really a percpu interrupt but up until now we have not used the percpu interrupt APIs to configure & control it. In preparation for doing so, introduce support for percpu_devid interrupts in cevt-r4k.
We switch from using request_irq() to using either setup_irq() or setup_percpu_irq() with an explicit struct irqaction such that we can set the flags, handler & name for that struct irqaction once rather than needing to duplicate them in calls to request_irq() and request_percpu_irq().
The IRQF_NOAUTOEN flag is passed because percpu interrupts automatically get IRQ_NOAUTOEN set by irq_set_percpu_devid_flags(). We opt into accepting this behaviour & explicitly enable the interrupt in r4k_clockevent_init() which is called on all CPUs during bringup.
---
arch/mips/kernel/cevt-r4k.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-)
arch/mips/kernel/cevt-r4k.c +22 -7
@@ -8,6 +8,7 @@*/ #include <linux/clockchips.h> #include <linux/interrupt.h> +#include <linux/once.h> #include <linux/percpu.h> #include <linux/smp.h> #include <linux/irq.h>
@@ -106,7 +107,6 @@ static unsigned int calculate_min_delta(void) } DEFINE_PER_CPU(struct clock_event_device, mips_clockevent_device); -int cp0_timer_irq_installed;irqreturn_t c0_compare_interrupt (int irq,void *dev_id) {
@@ -136,8 +136,9 @@ struct irqaction c0_compare_irqaction = {* IRQF_SHARED: The timer interrupt may be shared with other interrupts * such as perf counter and FDC interrupts. */ - .flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED, + .flags = IRQF_PERCPU | IRQF_TIMER | IRQF_SHARED | IRQF_NOAUTOEN, .name = "timer", + .percpu_dev_id = &mips_clockevent_device, };
@@ -222,11 +223,20 @@ unsigned int __weak get_c0_compare_int(void)return MIPS_CPU_IRQ_BASE + cp0_compare_irq; } +static void setup_c0_compare_int (int irq,int *err) +{ +if (irq_is_percpu_devid (irq)) + *err =setup_percpu_irq (irq, &c0_compare_irqaction); +else + *err =setup_irq (irq, &c0_compare_irqaction); +} +int r4k_clockevent_init (void ) {unsigned int cpu =smp_processor_id ();struct clock_event_device *cd;unsigned int irq, min_delta; +int err;if (!cpu_has_counter || !mips_hpt_frequency)return -ENXIO ;
@@ -258,12 +268,17 @@ int r4k_clockevent_init(void)clockevents_config_and_register (cd, mips_hpt_frequency, min_delta,0x7fffffff ); -if (cp0_timer_irq_installed) -return 0 ; - - cp0_timer_irq_installed =1 ; + err =0 ; +DO_ONCE (setup_c0_compare_int, irq, &err); +if (err) { +pr_err ("Unable to setup timer IRQ %d: %d\n" , irq, err); +return err; + } -setup_irq (irq, &c0_compare_irqaction); +if (irq_is_percpu_devid (irq)) +enable_percpu_irq (irq,IRQ_TYPE_NONE ); +else +enable_irq (irq);return 0 ; }
Signature · 1 line
2.14.1
RFC PATCH 8/9 irqchip: mips-cpu: Set timer, FDC & perf interrupts percpu_devid
In reply to Paul BurtonThe MIPS timer, fast debug channel (FDC) & performance counter overflow interrupts are all really percpu interrupts. However up until now the users of these interrupt haven't used the percpu interrupt APIs to configure & control them; instead using the regular non-percpu APIs such as request_irq(), enable_irq() etc. This has required hacks elsewhere, and generally does not fit well with the fact that the interrupts are actually percpu.
The users of these interrupts are now prepared for them to be used with the percpu interrupt APIs, so set them up as percpu_devid interrupts in order to allow these users to begin using the percpu interrupt APIs.
---
drivers/irqchip/irq-mips-cpu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/irqchip/irq-mips-cpu.c +8 -1
@@ -166,7 +166,14 @@ static int mips_cpu_intc_map(struct irq_domain *d, unsigned int irq,if (cpu_has_vint)set_vi_handler (hw, plat_irq_dispatch); -irq_set_chip_and_handler (irq, chip, handle_percpu_irq); +if ((irq == cp0_compare_irq) || + (irq == cp0_fdc_irq) || + (irq == cp0_perfcount_irq)) { +irq_set_chip_and_handler (irq, chip, handle_percpu_devid_irq); +irq_set_percpu_devid (irq); + }else { +irq_set_chip_and_handler (irq, chip, handle_percpu_irq); + }return 0 ; }
Signature · 1 line
2.14.1
RFC PATCH 9/9 irqchip: mips-gic: Remove gic_all_vpes_local_irq_controller
In reply to Paul BurtonThe gic_all_vpes_local_irq_controller irq_chip in the MIPS GIC driver is a hack which was necessary due to other drivers & MIPS arch code not using the percpu interrupt APIs to configure & control interrupts which are really percpu.
This is no longer a problem - other drivers & arch code support using the percpu interrupt APIs so we can now remove the gic_all_vpes_local_irq_controller hack.
---
drivers/irqchip/irq-mips-gic.c | 69 +++++------------------------------------- 1 file changed, 7 insertions(+), 62 deletions(-)
drivers/irqchip/irq-mips-gic.c +7 -62
@@ -337,40 +337,6 @@ static struct irq_chip gic_local_irq_controller = { .irq_unmask = gic_unmask_local_irq, }; -static void gic_mask_local_irq_all_vpes (struct irq_data *d) -{ -int intr =GIC_HWIRQ_TO_LOCAL (d->hwirq); -int i; -unsigned long flags; - -spin_lock_irqsave (&gic_lock, flags); -for (i =0 ; i < gic_vpes; i++) { -write_gic_vl_other (mips_cm_vp_id (i)); -write_gic_vo_rmask (BIT (intr)); - } -spin_unlock_irqrestore (&gic_lock, flags); -} - -static void gic_unmask_local_irq_all_vpes (struct irq_data *d) -{ -int intr =GIC_HWIRQ_TO_LOCAL (d->hwirq); -int i; -unsigned long flags; - -spin_lock_irqsave (&gic_lock, flags); -for (i =0 ; i < gic_vpes; i++) { -write_gic_vl_other (mips_cm_vp_id (i)); -write_gic_vo_smask (BIT (intr)); - } -spin_unlock_irqrestore (&gic_lock, flags); -} - -static struct irq_chip gic_all_vpes_local_irq_controller = { - .name ="MIPS GIC Local" , - .irq_mask = gic_mask_local_irq_all_vpes, - .irq_unmask = gic_unmask_local_irq_all_vpes, -}; -static void __gic_irq_dispatch (void ) {gic_handle_local_int (false);
@@ -471,35 +437,14 @@ static int gic_irq_domain_map(struct irq_domain *d, unsigned int virq,return gic_shared_irq_domain_map (d, virq, hwirq,0 ); } -switch (GIC_HWIRQ_TO_LOCAL (hwirq)) { -case GIC_LOCAL_INT_TIMER : -case GIC_LOCAL_INT_PERFCTR : -case GIC_LOCAL_INT_FDC : -/* -* HACK: These are all really percpu interrupts, but -* the rest of the MIPS kernel code does not use the -* percpu IRQ API for them. -*/ - err =irq_domain_set_hwirq_and_chip (d, virq, hwirq, - &gic_all_vpes_local_irq_controller, -NULL ); -if (err) -return err; - -irq_set_handler (virq, handle_percpu_irq); -break ; + err =irq_domain_set_hwirq_and_chip (d, virq, hwirq, + &gic_local_irq_controller, +NULL ); +if (err) +return err; -default : - err =irq_domain_set_hwirq_and_chip (d, virq, hwirq, - &gic_local_irq_controller, -NULL ); -if (err) -return err; - -irq_set_handler (virq, handle_percpu_devid_irq); -irq_set_percpu_devid (virq); -break ; - } +irq_set_handler (virq, handle_percpu_devid_irq); +irq_set_percpu_devid (virq);return gic_local_irq_domain_map (d, virq, hwirq); }
Signature · 1 line
2.14.1