genirq: Another round of tree wide cleanups
Subsystems (20)
cover genirq: Another round of tree wide cleanups
Since the last tree wide sweep a serious amount of braindamage, blatant abuse and serious trainwrecks of the generic irq subsystem has found its way into mainline.
The top score on the shitlist definitely gets this gem:
#include "../../../kernel/irq/settings.h"
tightly followed by the HYpedPERVersity irq handling.
The series contains the following cleanups:
- Rewrite abusive code written by incomptetent ...
- Replace open coded constructs by the proper core functions.
- Replace common patterns by a core implementation
This adds a few functions to the core code, which might be not necessary at all, but I'm not masochistic enough to try to dechipher the undocumented mess of Xen and HyperV.
The releavant patches have a Not-Yet-SOB tag and might be dropped if the maintainers of the code in question can't come up with reasonable explanations why they are necessary at all.
Thanks,
tglx
--- arch/arm/mach-imx/pm-imx6q.c | 7 +- arch/arm/mach-mmp/pm-mmp2.c | 16 ----- arch/arm/mach-mmp/pm-pxa910.c | 20 +----- arch/arm/mach-omap1/ams-delta-fiq.c | 7 -- arch/blackfin/Kconfig | 1 arch/blackfin/kernel/irqchip.c | 36 ++---------- arch/ia64/kernel/irq_ia64.c | 10 +-- arch/metag/kernel/irq.c | 20 +----- arch/mips/kernel/smtc.c | 2 arch/mips/sgi-ip22/ip22-int.c | 2 arch/mips/sgi-ip22/ip22-time.c | 2 arch/mips/sibyte/bcm1480/smp.c | 2 arch/mips/sibyte/sb1250/smp.c | 2 arch/mn10300/kernel/mn10300-watchdog.c | 2 arch/powerpc/kernel/eeh_driver.c | 26 +++++++- arch/powerpc/kernel/irq.c | 8 -- arch/powerpc/sysdev/ehv_pic.c | 10 --- arch/sh/kernel/irq.c | 16 ----- arch/sparc/kernel/time_64.c | 2 arch/x86/include/asm/hardirq.h | 3 + arch/x86/include/asm/mshyperv.h | 4 + arch/x86/kernel/cpu/mshyperv.c | 97 ++++++++++++++++++++------------- arch/x86/kernel/irq.c | 6 ++ arch/x86/xen/spinlock.c | 2 arch/xtensa/kernel/irq.c | 20 +----- drivers/hv/vmbus_drv.c | 39 +------------ drivers/pci/host/pcie-designware.c | 4 - drivers/s390/cio/cio.c | 5 - drivers/xen/events/events_2l.c | 15 +---- drivers/xen/events/events_base.c | 27 ++------- drivers/xen/events/events_fifo.c | 8 -- include/linux/irq.h | 8 ++ include/linux/kernel_stat.h | 12 ++-- kernel/irq/chip.c | 15 +++++ kernel/irq/irqdesc.c | 16 +++++ kernel/irq/manage.c | 6 +- 36 files changed, 204 insertions(+), 274 deletions(-)
PATCH 1/26 powerpc: irq: Use generic_handle_irq
No functional change
--- arch/powerpc/kernel/irq.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/powerpc/kernel/irq.c +2 -6
@@ -465,7 +465,6 @@ static inline void check_stack_overflow(void __do_irq (struct pt_regs *regs) { -struct irq_desc *desc;unsigned int irq;irq_enter ();
@@ -487,11 +486,8 @@ void __do_irq(struct pt_regs *regs)/* And finally process it */ if (unlikely (irq ==NO_IRQ ))__get_cpu_var (irq_stat).spurious_irqs++; -else { - desc =irq_to_desc (irq); -if (likely (desc)) - desc->handle_irq (irq, desc); - } +else +generic_handle_irq (irq);trace_irq_exit (regs);
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] powerpc: Irq: Use generic_handle_irq
powerpc: Irq: Use generic_handle_irq
Commit-ID: a4e04c9f219d2c00764ffa7ba45500411815879d Gitweb: http://git.kernel.org/tip/a4e04c9f219d2c00764ffa7ba45500411815879d Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:08 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:52 +0100
powerpc: Irq: Use generic_handle_irq
No functional change
--- arch/powerpc/kernel/irq.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
arch/powerpc/kernel/irq.c +2 -6
@@ -465,7 +465,6 @@ static inline void check_stack_overflow(void)void __do_irq (struct pt_regs *regs) { -struct irq_desc *desc;unsigned int irq;irq_enter ();
@@ -487,11 +486,8 @@ void __do_irq(struct pt_regs *regs)/* And finally process it */ if (unlikely (irq ==NO_IRQ ))__get_cpu_var (irq_stat).spurious_irqs++; -else { - desc =irq_to_desc (irq); -if (likely (desc)) - desc->handle_irq (irq, desc); - } +else +generic_handle_irq (irq);trace_irq_exit (regs);
PATCH 2/26 powerpc:evh_pic: Kill irq_desc abuse
In reply to Thomas GleixnerI'm really grumpy about this one. The line:
#include "../../../kernel/irq/settings.h"
should have been an alarm sign for all people who added their SOB to this trainwreck.
When I cleaned up the mess people made with interrupt descriptors a few years ago, I warned that I'm going to hunt down new offenders and treat them with stinking trouts. In this case I'll use frozen shark for a better educational value.
The whole idiocy which was done there could have been avoided with two lines of perfectly fine code. And do not complain about the lack of correct examples in tree.
The solution is simple:
Remove the brainfart and use the proper functions, which should have been used in the first place
--- arch/powerpc/sysdev/ehv_pic.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
arch/powerpc/sysdev/ehv_pic.c +2 -8
@@ -28,8 +28,6 @@#include <asm/ehv_pic.h> #include <asm/fsl_hcalls.h> -#include "../../../kernel/irq/settings.h" -static struct ehv_pic *global_ehv_pic;static DEFINE_SPINLOCK (ehv_pic_lock);
@@ -113,17 +111,13 @@ static unsigned int ehv_pic_type_to_vecpint ehv_pic_set_irq_type (struct irq_data *d,unsigned int flow_type) {unsigned int src =virq_to_hw (d->irq); -struct irq_desc *desc =irq_to_desc (d->irq);unsigned int vecpri, vold, vnew, prio, cpu_dest;unsigned long flags;if (flow_type ==IRQ_TYPE_NONE ) flow_type =IRQ_TYPE_LEVEL_LOW ; -irq_settings_clr_level (desc); -irq_settings_set_trigger_mask (desc, flow_type); -if (flow_type & (IRQ_TYPE_LEVEL_HIGH |IRQ_TYPE_LEVEL_LOW )) -irq_settings_set_level (desc); +irqd_set_trigger_type (d, flow_type); vecpri =ehv_pic_type_to_vecpri (flow_type);
@@ -144,7 +138,7 @@ int ehv_pic_set_irq_type(struct irq_dataev_int_set_config (src, vecpri, prio, cpu_dest);spin_unlock_irqrestore (&ehv_pic_lock, flags); -return 0 ; +return IRQ_SET_MASK_OK_NOCOPY ; }static struct irq_chip ehv_pic_irq_chip = {
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] powerpc:eVh_pic: Kill irq_desc abuse
powerpc:eVh_pic: Kill irq_desc abuse
Commit-ID: c866cda47f2c6c8abb929933b7794e9a92d7c924 Gitweb: http://git.kernel.org/tip/c866cda47f2c6c8abb929933b7794e9a92d7c924 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:08 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:51 +0100
powerpc:eVh_pic: Kill irq_desc abuse
I'm really grumpy about this one. The line:
#include "../../../kernel/irq/settings.h"
should have been an alarm sign for all people who added their SOB to this trainwreck.
When I cleaned up the mess people made with interrupt descriptors a few years ago, I warned that I'm going to hunt down new offenders and treat them with stinking trouts. In this case I'll use frozen shark for a better educational value.
The whole idiocy which was done there could have been avoided with two lines of perfectly fine code. And do not complain about the lack of correct examples in tree.
The solution is simple:
Remove the brainfart and use the proper functions, which should have been used in the first place
--- arch/powerpc/sysdev/ehv_pic.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
arch/powerpc/sysdev/ehv_pic.c +2 -8
@@ -28,8 +28,6 @@#include <asm/ehv_pic.h> #include <asm/fsl_hcalls.h> -#include "../../../kernel/irq/settings.h" -static struct ehv_pic *global_ehv_pic;static DEFINE_SPINLOCK (ehv_pic_lock);
@@ -113,17 +111,13 @@ static unsigned int ehv_pic_type_to_vecpri(unsigned int type)int ehv_pic_set_irq_type (struct irq_data *d,unsigned int flow_type) {unsigned int src =virq_to_hw (d->irq); -struct irq_desc *desc =irq_to_desc (d->irq);unsigned int vecpri, vold, vnew, prio, cpu_dest;unsigned long flags;if (flow_type ==IRQ_TYPE_NONE ) flow_type =IRQ_TYPE_LEVEL_LOW ; -irq_settings_clr_level (desc); -irq_settings_set_trigger_mask (desc, flow_type); -if (flow_type & (IRQ_TYPE_LEVEL_HIGH |IRQ_TYPE_LEVEL_LOW )) -irq_settings_set_level (desc); +irqd_set_trigger_type (d, flow_type); vecpri =ehv_pic_type_to_vecpri (flow_type);
@@ -144,7 +138,7 @@ int ehv_pic_set_irq_type(struct irq_data *d, unsigned int flow_type)ev_int_set_config (src, vecpri, prio, cpu_dest);spin_unlock_irqrestore (&ehv_pic_lock, flags); -return 0 ; +return IRQ_SET_MASK_OK_NOCOPY ; }static struct irq_chip ehv_pic_irq_chip = {
PATCH 3/26 powerpc: eeh: Kill another abuse of irq_desc
In reply to Thomas Gleixnercommit 91150af3a (powerpc/eeh: Fix unbalanced enable for IRQ) is another brilliant example of trainwreck engineering.
The patch "fixes" the issue of an unbalanced call to irq_enable() which causes a prominent warning by checking the disabled state of the interrupt line and call conditionally into the core code.
This is wrong in two aspects:
1) The warning is there to tell users, that they need to fix their asymetric enable/disable patterns by finding the root cause and solving it there.
It's definitely not meant to work around it by conditionally calling into the core code depending on the random state of the irq line.
Asymetric irq_disable/enable calls are a clear sign of wrong usage of the interfaces which have to be cured at the root and not by somehow hacking around it.
2) The abuse of core internal data structure instead of using the proper interfaces for retrieving the information for the 'hack around'
irq_desc is core internal and it's clear enough stated.
Replace at least the irq_desc abuse with the proper functions and add a big fat comment why this is absurd and completely wrong.
--- arch/powerpc/kernel/eeh_driver.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
arch/powerpc/kernel/eeh_driver.c +21 -5
@@ -143,15 +143,31 @@ static void eeh_disable_irq(struct pci_dstatic void eeh_enable_irq (struct pci_dev *dev) {struct eeh_dev *edev =pci_dev_to_eeh_dev (dev); -struct irq_desc *desc;if ((edev->mode) &EEH_DEV_IRQ_DISABLED ) { edev->mode &= ~EEH_DEV_IRQ_DISABLED ; - - desc =irq_to_desc (dev->irq); -if (desc && desc->depth >0 ) +/* +* FIXME !!!!! +* +* This is just ass backwards. This maze has +* unbalanced irq_enable/disable calls. So instead of +* finding the root cause it works around the warning +* in the irq_enable code by conditionally calling +* into it. +* +* That's just wrong.The warning in the core code is +* there to tell people to fix their assymetries in +* their own code, not by abusing the core information +* to avoid it. +* +* I so wish that the assymetry would be the other way +* round and a few more irq_disable calls render that +* shit unusable forever. +* +* tglx +*/ + if (irqd_irq_disabled(irq_get_irq_data(dev->irq))enable_irq (dev->irq); - } }/**
Re: [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc
The problems iirc have to do with drivers doing stupid things, but I'll let Gavin comment further and fix that up properly.
Cheers,
Ben.
Re: [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc
In reply to Thomas GleixnerQuoted 21 lines · Thomas Gleixner
commit
91150af3a(powerpc/eeh: Fix unbalanced enable for IRQ) is another brilliant example of trainwreck engineering.The patch "fixes" the issue of an unbalanced call to
irq_enable()which causes a prominent warning by checking the disabled state of the interrupt line and call conditionally into the core code.This is wrong in two aspects:
1) The warning is there to tell users, that they need to fix their asymetric enable/disable patterns by finding the root cause and solving it there.
It's definitely not meant to work around it by conditionally calling into the core code depending on the random state of the irq line.
Asymetric irq_disable/enable calls are a clear sign of wrong usage of the interfaces which have to be cured at the root and not by somehow hacking around it.
Quoted 9 lines
2) The abuse of core internal data structure instead of using the proper interfaces for retrieving the information for the 'hack around'
irq_descis core internal and it's clear enough stated.Replace at least the
irq_descabuse with the proper functions and add a big fat comment why this is absurd and completely wrong.
Thanks for pointing it out. I think we might have this patch for now and I'll look into individual drivers to fix the unbalanced function calls later one by one.
Thanks,
Gavin
Quoted 51 lines
Signed-off-by Thomas Gleixner <[email protected]>Cc Gavin Shan <[email protected]>Cc Benjamin Herrenschmidt <[email protected]>Cc ppc <[email protected]>---
arch/powerpc/kernel/eeh_driver.c| 26 +++++++++++++++++++++-----1 file changed, 21 insertions(+), 5 deletions(-)Index:
tip/arch/powerpc/kernel/eeh_driver.c
===================================================================arch/powerpc/kernel/eeh_driver.c +21
-5@@ -143,15 +143,31 @@ static void eeh_disable_irq(struct pci_dstatic void eeh_enable_irq (struct pci_dev *dev) {struct eeh_dev *edev =pci_dev_to_eeh_dev (dev); -struct irq_desc *desc;if ((edev->mode) &EEH_DEV_IRQ_DISABLED ) { edev->mode &= ~EEH_DEV_IRQ_DISABLED ; - - desc =irq_to_desc (dev->irq); -if (desc && desc->depth >0 ) +/* +* FIXME !!!!! +* +* This is just ass backwards. This maze has +* unbalanced irq_enable/disable calls. So instead of +* finding the root cause it works around the warning +* in the irq_enable code by conditionally calling +* into it. +* +* That's just wrong.The warning in the core code is +* there to tell people to fix their assymetries in +* their own code, not by abusing the core information +* to avoid it. +* +* I so wish that the assymetry would be the other way +* round and a few more irq_disable calls render that +* shit unusable forever. +* +* tglx +*/ + if (irqd_irq_disabled(irq_get_irq_data(dev->irq))enable_irq (dev->irq); - } }/**
Re: [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc
Quoted 28 lines · Gavin Shan
Quoted 27 lines · Thomas Gleixner
commit
91150af3a(powerpc/eeh: Fix unbalanced enable for IRQ) is another brilliant example of trainwreck engineering.The patch "fixes" the issue of an unbalanced call to
irq_enable()which causes a prominent warning by checking the disabled state of the interrupt line and call conditionally into the core code.This is wrong in two aspects:
1) The warning is there to tell users, that they need to fix their asymetric enable/disable patterns by finding the root cause and solving it there.
It's definitely not meant to work around it by conditionally calling into the core code depending on the random state of the irq line.
Asymetric irq_disable/enable calls are a clear sign of wrong usage of the interfaces which have to be cured at the root and not by somehow hacking around it.
2) The abuse of core internal data structure instead of using the proper interfaces for retrieving the information for the 'hack around'
irq_descis core internal and it's clear enough stated.
Quoted 7 lines
Quoted 3 lines
Replace at least the
irq_descabuse with the proper functions and add a big fat comment why this is absurd and completely wrong.Thanks for pointing it out. I think we might have this patch for now and I'll look into individual drivers to fix the unbalanced function calls later one by one.
Fine with me. You wont escape my scan scripts :)
Thanks,
tglx
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] powerpc: Eeh: Kill another abuse of irq_desc
In reply to Thomas Gleixnerpowerpc: Eeh: Kill another abuse of irq_desc
Commit-ID: b8a9a11b976810ba12a43c4fe699a14892c97e52 Gitweb: http://git.kernel.org/tip/b8a9a11b976810ba12a43c4fe699a14892c97e52 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:09 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:52 +0100
powerpc: Eeh: Kill another abuse of irq_desc
commit 91150af3a (powerpc/eeh: Fix unbalanced enable for IRQ) is another brilliant example of trainwreck engineering.
The patch "fixes" the issue of an unbalanced call to irq_enable() which causes a prominent warning by checking the disabled state of the interrupt line and call conditionally into the core code.
This is wrong in two aspects:
1) The warning is there to tell users, that they need to fix their asymetric enable/disable patterns by finding the root cause and solving it there.
It's definitely not meant to work around it by conditionally calling into the core code depending on the random state of the irq line.
Asymetric irq_disable/enable calls are a clear sign of wrong usage of the interfaces which have to be cured at the root and not by somehow hacking around it.
2) The abuse of core internal data structure instead of using the proper interfaces for retrieving the information for the 'hack around'
irq_desc is core internal and it's clear enough stated.
Replace at least the irq_desc abuse with the proper functions and add a big fat comment why this is absurd and completely wrong.
--- arch/powerpc/kernel/eeh_driver.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
arch/powerpc/kernel/eeh_driver.c +21 -5
@@ -143,15 +143,31 @@ static void eeh_disable_irq(struct pci_dev *dev)static void eeh_enable_irq (struct pci_dev *dev) {struct eeh_dev *edev =pci_dev_to_eeh_dev (dev); -struct irq_desc *desc;if ((edev->mode) &EEH_DEV_IRQ_DISABLED ) { edev->mode &= ~EEH_DEV_IRQ_DISABLED ; - - desc =irq_to_desc (dev->irq); -if (desc && desc->depth >0 ) +/* +* FIXME !!!!! +* +* This is just ass backwards. This maze has +* unbalanced irq_enable/disable calls. So instead of +* finding the root cause it works around the warning +* in the irq_enable code by conditionally calling +* into it. +* +* That's just wrong.The warning in the core code is +* there to tell people to fix their assymetries in +* their own code, not by abusing the core information +* to avoid it. +* +* I so wish that the assymetry would be the other way +* round and a few more irq_disable calls render that +* shit unusable forever. +* +* tglx +*/ + if (irqd_irq_disabled(irq_get_irq_data(dev->irq))enable_irq (dev->irq); - } }/**
PATCH 4/26 xtensa: Use irq_set_affinity instead of homebrewn code
In reply to Thomas GleixnerThere is no point in having an incomplete copy of irq_set_affinity() for the hotplug irq migration code.
Use the core function instead and while at it switch to for_each_active_irq()
--- arch/xtensa/kernel/irq.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
arch/xtensa/kernel/irq.c +3 -17
@@ -155,18 +155,6 @@ void __init init_IRQ(void) }#ifdef CONFIG_HOTPLUG_CPU -static void route_irq (struct irq_data *data,unsigned int irq,unsigned int cpu) -{ -struct irq_desc *desc =irq_to_desc (irq); -struct irq_chip *chip =irq_data_get_irq_chip (data); -unsigned long flags; - -raw_spin_lock_irqsave (&desc->lock, flags); -if (chip->irq_set_affinity) - chip->irq_set_affinity (data,cpumask_of (cpu), false); -raw_spin_unlock_irqrestore (&desc->lock, flags); -} -/* * The CPU has been marked offline. Migrate IRQs off this CPU. If * the affinity settings do not allow other CPUs, force them onto any
@@ -175,10 +163,9 @@ static void route_irq(struct irq_data *dvoid migrate_irqs (void ) {unsigned int i, cpu =smp_processor_id (); -struct irq_desc *desc; -for_each_irq_desc (i, desc) { -struct irq_data *data =irq_desc_get_irq_data (desc); +for_each_active_irq (i) { +struct irq_data *data =irq_get_irq_data (i);unsigned int newcpu;if (irqd_is_per_cpu (data))
@@ -197,8 +184,7 @@ void migrate_irqs(void) newcpu =cpumask_any_and (data->affinity, cpu_online_mask); } - -route_irq (data, i, newcpu); +irq_set_affinity (i,cpumask_of (newcpu)); } }#endif /* CONFIG_HOTPLUG_CPU */
Re: [patch 04/26] xtensa: Use irq_set_affinity instead of homebrewn code
Quoted 6 lines · Thomas Gleixner
There is no point in having an incomplete copy of
irq_set_affinity()for the hotplug irq migration code.Use the core function instead and while at it switch to
for_each_active_irq()
Quoted 6 lines
Signed-off-by Thomas Gleixner <[email protected]>Cc Chris Zankel <[email protected]>Cc xtensa <[email protected]>--- arch/xtensa/kernel/irq.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
Signature · 2 lines
Thanks. -- Max
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] xtensa: Use irq_set_affinity instead of homebrewn code
In reply to Thomas Gleixnerxtensa: Use irq_set_affinity instead of homebrewn code
Commit-ID: b58d971da3433654787a88c40c6fca00f5bbaa04 Gitweb: http://git.kernel.org/tip/b58d971da3433654787a88c40c6fca00f5bbaa04 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:10 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:55 +0100
xtensa: Use irq_set_affinity instead of homebrewn code
There is no point in having an incomplete copy of irq_set_affinity() for the hotplug irq migration code.
Use the core function instead and while at it switch to for_each_active_irq()
--- arch/xtensa/kernel/irq.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
arch/xtensa/kernel/irq.c +3 -19
@@ -155,18 +155,6 @@ void __init init_IRQ(void) }#ifdef CONFIG_HOTPLUG_CPU -static void route_irq (struct irq_data *data,unsigned int irq,unsigned int cpu) -{ -struct irq_desc *desc =irq_to_desc (irq); -struct irq_chip *chip =irq_data_get_irq_chip (data); -unsigned long flags; - -raw_spin_lock_irqsave (&desc->lock, flags); -if (chip->irq_set_affinity) - chip->irq_set_affinity (data,cpumask_of (cpu), false); -raw_spin_unlock_irqrestore (&desc->lock, flags); -} -/* * The CPU has been marked offline. Migrate IRQs off this CPU. If * the affinity settings do not allow other CPUs, force them onto any
@@ -175,10 +163,9 @@ static void route_irq(struct irq_data *data, unsigned int irq, unsigned int cpu)void migrate_irqs (void ) {unsigned int i, cpu =smp_processor_id (); -struct irq_desc *desc; -for_each_irq_desc (i, desc) { -struct irq_data *data =irq_desc_get_irq_data (desc); +for_each_active_irq (i) { +struct irq_data *data =irq_get_irq_data (i);unsigned int newcpu;if (irqd_is_per_cpu (data))
@@ -194,11 +181,8 @@ void migrate_irqs(void) i, cpu); cpumask_setall(data->affinity); - newcpu =cpumask_any_and (data->affinity, - cpu_online_mask); } - -route_irq (data, i, newcpu); +irq_set_affinity (i, data->affinity); } }#endif /* CONFIG_HOTPLUG_CPU */
PATCH 5/26 sh: Use irq_set_affinity instead of homebrewn code
In reply to Thomas GleixnerThere is no point in having an incomplete copy of irq_set_affinity() for the hotplug irq migration code.
Use the core function instead.
--- arch/sh/kernel/irq.c | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-)
Index: tip/arch/sh/kernel/irq.c =================================--- tip.orig/arch/sh/kernel/irq.c +++ tip/arch/sh/kernel/irq.c
@@ -217,19 +217,6 @@ void __init init_IRQ(void)
}
#ifdef CONFIG_HOTPLUG_CPU
-static void route_irq(struct irq_data *data, unsigned int irq, unsigned int cpu) -{
- struct irq_desc *desc = irq_to_desc(irq);
- struct irq_chip *chip = irq_data_get_irq_chip(data);
-
- printk(KERN_INFO "IRQ%u: moving from cpu%u to cpu%u\n",
- irq, data->node, cpu);
-
- raw_spin_lock_irq(&desc->lock);
- chip->irq_set_affinity(data, cpumask_of(cpu), false);
- raw_spin_unlock_irq(&desc->lock);
-}
-
/*
* The CPU has been marked offline. Migrate IRQs off this CPU. If
* the affinity settings do not allow other CPUs, force them onto any
@@ -253,8 +240,7 @@ void migrate_irqs(void)
newcpu = cpumask_any_and(data->affinity,
cpu_online_mask);
}
-
- route_irq(data, irq, newcpu);
+ irq_set_affinity(irq, cpumask_of(newcpu));
}
}
}
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] sh: Use irq_set_affinity instead of homebrewn code
sh: Use irq_set_affinity instead of homebrewn code
Commit-ID: 6decf1a33c386d4addc2ed9d269c3868f08c70bb Gitweb: http://git.kernel.org/tip/6decf1a33c386d4addc2ed9d269c3868f08c70bb Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:10 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:55 +0100
sh: Use irq_set_affinity instead of homebrewn code
There is no point in having an incomplete copy of irq_set_affinity() for the hotplug irq migration code.
Use the core function instead.
--- arch/sh/kernel/irq.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-)
arch/sh/kernel/irq.c +1 -17
@@ -217,19 +217,6 @@ void __init init_IRQ(void) }#ifdef CONFIG_HOTPLUG_CPU -static void route_irq (struct irq_data *data,unsigned int irq,unsigned int cpu) -{ -struct irq_desc *desc =irq_to_desc (irq); -struct irq_chip *chip =irq_data_get_irq_chip (data); - -printk (KERN_INFO "IRQ%u: moving from cpu%u to cpu%u\n" , - irq, data->node, cpu); - -raw_spin_lock_irq (&desc->lock); - chip->irq_set_affinity (data,cpumask_of (cpu), false); -raw_spin_unlock_irq (&desc->lock); -} -/* * The CPU has been marked offline. Migrate IRQs off this CPU. If * the affinity settings do not allow other CPUs, force them onto any
@@ -250,11 +237,8 @@ void migrate_irqs(void) irq, cpu);cpumask_setall (data->affinity); - newcpu =cpumask_any_and (data->affinity, - cpu_online_mask); } - -route_irq (data, irq, newcpu); +irq_set_affinity (irq, data->affinity); } } }
PATCH 6/26 metag: Use irq_set_affinity instead of homebrewn code
In reply to Thomas GleixnerThere is no point in having an incomplete copy of irq_set_affinity() for the hotplug irq migration code.
Use the core function instead and while at it switch to for_each_active_irq()
--- arch/metag/kernel/irq.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)
arch/metag/kernel/irq.c +3 -17
@@ -261,18 +261,6 @@ int __init arch_probe_nr_irqs(void) }#ifdef CONFIG_HOTPLUG_CPU -static void route_irq (struct irq_data *data,unsigned int irq,unsigned int cpu) -{ -struct irq_desc *desc =irq_to_desc (irq); -struct irq_chip *chip =irq_data_get_irq_chip (data); -unsigned long flags; - -raw_spin_lock_irqsave (&desc->lock, flags); -if (chip->irq_set_affinity) - chip->irq_set_affinity (data,cpumask_of (cpu), false); -raw_spin_unlock_irqrestore (&desc->lock, flags); -} -/* * The CPU has been marked offline. Migrate IRQs off this CPU. If * the affinity settings do not allow other CPUs, force them onto any
@@ -281,10 +269,9 @@ static void route_irq(struct irq_data *dvoid migrate_irqs (void ) {unsigned int i, cpu =smp_processor_id (); -struct irq_desc *desc; -for_each_irq_desc (i, desc) { -struct irq_data *data =irq_desc_get_irq_data (desc); +for_each_active_irq (i) { +struct irq_data *data =irq_get_irq_data (i);unsigned int newcpu;if (irqd_is_per_cpu (data))
@@ -303,8 +290,7 @@ void migrate_irqs(void) newcpu =cpumask_any_and (data->affinity, cpu_online_mask); } - -route_irq (data, i, newcpu); +irq_set_affinity (i,cpumask_of (newcpu)); } }#endif /* CONFIG_HOTPLUG_CPU */
Re: [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
Hi Thomas,
Quoted 2 lines · Thomas Gleixner
There is no point in having an incomplete copy of
irq_set_affinity()for the hotplug irq migration code.
That sounds reasonable, but when I gave it a try I started getting warnings on the log after offlining one cpu then the other:
META213-Thread0 DSP [LogF] IRQ13 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ14 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ15 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ18 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ29 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ30 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ31 no longer affine to CPU1
It appears that the irq affinities weren't getting modified previously, whereas now irq_do_set_affinity() does do cpumask_copy(data->affinity, mask). Once all CPUs have been offlined at least once you get those spurious messages even though the IRQ affinities haven't been explicitly limited by anything.
I wonder if the stored affinity should really be altered in this case?
Cheers
James
Quoted 59 lines
Use the core function instead and while at it switch to
for_each_active_irq()Signed-off-by Thomas Gleixner <[email protected]>Cc James Hogan <[email protected]>Cc metag <[email protected]>--- arch/metag/kernel/irq.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-)Index:
tip/arch/metag/kernel/irq.c
===================================================================arch/metag/kernel/irq.c +3
-17@@ -261,18 +261,6 @@ int __init arch_probe_nr_irqs(void) }#ifdef CONFIG_HOTPLUG_CPU -static void route_irq (struct irq_data *data,unsigned int irq,unsigned int cpu) -{ -struct irq_desc *desc =irq_to_desc (irq); -struct irq_chip *chip =irq_data_get_irq_chip (data); -unsigned long flags; - -raw_spin_lock_irqsave (&desc->lock, flags); -if (chip->irq_set_affinity) - chip->irq_set_affinity (data,cpumask_of (cpu), false); -raw_spin_unlock_irqrestore (&desc->lock, flags); -} -/* * The CPU has been marked offline. Migrate IRQs off this CPU. If * the affinity settings do not allow other CPUs, force them onto any @@ -281,10 +269,9 @@ static void route_irq(struct irq_data *dvoid migrate_irqs (void ) {unsigned int i, cpu =smp_processor_id (); -struct irq_desc *desc; -for_each_irq_desc (i, desc) { -struct irq_data *data =irq_desc_get_irq_data (desc); +for_each_active_irq (i) { +struct irq_data *data =irq_get_irq_data (i);unsigned int newcpu;if (irqd_is_per_cpu (data))@@ -303,8 +290,7 @@ void migrate_irqs(void) newcpu =cpumask_any_and (data->affinity, cpu_online_mask); } - -route_irq (data, i, newcpu); +irq_set_affinity (i,cpumask_of (newcpu)); } }#endif /* CONFIG_HOTPLUG_CPU */
Re: [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
Quoted 17 lines · James Hogan
Hi Thomas,
Quoted 2 lines · Thomas Gleixner
There is no point in having an incomplete copy of
irq_set_affinity()for the hotplug irq migration code.That sounds reasonable, but when I gave it a try I started getting warnings on the log after offlining one cpu then the other:
META213-Thread0 DSP [LogF] IRQ13 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ14 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ15 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ18 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ29 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ30 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ31 no longer affine to CPU1
Quoted 7 lines
It appears that the irq affinities weren't getting modified previously, whereas now
irq_do_set_affinity()does docpumask_copy(data->affinity, mask). Once all CPUs have been offlined at least once you get those spurious messages even though the IRQ affinities haven't been explicitly limited by anything.I wonder if the stored affinity should really be altered in this case?
Delta patch below.
You need that irq-metag part in any case as the user space interface does not filter out stuff. Assume you offlined core 1 and user changes affinity from 0xf to 0xe. So your selector will pick core 1 which is offline....
Btw, our handling of this is a bit awkward. Right now we let the user do
echo 0xf > /proc/irq/$N/smp_affinity
and reading that back will give you 0xf though the kernel just selects a subset or even a single target cpu and one has to analyze /proc/interrupts to find out which one.
We should add some mechanism to tell the user what's really going on. But that's a separate issue.
Thanks,
tglx
arch/metag/kernel/irq.c +1 -3
@@ -287,10 +287,8 @@ void migrate_irqs(void) i, cpu); cpumask_setall(data->affinity); - newcpu =cpumask_any_and (data->affinity, - cpu_online_mask); } -irq_set_affinity (i,cpumask_of (newcpu)); +irq_set_affinity (i, data->affinity); } }#endif /* CONFIG_HOTPLUG_CPU */
drivers/irqchip/irq-metag.c +1 -1
@@ -201,7 +201,7 @@ static int metag_internal_irq_set_affini* one cpu (the interrupt code doesn't support it), so we just * pick the first cpu we find in 'cpumask'. */ - cpu =cpumask_any (cpumask); + cpu =cpumask_any_and (cpumask, cpu_online_mask); thread = cpu_2_hwthread_id[cpu]; metag_out32(TBI_TRIG_VEC(TBID_SIGNUM_TR1(thread)),
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
Quoted 2 lines · Thomas Gleixner
On Mon, 24 Feb 2014, James Hogan wrote:
Delta patch below.
Does that fix your issue?
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
In reply to Thomas GleixnerHi Thomas,
Sorry for delay, I didn't get a chance to try this earlier.
Quoted 22 lines · On Monday 24 February 2014 15:24:55 Thomas Gleixner wrote:
Quoted 21 lines · James Hogan
Quoted 2 lines · Thomas Gleixner
There is no point in having an incomplete copy of
irq_set_affinity()for the hotplug irq migration code.That sounds reasonable, but when I gave it a try I started getting warnings on the log after offlining one cpu then the other:
META213-Thread0 DSP [LogF] IRQ13 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ14 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ15 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ18 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ29 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ30 no longer affine to CPU1 META213-Thread0 DSP [LogF] IRQ31 no longer affine to CPU1
It appears that the irq affinities weren't getting modified previously, whereas now
irq_do_set_affinity()does docpumask_copy(data->affinity, mask). Once all CPUs have been offlined at least once you get those spurious messages even though the IRQ affinities haven't been explicitly limited by anything.
Quoted 3 lines
Quoted 1 line
I wonder if the stored affinity should really be altered in this case?
Delta patch below.
Thanks, that does the trick although the same thing needs doing in drivers/irqchips/irq-metag-ext.c too.
Quoted 5 lines
You need that irq-metag part in any case as the user space interface does not filter out stuff. Assume you offlined core 1 and user changes affinity from
0xfto0xe. So your selector will pick core 1 which is offline....
... crap, you're absolutely right. Thanks for spotting that. I'll apply the irqchip hunks for v3.14.
As for the rest, I'll take this patch (with the irq.c hunk below) through the metag tree if it's okay with you so I can make sure it goes after the irqchip fixes (otherwise cpu0 hotplug blows up too).
Thanks a lot,
Cheers
James
Quoted 53 lines
Btw, our handling of this is a bit awkward. Right now we let the user do
echo 0xf > /proc/irq/$N/smp_affinityand reading that back will give you
0xfthough the kernel just selects a subset or even a single target cpu and one has to analyze/proc/interruptsto find out which one.We should add some mechanism to tell the user what's really going on. But that's a separate issue.
Thanks,
tglx
Index:
tip/arch/metag/kernel/irq.c
===================================================================arch/metag/kernel/irq.c +1
-3@@ -287,10 +287,8 @@ void migrate_irqs(void) i, cpu); cpumask_setall(data->affinity); - newcpu =cpumask_any_and (data->affinity, - cpu_online_mask); } -irq_set_affinity (i,cpumask_of (newcpu)); +irq_set_affinity (i, data->affinity); } }#endif /* CONFIG_HOTPLUG_CPU */ Index:
tip/drivers/irqchip/irq-metag.c
===================================================================drivers/irqchip/irq-metag.c +1
-2@@ -201,7 +201,7 @@ static int metag_internal_irq_set_affini* one cpu (the interrupt code doesn't support it), so we just * pick the first cpu we find in 'cpumask'. */ - cpu =cpumask_any (cpumask); + cpu =cpumask_any_and (cpumask, cpu_online_mask); thread = cpu_2_hwthread_id[cpu]; metag_out32(TBI_TRIG_VEC(TBID_SIGNUM_TR1(thread)), --To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
Quoted 11 lines · James Hogan
Quoted 4 lines
You need that irq-metag part in any case as the user space interface does not filter out stuff. Assume you offlined core 1 and user changes affinity from
0xfto0xe. So your selector will pick core 1 which is offline....... crap, you're absolutely right. Thanks for spotting that. I'll apply the irqchip hunks for v3.14.
As for the rest, I'll take this patch (with the
irq.chunk below) through the metag tree if it's okay with you so I can make sure it goes after the irqchip fixes (otherwise cpu0 hotplug blows up too).
Fine with me.
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/26 pci: pcie-designware: Remove irq_desc abuse
In reply to Thomas GleixnerThere is no reason to care about irq_desc in that context, escpecially as irq_data for that interrupt is retrieved as well.
Use the proper accessor for the msi descriptor
--- drivers/pci/host/pcie-designware.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pci/host/pcie-designware.c +1 -3
@@ -294,14 +294,12 @@ no_valid_irq:static void clear_irq (unsigned int irq) {unsigned int pos, nvec; -struct irq_desc *desc;struct msi_desc *msi;struct pcie_port *pp;struct irq_data *data =irq_get_irq_data (irq);/* get the port structure */ - desc =irq_to_desc (irq); - msi =irq_desc_get_msi_desc (desc); + msi =irq_data_get_msi (data); pp =sys_to_pcie (msi->dev->bus->sysdata);if (!pp) {BUG ();
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] pci: pcie-designware: Remove irq_desc abuse
pci: pcie-designware: Remove irq_desc abuse
Commit-ID: f7bfca6db60a6ca0a73126918b2fb6f851065947 Gitweb: http://git.kernel.org/tip/f7bfca6db60a6ca0a73126918b2fb6f851065947 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:11 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:52 +0100
pci: pcie-designware: Remove irq_desc abuse
There is no reason to care about irq_desc in that context, escpecially as irq_data for that interrupt is retrieved as well.
Use the proper accessor for the msi descriptor
--- drivers/pci/host/pcie-designware.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/pci/host/pcie-designware.c +1 -3
@@ -294,14 +294,12 @@ no_valid_irq:static void clear_irq (unsigned int irq) {unsigned int pos, nvec; -struct irq_desc *desc;struct msi_desc *msi;struct pcie_port *pp;struct irq_data *data =irq_get_irq_data (irq);/* get the port structure */ - desc =irq_to_desc (irq); - msi =irq_desc_get_msi_desc (desc); + msi =irq_data_get_msi (data); pp =sys_to_pcie (msi->dev->bus->sysdata);if (!pp) {BUG ();
PATCH 8/26 arm: Replace various irq_desc accesses
In reply to Thomas GleixnerAn embedded and charset-unspecified text was scrubbed...
Name: arm-replace-various-irq-to-desc-accesses.patch
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140223/b40ca264/attachment.ksh>
Re: [patch 08/26] arm: Replace various irq_desc accesses
Quoted 4 lines · Thomas Gleixner
Use the proper functions. There is no need to fiddle with
irq_desc.Signed-off-by Thomas Gleixner <[email protected]>Cc Shawn Guo <[email protected]>
...
Quoted 1 line
arch/arm/mach-imx/pm-imx6q.c | 7 +++----
Re: [patch 08/26] arm: Replace various irq_desc accesses
Quoted 9 lines · Shawn Guo
Quoted 4 lines · Thomas Gleixner
Use the proper functions. There is no need to fiddle with
irq_desc.Signed-off-by Thomas Gleixner <[email protected]>Cc Shawn Guo <[email protected]>...
Quoted 1 line
arch/arm/mach-imx/pm-imx6q.c | 7 +++----Acked-by Shawn Guo <[email protected]>
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] arm: Replace various irq_desc accesses
In reply to Thomas Gleixnerarm: Replace various irq_desc accesses
Commit-ID: 8435cf757632a5559fbbf1cb79299716c8d5b651 Gitweb: http://git.kernel.org/tip/8435cf757632a5559fbbf1cb79299716c8d5b651 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:12 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:52 +0100
arm: Replace various irq_desc accesses
Use the proper functions. There is no need to fiddle with irq_desc.
--- arch/arm/mach-imx/pm-imx6q.c | 7 +++---- arch/arm/mach-omap1/ams-delta-fiq.c | 7 ++----- 2 files changed, 5 insertions(+), 9 deletions(-)
arch/arm/mach-imx/pm-imx6q.c +3 -4
@@ -120,7 +120,7 @@ static void imx6q_enable_wb(bool enable)int imx6q_set_lpm (enum mxc_cpu_pwr_mode mode) { -struct irq_desc *iomuxc_irq_desc; +struct irq_data *iomuxc_irq_data =irq_get_irq_data (32 );u32 val =readl_relaxed (ccm_base +CLPCR ); val &= ~BM_CLPCR_LPM ;
@@ -167,10 +167,9 @@ int imx6q_set_lpm(enum mxc_cpu_pwr_mode mode)* 3) Software should mask IRQ #32 right after CCM Low-Power mode * is set (set bits 0-1 of CCM_CLPCR). */ - iomuxc_irq_desc =irq_to_desc (32 ); -imx_gpc_irq_unmask (&iomuxc_irq_desc->irq_data); +imx_gpc_irq_unmask (iomuxc_irq_data);writel_relaxed (val, ccm_base +CLPCR ); -imx_gpc_irq_mask (&iomuxc_irq_desc->irq_data); +imx_gpc_irq_mask (iomuxc_irq_data);return 0 ; }
arch/arm/mach-omap1/ams-delta-fiq.c +2 -5
@@ -44,13 +44,10 @@ static unsigned int irq_counter[16];static irqreturn_t deferred_fiq (int irq,void *dev_id) { -struct irq_desc *irq_desc; -struct irq_chip *irq_chip =NULL ;int gpio, irq_num, fiq_count; +struct irq_chip *irq_chip; - irq_desc =irq_to_desc (gpio_to_irq (AMS_DELTA_GPIO_PIN_KEYBRD_CLK )); -if (irq_desc) - irq_chip = irq_desc->irq_data.chip; + irq_chip =irq_get_irq_chip (gpio_to_irq (AMS_DELTA_GPIO_PIN_KEYBRD_CLK ));/* * For each handled GPIO interrupt, keep calling its interrupt handler
Re: [patch 08/26] arm: Replace various irq_desc accesses
In reply to Thomas GleixnerQuoted 5 lines · Thomas Gleixner
arch/arm/mach-omap1/ams-delta-fiq.c +0
-0@@ -44,13 +44,10 @@ static unsigned int irq_counter[16];static irqreturn_t deferred_fiq (int irq,void *dev_id)
arch/arm/mach-omap1/ams-delta-fiq.c static unsigned int irq_counter[16]; · line 50
Quoted 10 lines
arch/arm/mach-omap1/ams-delta-fiq.c +2
-5{ -struct irq_desc *irq_desc; -struct irq_chip *irq_chip =NULL ;int gpio, irq_num, fiq_count; +struct irq_chip *irq_chip; - irq_desc =irq_to_desc (gpio_to_irq (AMS_DELTA_GPIO_PIN_KEYBRD_CLK )); -if (irq_desc) - irq_chip = irq_desc->irq_data.chip; + irq_chip =irq_get_irq_chip (gpio_to_irq (AMS_DELTA_GPIO_PIN_KEYBRD_CLK ));
I got a compile error because irq_get_irq_chip() doesn't exist. I suppose you meant irq_get_chip.
Arnd
PATCH 9/26 arm: mmp: Remove pointless fiddling with irq internals
In reply to Thomas GleixnerAn embedded and charset-unspecified text was scrubbed...
Name: arm-mmp-remove-idiotic-fiddling-with-irq-internals.patch
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140223/ef9b3db6/attachment.ksh>
Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
Hi Thomas,
Quoted 7 lines · Thomas Gleixner
The pm-mmp2 and pm-pxa910 power management related
irq_set_wakecallbacks fiddle pointlessly with the irq actions for no reason except for lack of understanding how the wakeup mechanism works.On supsend the core disables all interrupts lazily, i.e. it does not mask them at the irq controller level. So any interrupt which is firing during supsend will mark the corresponding interrupt line as
s/supsend/suspend/ twice
Quoted 3 lines
pending. Just before the core powers down it checks whether there are interrupts pending from interrupt lines which are marked as wakeup sources and if so it aborts the resume and resends the interrupts.
It's the suspend that is aborted, not the resume.
Other than that your change looks fine.
Uwe
Signature · 2 lines
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |
Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
Quoted 10 lines · Uwe Kleine-K?nig
Hi Thomas,
Quoted 7 lines · Thomas Gleixner
The pm-mmp2 and pm-pxa910 power management related
irq_set_wakecallbacks fiddle pointlessly with the irq actions for no reason except for lack of understanding how the wakeup mechanism works.On supsend the core disables all interrupts lazily, i.e. it does not mask them at the irq controller level. So any interrupt which is firing during supsend will mark the corresponding interrupt line as
Quoted 8 lines
s/supsend/suspend/ twice
Quoted 3 lines
pending. Just before the core powers down it checks whether there are interrupts pending from interrupt lines which are marked as wakeup sources and if so it aborts the resume and resends the interrupts.
It's the suspend that is aborted, not the resume.
Other than that your change looks fine.
For pxa910 and MMP2, wake up source only wake up the AP subsystem. The AP subsystem includes the APMU(AP Power Mangament Unit) and cores. Now the core is still powered down. APMU will check the interrupt lines, and find
that there are interrupt pending, it will power on the cores.
So if the irq is disabled, even wake up source can wake up AP subsystem, but the core is still powered down. It will not be powered up by APMU.
Quoted 10 lines
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig | Industrial Linux Solutions | http://www.pengutronix.de/ |_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
Quoted 20 lines · Chao Xie
Quoted 10 lines · Uwe Kleine-K?nig
Hi Thomas,
Quoted 7 lines · Thomas Gleixner
The pm-mmp2 and pm-pxa910 power management related
irq_set_wakecallbacks fiddle pointlessly with the irq actions for no reason except for lack of understanding how the wakeup mechanism works.On supsend the core disables all interrupts lazily, i.e. it does not mask them at the irq controller level. So any interrupt which is firing during supsend will mark the corresponding interrupt line as
Quoted 8 lines
s/supsend/suspend/ twice
Quoted 3 lines
pending. Just before the core powers down it checks whether there are interrupts pending from interrupt lines which are marked as wakeup sources and if so it aborts the resume and resends the interrupts.
It's the suspend that is aborted, not the resume.
Other than that your change looks fine.
Quoted 8 lines
For pxa910 and MMP2, wake up source only wake up the AP subsystem. The AP subsystem includes the APMU(AP Power Mangament Unit) and cores. Now the core is still powered down. APMU will check the interrupt lines, and find
that there are interrupt pending, it will power on the cores.
So if the irq is disabled, even wake up source can wake up AP subsystem, but the core is still powered down. It will not be powered up by APMU.
Yes, suspend/resume can't work if the above code is removed.
Interrupt source (logic AND with interrupt mask register) is connected to MPMU as
wakeup source. If the interrupt is disabled, there's no wakeup source event.
And APMU is waken up by MPMU.
So please don't remove the above code. We must keep these interrupt lines active to wake up the whole system.
Regards
Haojian
Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
Quoted 32 lines · Haojian Zhuang
Quoted 20 lines · Chao Xie
Quoted 10 lines · Uwe Kleine-König
Hi Thomas,
Quoted 7 lines · Thomas Gleixner
The pm-mmp2 and pm-pxa910 power management related
irq_set_wakecallbacks fiddle pointlessly with the irq actions for no reason except for lack of understanding how the wakeup mechanism works.On supsend the core disables all interrupts lazily, i.e. it does not mask them at the irq controller level. So any interrupt which is firing during supsend will mark the corresponding interrupt line as
Quoted 8 lines
s/supsend/suspend/ twice
Quoted 3 lines
pending. Just before the core powers down it checks whether there are interrupts pending from interrupt lines which are marked as wakeup sources and if so it aborts the resume and resends the interrupts.
It's the suspend that is aborted, not the resume.
Other than that your change looks fine.
Quoted 8 lines
For pxa910 and MMP2, wake up source only wake up the AP subsystem. The AP subsystem includes the APMU(AP Power Mangament Unit) and cores. Now the core is still powered down. APMU will check the interrupt lines, and find
that there are interrupt pending, it will power on the cores.
So if the irq is disabled, even wake up source can wake up AP subsystem, but the core is still powered down. It will not be powered up by APMU.Yes, suspend/resume can't work if the above code is removed.
Quoted 8 lines
Interrupt source (logic AND with interrupt mask register) is connected to MPMU as
wakeup source. If the interrupt is disabled, there's no wakeup source event.And APMU is waken up by MPMU.
So please don't remove the above code. We must keep these interrupt lines active to wake up the whole system.
They are kept active at the interrupt controller level. You just refuse to understand how the internals of the interrupt subsystem work.
And even if you would need this flag, then fiddling with the irq desc internals is a big NONO. There is a proper way to hand that in.
Thanks,
tglx
Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
Quoted 38 lines · Thomas Gleixner
Quoted 36 lines · Haojian Zhuang
Quoted 20 lines · Chao Xie
Quoted 10 lines · Uwe Kleine-K?nig
Hi Thomas,
Quoted 7 lines · Thomas Gleixner
The pm-mmp2 and pm-pxa910 power management related
irq_set_wakecallbacks fiddle pointlessly with the irq actions for no reason except for lack of understanding how the wakeup mechanism works.On supsend the core disables all interrupts lazily, i.e. it does not mask them at the irq controller level. So any interrupt which is firing during supsend will mark the corresponding interrupt line as
Quoted 8 lines
s/supsend/suspend/ twice
Quoted 3 lines
pending. Just before the core powers down it checks whether there are interrupts pending from interrupt lines which are marked as wakeup sources and if so it aborts the resume and resends the interrupts.
It's the suspend that is aborted, not the resume.
Other than that your change looks fine.
Quoted 8 lines
For pxa910 and MMP2, wake up source only wake up the AP subsystem. The AP subsystem includes the APMU(AP Power Mangament Unit) and cores. Now the core is still powered down. APMU will check the interrupt lines, and find
that there are interrupt pending, it will power on the cores.
So if the irq is disabled, even wake up source can wake up AP subsystem, but the core is still powered down. It will not be powered up by APMU.Yes, suspend/resume can't work if the above code is removed.
Interrupt source (logic AND with interrupt mask register) is connected to MPMU as
wakeup source. If the interrupt is disabled, there's no wakeup source event.
Quoted 9 lines
Quoted 4 lines
And APMU is waken up by MPMU.
So please don't remove the above code. We must keep these interrupt lines active to wake up the whole system.
They are kept active at the interrupt controller level. You just refuse to understand how the internals of the interrupt subsystem work.
If no irq_disable callback is hooked, when do irq_disable, it will not actually disable
the interrupt, it will depend on next time when the irq happens, the handler will first mask
the interrupt as this interrupt never happens.
So after system suspended, the interrupt happens, but the device driver will not recieve this interrupt
because it is masked.
It results in that the device driver miss a important interrupt which related to something need to be
handled. If user application for example android has power managment daemon. It will find that nothing
to handle, it will make the system enter suspend again.
Quoted 3 lines
And even if you would need this flag, then fiddling with the irq desc internals is a big NONO. There is a proper way to hand that in.
So can you suggest the proper way to handle it? Thanks.
Quoted 4 lines
Thanks,
tglx
Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
Quoted 48 lines · Chao Xie
Quoted 38 lines · Thomas Gleixner
Quoted 36 lines · Haojian Zhuang
Quoted 20 lines · Chao Xie
Quoted 10 lines · Uwe Kleine-K?nig
Hi Thomas,
Quoted 7 lines · Thomas Gleixner
The pm-mmp2 and pm-pxa910 power management related
irq_set_wakecallbacks fiddle pointlessly with the irq actions for no reason except for lack of understanding how the wakeup mechanism works.On supsend the core disables all interrupts lazily, i.e. it does not mask them at the irq controller level. So any interrupt which is firing during supsend will mark the corresponding interrupt line as
Quoted 8 lines
s/supsend/suspend/ twice
Quoted 3 lines
pending. Just before the core powers down it checks whether there are interrupts pending from interrupt lines which are marked as wakeup sources and if so it aborts the resume and resends the interrupts.
It's the suspend that is aborted, not the resume.
Other than that your change looks fine.
Quoted 8 lines
For pxa910 and MMP2, wake up source only wake up the AP subsystem. The AP subsystem includes the APMU(AP Power Mangament Unit) and cores. Now the core is still powered down. APMU will check the interrupt lines, and find
that there are interrupt pending, it will power on the cores.
So if the irq is disabled, even wake up source can wake up AP subsystem, but the core is still powered down. It will not be powered up by APMU.Yes, suspend/resume can't work if the above code is removed.
Interrupt source (logic AND with interrupt mask register) is connected to MPMU as
wakeup source. If the interrupt is disabled, there's no wakeup source event.Quoted 9 lines
Quoted 4 lines
And APMU is waken up by MPMU.
So please don't remove the above code. We must keep these interrupt lines active to wake up the whole system.
They are kept active at the interrupt controller level. You just refuse to understand how the internals of the interrupt subsystem work.
Quoted 14 lines
If no
irq_disablecallback is hooked, when doirq_disable, it will not actually disable
the interrupt, it will depend on next time when the irq happens, the handler will first mask
the interrupt as this interrupt never happens.
So after system suspended, the interrupt happens, but the device driver will not recieve this interrupt
because it is masked.
It results in that the device driver miss a important interrupt which related to something need to be
handled. If user application for example android has power managment daemon. It will find that nothing
to handle, it will make the system enter suspend again.
Let me list the logic to make it easier to understand.
suspend_enter()
--> dpm_suspend_end()
--> dpm_suspend_noirq()
--> suspend_device_irqs()
--> __disable_irq()
--> set IRQS_SUSPENDED && call
irq_disable() if necessary
--> syscore_suspend()
--> check_wakeup_irqs()
If there's no pending irq in suspend process &&IRQS_SUSPENDED is set,
then mask the irq.
Yes, we didn't implement disable_irq(). But we must implement mask_irq().
So system suspends. Then system will never be waken up by this irq any more since
it's masked.
Quoted 10 lines
Quoted 3 lines
And even if you would need this flag, then fiddling with the irq desc internals is a big NONO. There is a proper way to hand that in.
So can you suggest the proper way to handle it? Thanks.
Quoted 4 lines
Thanks,
tglx
Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
Quoted 12 lines · Haojian Zhuang
Let me list the logic to make it easier to understand.
suspend_enter()
-->dpm_suspend_end()--> dpm_suspend_noirq() --> suspend_device_irqs() --> __disable_irq() --> set IRQS_SUSPENDED && call irq_disable() if necessary --> syscore_suspend() --> check_wakeup_irqs() If there's no pending irq in suspend process &&
Quoted 8 lines
IRQS_SUSPENDEDis set,
then mask the irq.Yes, we didn't implement
disable_irq(). But we must implementmask_irq().So system suspends. Then system will never be waken up by this irq any more since
it's masked.
This is so wrong, it's not even funny anymore.
check_wakeup_irqs()
{
for_each_irq_desc(irq, desc) {
if (irqd_is_wakeup_set(&desc->irq_data)) {
if (desc->depth == 1 && desc->istate & IRQS_PENDING)
return -EBUSY;
continue;
}So all interrupt lines which have been marked as wakeup sources are not masked. And we only mask the other lines if the irq chip has the IRQCHIP_MASK_ON_SUSPEND flag set.
if (desc->istate & IRQS_SUSPENDED &&
irq_desc_get_chip(desc)->flags & IRQCHIP_MASK_ON_SUSPEND)
mask_irq(desc);}
The interrupts which can wake up your system fall into the irqd_is_wakeup_set() clause. So nothing masks the interrupts at these interrupt controller level. Your chip does not have the IRQCHIP_MASK_ON_SUSPEND flag set either, so not a single interrupt line gets masked.
The only thing you do with your hackery is to avoid that the interrupt is marked disabled. And that means that you violate the rules of the suspend logic.
We lazy disable the interrupts when we go into suspend in order to abort the suspend when a wakeup interrupt happens between the suspend_device_irqs() and check_wakeup_irqs(). Your hackery allows the system to handle the interrupt, so we have no indication that the suspend should be aborted.
You insist, that the interrupt line is masked at the irq chip level on suspend, but you completely fail to explain how this should happen. All you came up with so far is handwaving and a proper proof of incompetence.
I'm really start to get grumpy about this utter waste of time.
Thanks,
tglx
Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
In reply to Chao XieQuoted 20 lines · Chao Xie
Quoted 10 lines · Uwe Kleine-König
Hi Thomas,
Quoted 7 lines · Thomas Gleixner
The pm-mmp2 and pm-pxa910 power management related
irq_set_wakecallbacks fiddle pointlessly with the irq actions for no reason except for lack of understanding how the wakeup mechanism works.On supsend the core disables all interrupts lazily, i.e. it does not mask them at the irq controller level. So any interrupt which is firing during supsend will mark the corresponding interrupt line as
Quoted 8 lines
s/supsend/suspend/ twice
Quoted 3 lines
pending. Just before the core powers down it checks whether there are interrupts pending from interrupt lines which are marked as wakeup sources and if so it aborts the resume and resends the interrupts.
It's the suspend that is aborted, not the resume.
Other than that your change looks fine.
Quoted 7 lines
For pxa910 and MMP2, wake up source only wake up the AP subsystem. The AP subsystem includes the APMU(AP Power Mangament Unit) and cores. Now the core is still powered down. APMU will check the interrupt lines, and find
that there are interrupt pending, it will power on the cores.
So if the irq is disabled, even wake up source can wake up AP subsystem, but the core is still powered down. It will not be powered up by APMU.
The interrupt is NOT disabled at the interrupt chip level. The core does:
suspend_device_irqs() {
__disable_irq() {
if (!desc->depth++)
irq_disable(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);
}Your chip does not have a chip->irq_disable() callback installed, so the interrupt is not masked at the controller level. So APMU sees the interrupt enabled.
APMU does not care about the irq_desc->depth counter and the irq_data IRQD_DISABLED state bit.
So this hackery is completely pointless.
Thanks,
tglx
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] arm: mmp: Remove pointless fiddling with irq internals
In reply to Thomas Gleixnerarm: mmp: Remove pointless fiddling with irq internals
Commit-ID: 49f3fbc7b8576fd578f3504c65aae9b8a212d0f6 Gitweb: http://git.kernel.org/tip/49f3fbc7b8576fd578f3504c65aae9b8a212d0f6 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:13 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:52 +0100
arm: mmp: Remove pointless fiddling with irq internals
The pm-mmp2 and pm-pxa910 power management related irq_set_wake callbacks fiddle pointlessly with the irq actions for no reason except for lack of understanding how the wakeup mechanism works.
On supsend the core disables all interrupts lazily, i.e. it does not mask them at the irq controller level. So any interrupt which is firing during suspend will mark the corresponding interrupt line as pending. Just before the core powers down it checks whether there are interrupts pending from interrupt lines which are marked as wakeup sources and if so it aborts the suspend and resends the interrupts. If there was no interrupt at this point, the cpu goes into suspend with these interrupts unmasked.
The IRQF_NO_SUSPEND flag for interrupt actions is a totally different mechanism. That allows the device driver to prevent the core from disabling the interrupt despite the fact that it is not marked as a wakeup source. This has nothing to do with the case at hand. It was introduced for special cases where lazy disable is not possible.
Remove the nonsense along with the braindamaged boundary check. The core code does NOT call these functions out of boundary.
Add a FIXME comment to an unhandled error path which merily printks some useless blurb instead of returning a proper error code.
--- arch/arm/mach-mmp/pm-mmp2.c | 16 +--------------- arch/arm/mach-mmp/pm-pxa910.c | 20 ++++---------------- 2 files changed, 5 insertions(+), 31 deletions(-)
arch/arm/mach-mmp/pm-mmp2.c +1 -15
@@ -27,22 +27,8 @@int mmp2_set_wake (struct irq_data *d,unsigned int on) { -int irq = d->irq; -struct irq_desc *desc =irq_to_desc (irq);unsigned long data =0 ; - -if (unlikely (irq >= nr_irqs)) { -pr_err ("IRQ nubmers are out of boundary!\n" ); -return -EINVAL ; - } - -if (on) { -if (desc->action) - desc->action->flags |=IRQF_NO_SUSPEND ; - }else { -if (desc->action) - desc->action->flags &= ~IRQF_NO_SUSPEND ; - } +int irq = d->irq;/* enable wakeup sources */ switch (irq) {
arch/arm/mach-mmp/pm-pxa910.c +4 -16
@@ -27,22 +27,8 @@int pxa910_set_wake (struct irq_data *data,unsigned int on) { -int irq = data->irq; -struct irq_desc *desc =irq_to_desc (data->irq);uint32_t awucrm =0 , apcr =0 ; - -if (unlikely (irq >= nr_irqs)) { -pr_err ("IRQ nubmers are out of boundary!\n" ); -return -EINVAL ; - } - -if (on) { -if (desc->action) - desc->action->flags |=IRQF_NO_SUSPEND ; - }else { -if (desc->action) - desc->action->flags &= ~IRQF_NO_SUSPEND ; - } +int irq = data->irq;/* setting wakeup sources */ switch (irq) {
@@ -115,9 +101,11 @@ int pxa910_set_wake(struct irq_data *data, unsigned int on)if (irq >=IRQ_GPIO_START && irq <IRQ_BOARD_START ) { awucrm =MPMU_AWUCRM_WAKEUP (2 ); apcr |=MPMU_APCR_SLPWP2 ; - }else + }else { +/* FIXME: This should return a proper error code ! */ printk (KERN_ERR "Error: no defined wake up source irq: %d\n" , irq); + } }if (on) {
PATCH 10/26 blackfin:Use generic /proc/interrupts implementation
In reply to Thomas GleixnerThere is nothing special in that blackfin code. Use the core implementation.
--- arch/blackfin/Kconfig | 1 + arch/blackfin/kernel/irqchip.c | 36 +++++++----------------------------- 2 files changed, 8 insertions(+), 29 deletions(-)
arch/blackfin/Kconfig +1 -0
@@ -34,6 +34,7 @@ config BLACKFIN select ARCH_WANT_IPC_PARSE_VERSION select GENERIC_ATOMIC64 select GENERIC_IRQ_PROBE + select GENERIC_IRQ_SHOW select HAVE_NMI_WATCHDOG if NMI_WATCHDOG select GENERIC_SMP_IDLE_THREAD select ARCH_USES_GETTIMEOFFSET if !GENERIC_CLOCKEVENTS
arch/blackfin/kernel/irqchip.c +7 -29
@@ -33,37 +33,15 @@ static struct irq_desc bad_irq_desc = {#endif #ifdef CONFIG_PROC_FS -int show_interrupts (struct seq_file *p,void *v) +int arch_show_interrupts (struct seq_file *p,int prec) { -int i = *(loff_t *) v, j; -struct irqaction *action; -unsigned long flags; +int j; -if (i <NR_IRQS ) { -struct irq_desc *desc =irq_to_desc (i); - -raw_spin_lock_irqsave (&desc->lock, flags); - action = desc->action; -if (!action) - goto skip; -seq_printf (p,"%3d: " , i); -for_each_online_cpu (j) -seq_printf (p,"%10u " ,kstat_irqs_cpu (i, j)); -seq_printf (p," %8s" ,irq_desc_get_chip (desc)->name); -seq_printf (p," %s" , action->name); -for (action = action->next; action; action = action->next) -seq_printf (p," %s" , action->name); - -seq_putc (p,'\n' ); - skip: -raw_spin_unlock_irqrestore (&desc->lock, flags); - }else if (i ==NR_IRQS ) { -seq_printf (p,"NMI: " ); -for_each_online_cpu (j) -seq_printf (p,"%10u " , cpu_pda[j].__nmi_count); -seq_printf (p," CORE Non Maskable Interrupt\n" ); -seq_printf (p,"Err: %10u\n" ,atomic_read (&irq_err_count)); - } +seq_printf (p,"%*s: " , prec"NMI" ); +for_each_online_cpu (j) +seq_printf (p,"%10u " , cpu_pda[j].__nmi_count); +seq_printf (p," CORE Non Maskable Interrupt\n" ); +seq_printf (p,"%*s: %10u\n" , prec,"ERR" ,atomic_read (&irq_err_count));return 0 ; }#endif
Re: [patch 10/26] blackfin:Use generic /proc/interrupts implementation
Hi Thomas,
Quoted 64 lines · Thomas Gleixner
There is nothing special in that blackfin code. Use the core implementation.
Signed-off-by Thomas Gleixner <[email protected]>Cc Steven Miao <[email protected]>Cc bfin <[email protected]>--- arch/blackfin/Kconfig | 1 + arch/blackfin/kernel/irqchip.c | 36 +++++++----------------------------- 2 files changed, 8 insertions(+), 29 deletions(-)Index: tip/arch/blackfin/Kconfig
===================================================================arch/blackfin/Kconfig +1
-0@@ -34,6 +34,7 @@ config BLACKFIN select ARCH_WANT_IPC_PARSE_VERSION select GENERIC_ATOMIC64 select GENERIC_IRQ_PROBE + select GENERIC_IRQ_SHOW select HAVE_NMI_WATCHDOG if NMI_WATCHDOG select GENERIC_SMP_IDLE_THREAD select ARCH_USES_GETTIMEOFFSET if !GENERIC_CLOCKEVENTSIndex:
tip/arch/blackfin/kernel/irqchip.c
===================================================================arch/blackfin/kernel/irqchip.c +2
-27@@ -33,37 +33,15 @@ static struct irq_desc bad_irq_desc = {#endif #ifdef CONFIG_PROC_FS -int show_interrupts (struct seq_file *p,void *v) +int arch_show_interrupts (struct seq_file *p,int prec) { -int i = *(loff_t *) v, j; -struct irqaction *action; -unsigned long flags; +int j; -if (i <NR_IRQS ) { -struct irq_desc *desc =irq_to_desc (i); - -raw_spin_lock_irqsave (&desc->lock, flags); - action = desc->action; -if (!action) - goto skip; -seq_printf (p,"%3d: " , i); -for_each_online_cpu (j) -seq_printf (p,"%10u " ,kstat_irqs_cpu (i, j)); -seq_printf (p," %8s" ,irq_desc_get_chip (desc)->name); -seq_printf (p," %s" , action->name); -for (action = action->next; action; action = action->next) -seq_printf (p," %s" , action->name); - -seq_putc (p,'\n' ); - skip: -raw_spin_unlock_irqrestore (&desc->lock, flags); - }else if (i ==NR_IRQS ) { -seq_printf (p,"NMI: " ); -for_each_online_cpu (j) -seq_printf (p,"%10u " , cpu_pda[j].__nmi_count); -seq_printf (p," CORE Non Maskable Interrupt\n" );
arch/blackfin/kernel/irqchip.c static struct irq_desc bad_irq_desc = { · line 47
Quoted 10 lines
arch/blackfin/kernel/irqchip.c +5
-2- seq_printf(p, "Err: %10u\n", atomic_read(&irq_err_count)); - } +seq_printf (p,"%*s: " , prec"NMI" ); +for_each_online_cpu (j) +seq_printf (p,"%10u " , cpu_pda[j].__nmi_count); +seq_printf (p," CORE Non Maskable Interrupt\n" ); +seq_printf (p,"%*s: %10u\n" , prec,"ERR" ,atomic_read (&irq_err_count)); return 0; }#endif
Thanks. Applied.
-steven
PATCH 11/26 genirq: Add a kstat helper to increment irq stats
In reply to Thomas GleixnerThere is a common pattern all over the place:
kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));
This results in a call to core code anyway. So provide a function which does the same thing in core.
While at it, replace the butt ugly macro with an inline.
--- include/linux/kernel_stat.h | 12 +++++++----- kernel/irq/irqdesc.c | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-)
include/linux/kernel_stat.h +7 -5
@@ -54,11 +54,13 @@ extern unsigned long long nr_context_swi#include <linux/irq.h> extern unsigned int kstat_irqs_cpu (unsigned int irq,int cpu); -#define kstat_incr_irqs_this_cpu (irqno,DESC ) \ -do { \ - __this_cpu_inc(*(DESC)->kstat_irqs); \ - __this_cpu_inc(kstat.irqs_sum); \ -} while (0) +static inline void kstat_incr_irqs_this_cpu (unsigned int irq,struct irq_desc *desc) +{ +__this_cpu_inc (*desc->kstat_irqs); +__this_cpu_inc (kstat.irqs_sum); +} + +extern void kstat_incr_irq_this_cpu (unsigned int irq);static inline void kstat_incr_softirqs_this_cpu (unsigned int irq) {
kernel/irq/irqdesc.c +5 -0
@@ -489,6 +489,11 @@ void dynamic_irq_cleanup(unsigned int irraw_spin_unlock_irqrestore (&desc->lock, flags); } +void kstat_incr_irq_this_cpu (unsigned int irq) +{ +kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +} +unsigned int kstat_irqs_cpu (unsigned int irq,int cpu) {struct irq_desc *desc =irq_to_desc (irq);
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] genirq: Add a kstat helper to increment irq stats
genirq: Add a kstat helper to increment irq stats
Commit-ID: 792d0018a5fe31ef8ef9d07a7a02081d4abdf6b7 Gitweb: http://git.kernel.org/tip/792d0018a5fe31ef8ef9d07a7a02081d4abdf6b7 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:14 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:53 +0100
genirq: Add a kstat helper to increment irq stats
There is a common pattern all over the place:
kstat_incr_irqs_this_cpu(irq, irq_to_desc(irq));
This results in a call to core code anyway. So provide a function which does the same thing in core.
While at it, replace the butt ugly macro with an inline.
--- include/linux/kernel_stat.h | 12 +++++++----- kernel/irq/irqdesc.c | 5 +++++ 2 files changed, 12 insertions(+), 5 deletions(-)
include/linux/kernel_stat.h +7 -5
@@ -54,11 +54,13 @@ extern unsigned long long nr_context_switches(void);#include <linux/irq.h> extern unsigned int kstat_irqs_cpu (unsigned int irq,int cpu); -#define kstat_incr_irqs_this_cpu (irqno,DESC ) \ -do { \ - __this_cpu_inc(*(DESC)->kstat_irqs); \ - __this_cpu_inc(kstat.irqs_sum); \ -} while (0) +static inline void kstat_incr_irqs_this_cpu (unsigned int irq,struct irq_desc *desc) +{ +__this_cpu_inc (*desc->kstat_irqs); +__this_cpu_inc (kstat.irqs_sum); +} + +extern void kstat_incr_irq_this_cpu (unsigned int irq);static inline void kstat_incr_softirqs_this_cpu (unsigned int irq) {
kernel/irq/irqdesc.c +5 -0
@@ -489,6 +489,11 @@ void dynamic_irq_cleanup(unsigned int irq)raw_spin_unlock_irqrestore (&desc->lock, flags); } +void kstat_incr_irq_this_cpu (unsigned int irq) +{ +kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +} +unsigned int kstat_irqs_cpu (unsigned int irq,int cpu) {struct irq_desc *desc =irq_to_desc (irq);
PATCH 12/26 mips: Use the core irq stats function
In reply to Thomas GleixnerLet the core do the irq_desc resolution.
No functional change.
--- arch/mips/kernel/smtc.c | 2 +- arch/mips/sgi-ip22/ip22-int.c | 2 +- arch/mips/sgi-ip22/ip22-time.c | 2 +- arch/mips/sibyte/bcm1480/smp.c | 2 +- arch/mips/sibyte/sb1250/smp.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
arch/mips/kernel/smtc.c +1 -1
@@ -1007,7 +1007,7 @@ static void __irq_entry smtc_clock_tick_int irq =MIPS_CPU_IRQ_BASE +1 ;irq_enter (); -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq); cd = &per_cpu (mips_clockevent_device, cpu); cd->event_handler (cd);irq_exit ();
arch/mips/sgi-ip22/ip22-int.c +1 -1
@@ -148,7 +148,7 @@ static void __irq_entry indy_buserror_irint irq =SGI_BUSERR_IRQ ;irq_enter (); -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq);ip22_be_interrupt (irq);irq_exit (); }
arch/mips/sgi-ip22/ip22-time.c +1 -1
@@ -123,7 +123,7 @@ void __irq_entry indy_8254timer_irq(voidchar c;irq_enter (); -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq);printk (KERN_ALERT "Oops, got 8254 interrupt.\n" );ArcRead (0 , &c,1 , &cnt);ArcEnterInteractiveMode ();
arch/mips/sibyte/bcm1480/smp.c +1 -1
@@ -182,7 +182,7 @@ void bcm1480_mailbox_interrupt(void)int irq =K_BCM1480_INT_MBOX_0_0 ;unsigned int action; -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq);/* Load the mailbox register to figure out what we're supposed to do */ action = (__raw_readq (mailbox_0_regs[cpu]) >>48 ) &0xffff ;
arch/mips/sibyte/sb1250/smp.c +1 -1
@@ -170,7 +170,7 @@ void sb1250_mailbox_interrupt(void)int irq =K_INT_MBOX_0 ;unsigned int action; -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq);/* Load the mailbox register to figure out what we're supposed to do */ action = (____raw_readq (mailbox_regs[cpu]) >>48 ) &0xffff ;
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] mips: Use the core irq stats function
mips: Use the core irq stats function
Commit-ID: 310ff2c87e72208e4f04f33687abe9d208ffefe3 Gitweb: http://git.kernel.org/tip/310ff2c87e72208e4f04f33687abe9d208ffefe3 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:14 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:53 +0100
mips: Use the core irq stats function
Let the core do the irq_desc resolution.
No functional change.
--- arch/mips/kernel/smtc.c | 2 +- arch/mips/sgi-ip22/ip22-int.c | 2 +- arch/mips/sgi-ip22/ip22-time.c | 2 +- arch/mips/sibyte/bcm1480/smp.c | 2 +- arch/mips/sibyte/sb1250/smp.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-)
arch/mips/kernel/smtc.c +1 -1
@@ -1007,7 +1007,7 @@ static void __irq_entry smtc_clock_tick_interrupt(void)int irq =MIPS_CPU_IRQ_BASE +1 ;irq_enter (); -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq); cd = &per_cpu (mips_clockevent_device, cpu); cd->event_handler (cd);irq_exit ();
arch/mips/sgi-ip22/ip22-int.c +1 -1
@@ -148,7 +148,7 @@ static void __irq_entry indy_buserror_irq(void)int irq =SGI_BUSERR_IRQ ;irq_enter (); -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq);ip22_be_interrupt (irq);irq_exit (); }
arch/mips/sgi-ip22/ip22-time.c +1 -1
@@ -123,7 +123,7 @@ void __irq_entry indy_8254timer_irq(void)char c;irq_enter (); -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq);printk (KERN_ALERT "Oops, got 8254 interrupt.\n" );ArcRead (0 , &c,1 , &cnt);ArcEnterInteractiveMode ();
arch/mips/sibyte/bcm1480/smp.c +1 -1
@@ -182,7 +182,7 @@ void bcm1480_mailbox_interrupt(void)int irq =K_BCM1480_INT_MBOX_0_0 ;unsigned int action; -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq);/* Load the mailbox register to figure out what we're supposed to do */ action = (__raw_readq (mailbox_0_regs[cpu]) >>48 ) &0xffff ;
arch/mips/sibyte/sb1250/smp.c +1 -1
@@ -170,7 +170,7 @@ void sb1250_mailbox_interrupt(void)int irq =K_INT_MBOX_0 ;unsigned int action; -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq);/* Load the mailbox register to figure out what we're supposed to do */ action = (____raw_readq (mailbox_regs[cpu]) >>48 ) &0xffff ;
PATCH 13/26 sparc: Use the core irq stats function
In reply to Thomas GleixnerLet the core do the irq_desc resolution.
No functional change.
--- arch/sparc/kernel/time_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Index: tip/arch/sparc/kernel/time_64.c =================================--- tip.orig/arch/sparc/kernel/time_64.c +++ tip/arch/sparc/kernel/time_64.c
@@ -733,7 +733,7 @@ void __irq_entry timer_interrupt(int irq
irq_enter();
local_cpu_data().irq0_irqs++;
- kstat_incr_irqs_this_cpu(0, irq_to_desc(0));
+ kstat_incr_irq_this_cpu(0);
if (unlikely(!evt->event_handler)) {
printk(KERN_WARNING
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] sparc: Use the core irq stats function
sparc: Use the core irq stats function
Commit-ID: 87a69ad6409b2c7a95e2e6e4ddbc380046cb7730 Gitweb: http://git.kernel.org/tip/87a69ad6409b2c7a95e2e6e4ddbc380046cb7730 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:15 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:53 +0100
sparc: Use the core irq stats function
Let the core do the irq_desc resolution.
No functional change.
--- arch/sparc/kernel/time_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/sparc/kernel/time_64.c +1 -1
@@ -733,7 +733,7 @@ void __irq_entry timer_interrupt(int irq, struct pt_regs *regs)irq_enter ();local_cpu_data ().irq0_irqs++; -kstat_incr_irqs_this_cpu (0 ,irq_to_desc (0 )); +kstat_incr_irq_this_cpu (0 );if (unlikely (!evt->event_handler)) { printk(KERN_WARNING
Re: [patch 13/26] sparc: Use the core irq stats function
In reply to Thomas GleixnerFrom: Thomas Gleixner <[email protected]>
Date: Sun, 23 Feb 2014 21:40:15 -0000
Quoted 7 lines
Let the core do the
irq_descresolution.No functional change.
Signed-off-by Thomas Gleixner <[email protected]>Cc "David S. Miller" <[email protected]>Cc sparc <[email protected]>
PATCH 14/26 mn10300: Use the core irq stats function
In reply to Thomas GleixnerLet the core do the irq_desc resolution.
No functional change.
--- arch/mn10300/kernel/mn10300-watchdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mn10300/kernel/mn10300-watchdog.c +1 -1
@@ -142,7 +142,7 @@ void watchdog_interrupt(struct pt_regs *NMICR =NMICR_WDIF ;nmi_count (smp_processor_id ())++; -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq);for_each_online_cpu (cpu) {
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] mn10300: Use the core irq stats function
mn10300: Use the core irq stats function
Commit-ID: a21748c93544901448777b5fa2abe1194c02c6dc Gitweb: http://git.kernel.org/tip/a21748c93544901448777b5fa2abe1194c02c6dc Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:16 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:53 +0100
mn10300: Use the core irq stats function
Let the core do the irq_desc resolution.
No functional change.
--- arch/mn10300/kernel/mn10300-watchdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mn10300/kernel/mn10300-watchdog.c +1 -1
@@ -142,7 +142,7 @@ void watchdog_interrupt(struct pt_regs *regs, enum exception_code excep)NMICR =NMICR_WDIF ;nmi_count (smp_processor_id ())++; -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq);for_each_online_cpu (cpu) {
PATCH 15/26 x86: xen: Use the core irq stats function
In reply to Thomas GleixnerLet the core do the irq_desc resolution.
No functional change.
--- arch/x86/xen/spinlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/spinlock.c +1 -1
@@ -183,7 +183,7 @@ __visible void xen_lock_spinning(structlocal_irq_save (flags); -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq); out:cpumask_clear_cpu (cpu, &waiting_cpus); w->lock =NULL ;
Re: [Xen-devel] [patch 15/26] x86: xen: Use the core irq stats function
Quoted 3 lines · Thomas Gleixner
Let the core do the
irq_descresolution.No functional change.
David
Re: [patch 15/26] x86: xen: Use the core irq stats function
In reply to Thomas GleixnerQuoted 3 lines · Thomas Gleixner
Let the core do the
irq_descresolution.No functional change.
David
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] x86: Xen: Use the core irq stats function
In reply to Thomas Gleixnerx86: Xen: Use the core irq stats function
Commit-ID: 770144ea7beb3e0537277a96b104ba1daa965f76 Gitweb: http://git.kernel.org/tip/770144ea7beb3e0537277a96b104ba1daa965f76 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:16 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:53 +0100
x86: Xen: Use the core irq stats function
Let the core do the irq_desc resolution.
No functional change.
--- arch/x86/xen/spinlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/spinlock.c +1 -1
@@ -183,7 +183,7 @@ __visible void xen_lock_spinning(struct arch_spinlock *lock, __ticket_t want)local_irq_save (flags); -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq); out:cpumask_clear_cpu (cpu, &waiting_cpus); w->lock =NULL ;
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] x86: Xen: Use the core irq stats function
In reply to Thomas Gleixnerx86: Xen: Use the core irq stats function
Commit-ID: 770144ea7beb3e0537277a96b104ba1daa965f76 Gitweb: http://git.kernel.org/tip/770144ea7beb3e0537277a96b104ba1daa965f76 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:16 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:53 +0100
x86: Xen: Use the core irq stats function
Let the core do the irq_desc resolution.
No functional change.
--- arch/x86/xen/spinlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/xen/spinlock.c +1 -1
@@ -183,7 +183,7 @@ __visible void xen_lock_spinning(struct arch_spinlock *lock, __ticket_t want)local_irq_save (flags); -kstat_incr_irqs_this_cpu (irq,irq_to_desc (irq)); +kstat_incr_irq_this_cpu (irq); out:cpumask_clear_cpu (cpu, &waiting_cpus); w->lock =NULL ;
PATCH 16/26 s390: cio: Use the core irq stats function
In reply to Thomas GleixnerLet the core do the irq_desc resolution.
No functional change.
--- drivers/s390/cio/cio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/s390/cio/cio.c +1 -4
@@ -584,8 +584,6 @@ static irqreturn_t do_cio_interrupt(intreturn IRQ_HANDLED ; } -static struct irq_desc *irq_desc_io; -static struct irqaction io_interrupt = { .name ="IO" , .handler = do_cio_interrupt,
@@ -596,7 +594,6 @@ void __init init_cio_interrupts(void)irq_set_chip_and_handler (IO_INTERRUPT , &dummy_irq_chip, handle_percpu_irq);setup_irq (IO_INTERRUPT , &io_interrupt); - irq_desc_io =irq_to_desc (IO_INTERRUPT ); }#ifdef CONFIG_CCW_CONSOLE
@@ -623,7 +620,7 @@ void cio_tsch(struct subchannel *sch)local_bh_disable ();irq_enter (); } -kstat_incr_irqs_this_cpu (IO_INTERRUPT , irq_desc_io); +kstat_incr_irq_this_cpu (IO_INTERRUPT );if (sch->driver && sch->driver->irq) sch->driver->irq (sch);else
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] s390: Cio: Use the core irq stats function
s390: Cio: Use the core irq stats function
Commit-ID: bc5dfcff65f24f15567f766d8bd081d594ef8cc2 Gitweb: http://git.kernel.org/tip/bc5dfcff65f24f15567f766d8bd081d594ef8cc2 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:17 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:54 +0100
s390: Cio: Use the core irq stats function
Let the core do the irq_desc resolution.
No functional change.
--- drivers/s390/cio/cio.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/s390/cio/cio.c +1 -4
@@ -584,8 +584,6 @@ static irqreturn_t do_cio_interrupt(int irq, void *dummy)return IRQ_HANDLED ; } -static struct irq_desc *irq_desc_io; -static struct irqaction io_interrupt = { .name ="IO" , .handler = do_cio_interrupt,
@@ -596,7 +594,6 @@ void __init init_cio_interrupts(void)irq_set_chip_and_handler (IO_INTERRUPT , &dummy_irq_chip, handle_percpu_irq);setup_irq (IO_INTERRUPT , &io_interrupt); - irq_desc_io =irq_to_desc (IO_INTERRUPT ); }#ifdef CONFIG_CCW_CONSOLE
@@ -623,7 +620,7 @@ void cio_tsch(struct subchannel *sch)local_bh_disable ();irq_enter (); } -kstat_incr_irqs_this_cpu (IO_INTERRUPT , irq_desc_io); +kstat_incr_irq_this_cpu (IO_INTERRUPT );if (sch->driver && sch->driver->irq) sch->driver->irq (sch);else
PATCH 17/26 ia64: Use the core irq stats function
In reply to Thomas GleixnerLet the core do the irq_desc resolution.
No functional change.
--- arch/ia64/kernel/irq_ia64.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
Index: tip/arch/ia64/kernel/irq_ia64.c =================================--- tip.orig/arch/ia64/kernel/irq_ia64.c +++ tip/arch/ia64/kernel/irq_ia64.c
@@ -489,14 +489,13 @@ ia64_handle_irq (ia64_vector vector, str
ia64_srlz_d();
while (vector != IA64_SPURIOUS_INT_VECTOR) {
int irq = local_vector_to_irq(vector);
- struct irq_desc *desc = irq_to_desc(irq);
if (unlikely(IS_LOCAL_TLB_FLUSH(vector))) {
smp_local_flush_tlb();
- kstat_incr_irqs_this_cpu(irq, desc);
+ kstat_incr_irq_this_cpu(irq);
} else if (unlikely(IS_RESCHEDULE(vector))) {
scheduler_ipi();
- kstat_incr_irqs_this_cpu(irq, desc);
+ kstat_incr_irq_this_cpu(irq);
} else {
ia64_setreg(_IA64_REG_CR_TPR, vector); ia64_srlz_d();
@@ -549,13 +548,12 @@ void ia64_process_pending_intr(void)
*/
while (vector != IA64_SPURIOUS_INT_VECTOR) {
int irq = local_vector_to_irq(vector);
- struct irq_desc *desc = irq_to_desc(irq);
if (unlikely(IS_LOCAL_TLB_FLUSH(vector))) {
smp_local_flush_tlb();
- kstat_incr_irqs_this_cpu(irq, desc);
+ kstat_incr_irq_this_cpu(irq);
} else if (unlikely(IS_RESCHEDULE(vector))) {
- kstat_incr_irqs_this_cpu(irq, desc);
+ kstat_incr_irq_this_cpu(irq);
} else {
struct pt_regs *old_regs = set_irq_regs(NULL);
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] ia64: Use the core irq stats function
ia64: Use the core irq stats function
Commit-ID: 3611587aa15f4ff75a2af3483d6a02accada8ec8 Gitweb: http://git.kernel.org/tip/3611587aa15f4ff75a2af3483d6a02accada8ec8 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:17 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:54 +0100
ia64: Use the core irq stats function
Let the core do the irq_desc resolution.
No functional change.
--- arch/ia64/kernel/irq_ia64.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
arch/ia64/kernel/irq_ia64.c +4 -6
@@ -489,14 +489,13 @@ ia64_handle_irq (ia64_vector vector, struct pt_regs *regs)ia64_srlz_d ();while (vector !=IA64_SPURIOUS_INT_VECTOR ) {int irq =local_vector_to_irq (vector); -struct irq_desc *desc =irq_to_desc (irq);if (unlikely (IS_LOCAL_TLB_FLUSH (vector))) {smp_local_flush_tlb (); -kstat_incr_irqs_this_cpu (irq, desc); +kstat_incr_irq_this_cpu (irq); }else if (unlikely (IS_RESCHEDULE (vector))) {scheduler_ipi (); -kstat_incr_irqs_this_cpu (irq, desc); +kstat_incr_irq_this_cpu (irq); }else {ia64_setreg (_IA64_REG_CR_TPR, vector);ia64_srlz_d ();
@@ -549,13 +548,12 @@ void ia64_process_pending_intr(void)*/ while (vector !=IA64_SPURIOUS_INT_VECTOR ) {int irq =local_vector_to_irq (vector); -struct irq_desc *desc =irq_to_desc (irq);if (unlikely (IS_LOCAL_TLB_FLUSH (vector))) {smp_local_flush_tlb (); -kstat_incr_irqs_this_cpu (irq, desc); +kstat_incr_irq_this_cpu (irq); }else if (unlikely (IS_RESCHEDULE (vector))) { -kstat_incr_irqs_this_cpu (irq, desc); +kstat_incr_irq_this_cpu (irq); }else {struct pt_regs *old_regs =set_irq_regs (NULL );
PATCH 18/26 xen: Use the proper irq functions
In reply to Thomas GleixnerI really can't understand why people keep adding irq_desc abuse. We have enough proper interfaces. Delete another 14 lines of hackery.
--- drivers/xen/events/events_2l.c | 15 ++++----------- drivers/xen/events/events_base.c | 7 ++----- drivers/xen/events/events_fifo.c | 8 ++------ 3 files changed, 8 insertions(+), 22 deletions(-)
drivers/xen/events/events_2l.c +4 -11
@@ -166,7 +166,6 @@ static void evtchn_2l_handle_events(unsiint start_word_idx, start_bit_idx;int word_idx, bit_idx;int i; -struct irq_desc *desc;struct shared_info *s = HYPERVISOR_shared_info;struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu);
@@ -176,11 +175,8 @@ static void evtchn_2l_handle_events(unsiunsigned int evtchn =evtchn_from_irq (irq); word_idx = evtchn /BITS_PER_LONG ; bit_idx = evtchn %BITS_PER_LONG ; -if (active_evtchns (cpu, s, word_idx) & (1ULL << bit_idx)) { - desc =irq_to_desc (irq); -if (desc) -generic_handle_irq_desc (irq, desc); - } +if (active_evtchns (cpu, s, word_idx) & (1ULL << bit_idx)) +generic_handle_irq (irq); }/*
@@ -245,11 +241,8 @@ static void evtchn_2l_handle_events(unsi port = (word_idx *BITS_PER_EVTCHN_WORD ) + bit_idx; irq =get_evtchn_to_irq (port); -if (irq !=-1 ) { - desc =irq_to_desc (irq); -if (desc) -generic_handle_irq_desc (irq, desc); - } +if (irq !=-1 ) +generic_handle_irq (irq); bit_idx = (bit_idx +1 ) %BITS_PER_EVTCHN_WORD ;
drivers/xen/events/events_base.c +2 -5
@@ -336,9 +336,8 @@ static void bind_evtchn_to_cpu(unsignedBUG_ON (irq ==-1 );#ifdef CONFIG_SMP -cpumask_copy (irq_to_desc (irq)->irq_data.affinity,cpumask_of (cpu)); +cpumask_copy (irq_get_irq_data (irq)->affinity,cpumask_of (cpu));#endif -xen_evtchn_port_bind_to_cpu (info, cpu); info->cpu = cpu;
@@ -373,10 +372,8 @@ static void xen_irq_init(unsigned irq) {struct irq_info *info;#ifdef CONFIG_SMP -struct irq_desc *desc =irq_to_desc (irq); -/* By default all event channels notify CPU#0. */ -cpumask_copy (desc->irq_data.affinity,cpumask_of (0 )); +cpumask_copy (irq_get_irq_data (irq)->affinity,cpumask_of (0 ));#endif info =kzalloc (sizeof (*info),GFP_KERNEL );
drivers/xen/events/events_fifo.c +2 -6
@@ -235,14 +235,10 @@ static uint32_t clear_linked(volatile evstatic void handle_irq_for_port (unsigned port) {int irq; -struct irq_desc *desc; irq =get_evtchn_to_irq (port); -if (irq !=-1 ) { - desc =irq_to_desc (irq); -if (desc) -generic_handle_irq_desc (irq, desc); - } +if (irq !=-1 ) +generic_handle_irq (irq); } static void consume_one_event(unsigned cpu,
Re: [Xen-devel] [patch 18/26] xen: Use the proper irq functions
Quoted 2 lines · Thomas Gleixner
I really can't understand why people keep adding
irq_descabuse. We have enough proper interfaces. Delete another 14 lines of hackery.
generic_handler_irq() already tests for !desc so use this instead of generic_handle_irq_desc(). Use irq_get_irq_data() instead of desc->irq_data.
Otherwise,
David
Re: [Xen-devel] [patch 18/26] xen: Use the proper irq functions
Quoted 7 lines · David Vrabel
Quoted 2 lines · Thomas Gleixner
I really can't understand why people keep adding
irq_descabuse. We have enough proper interfaces. Delete another 14 lines of hackery.
generic_handler_irq()already tests for !desc so use this instead ofgeneric_handle_irq_desc(). Useirq_get_irq_data()instead ofdesc->irq_data.
Fair enough. I was not really in the mood to come up with proper changelogs :)
Quoted 6 lines
Otherwise,
Reviewed-by David Vrabel <[email protected]>David
Re: [patch 18/26] xen: Use the proper irq functions
In reply to David VrabelQuoted 7 lines · David Vrabel
Quoted 2 lines · Thomas Gleixner
I really can't understand why people keep adding
irq_descabuse. We have enough proper interfaces. Delete another 14 lines of hackery.
generic_handler_irq()already tests for !desc so use this instead ofgeneric_handle_irq_desc(). Useirq_get_irq_data()instead ofdesc->irq_data.
Fair enough. I was not really in the mood to come up with proper changelogs :)
Quoted 6 lines
Otherwise,
Reviewed-by David Vrabel <[email protected]>David
Re: [patch 18/26] xen: Use the proper irq functions
In reply to Thomas GleixnerQuoted 2 lines · Thomas Gleixner
I really can't understand why people keep adding
irq_descabuse. We have enough proper interfaces. Delete another 14 lines of hackery.
generic_handler_irq() already tests for !desc so use this instead of generic_handle_irq_desc(). Use irq_get_irq_data() instead of desc->irq_data.
Otherwise,
David
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] xen: Use the proper irq functions
In reply to Thomas Gleixnerxen: Use the proper irq functions
Commit-ID: 589d03e93f6cd595f68891e48f0804f2c8f38aae Gitweb: http://git.kernel.org/tip/589d03e93f6cd595f68891e48f0804f2c8f38aae Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:18 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:52 +0100
xen: Use the proper irq functions
generic_handler_irq() already tests for !desc so use this instead of generic_handle_irq_desc().
Use irq_get_irq_data() instead of desc->irq_data.
--- drivers/xen/events/events_2l.c | 15 ++++----------- drivers/xen/events/events_base.c | 7 ++----- drivers/xen/events/events_fifo.c | 8 ++------ 3 files changed, 8 insertions(+), 22 deletions(-)
drivers/xen/events/events_2l.c +4 -11
@@ -166,7 +166,6 @@ static void evtchn_2l_handle_events(unsigned cpu)int start_word_idx, start_bit_idx;int word_idx, bit_idx;int i; -struct irq_desc *desc;struct shared_info *s = HYPERVISOR_shared_info;struct vcpu_info *vcpu_info =__this_cpu_read (xen_vcpu);
@@ -176,11 +175,8 @@ static void evtchn_2l_handle_events(unsigned cpu)unsigned int evtchn =evtchn_from_irq (irq); word_idx = evtchn /BITS_PER_LONG ; bit_idx = evtchn %BITS_PER_LONG ; -if (active_evtchns (cpu, s, word_idx) & (1ULL << bit_idx)) { - desc =irq_to_desc (irq); -if (desc) -generic_handle_irq_desc (irq, desc); - } +if (active_evtchns (cpu, s, word_idx) & (1ULL << bit_idx)) +generic_handle_irq (irq); }/*
@@ -245,11 +241,8 @@ static void evtchn_2l_handle_events(unsigned cpu) port = (word_idx *BITS_PER_EVTCHN_WORD ) + bit_idx; irq =get_evtchn_to_irq (port); -if (irq !=-1 ) { - desc =irq_to_desc (irq); -if (desc) -generic_handle_irq_desc (irq, desc); - } +if (irq !=-1 ) +generic_handle_irq (irq); bit_idx = (bit_idx +1 ) %BITS_PER_EVTCHN_WORD ;
drivers/xen/events/events_base.c +2 -5
@@ -336,9 +336,8 @@ static void bind_evtchn_to_cpu(unsigned int chn, unsigned int cpu)BUG_ON (irq ==-1 );#ifdef CONFIG_SMP -cpumask_copy (irq_to_desc (irq)->irq_data.affinity,cpumask_of (cpu)); +cpumask_copy (irq_get_irq_data (irq)->affinity,cpumask_of (cpu));#endif -xen_evtchn_port_bind_to_cpu (info, cpu); info->cpu = cpu;
@@ -373,10 +372,8 @@ static void xen_irq_init(unsigned irq) {struct irq_info *info;#ifdef CONFIG_SMP -struct irq_desc *desc =irq_to_desc (irq); -/* By default all event channels notify CPU#0. */ -cpumask_copy (desc->irq_data.affinity,cpumask_of (0 )); +cpumask_copy (irq_get_irq_data (irq)->affinity,cpumask_of (0 ));#endif info =kzalloc (sizeof (*info),GFP_KERNEL );
drivers/xen/events/events_fifo.c +2 -6
@@ -235,14 +235,10 @@ static uint32_t clear_linked(volatile event_word_t *word)static void handle_irq_for_port (unsigned port) {int irq; -struct irq_desc *desc; irq =get_evtchn_to_irq (port); -if (irq !=-1 ) { - desc =irq_to_desc (irq); -if (desc) -generic_handle_irq_desc (irq, desc); - } +if (irq !=-1 ) +generic_handle_irq (irq); } static void consume_one_event(unsigned cpu,
PATCH 19/26 genirq: Provide irqd_irq_has_actions()
In reply to Thomas GleixnerXen has an oddball probing_irq() function. Provide a proper interface unless Konrad decides that this probing_irq() function can be ripped out completely.
--- include/linux/irq.h | 7 +++++++ kernel/irq/manage.c | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-)
include/linux/irq.h +7 -0
@@ -173,6 +173,7 @@ struct irq_data {* IRQD_IRQ_DISABLED - Disabled state of the interrupt * IRQD_IRQ_MASKED - Masked state of the interrupt * IRQD_IRQ_INPROGRESS - In progress state of the interrupt +* IRQD_IRQ_HAS_ACTION - Set if action(s) installed */ enum {IRQD_TRIGGER_MASK =0xf ,
@@ -186,6 +187,7 @@ enum {IRQD_IRQ_DISABLED = (1 <<16 ),IRQD_IRQ_MASKED = (1 <<17 ),IRQD_IRQ_INPROGRESS = (1 <<18 ), + IRQD_IRQ_HAS_ACTION = (1 << 19), };static inline bool irqd_is_setaffinity_pending (struct irq_data *d)
@@ -257,6 +259,11 @@ static inline bool irqd_irq_inprogress(sreturn d->state_use_accessors &IRQD_IRQ_INPROGRESS ; } +static inline bool irqd_irq_has_actions (struct irq_data *d) +{ +return d->state_use_accessors &IRQD_IRQ_HAS_ACTION ; +} +/* * Functions for chained handlers which can be enabled/disabled by the * standard disable_irq/enable_irq calls. Must be called with
kernel/irq/manage.c +5 -1
@@ -1204,6 +1204,8 @@ __setup_irq(unsigned int irq, struct irq desc->irq_count =0 ; desc->irqs_unhandled =0 ; +irqd_set (irq_desc_get_irq_data (desc),IRQD_IRQ_HAS_ACTION ); +/* * Check whether we disabled the irq via the spurious handler * before. Reenable it and give it another chance.
@@ -1319,8 +1321,10 @@ static struct irqaction *__free_irq(unsi *action_ptr = action->next;/* If this was the last handler, shut down the IRQ line: */ -if (!desc->action) +if (!desc->action) { +irqd_clear (irq_desc_get_irq_data (desc),IRQD_IRQ_HAS_ACTION );irq_shutdown (desc); + }#ifdef CONFIG_SMP /* make sure affinity_hint is cleaned up */
PATCH 20/26 genirq: Provide irq_is_allocated()
In reply to Thomas GleixnerAnother proper interface to replace Xen hackery. No idea why Xen needs this, but I'm not masochistic enough to understand that mess.
--- kernel/irq/irqdesc.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
kernel/irq/irqdesc.c +11 -0
@@ -390,6 +390,17 @@ err:EXPORT_SYMBOL_GPL (__irq_alloc_descs);/** +* irq_is_allocated - query whether an irq desc is allocated for an irq number +* @irq: irq number +* +* Returns a momentary racy snapshot of the allocation state +*/ +bool irq_is_allocated (unsigned int irq) +{ +return irq < nr_irqs &&test_bit (irq, allocated_irqs); +} + +/** * irq_reserve_irqs - mark irqs allocated * @from: mark from irq number * @cnt: number of irqs to mark
PATCH 21/26 xen: Get rid of the last irq_desc abuse
In reply to Thomas GleixnerI'd prefer to drop that completely but there seems to be some mystic value to the error printout and the allocation check.
--- drivers/xen/events/events_base.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-)
drivers/xen/events/events_base.c +5 -14
@@ -487,13 +487,6 @@ static void pirq_query_unmask(int irq) info->u.pirq.flags |=PIRQ_NEEDS_EOI ; } -static bool probing_irq (int irq) -{ -struct irq_desc *desc =irq_to_desc (irq); - -return desc && desc->action ==NULL ; -} -static void eoi_pirq (struct irq_data *data) {int evtchn =evtchn_from_irq (data->irq);
@@ -517,7 +510,7 @@ static void mask_ack_pirq(struct irq_dateoi_pirq (data); } -static unsigned int __startup_pirq (unsigned int irq) +static unsigned int __startup_pirq (struct irq_data *data,unsigned int irq) {struct evtchn_bind_pirq bind_pirq;struct irq_info *info =info_for_irq (irq);
@@ -535,7 +528,7 @@ static unsigned int __startup_pirq(unsig BIND_PIRQ__WILL_SHARE :0 ; rc =HYPERVISOR_event_channel_op (EVTCHNOP_bind_pirq, &bind_pirq);if (rc !=0 ) { -if (!probing_irq (irq)) +if (!data ||irqd_irq_has_action (data))pr_info ("Failed to obtain physical IRQ %d\n" , irq);return 0 ; }
@@ -562,7 +555,7 @@ out:static unsigned int startup_pirq (struct irq_data *data) { -return __startup_pirq (data->irq); +return __startup_pirq (data, data->irq); }static void shutdown_pirq (struct irq_data *data)
@@ -769,15 +762,13 @@ error_irq:int xen_destroy_irq (int irq) { -struct irq_desc *desc;struct physdev_unmap_pirq unmap_irq;struct irq_info *info =info_for_irq (irq);int rc = -ENOENT ;mutex_lock (&irq_mapping_update_lock); - desc =irq_to_desc (irq); -if (!desc) +if (!irq_is_allocated (irq)) goto out;if (xen_initial_domain ()) {
@@ -1432,7 +1423,7 @@ static void restore_pirqs(void)printk (KERN_DEBUG "xen: --> irq=%d, pirq=%d\n" , irq, map_irq.pirq); -__startup_pirq (irq); +__startup_pirq (irq_get_irq_data (irq), irq); } }
Re: [Xen-devel] [patch 21/26] xen: Get rid of the last irq_desc abuse
Quoted 2 lines · Thomas Gleixner
I'd prefer to drop that completely but there seems to be some mystic value to the error printout and the allocation check.
Warn if any PIRQ cannot be bound to an event channel. Remove an unnecessary test for !desc in xen_destroy_irq() since the only caller will only do so if the irq was previously allocated.
Quoted 2 lines
drivers/xen/events/events_base.c +0
-0
[...]
drivers/xen/events/events_base.c static unsigned int __startup_pirq(unsig · line 532
Quoted 7 lines
drivers/xen/events/events_base.c +1
-1@@ -535,7 +528,7 @@ static unsigned int __startup_pirq(unsig BIND_PIRQ__WILL_SHARE :0 ; rc =HYPERVISOR_event_channel_op (EVTCHNOP_bind_pirq, &bind_pirq);if (rc !=0 ) { -if (!probing_irq (irq)) +if (!data ||irqd_irq_has_action (data))pr_info ("Failed to obtain physical IRQ %d\n" , irq);
Remove this if and change the pr_info() to a pr_warn().
This hypercall never fails in practice, but it's still useful to have the message in case on some systems it does.
Quoted 7 lines
drivers/xen/events/events_base.c +0
-1return 0 ; }@@ -769,15 +762,13 @@ error_irq:int xen_destroy_irq (int irq) { -struct irq_desc *desc;
drivers/xen/events/events_base.c error_irq: · line 772
Quoted 10 lines
drivers/xen/events/events_base.c +1
-2struct physdev_unmap_pirq unmap_irq;struct irq_info *info =info_for_irq (irq);int rc = -ENOENT ;mutex_lock (&irq_mapping_update_lock); - desc =irq_to_desc (irq); -if (!desc) +if (!irq_is_allocated (irq)) goto out;
Remove this test. The only caller of xen_destroy_irq() will only do so if the irq was previously fully setup.
I think this means you don't need to introduce the irqd_irq_has_action() and irq_is_allocated() helpers.
David
Re: [Xen-devel] [patch 21/26] xen: Get rid of the last irq_desc abuse
Quoted 21 lines · David Vrabel
Quoted 2 lines · Thomas Gleixner
I'd prefer to drop that completely but there seems to be some mystic value to the error printout and the allocation check.
Warn if any PIRQ cannot be bound to an event channel. Remove an unnecessary test for !desc in
xen_destroy_irq()since the only caller will only do so if the irq was previously allocated.Quoted 2 lines
drivers/xen/events/events_base.c +0
-0[...]
drivers/xen/events/events_base.c static unsigned int __startup_pirq(unsig · line 532
Quoted 7 lines
drivers/xen/events/events_base.c +1
-1@@ -535,7 +528,7 @@ static unsigned int __startup_pirq(unsig BIND_PIRQ__WILL_SHARE :0 ; rc =HYPERVISOR_event_channel_op (EVTCHNOP_bind_pirq, &bind_pirq);if (rc !=0 ) { -if (!probing_irq (irq)) +if (!data ||irqd_irq_has_action (data))pr_info ("Failed to obtain physical IRQ %d\n" , irq);Remove this if and change the
pr_info()to apr_warn().
Quoted 2 lines
This hypercall never fails in practice, but it's still useful to have the message in case on some systems it does.
Sure, I understood the value of the printk, but I failed to see the reason for probing_irq(). Will change it.
Quoted 13 lines
Quoted 13 lines
drivers/xen/events/events_base.c +0
-1return 0 ; }@@ -769,15 +762,13 @@ error_irq:int xen_destroy_irq (int irq) { -struct irq_desc *desc;struct physdev_unmap_pirq unmap_irq;struct irq_info *info =info_for_irq (irq);int rc = -ENOENT ;mutex_lock (&irq_mapping_update_lock);
Quoted 7 lines
drivers/xen/events/events_base.c error_irq: · line 772
Quoted 4 lines
drivers/xen/events/events_base.c +1
-2- desc =irq_to_desc (irq); -if (!desc) +if (!irq_is_allocated (irq)) goto out;Remove this test. The only caller of
xen_destroy_irq()will only do so if the irq was previously fully setup.
I was not sure about that, but thanks for confirming.
Quoted 2 lines
I think this means you don't need to introduce the
irqd_irq_has_action()andirq_is_allocated()helpers.
I just invented them in case xen really needs those tests.
Thanks,
tglx
Re: [patch 21/26] xen: Get rid of the last irq_desc abuse
In reply to David VrabelQuoted 21 lines · David Vrabel
Quoted 2 lines · Thomas Gleixner
I'd prefer to drop that completely but there seems to be some mystic value to the error printout and the allocation check.
Warn if any PIRQ cannot be bound to an event channel. Remove an unnecessary test for !desc in
xen_destroy_irq()since the only caller will only do so if the irq was previously allocated.Quoted 2 lines
drivers/xen/events/events_base.c +0
-0[...]
drivers/xen/events/events_base.c static unsigned int __startup_pirq(unsig · line 532
Quoted 7 lines
drivers/xen/events/events_base.c +1
-1@@ -535,7 +528,7 @@ static unsigned int __startup_pirq(unsig BIND_PIRQ__WILL_SHARE :0 ; rc =HYPERVISOR_event_channel_op (EVTCHNOP_bind_pirq, &bind_pirq);if (rc !=0 ) { -if (!probing_irq (irq)) +if (!data ||irqd_irq_has_action (data))pr_info ("Failed to obtain physical IRQ %d\n" , irq);Remove this if and change the
pr_info()to apr_warn().
Quoted 2 lines
This hypercall never fails in practice, but it's still useful to have the message in case on some systems it does.
Sure, I understood the value of the printk, but I failed to see the reason for probing_irq(). Will change it.
Quoted 13 lines
Quoted 13 lines
drivers/xen/events/events_base.c +0
-1return 0 ; }@@ -769,15 +762,13 @@ error_irq:int xen_destroy_irq (int irq) { -struct irq_desc *desc;struct physdev_unmap_pirq unmap_irq;struct irq_info *info =info_for_irq (irq);int rc = -ENOENT ;mutex_lock (&irq_mapping_update_lock);
Quoted 7 lines
drivers/xen/events/events_base.c error_irq: · line 772
Quoted 4 lines
drivers/xen/events/events_base.c +1
-2- desc =irq_to_desc (irq); -if (!desc) +if (!irq_is_allocated (irq)) goto out;Remove this test. The only caller of
xen_destroy_irq()will only do so if the irq was previously fully setup.
I was not sure about that, but thanks for confirming.
Quoted 2 lines
I think this means you don't need to introduce the
irqd_irq_has_action()andirq_is_allocated()helpers.
I just invented them in case xen really needs those tests.
Thanks,
tglx
Re: [patch 21/26] xen: Get rid of the last irq_desc abuse
In reply to Thomas GleixnerQuoted 2 lines · Thomas Gleixner
I'd prefer to drop that completely but there seems to be some mystic value to the error printout and the allocation check.
Warn if any PIRQ cannot be bound to an event channel. Remove an unnecessary test for !desc in xen_destroy_irq() since the only caller will only do so if the irq was previously allocated.
Quoted 2 lines
drivers/xen/events/events_base.c +0
-0
[...]
drivers/xen/events/events_base.c static unsigned int __startup_pirq(unsig · line 532
Quoted 7 lines
drivers/xen/events/events_base.c +1
-1@@ -535,7 +528,7 @@ static unsigned int __startup_pirq(unsig BIND_PIRQ__WILL_SHARE :0 ; rc =HYPERVISOR_event_channel_op (EVTCHNOP_bind_pirq, &bind_pirq);if (rc !=0 ) { -if (!probing_irq (irq)) +if (!data ||irqd_irq_has_action (data))pr_info ("Failed to obtain physical IRQ %d\n" , irq);
Remove this if and change the pr_info() to a pr_warn().
This hypercall never fails in practice, but it's still useful to have the message in case on some systems it does.
Quoted 7 lines
drivers/xen/events/events_base.c +0
-1return 0 ; }@@ -769,15 +762,13 @@ error_irq:int xen_destroy_irq (int irq) { -struct irq_desc *desc;
drivers/xen/events/events_base.c error_irq: · line 772
Quoted 10 lines
drivers/xen/events/events_base.c +1
-2struct physdev_unmap_pirq unmap_irq;struct irq_info *info =info_for_irq (irq);int rc = -ENOENT ;mutex_lock (&irq_mapping_update_lock); - desc =irq_to_desc (irq); -if (!desc) +if (!irq_is_allocated (irq)) goto out;
Remove this test. The only caller of xen_destroy_irq() will only do so if the irq was previously fully setup.
I think this means you don't need to introduce the irqd_irq_has_action() and irq_is_allocated() helpers.
David
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] xen: Get rid of the last irq_desc abuse
In reply to Thomas Gleixnerxen: Get rid of the last irq_desc abuse
Commit-ID: 02893afdd310fab8f41f6afbe5233c6609ec19ed Gitweb: http://git.kernel.org/tip/02893afdd310fab8f41f6afbe5233c6609ec19ed Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:20 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:53 +0100
xen: Get rid of the last irq_desc abuse
Warn if any PIRQ cannot be bound to an event channel. Remove the check for irq_desc->action. This hypercall never fails in practice so we can emit a warning unconditionally.
Remove a check for a valid irq desc. The only caller of xen_destroy_irq() will only do so if the irq was previously fully setup, which means the descriptor has been allocated as well.
--- drivers/xen/events/events_base.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/xen/events/events_base.c +1 -14
@@ -487,13 +487,6 @@ static void pirq_query_unmask(int irq) info->u.pirq.flags |=PIRQ_NEEDS_EOI ; } -static bool probing_irq (int irq) -{ -struct irq_desc *desc =irq_to_desc (irq); - -return desc && desc->action ==NULL ; -} -static void eoi_pirq (struct irq_data *data) {int evtchn =evtchn_from_irq (data->irq);
@@ -535,8 +528,7 @@ static unsigned int __startup_pirq(unsigned int irq) BIND_PIRQ__WILL_SHARE :0 ; rc =HYPERVISOR_event_channel_op (EVTCHNOP_bind_pirq, &bind_pirq);if (rc !=0 ) { -if (!probing_irq (irq)) -pr_info ("Failed to obtain physical IRQ %d\n" , irq); +pr_warn ("Failed to obtain physical IRQ %d\n" , irq);return 0 ; } evtchn = bind_pirq.port;
@@ -769,17 +761,12 @@ error_irq:int xen_destroy_irq (int irq) { -struct irq_desc *desc;struct physdev_unmap_pirq unmap_irq;struct irq_info *info =info_for_irq (irq);int rc = -ENOENT ;mutex_lock (&irq_mapping_update_lock); - desc =irq_to_desc (irq); -if (!desc) - goto out; -if (xen_initial_domain ()) { unmap_irq.pirq = info->u.pirq.pirq; unmap_irq.domid = info->u.pirq.domid;
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] xen: Get rid of the last irq_desc abuse
In reply to Thomas Gleixnerxen: Get rid of the last irq_desc abuse
Commit-ID: 02893afdd310fab8f41f6afbe5233c6609ec19ed Gitweb: http://git.kernel.org/tip/02893afdd310fab8f41f6afbe5233c6609ec19ed Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:20 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:53 +0100
xen: Get rid of the last irq_desc abuse
Warn if any PIRQ cannot be bound to an event channel. Remove the check for irq_desc->action. This hypercall never fails in practice so we can emit a warning unconditionally.
Remove a check for a valid irq desc. The only caller of xen_destroy_irq() will only do so if the irq was previously fully setup, which means the descriptor has been allocated as well.
--- drivers/xen/events/events_base.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-)
drivers/xen/events/events_base.c +1 -14
@@ -487,13 +487,6 @@ static void pirq_query_unmask(int irq) info->u.pirq.flags |=PIRQ_NEEDS_EOI ; } -static bool probing_irq (int irq) -{ -struct irq_desc *desc =irq_to_desc (irq); - -return desc && desc->action ==NULL ; -} -static void eoi_pirq (struct irq_data *data) {int evtchn =evtchn_from_irq (data->irq);
@@ -535,8 +528,7 @@ static unsigned int __startup_pirq(unsigned int irq) BIND_PIRQ__WILL_SHARE :0 ; rc =HYPERVISOR_event_channel_op (EVTCHNOP_bind_pirq, &bind_pirq);if (rc !=0 ) { -if (!probing_irq (irq)) -pr_info ("Failed to obtain physical IRQ %d\n" , irq); +pr_warn ("Failed to obtain physical IRQ %d\n" , irq);return 0 ; } evtchn = bind_pirq.port;
@@ -769,17 +761,12 @@ error_irq:int xen_destroy_irq (int irq) { -struct irq_desc *desc;struct physdev_unmap_pirq unmap_irq;struct irq_info *info =info_for_irq (irq);int rc = -ENOENT ;mutex_lock (&irq_mapping_update_lock); - desc =irq_to_desc (irq); -if (!desc) - goto out; -if (xen_initial_domain ()) { unmap_irq.pirq = info->u.pirq.pirq; unmap_irq.domid = info->u.pirq.domid;
David Vrabel
Reviewed-byRe: [Xen-devel] [tip:irq/core] xen: Get rid of the last irq_desc abuse
Quoted 9 lines · tip-bot for Thomas Gleixner
Commit-ID: 02893afdd310fab8f41f6afbe5233c6609ec19ed Gitweb: http://git.kernel.org/tip/02893afdd310fab8f41f6afbe5233c6609ec19ed Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:20 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:53 +0100xen: Get rid of the last
irq_descabuse
Quoted 7 lines
Warn if any PIRQ cannot be bound to an event channel. Remove the check for
irq_desc->action. This hypercall never fails in practice so we can emit a warning unconditionally.Remove a check for a valid irq desc. The only caller of
xen_destroy_irq()will only do so if the irq was previously fully setup, which means the descriptor has been allocated as well.
Thanks.
David
David Vrabel
Reviewed-byRe: [tip:irq/core] xen: Get rid of the last irq_desc abuse
In reply to tip-bot for Thomas GleixnerQuoted 9 lines · tip-bot for Thomas Gleixner
Commit-ID: 02893afdd310fab8f41f6afbe5233c6609ec19ed Gitweb: http://git.kernel.org/tip/02893afdd310fab8f41f6afbe5233c6609ec19ed Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:20 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:53 +0100xen: Get rid of the last
irq_descabuse
Quoted 7 lines
Warn if any PIRQ cannot be bound to an event channel. Remove the check for
irq_desc->action. This hypercall never fails in practice so we can emit a warning unconditionally.Remove a check for a valid irq desc. The only caller of
xen_destroy_irq()will only do so if the irq was previously fully setup, which means the descriptor has been allocated as well.
Thanks.
David
PATCH 22/26 x86: Add proper vector accounting for HyperV
In reply to Thomas GleixnerHyperV abuses a device interrupt to account for the HYPERVISOR_CALLBACK_VECTOR.
Provide proper accounting as we have for the other vectors as well.
--- arch/x86/include/asm/hardirq.h | 3 +++ arch/x86/kernel/irq.c | 6 ++++++ 2 files changed, 9 insertions(+)
arch/x86/include/asm/hardirq.h +3 -0
@@ -33,6 +33,9 @@ typedef struct {#ifdef CONFIG_X86_MCE_THRESHOLD unsigned int irq_threshold_count;#endif +#if defined(CONFIG_HYPERV ) || defined(CONFIG_XEN ) +unsigned int irq_hv_callback_count; +#endif }____cacheline_aligned irq_cpustat_t;DECLARE_PER_CPU_SHARED_ALIGNED (irq_cpustat_t, irq_stat);
arch/x86/kernel/irq.c +6 -0
@@ -125,6 +125,12 @@ int arch_show_interrupts(struct seq_fileseq_printf (p,"%10u " ,per_cpu (mce_poll_count, j));seq_printf (p," Machine check polls\n" );#endif +#if defined(CONFIG_HYPERV ) || defined(CONFIG_XEN ) +seq_printf (p,"%*s: " , prec,"THR" ); +for_each_online_cpu (j) +seq_printf (p,"%10u " ,irq_stats (j)->irq_hv_callback_count); +seq_printf (p," Hypervisor callback interrupts\n" ); +#endif seq_printf (p,"%*s: %10u\n" , prec,"ERR" ,atomic_read (&irq_err_count));#if defined(CONFIG_X86_IO_APIC )seq_printf (p,"%*s: %10u\n" , prec,"MIS" ,atomic_read (&irq_mis_count));
RE: [patch 22/26] x86: Add proper vector accounting for HyperV
Quoted 9 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Sunday, February 23, 2014 1:40 PM
To: LKML
Cc: Ingo Molnar; Peter Zijlstra; x86; Konrad Rzeszutek Wilk; KY Srinivasan
Subject: [patch 22/26] x86: Add proper vector accounting for HyperV
Quoted 4 lines
HyperV abuses a device interrupt to account for the
HYPERVISOR_CALLBACK_VECTOR.Provide proper accounting as we have for the other vectors as well.
Thomas,
Thank you for cleaning up this code.
Regards,
K. Y
Quoted 43 lines
Signed-off-by Thomas Gleixner <[email protected]>Cc x86 <[email protected]>Cc Konrad Rzeszutek Wilk <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>--- arch/x86/include/asm/hardirq.h | 3 +++ arch/x86/kernel/irq.c | 6 ++++++ 2 files changed, 9 insertions(+)Index:
tip/arch/x86/include/asm/hardirq.h
==========================================================
=========arch/x86/include/asm/hardirq.h +3
-0@@ -33,6 +33,9 @@ typedef struct {#ifdef CONFIG_X86_MCE_THRESHOLD unsigned int irq_threshold_count;#endif +#if defined(CONFIG_HYPERV ) || defined(CONFIG_XEN ) +unsigned int irq_hv_callback_count; +#endif }____cacheline_aligned irq_cpustat_t;DECLARE_PER_CPU_SHARED_ALIGNED (irq_cpustat_t, irq_stat);Index:
tip/arch/x86/kernel/irq.c
==========================================================
=========arch/x86/kernel/irq.c +5
-0@@ -125,6 +125,12 @@ int arch_show_interrupts(struct seq_fileseq_printf (p,"%10u " ,per_cpu (mce_poll_count, j));seq_printf (p," Machine check polls\n" );#endif +#if defined(CONFIG_HYPERV ) || defined(CONFIG_XEN ) +seq_printf (p,"%*s: " , prec,"THR" ); +for_each_online_cpu (j) +seq_printf (p,"%10u " ,irq_stats (j)->irq_hv_callback_count); +seq_printf (p," Hypervisor callback interrupts\n" );#endif seq_printf (p,"%*s: %10u\n" , prec,"ERR" ,atomic_read (&irq_err_count));#if defined(CONFIG_X86_IO_APIC )seq_printf (p,"%*s: %10u\n" , prec,"MIS" ,atomic_read (&irq_mis_count));
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] x86: Add proper vector accounting for HYPERVISOR_CALLBACK_VECTOR
In reply to Thomas Gleixnerx86: Add proper vector accounting for HYPERVISOR_CALLBACK_VECTOR
Commit-ID: 929320e4b4c10708d3477d7e395f0ce7b0cc8744 Gitweb: http://git.kernel.org/tip/929320e4b4c10708d3477d7e395f0ce7b0cc8744 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:20 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:54 +0100
x86: Add proper vector accounting for HYPERVISOR_CALLBACK_VECTOR
HyperV abuses a device interrupt to account for the HYPERVISOR_CALLBACK_VECTOR.
Provide proper accounting as we have for the other vectors as well.
--- arch/x86/include/asm/hardirq.h | 3 +++ arch/x86/kernel/irq.c | 6 ++++++ 2 files changed, 9 insertions(+)
arch/x86/include/asm/hardirq.h +3 -0
@@ -33,6 +33,9 @@ typedef struct {#ifdef CONFIG_X86_MCE_THRESHOLD unsigned int irq_threshold_count;#endif +#if defined(CONFIG_HYPERV ) || defined(CONFIG_XEN ) +unsigned int irq_hv_callback_count; +#endif }____cacheline_aligned irq_cpustat_t;DECLARE_PER_CPU_SHARED_ALIGNED (irq_cpustat_t, irq_stat);
arch/x86/kernel/irq.c +6 -0
@@ -125,6 +125,12 @@ int arch_show_interrupts(struct seq_file *p, int prec)seq_printf (p,"%10u " ,per_cpu (mce_poll_count, j));seq_printf (p," Machine check polls\n" );#endif +#if defined(CONFIG_HYPERV ) || defined(CONFIG_XEN ) +seq_printf (p,"%*s: " , prec,"THR" ); +for_each_online_cpu (j) +seq_printf (p,"%10u " ,irq_stats (j)->irq_hv_callback_count); +seq_printf (p," Hypervisor callback interrupts\n" ); +#endif seq_printf (p,"%*s: %10u\n" , prec,"ERR" ,atomic_read (&irq_err_count));#if defined(CONFIG_X86_IO_APIC )seq_printf (p,"%*s: %10u\n" , prec,"MIS" ,atomic_read (&irq_mis_count));
RE: [patch 22/26] x86: Add proper vector accounting for HyperV
In reply to Thomas GleixnerQuoted 12 lines
-----Original Message-----
From: [email protected] [mailto:linux-kernel- [email protected]] On Behalf Of Thomas Gleixner
Sent: Sunday, 23 February, 2014 3:40 PM
To: LKML
Cc: Ingo Molnar; Peter Zijlstra; x86; Konrad Rzeszutek Wilk; K. Y. Srinivasan
Subject: [patch 22/26] x86: Add proper vector accounting for HyperVHyperV abuses a device interrupt to account for the
HYPERVISOR_CALLBACK_VECTOR.Provide proper accounting as we have for the other vectors as well.
...
Quoted 5 lines
Index:
tip/arch/x86/kernel/irq.c
===================================================================
arch/x86/kernel/irq.c int arch_show_interrupts(struct seq_file · line 133
Quoted 9 lines
arch/x86/kernel/irq.c +6
-0@@ -125,6 +125,12 @@ int arch_show_interrupts(struct seq_fileseq_printf (p,"%10u " ,per_cpu (mce_poll_count, j));seq_printf (p," Machine check polls\n" );#endif +#if defined(CONFIG_HYPERV ) || defined(CONFIG_XEN ) +seq_printf (p,"%*s: " , prec,"THR" ); +for_each_online_cpu (j) +seq_printf (p,"%10u " ,irq_stats (j)->irq_hv_callback_count); +seq_printf (p," Hypervisor callback interrupts\n" ); +#endif
...
Should this have used a different short string than "THR", which is already used for "Threshold APIC interrupts"?
---
Rob Elliott HP Server Storage
PATCH 23/26 xen: Add proper irq accounting for HYPERCALL vector
In reply to Thomas Gleixner--- drivers/xen/events/events_base.c | 1 + 1 file changed, 1 insertion(+)
drivers/xen/events/events_base.c +1 -0
@@ -1239,6 +1239,7 @@ void xen_evtchn_do_upcall(struct pt_regs#ifdef CONFIG_X86 exit_idle ();#endif +inc_irq_stat (irq_hv_callback_count);__xen_evtchn_do_upcall ();
Re: [Xen-devel] [patch 23/26] xen: Add proper irq accounting for HYPERCALL vector
drivers/xen/events/events_base.c void xen_evtchn_do_upcall(struct pt_regs · line 1244
Quoted 9 lines · Thomas Gleixner
drivers/xen/events/events_base.c +1
-0@@ -1239,6 +1239,7 @@ void xen_evtchn_do_upcall(struct pt_regs#ifdef CONFIG_X86 exit_idle ();#endif +inc_irq_stat (irq_hv_callback_count);__xen_evtchn_do_upcall ();
David
Re: [patch 23/26] xen: Add proper irq accounting for HYPERCALL vector
In reply to Thomas Gleixnerdrivers/xen/events/events_base.c void xen_evtchn_do_upcall(struct pt_regs · line 1244
Quoted 9 lines · Thomas Gleixner
drivers/xen/events/events_base.c +1
-0@@ -1239,6 +1239,7 @@ void xen_evtchn_do_upcall(struct pt_regs#ifdef CONFIG_X86 exit_idle ();#endif +inc_irq_stat (irq_hv_callback_count);__xen_evtchn_do_upcall ();
David
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] xen: Add proper irq accounting for HYPERCALL vector
In reply to Thomas Gleixnerxen: Add proper irq accounting for HYPERCALL vector
Commit-ID: 99c8b79d3c165f8e2a6247c14bfa1429e7efe51f Gitweb: http://git.kernel.org/tip/99c8b79d3c165f8e2a6247c14bfa1429e7efe51f Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:21 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:54 +0100
xen: Add proper irq accounting for HYPERCALL vector
--- drivers/xen/events/events_base.c | 1 + 1 file changed, 1 insertion(+)
drivers/xen/events/events_base.c +1 -0
@@ -1235,6 +1235,7 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)#ifdef CONFIG_X86 exit_idle ();#endif +inc_irq_stat (irq_hv_callback_count);__xen_evtchn_do_upcall ();
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] xen: Add proper irq accounting for HYPERCALL vector
In reply to Thomas Gleixnerxen: Add proper irq accounting for HYPERCALL vector
Commit-ID: 99c8b79d3c165f8e2a6247c14bfa1429e7efe51f Gitweb: http://git.kernel.org/tip/99c8b79d3c165f8e2a6247c14bfa1429e7efe51f Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:21 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:54 +0100
xen: Add proper irq accounting for HYPERCALL vector
--- drivers/xen/events/events_base.c | 1 + 1 file changed, 1 insertion(+)
drivers/xen/events/events_base.c +1 -0
@@ -1235,6 +1235,7 @@ void xen_evtchn_do_upcall(struct pt_regs *regs)#ifdef CONFIG_X86 exit_idle ();#endif +inc_irq_stat (irq_hv_callback_count);__xen_evtchn_do_upcall ();
PATCH 24/26 genirq: Provide handle_percpu_simple_irq()
In reply to Thomas GleixnerSpecial case for vmbus to replace their homegrown flow handler.
Not sure whether we need it at all. I can't see a reason why that needs special handling at all if CONFIG_HYPERV=n
--- include/linux/irq.h | 1 + kernel/irq/chip.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)
include/linux/irq.h +1 -0
@@ -423,6 +423,7 @@ extern void handle_edge_irq(unsigned intextern void handle_edge_eoi_irq (unsigned int irq,struct irq_desc *desc);extern void handle_simple_irq (unsigned int irq,struct irq_desc *desc);extern void handle_percpu_irq (unsigned int irq,struct irq_desc *desc); +extern void handle_percpu_simple_irq (unsigned int irq,struct irq_desc *desc);extern void handle_percpu_devid_irq (unsigned int irq,struct irq_desc *desc);extern void handle_bad_irq (unsigned int irq,struct irq_desc *desc);extern void handle_nested_irq (unsigned int irq);
kernel/irq/chip.c +15 -0
@@ -623,6 +623,21 @@ handle_percpu_irq(unsigned int irq, stru }/** +* handle_percpu_simple_irq - Per CPU local irq handler +* @irq: the interrupt number +* @desc: the interrupt description structure for this irq +* +* Per CPU interrupts on SMP machines without locking +* requirements. No ack/eoi handling. +*/ +void +handle_percpu_simple_irq (unsigned int irq,struct irq_desc *desc) +{ +kstat_incr_irqs_this_cpu (irq, desc); +handle_irq_event_percpu (desc, desc->action); +} + +/** * handle_percpu_devid_irq - Per CPU local irq handler with per cpu dev ids * @irq: the interrupt number * @desc: the interrupt description structure for this irq
RE: [patch 24/26] genirq: Provide handle_percpu_simple_irq()
Quoted 9 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Sunday, February 23, 2014 1:40 PM
To: LKML
Cc: Ingo Molnar; Peter Zijlstra; KY Srinivasan; Greg Kroah-Hartman
Subject: [patch 24/26] genirq: Providehandle_percpu_simple_irq()
Quoted 4 lines
Special case for vmbus to replace their homegrown flow handler.
Not sure whether we need it at all. I can't see a reason why that needs special handling at all if
CONFIG_HYPERV=n
Thomas,
Thank you for cleaning up this code. All of the VMBUS code is active only if CONFIG_HYPERV is set.
Regards,
K. Y
Quoted 48 lines
Not-Yet-Signed-off-by Thomas Gleixner <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc Greg Kroah-Hartman <[email protected]>--- include/linux/irq.h | 1 + kernel/irq/chip.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+)Index:
tip/include/linux/irq.h
==========================================================
=========include/linux/irq.h +0
-0@@ -423,6 +423,7 @@ extern void handle_edge_irq(unsigned int externvoid
handle_edge_eoi_irq(unsigned int irq, struct irq_desc *desc); extern voidhandle_simple_irq(unsigned int irq, struct irq_desc *desc); extern voidhandle_percpu_irq(unsigned int irq, struct irq_desc *desc);include/linux/irq.h +2
-0+extern void handle_percpu_simple_irq (unsigned int irq,struct irq_desc +*desc); extern void handle_percpu_devid_irq(unsigned int irq, struct irq_desc*desc); extern void
handle_bad_irq(unsigned int irq, struct irq_desc *desc); extern voidhandle_nested_irq(unsigned int irq);
Index:tip/kernel/irq/chip.c
==========================================================
=========kernel/irq/chip.c +13
-0@@ -623,6 +623,21 @@ handle_percpu_irq(unsigned int irq, stru }/** +* handle_percpu_simple_irq - Per CPU local irq handler +* @irq: the interrupt number +* @desc: the interrupt description structure for this irq +* +* Per CPU interrupts on SMP machines without locking +* requirements. No ack/eoi handling. +*/ +void +handle_percpu_simple_irq (unsigned int irq,struct irq_desc *desc) { +kstat_incr_irqs_this_cpu (irq, desc); +handle_irq_event_percpu (desc, desc->action); } + +/** * handle_percpu_devid_irq - Per CPU local irq handler with per cpu dev ids * @irq: the interrupt number * @desc: the interrupt description structure for this irq
PATCH 25/26 x86: hyperv: Cleanup the irq mess
In reply to Thomas GleixnerThe vmbus/hyperv interrupt handling is another complete trainwreck and probably the worst of all currently in tree.
If CONFIG_HYPERV=y then the interrupt delivery to the vmbus happens via the direct HYPERVISOR_CALLBACK_VECTOR. So far so good, but:
The driver requests first a normal device interrupt. The only reason to do so is to increment the interrupt stats of that device interrupt.
We have proper accounting mechanisms for direct vectors, but of course it's too much effort to add that 5 lines of code.
Aside of that the alloc_intr_gate() is not protected against reallocation which makes module reload impossible.
If CONFIG_HYPERV=n then the vmbus request a regular device interrupt via request_irq() and installs it's own private flow handler. Of course this lacks any explanation why it can't use the standard flow handler or the existing handle_percpu_irq handler.
Solution to the problem is simple to rip out the whole mess and implement it correctly.
First of all move all that code to arch/x86/kernel/cpu/mshyperv.c
For the CONFIG_HYPERV=y case merily install the HYPERVISOR_CALLBACK_VECTOR with proper reallocation protection and use the proper direct vector accounting mechanism.
For the CONFIG_HYPERV=n case request the device irq and install the weird flow handler.
If the special flow handler can go away, which I assume to be true, then this simplifies the code even further.
--- arch/x86/include/asm/mshyperv.h | 4 + arch/x86/kernel/cpu/mshyperv.c | 97 ++++++++++++++++++++++++---------------- drivers/hv/vmbus_drv.c | 39 +--------------- 3 files changed, 66 insertions(+), 74 deletions(-)
arch/x86/include/asm/mshyperv.h +3 -1
@@ -2,6 +2,7 @@#define _ASM_X86_MSHYPER_H#include <linux/types.h> +#include <linux/interrupt.h> #include <asm/hyperv.h> struct ms_hyperv_info {
@@ -16,6 +17,7 @@ void hyperv_callback_vector(void);#define trace_hyperv_callback_vector hyperv_callback_vector#endif void hyperv_vector_handler (struct pt_regs *regs); -void hv_register_vmbus_handler (int irq,irq_handler_t handler); +int hv_setup_vmbus_irq (int irq,irq_handler_t handler,void *dev_id); +void hv_remove_vmbus_irq (int irq,void *dev_id);#endif
arch/x86/kernel/cpu/mshyperv.c +59 -38
112 lines not on this page · raw message
drivers/hv/vmbus_drv.c +4 -35
@@ -25,7 +25,6 @@#include <linux/init.h> #include <linux/module.h> #include <linux/device.h> -#include <linux/irq.h> #include <linux/interrupt.h> #include <linux/sysctl.h> #include <linux/slab.h>
@@ -558,9 +557,6 @@ static struct bus_type hv_bus = { .dev_groups = vmbus_groups, }; -static const char *driver_name ="hyperv" ; - -struct onmessage_work_context {struct work_struct work;struct hv_message msg;
@@ -677,19 +673,6 @@ static irqreturn_t vmbus_isr(int irq, vo }/* -* vmbus interrupt flow handler: -* vmbus interrupts can concurrently occur on multiple CPUs and -* can be handled concurrently. -*/ - -static void vmbus_flow_handler (unsigned int irq,struct irq_desc *desc) -{ -kstat_incr_irqs_this_cpu (irq, desc); - - desc->action->handler (irq, desc->action->dev_id); -} - -/* * vmbus_bus_init -Main vmbus driver initialization routine. * * Here, we
@@ -715,26 +698,13 @@ static int vmbus_bus_init(int irq)if (ret) goto err_cleanup; - ret =request_irq (irq, vmbus_isr,0 , driver_name, hv_acpi_dev); + ret =hv_setup_vmbus_irq (irq, vmbus_isr, hv_acpi_dev);if (ret !=0 ) { -pr_err ("Unable to request IRQ %d\n" , - irq); +pr_err ("Unable to request IRQ %d\n" , irq); goto err_unregister; } -/* -* Vmbus interrupts can be handled concurrently on -* different CPUs. Establish an appropriate interrupt flow -* handler that can support this model. -*/ -irq_set_handler (irq, vmbus_flow_handler); - -/* -* Register our interrupt handler. -*/ -hv_register_vmbus_handler (irq, vmbus_isr); - ret =hv_synic_alloc ();if (ret) goto err_alloc;
@@ -753,7 +723,7 @@ static int vmbus_bus_init(int irq) err_alloc:hv_synic_free (); -free_irq (irq, hv_acpi_dev); +hv_remove_vmbus_irq (irq, hv_acpi_dev); err_unregister:bus_unregister (&hv_bus);
@@ -978,8 +948,7 @@ cleanup: static void __exit vmbus_exit(void) { - -free_irq (irq, hv_acpi_dev); +hv_remove_vmbus_irq (irq, hv_acpi_dev);vmbus_free_channels ();bus_unregister (&hv_bus);hv_cleanup ();
RE: [patch 25/26] x86: hyperv: Cleanup the irq mess
Quoted 26 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Sunday, February 23, 2014 1:40 PM
To: LKML
Cc: Ingo Molnar; Peter Zijlstra; x86; KY Srinivasan; Greg Kroah-Hartman; linuxdrivers
Subject: [patch 25/26] x86: hyperv: Cleanup the irq messThe vmbus/hyperv interrupt handling is another complete trainwreck and probably the worst of all currently in tree.
If
CONFIG_HYPERV=ythen the interrupt delivery to the vmbus happens via the directHYPERVISOR_CALLBACK_VECTOR. So far so good, but:The driver requests first a normal device interrupt. The only reason to do so is to increment the interrupt stats of that device interrupt.
We have proper accounting mechanisms for direct vectors, but of course it's too much effort to add that 5 lines of code.
Aside of that the
alloc_intr_gate()is not protected against reallocation which makes module reload impossible.
Quoted 7 lines
If
CONFIG_HYPERV=nthen the vmbus request a regular device interrupt viarequest_irq()and installs it's own private flow handler. Of course this lacks any explanation why it can't use the standard flow handler or the existinghandle_percpu_irqhandler.Solution to the problem is simple to rip out the whole mess and implement it correctly.
Thomas,
Thank you for cleaning up this code. When CONFIG_HYPERV== n, none of the VMBUS code is active. The special case can go away as you have noted.
Regards,
K. Y
Quoted 247 lines
First of all move all that code to
arch/x86/kernel/cpu/mshyperv.cFor the
CONFIG_HYPERV=ycase merily install theHYPERVISOR_CALLBACK_VECTORwith proper reallocation protection and use the proper direct vector accounting mechanism.For the
CONFIG_HYPERV=ncase request the device irq and install the weird flow handler.If the special flow handler can go away, which I assume to be true, then this simplifies the code even further.
Signed-off-by Thomas Gleixner <[email protected]>Cc x86 <[email protected]>Cc "K. Y. Srinivasan" <[email protected]>Cc Greg Kroah-Hartman <[email protected]>Cc linuxdrivers <[email protected]>--- arch/x86/include/asm/mshyperv.h | 4 + arch/x86/kernel/cpu/mshyperv.c | 97 ++++++++++++++++++++++++------ ---------- drivers/hv/vmbus_drv.c | 39 +--------------- 3 files changed, 66 insertions(+), 74 deletions(-)Index:
tip/arch/x86/include/asm/mshyperv.h
==========================================================
=========arch/x86/include/asm/mshyperv.h +1
-0@@ -2,6 +2,7 @@#define _ASM_X86_MSHYPER_H#include <linux/types.h> +#include <linux/interrupt.h> #include <asm/hyperv.h> struct ms_hyperv_info {@@ -16,6 +17,7 @@ void hyperv_callback_vector(void); #define
trace_hyperv_callback_vectorhyperv_callback_vector#endif voidhyperv_vector_handler(struct pt_regs *regs); -voidhv_register_vmbus_handler(int irq, irq_handler_t handler);arch/x86/include/asm/mshyperv.h +2
-0+int hv_setup_vmbus_irq (int irq,irq_handler_t handler,void *dev_id); +void hv_remove_vmbus_irq (int irq,void *dev_id);#endif Index:
tip/arch/x86/kernel/cpu/mshyperv.c
==========================================================
=========arch/x86/kernel/cpu/mshyperv.c +54
-10@@ -17,6 +17,7 @@#include <linux/hardirq.h> #include <linux/efi.h> #include <linux/interrupt.h> +#include <linux/irq.h> #include <asm/processor.h> #include <asm/hypervisor.h> #include <asm/hyperv.h> @@ -30,6 +31,64 @@struct ms_hyperv_info ms_hyperv;EXPORT_SYMBOL_GPL (ms_hyperv); +#ifdef CONFIG_HYPERV +static irq_handler_t *vmbus_handler; + +void hyperv_vector_handler (struct pt_regs *regs) { +struct pt_regs *old_regs =set_irq_regs (regs); + +irq_enter (); +exit_idle (); + +inc_irq_stat (irq_hv_callback_count); +if (vmbus_handler) +vmbus_handler (); + +irq_exit (); +set_irq_regs (old_regs); +} + +int hv_setup_vmbus_irq (int irq,irq_handler_t *handler,void *dev_id) { + vmbus_handler = handler; +/* +* Setup the IDT for hypervisor callback. Prevent reallocation +* at module reload. +*/ +if (!test_bit (HYPERVISOR_CALLBACK_VECTOR , used_vectors)) +alloc_intr_gate (HYPERVISOR_CALLBACK_VECTOR , + hyperv_callback_vector); +} + +void hv_remove_vmbus_irq (unsigned int irq,void *dev_id) { +/* We have no way to deallocate the interrupt gate */ + vmbus_handler =NULL ; +} +#else +int hv_setup_vmbus_irq (int irq,irq_handler_t handler,void *dev_id) { +int ret =request_irq (irq, handler,0 ,"hyperv" , dev_id); + +if (!ret) { +/* +* Vmbus interrupts can be handled concurrently on +* different CPUs. Install the simple percpu flow handler. +*/ +irq_set_handler (irq, handle_percpu_simple_irq); + } +return ret; +} + +void hv_remove_vmbus_irq (int irq,void *dev_id) { +free_irq (irq, dev_id);; +} +#endif +EXPORT_SYMBOL_GPL (hv_setup_vmbus_irq); +EXPORT_SYMBOL_GPL (hv_remove_vmbus_irq); +static uint32_t __init ms_hyperv_platform (void ) {u32 eax;@@ -113,41 +172,3 @@ const __refconst struct hypervisor_x86 x .init_platform = ms_hyperv_init_platform, };EXPORT_SYMBOL (x86_hyper_ms_hyperv); - -#if IS_ENABLED (CONFIG_HYPERV ) -static int vmbus_irq =-1 ; -static irq_handler_t vmbus_isr; - -void hv_register_vmbus_handler(int irq, irq_handler_t handler) -{ -/* -* Setup the IDT for hypervisor callback. -*/ - alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
hyperv_callback_vector);arch/x86/kernel/cpu/mshyperv.c +0
-23- - vmbus_irq = irq; - vmbus_isr = handler; -} - -void hyperv_vector_handler(struct pt_regs *regs) -{ -struct pt_regs *old_regs =set_irq_regs (regs); -struct irq_desc *desc; - -irq_enter (); -exit_idle (); - - desc =irq_to_desc (vmbus_irq); - -if (desc) -generic_handle_irq_desc (vmbus_irq, desc); - -irq_exit (); -set_irq_regs (old_regs); -} -#else -void hv_register_vmbus_handler(int irq, irq_handler_t handler) -{ -} -#endif -EXPORT_SYMBOL_GPL (hv_register_vmbus_handler);Index:
tip/drivers/hv/vmbus_drv.c
==========================================================
=========drivers/hv/vmbus_drv.c +4
-34@@ -25,7 +25,6 @@#include <linux/init.h> #include <linux/module.h> #include <linux/device.h> -#include <linux/irq.h> #include <linux/interrupt.h> #include <linux/sysctl.h> #include <linux/slab.h> @@ -558,9 +557,6 @@ static struct bus_type hv_bus = { .dev_groups = vmbus_groups, }; -static const char *driver_name ="hyperv" ; - -struct onmessage_work_context {struct work_struct work;struct hv_message msg;@@ -677,19 +673,6 @@ static irqreturn_t vmbus_isr(int irq, vo }/* -* vmbus interrupt flow handler: -* vmbus interrupts can concurrently occur on multiple CPUs and -* can be handled concurrently. -*/ - -static void vmbus_flow_handler(unsigned int irq, struct irq_desc *desc) -{ -kstat_incr_irqs_this_cpu (irq, desc); - - desc->action->handler (irq, desc->action->dev_id); -} - -/* * vmbus_bus_init -Main vmbus driver initialization routine. * * Here, we @@ -715,26 +698,13 @@ static int vmbus_bus_init(int irq)if (ret) goto err_cleanup; - ret =request_irq (irq, vmbus_isr,0 , driver_name, hv_acpi_dev); + ret =hv_setup_vmbus_irq (irq, vmbus_isr, hv_acpi_dev);if (ret !=0 ) { -pr_err ("Unable to request IRQ %d\n" , - irq); +pr_err ("Unable to request IRQ %d\n" , irq); goto err_unregister; } -/* -* Vmbus interrupts can be handled concurrently on -* different CPUs. Establish an appropriate interrupt flow -* handler that can support this model. -*/ -irq_set_handler (irq, vmbus_flow_handler); - -/* -* Register our interrupt handler. -*/ -hv_register_vmbus_handler (irq, vmbus_isr); - ret =hv_synic_alloc ();if (ret) goto err_alloc;@@ -753,7 +723,7 @@ static int vmbus_bus_init(int irq) err_alloc:hv_synic_free (); -free_irq (irq, hv_acpi_dev); +hv_remove_vmbus_irq (irq, hv_acpi_dev); err_unregister:bus_unregister (&hv_bus);@@ -978,8 +948,7 @@ cleanup: static void __exit vmbus_exit(void) { - -free_irq (irq, hv_acpi_dev); +hv_remove_vmbus_irq (irq, hv_acpi_dev);vmbus_free_channels ();bus_unregister (&hv_bus);hv_cleanup ();
RE: [patch 25/26] x86: hyperv: Cleanup the irq mess
Quoted 29 lines · KY Srinivasan
Quoted 29 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Sunday, February 23, 2014 1:40 PM
To: LKML
Cc: Ingo Molnar; Peter Zijlstra; x86; KY Srinivasan; Greg Kroah-Hartman; linuxdrivers
Subject: [patch 25/26] x86: hyperv: Cleanup the irq messThe vmbus/hyperv interrupt handling is another complete trainwreck and probably the worst of all currently in tree.
If
CONFIG_HYPERV=ythen the interrupt delivery to the vmbus happens via the directHYPERVISOR_CALLBACK_VECTOR. So far so good, but:The driver requests first a normal device interrupt. The only reason to do so is to increment the interrupt stats of that device interrupt.
We have proper accounting mechanisms for direct vectors, but of course it's too much effort to add that 5 lines of code.
Aside of that the
alloc_intr_gate()is not protected against reallocation which makes module reload impossible.If
CONFIG_HYPERV=nthen the vmbus request a regular device interrupt viarequest_irq()and installs it's own private flow handler. Of course this lacks any explanation why it can't use the standard flow handler or the existinghandle_percpu_irqhandler.
Quoted 7 lines
Quoted 2 lines
Solution to the problem is simple to rip out the whole mess and implement it correctly.
Thomas,
Thank you for cleaning up this code. When
CONFIG_HYPERV==n, none of the VMBUS code is active. The special case can go away as you have noted.
So, if CONFIG_HYPERV=n then you do not need the request_irq() fallback at all, right? Somehow I missed the HYPERV dependency of the VMBUS stuff
That makes stuff even simpler as we can get rid of those extra cases including the extra flow handler.
New patch below.
Thanks,
tglx
---
arch/x86/include/asm/mshyperv.h | 4 +- arch/x86/kernel/cpu/mshyperv.c | 78 ++++++++++++++++++++-------------------- drivers/hv/vmbus_drv.c | 39 ++------------------ 3 files changed, 47 insertions(+), 74 deletions(-)
arch/x86/include/asm/mshyperv.h +3 -1
@@ -2,6 +2,7 @@#define _ASM_X86_MSHYPER_H#include <linux/types.h> +#include <linux/interrupt.h> #include <asm/hyperv.h> struct ms_hyperv_info {
@@ -16,6 +17,7 @@ void hyperv_callback_vector(void);#define trace_hyperv_callback_vector hyperv_callback_vector#endif void hyperv_vector_handler (struct pt_regs *regs); -void hv_register_vmbus_handler (int irq,irq_handler_t handler); +int hv_setup_vmbus_irq (int irq,irq_handler_t handler,void *dev_id); +void hv_remove_vmbus_irq (int irq,void *dev_id);#endif
arch/x86/kernel/cpu/mshyperv.c +40 -38
93 lines not on this page · raw message
drivers/hv/vmbus_drv.c +4 -35
@@ -25,7 +25,6 @@#include <linux/init.h> #include <linux/module.h> #include <linux/device.h> -#include <linux/irq.h> #include <linux/interrupt.h> #include <linux/sysctl.h> #include <linux/slab.h>
@@ -558,9 +557,6 @@ static struct bus_type hv_bus = { .dev_groups = vmbus_groups, }; -static const char *driver_name ="hyperv" ; - -struct onmessage_work_context {struct work_struct work;struct hv_message msg;
@@ -677,19 +673,6 @@ static irqreturn_t vmbus_isr(int irq, vo }/* -* vmbus interrupt flow handler: -* vmbus interrupts can concurrently occur on multiple CPUs and -* can be handled concurrently. -*/ - -static void vmbus_flow_handler (unsigned int irq,struct irq_desc *desc) -{ -kstat_incr_irqs_this_cpu (irq, desc); - - desc->action->handler (irq, desc->action->dev_id); -} - -/* * vmbus_bus_init -Main vmbus driver initialization routine. * * Here, we
@@ -715,26 +698,13 @@ static int vmbus_bus_init(int irq)if (ret) goto err_cleanup; - ret =request_irq (irq, vmbus_isr,0 , driver_name, hv_acpi_dev); + ret =hv_setup_vmbus_irq (irq, vmbus_isr, hv_acpi_dev);if (ret !=0 ) { -pr_err ("Unable to request IRQ %d\n" , - irq); +pr_err ("Unable to request IRQ %d\n" , irq); goto err_unregister; } -/* -* Vmbus interrupts can be handled concurrently on -* different CPUs. Establish an appropriate interrupt flow -* handler that can support this model. -*/ -irq_set_handler (irq, vmbus_flow_handler); - -/* -* Register our interrupt handler. -*/ -hv_register_vmbus_handler (irq, vmbus_isr); - ret =hv_synic_alloc ();if (ret) goto err_alloc;
@@ -753,7 +723,7 @@ static int vmbus_bus_init(int irq) err_alloc:hv_synic_free (); -free_irq (irq, hv_acpi_dev); +hv_remove_vmbus_irq (irq, hv_acpi_dev); err_unregister:bus_unregister (&hv_bus);
@@ -978,8 +948,7 @@ cleanup: static void __exit vmbus_exit(void) { - -free_irq (irq, hv_acpi_dev); +hv_remove_vmbus_irq (irq, hv_acpi_dev);vmbus_free_channels ();bus_unregister (&hv_bus);hv_cleanup ();
KY Srinivasan
Acked-byRE: [patch 25/26] x86: hyperv: Cleanup the irq mess
Quoted 48 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Tuesday, February 25, 2014 11:10 AM
To: KY Srinivasan
Cc: LKML; Ingo Molnar; Peter Zijlstra; x86; Greg Kroah-Hartman; linuxdrivers
Subject: RE: [patch 25/26] x86: hyperv: Cleanup the irq messQuoted 30 lines · KY Srinivasan
Quoted 30 lines
-----Original Message-----
From: Thomas Gleixner [mailto:[email protected]]
Sent: Sunday, February 23, 2014 1:40 PM
To: LKML
Cc: Ingo Molnar; Peter Zijlstra; x86; KY Srinivasan; Greg Kroah-Hartman; linuxdrivers
Subject: [patch 25/26] x86: hyperv: Cleanup the irq messThe vmbus/hyperv interrupt handling is another complete trainwreck and probably the worst of all currently in tree.
If
CONFIG_HYPERV=ythen the interrupt delivery to the vmbus happens via the directHYPERVISOR_CALLBACK_VECTOR. So far so good, but:The driver requests first a normal device interrupt. The only reason to do so is to increment the interrupt stats of that device interrupt.
We have proper accounting mechanisms for direct vectors, but of course it's too much effort to add that 5 lines of code.
Aside of that the
alloc_intr_gate()is not protected against reallocation which makes module reload impossible.If
CONFIG_HYPERV=nthen the vmbus request a regular device interrupt viarequest_irq()and installs it's own private flow handler. Of course this lacks any explanation why it can't use the standard flow handler or the existinghandle_percpu_irqhandler.Quoted 7 lines
Quoted 2 lines
Solution to the problem is simple to rip out the whole mess and implement it correctly.
Thomas,
Thank you for cleaning up this code. When
CONFIG_HYPERV==n, none of the VMBUS code is active. The special case can go away as you have noted.
Quoted 7 lines
So, if
CONFIG_HYPERV=nthen you do not need therequest_irq()fallback at all, right? Somehow I missed the HYPERV dependency of the VMBUS stuffThat makes stuff even simpler as we can get rid of those extra cases including the extra flow handler.
New patch below.
Thanks Thomas.
Quoted 221 lines
Thanks,
tglx
---arch/x86/include/asm/mshyperv.h | 4 +- arch/x86/kernel/cpu/mshyperv.c | 78 ++++++++++++++++++++------------- ------- drivers/hv/vmbus_drv.c | 39 ++------------------ 3 files changed, 47 insertions(+), 74 deletions(-)Index:
tip/arch/x86/include/asm/mshyperv.h
==========================================================
=========arch/x86/include/asm/mshyperv.h +1
-0@@ -2,6 +2,7 @@#define _ASM_X86_MSHYPER_H#include <linux/types.h> +#include <linux/interrupt.h> #include <asm/hyperv.h> struct ms_hyperv_info {@@ -16,6 +17,7 @@ void hyperv_callback_vector(void); #define
trace_hyperv_callback_vectorhyperv_callback_vector#endif voidhyperv_vector_handler(struct pt_regs *regs); -voidhv_register_vmbus_handler(int irq, irq_handler_t handler);arch/x86/include/asm/mshyperv.h +2
-0+int hv_setup_vmbus_irq (int irq,irq_handler_t handler,void *dev_id); +void hv_remove_vmbus_irq (int irq,void *dev_id);#endif Index:
tip/arch/x86/kernel/cpu/mshyperv.c
==========================================================
=========arch/x86/kernel/cpu/mshyperv.c +37
-10@@ -17,6 +17,7 @@#include <linux/hardirq.h> #include <linux/efi.h> #include <linux/interrupt.h> +#include <linux/irq.h> #include <asm/processor.h> #include <asm/hypervisor.h> #include <asm/hyperv.h> @@ -30,6 +31,45 @@struct ms_hyperv_info ms_hyperv;EXPORT_SYMBOL_GPL (ms_hyperv); +#ifdef CONFIG_HYPERV +static irq_handler_t *vmbus_handler; + +void hyperv_vector_handler (struct pt_regs *regs) { +struct pt_regs *old_regs =set_irq_regs (regs); + +irq_enter (); +exit_idle (); + +inc_irq_stat (irq_hv_callback_count); +if (vmbus_handler) +vmbus_handler (); + +irq_exit (); +set_irq_regs (old_regs); +} + +int hv_setup_vmbus_irq (int irq,irq_handler_t *handler,void *dev_id) { + vmbus_handler = handler; +/* +* Setup the IDT for hypervisor callback. Prevent reallocation +* at module reload. +*/ +if (!test_bit (HYPERVISOR_CALLBACK_VECTOR , used_vectors)) +alloc_intr_gate (HYPERVISOR_CALLBACK_VECTOR , + hyperv_callback_vector); +} + +void hv_remove_vmbus_irq (unsigned int irq,void *dev_id) { +/* We have no way to deallocate the interrupt gate */ + vmbus_handler =NULL ; +} +EXPORT_SYMBOL_GPL (hv_setup_vmbus_irq); +EXPORT_SYMBOL_GPL (hv_remove_vmbus_irq); +#endif +static uint32_t __init ms_hyperv_platform (void ) {u32 eax;@@ -113,41 +153,3 @@ const __refconst struct hypervisor_x86 x .init_platform = ms_hyperv_init_platform, };EXPORT_SYMBOL (x86_hyper_ms_hyperv); - -#if IS_ENABLED (CONFIG_HYPERV ) -static int vmbus_irq =-1 ; -static irq_handler_t vmbus_isr; - -void hv_register_vmbus_handler(int irq, irq_handler_t handler) -{ -/* -* Setup the IDT for hypervisor callback. -*/ - alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR,
hyperv_callback_vector);arch/x86/kernel/cpu/mshyperv.c +0
-23- - vmbus_irq = irq; - vmbus_isr = handler; -} - -void hyperv_vector_handler(struct pt_regs *regs) -{ -struct pt_regs *old_regs =set_irq_regs (regs); -struct irq_desc *desc; - -irq_enter (); -exit_idle (); - - desc =irq_to_desc (vmbus_irq); - -if (desc) -generic_handle_irq_desc (vmbus_irq, desc); - -irq_exit (); -set_irq_regs (old_regs); -} -#else -void hv_register_vmbus_handler(int irq, irq_handler_t handler) -{ -} -#endif -EXPORT_SYMBOL_GPL (hv_register_vmbus_handler);Index:
tip/drivers/hv/vmbus_drv.c
==========================================================
=========drivers/hv/vmbus_drv.c +4
-34@@ -25,7 +25,6 @@#include <linux/init.h> #include <linux/module.h> #include <linux/device.h> -#include <linux/irq.h> #include <linux/interrupt.h> #include <linux/sysctl.h> #include <linux/slab.h> @@ -558,9 +557,6 @@ static struct bus_type hv_bus = { .dev_groups = vmbus_groups, }; -static const char *driver_name ="hyperv" ; - -struct onmessage_work_context {struct work_struct work;struct hv_message msg;@@ -677,19 +673,6 @@ static irqreturn_t vmbus_isr(int irq, vo }/* -* vmbus interrupt flow handler: -* vmbus interrupts can concurrently occur on multiple CPUs and -* can be handled concurrently. -*/ - -static void vmbus_flow_handler(unsigned int irq, struct irq_desc *desc) -{ -kstat_incr_irqs_this_cpu (irq, desc); - - desc->action->handler (irq, desc->action->dev_id); -} - -/* * vmbus_bus_init -Main vmbus driver initialization routine. * * Here, we @@ -715,26 +698,13 @@ static int vmbus_bus_init(int irq)if (ret) goto err_cleanup; - ret =request_irq (irq, vmbus_isr,0 , driver_name, hv_acpi_dev); + ret =hv_setup_vmbus_irq (irq, vmbus_isr, hv_acpi_dev);if (ret !=0 ) { -pr_err ("Unable to request IRQ %d\n" , - irq); +pr_err ("Unable to request IRQ %d\n" , irq); goto err_unregister; } -/* -* Vmbus interrupts can be handled concurrently on -* different CPUs. Establish an appropriate interrupt flow -* handler that can support this model. -*/ -irq_set_handler (irq, vmbus_flow_handler); - -/* -* Register our interrupt handler. -*/ -hv_register_vmbus_handler (irq, vmbus_isr); - ret =hv_synic_alloc ();if (ret) goto err_alloc;@@ -753,7 +723,7 @@ static int vmbus_bus_init(int irq) err_alloc:hv_synic_free (); -free_irq (irq, hv_acpi_dev); +hv_remove_vmbus_irq (irq, hv_acpi_dev); err_unregister:bus_unregister (&hv_bus);@@ -978,8 +948,7 @@ cleanup: static void __exit vmbus_exit(void) { - -free_irq (irq, hv_acpi_dev); +hv_remove_vmbus_irq (irq, hv_acpi_dev);vmbus_free_channels ();bus_unregister (&hv_bus);hv_cleanup ();
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] x86: Hyperv: Cleanup the irq mess
In reply to Thomas Gleixnerx86: Hyperv: Cleanup the irq mess
Commit-ID: 1aec169673d7db113c37367bbc371c2ba8109f06 Gitweb: http://git.kernel.org/tip/1aec169673d7db113c37367bbc371c2ba8109f06 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:22 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:54 +0100
x86: Hyperv: Cleanup the irq mess
The vmbus/hyperv interrupt handling is another complete trainwreck and probably the worst of all currently in tree.
If CONFIG_HYPERV=y then the interrupt delivery to the vmbus happens via the direct HYPERVISOR_CALLBACK_VECTOR. So far so good, but:
The driver requests first a normal device interrupt. The only reason to do so is to increment the interrupt stats of that device interrupt. For no reason it also installs a private flow handler.
We have proper accounting mechanisms for direct vectors, but of course it's too much effort to add that 5 lines of code.
Aside of that the alloc_intr_gate() is not protected against reallocation which makes module reload impossible.
Solution to the problem is simple to rip out the whole mess and implement it correctly.
First of all move all that code to arch/x86/kernel/cpu/mshyperv.c and merily install the HYPERVISOR_CALLBACK_VECTOR with proper reallocation protection and use the proper direct vector accounting mechanism.
--- arch/x86/include/asm/mshyperv.h | 4 ++- arch/x86/kernel/cpu/mshyperv.c | 78 +++++++++++++++++++++-------------------- drivers/hv/vmbus_drv.c | 39 +++------------------ 3 files changed, 47 insertions(+), 74 deletions(-)
arch/x86/include/asm/mshyperv.h +3 -1
@@ -2,6 +2,7 @@#define _ASM_X86_MSHYPER_H#include <linux/types.h> +#include <linux/interrupt.h> #include <asm/hyperv.h> struct ms_hyperv_info {
@@ -16,6 +17,7 @@ void hyperv_callback_vector(void);#define trace_hyperv_callback_vector hyperv_callback_vector#endif void hyperv_vector_handler (struct pt_regs *regs); -void hv_register_vmbus_handler (int irq,irq_handler_t handler); +int hv_setup_vmbus_irq (int irq,irq_handler_t handler,void *dev_id); +void hv_remove_vmbus_irq (int irq,void *dev_id);#endif
arch/x86/kernel/cpu/mshyperv.c +40 -38
93 lines not on this page · raw message
drivers/hv/vmbus_drv.c +4 -35
@@ -25,7 +25,6 @@#include <linux/init.h> #include <linux/module.h> #include <linux/device.h> -#include <linux/irq.h> #include <linux/interrupt.h> #include <linux/sysctl.h> #include <linux/slab.h>
@@ -558,9 +557,6 @@ static struct bus_type hv_bus = { .dev_groups = vmbus_groups, }; -static const char *driver_name ="hyperv" ; - -struct onmessage_work_context {struct work_struct work;struct hv_message msg;
@@ -677,19 +673,6 @@ static irqreturn_t vmbus_isr(int irq, void *dev_id) }/* -* vmbus interrupt flow handler: -* vmbus interrupts can concurrently occur on multiple CPUs and -* can be handled concurrently. -*/ - -static void vmbus_flow_handler (unsigned int irq,struct irq_desc *desc) -{ -kstat_incr_irqs_this_cpu (irq, desc); - - desc->action->handler (irq, desc->action->dev_id); -} - -/* * vmbus_bus_init -Main vmbus driver initialization routine. * * Here, we
@@ -715,26 +698,13 @@ static int vmbus_bus_init(int irq)if (ret) goto err_cleanup; - ret =request_irq (irq, vmbus_isr,0 , driver_name, hv_acpi_dev); + ret =hv_setup_vmbus_irq (irq, vmbus_isr, hv_acpi_dev);if (ret !=0 ) { -pr_err ("Unable to request IRQ %d\n" , - irq); +pr_err ("Unable to request IRQ %d\n" , irq); goto err_unregister; } -/* -* Vmbus interrupts can be handled concurrently on -* different CPUs. Establish an appropriate interrupt flow -* handler that can support this model. -*/ -irq_set_handler (irq, vmbus_flow_handler); - -/* -* Register our interrupt handler. -*/ -hv_register_vmbus_handler (irq, vmbus_isr); - ret =hv_synic_alloc ();if (ret) goto err_alloc;
@@ -753,7 +723,7 @@ static int vmbus_bus_init(int irq) err_alloc:hv_synic_free (); -free_irq (irq, hv_acpi_dev); +hv_remove_vmbus_irq (irq, hv_acpi_dev); err_unregister:bus_unregister (&hv_bus);
@@ -978,8 +948,7 @@ cleanup: static void __exit vmbus_exit(void) { - -free_irq (irq, hv_acpi_dev); +hv_remove_vmbus_irq (irq, hv_acpi_dev);vmbus_free_channels ();bus_unregister (&hv_bus);hv_cleanup ();
PATCH 26/26 genirq: Move kstats_inc_irqs_this_cpu() to core
In reply to Thomas GleixnerNo more users outside the core code. Put it into the poison cabinet. That also gets rid of the linux/irq.h include in kernel_stat.h
--- include/linux/kernel_stat.h | 8 -------- kernel/irq/internals.h | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-)
include/linux/kernel_stat.h +0 -8
@@ -51,15 +51,7 @@ DECLARE_PER_CPU(struct kernel_cpustat, kextern unsigned long long nr_context_switches (void ); -#include <linux/irq.h> extern unsigned int kstat_irqs_cpu (unsigned int irq,int cpu); - -static inline void kstat_incr_irqs_this_cpu (unsigned int irq,struct irq_desc *desc) -{ -__this_cpu_inc (*desc->kstat_irqs); -__this_cpu_inc (kstat.irqs_sum); -} -extern void kstat_incr_irq_this_cpu (unsigned int irq);static inline void kstat_incr_softirqs_this_cpu (unsigned int irq)
kernel/irq/internals.h +7 -0
@@ -6,6 +6,7 @@* of this file for your non core code. */ #include <linux/irqdesc.h> +#include <linux/kernel_stat.h> #ifdef CONFIG_SPARSE_IRQ # define IRQ_BITMAP_BITS (NR_IRQS + 8196)
@@ -180,3 +181,9 @@ static inline bool irqd_has_set(struct i {return d->state_use_accessors & mask; } + +static inline void kstat_incr_irqs_this_cpu (unsigned int irq,struct irq_desc *desc) +{ +__this_cpu_inc (*desc->kstat_irqs); +__this_cpu_inc (kstat.irqs_sum); +}
tip-bot for Thomas Gleixner
merge bot[tip:irq/core] genirq: Move kstat_incr_irqs_this_cpu() to core
genirq: Move kstat_incr_irqs_this_cpu() to core
Commit-ID: 8f945a3325bbe0dd651e2f496a53df9b06fc6d07 Gitweb: http://git.kernel.org/tip/8f945a3325bbe0dd651e2f496a53df9b06fc6d07 Author: Thomas Gleixner <[email protected]> AuthorDate: Sun, 23 Feb 2014 21:40:23 +0000 Committer: Thomas Gleixner <[email protected]> CommitDate: Tue, 4 Mar 2014 17:37:54 +0100
genirq: Move kstat_incr_irqs_this_cpu() to core
No more users outside the core code. Put it into the poison cabinet. That also gets rid of the linux/irq.h include in kernel_stat.h
--- include/linux/kernel_stat.h | 8 -------- kernel/irq/internals.h | 7 +++++++ 2 files changed, 7 insertions(+), 8 deletions(-)
include/linux/kernel_stat.h +0 -8
@@ -51,15 +51,7 @@ DECLARE_PER_CPU(struct kernel_cpustat, kernel_cpustat);extern unsigned long long nr_context_switches (void ); -#include <linux/irq.h> extern unsigned int kstat_irqs_cpu (unsigned int irq,int cpu); - -static inline void kstat_incr_irqs_this_cpu (unsigned int irq,struct irq_desc *desc) -{ -__this_cpu_inc (*desc->kstat_irqs); -__this_cpu_inc (kstat.irqs_sum); -} -extern void kstat_incr_irq_this_cpu (unsigned int irq);static inline void kstat_incr_softirqs_this_cpu (unsigned int irq)
kernel/irq/internals.h +7 -0
@@ -6,6 +6,7 @@* of this file for your non core code. */ #include <linux/irqdesc.h> +#include <linux/kernel_stat.h> #ifdef CONFIG_SPARSE_IRQ # define IRQ_BITMAP_BITS (NR_IRQS + 8196)
@@ -180,3 +181,9 @@ static inline bool irqd_has_set(struct irq_data *d, unsigned int mask) {return d->state_use_accessors & mask; } + +static inline void kstat_incr_irqs_this_cpu (unsigned int irq,struct irq_desc *desc) +{ +__this_cpu_inc (*desc->kstat_irqs); +__this_cpu_inc (kstat.irqs_sum); +}