All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch 00/26] genirq: Another round of tree wide cleanups
@ 2014-02-23 21:40 Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                   ` (25 more replies)
  0 siblings, 26 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra

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(-)





^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 02/26] powerpc:evh_pic: Kill irq_desc abuse
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Zijlstra, Benjamin Herrenschmidt,
	Ashish Kalra, Timur Tabi, Kumar Gala, ppc

[-- Attachment #1: power-evh-pic-kill-irq-desc-abuse.patch --]
[-- Type: text/plain, Size: 2369 bytes --]

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ashish Kalra <ashish.kalra@freescale.com>
Cc: Timur Tabi <timur@freescale.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
---
 arch/powerpc/sysdev/ehv_pic.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Index: tip/arch/powerpc/sysdev/ehv_pic.c
===================================================================
--- tip.orig/arch/powerpc/sysdev/ehv_pic.c
+++ tip/arch/powerpc/sysdev/ehv_pic.c
@@ -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_vecp
 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
 	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 = {



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 01/26] powerpc: irq: Use generic_handle_irq
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Benjamin Herrenschmidt, ppc

[-- Attachment #1: powerpc-irq-use-generic-handle-irq.patch --]
[-- Type: text/plain, Size: 931 bytes --]

No functional change

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
---
 arch/powerpc/kernel/irq.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Index: tip/arch/powerpc/kernel/irq.c
===================================================================
--- tip.orig/arch/powerpc/kernel/irq.c
+++ tip/arch/powerpc/kernel/irq.c
@@ -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);
 



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 01/26] powerpc: irq: Use generic_handle_irq
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra, Ingo Molnar, ppc

No functional change

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
---
 arch/powerpc/kernel/irq.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Index: tip/arch/powerpc/kernel/irq.c
===================================================================
--- tip.orig/arch/powerpc/kernel/irq.c
+++ tip/arch/powerpc/kernel/irq.c
@@ -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);
 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 02/26] powerpc:evh_pic: Kill irq_desc abuse
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra, Ashish Kalra, Ingo Molnar, ppc, Timur Tabi

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ashish Kalra <ashish.kalra@freescale.com>
Cc: Timur Tabi <timur@freescale.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
---
 arch/powerpc/sysdev/ehv_pic.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Index: tip/arch/powerpc/sysdev/ehv_pic.c
===================================================================
--- tip.orig/arch/powerpc/sysdev/ehv_pic.c
+++ tip/arch/powerpc/sysdev/ehv_pic.c
@@ -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_vecp
 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
 	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 = {

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Gavin Shan, Benjamin Herrenschmidt, ppc

[-- Attachment #1: powerpc-eeh-kill-more-abuse-of-irq-desc.patch --]
[-- Type: text/plain, Size: 2728 bytes --]

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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
---
 arch/powerpc/kernel/eeh_driver.c |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

Index: tip/arch/powerpc/kernel/eeh_driver.c
===================================================================
--- tip.orig/arch/powerpc/kernel/eeh_driver.c
+++ tip/arch/powerpc/kernel/eeh_driver.c
@@ -143,15 +143,31 @@ static void eeh_disable_irq(struct pci_d
 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);
-	}
 }
 
 /**



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra, Ingo Molnar, ppc, Gavin Shan

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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
---
 arch/powerpc/kernel/eeh_driver.c |   26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

Index: tip/arch/powerpc/kernel/eeh_driver.c
===================================================================
--- tip.orig/arch/powerpc/kernel/eeh_driver.c
+++ tip/arch/powerpc/kernel/eeh_driver.c
@@ -143,15 +143,31 @@ static void eeh_disable_irq(struct pci_d
 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);
-	}
 }
 
 /**

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 05/26] sh: Use irq_set_affinity instead of homebrewn code
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Paul Mundt, sh

There is no point in having an incomplete copy of irq_set_affinity()
for the hotplug irq migration code.

Use the core function instead.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: sh <linux-sh@vger.kernel.org>
---
 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));
 		}
 	}
 }



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 04/26] xtensa: Use irq_set_affinity instead of homebrewn code
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (2 preceding siblings ...)
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-02-24  0:32   ` Max Filippov
  2014-03-04 16:43   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                   ` (21 subsequent siblings)
  25 siblings, 2 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Chris Zankel, xtensa

[-- Attachment #1: xtensa-irq-use-the-proper-core-functions.patch --]
[-- Type: text/plain, Size: 1838 bytes --]

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()

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Chris Zankel <chris@zankel.net>
Cc: xtensa <linux-xtensa@linux-xtensa.org>
---
 arch/xtensa/kernel/irq.c |   20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

Index: tip/arch/xtensa/kernel/irq.c
===================================================================
--- tip.orig/arch/xtensa/kernel/irq.c
+++ tip/arch/xtensa/kernel/irq.c
@@ -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 *d
 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))
@@ -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 */



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 05/26] sh: Use irq_set_affinity instead of homebrewn code
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Paul Mundt, sh

[-- Attachment #1: sh-irq-use-the-proper-core-functions.patch --]
[-- Type: text/plain, Size: 1377 bytes --]

There is no point in having an incomplete copy of irq_set_affinity()
for the hotplug irq migration code.

Use the core function instead.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: sh <linux-sh@vger.kernel.org>
---
 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));
 		}
 	}
 }



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 07/26] pci: pcie-designware: Remove irq_desc abuse
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Zijlstra, Bjorn Helgaas, Jingoo Han, Mohit Kumar, pci

[-- Attachment #1: pci-pcie-designware-remove-irq-desc-abuse.patch --]
[-- Type: text/plain, Size: 1107 bytes --]

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mohit Kumar <mohit.kumar@st.com>
Cc: pci <linux-pci@vger.kernel.org>
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: tip/drivers/pci/host/pcie-designware.c
===================================================================
--- tip.orig/drivers/pci/host/pcie-designware.c
+++ tip/drivers/pci/host/pcie-designware.c
@@ -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();



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (4 preceding siblings ...)
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-02-24 13:24   ` James Hogan
  2014-02-23 21:40   ` Thomas Gleixner
                   ` (19 subsequent siblings)
  25 siblings, 1 reply; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, James Hogan, metag

[-- Attachment #1: metag-irq-use-the-proper-core-functions.patch --]
[-- Type: text/plain, Size: 1845 bytes --]

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()

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: metag <linux-metag@vger.kernel.org>
---
 arch/metag/kernel/irq.c |   20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

Index: tip/arch/metag/kernel/irq.c
===================================================================
--- tip.orig/arch/metag/kernel/irq.c
+++ tip/arch/metag/kernel/irq.c
@@ -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 *d
 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))
@@ -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 */



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 07/26] pci: pcie-designware: Remove irq_desc abuse
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Zijlstra, Bjorn Helgaas, Jingoo Han, Mohit Kumar, pci

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Jingoo Han <jg1.han@samsung.com>
Cc: Mohit Kumar <mohit.kumar@st.com>
Cc: pci <linux-pci@vger.kernel.org>
---
 drivers/pci/host/pcie-designware.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: tip/drivers/pci/host/pcie-designware.c
===================================================================
--- tip.orig/drivers/pci/host/pcie-designware.c
+++ tip/drivers/pci/host/pcie-designware.c
@@ -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();



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 08/26] arm: Replace various irq_desc accesses
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Zijlstra, Shawn Guo, arm, omap, Tony Lindgren,
	Russell King

[-- Attachment #1: arm-replace-various-irq-to-desc-accesses.patch --]
[-- Type: text/plain, Size: 2136 bytes --]

Use the proper functions. There is no need to fiddle with irq_desc.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Shawn Guo <shawn.guo@linaro.org>
Cc: arm <linux-arm-kernel@lists.infradead.org>
Cc: omap <linux-omap@vger.kernel.org>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
---
 arch/arm/mach-imx/pm-imx6q.c        |    7 +++----
 arch/arm/mach-omap1/ams-delta-fiq.c |    7 ++-----
 2 files changed, 5 insertions(+), 9 deletions(-)

Index: tip/arch/arm/mach-imx/pm-imx6q.c
===================================================================
--- tip.orig/arch/arm/mach-imx/pm-imx6q.c
+++ tip/arch/arm/mach-imx/pm-imx6q.c
@@ -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
 	 * 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;
 }
Index: tip/arch/arm/mach-omap1/ams-delta-fiq.c
===================================================================
--- tip.orig/arch/arm/mach-omap1/ams-delta-fiq.c
+++ tip/arch/arm/mach-omap1/ams-delta-fiq.c
@@ -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



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 08/26] arm: Replace various irq_desc accesses
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: linux-arm-kernel

An 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>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Zijlstra, arm, Eric Miao, Haojian Zhuang,
	Russell King

[-- Attachment #1: arm-mmp-remove-idiotic-fiddling-with-irq-internals.patch --]
[-- Type: text/plain, Size: 3370 bytes --]

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 supsend 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 resume and resends the interrupts.

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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: arm <linux-arm-kernel@lists.infradead.org>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
---
 arch/arm/mach-mmp/pm-mmp2.c   |   16 +---------------
 arch/arm/mach-mmp/pm-pxa910.c |   20 ++++----------------
 2 files changed, 5 insertions(+), 31 deletions(-)

Index: tip/arch/arm/mach-mmp/pm-mmp2.c
===================================================================
--- tip.orig/arch/arm/mach-mmp/pm-mmp2.c
+++ tip/arch/arm/mach-mmp/pm-mmp2.c
@@ -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) {
Index: tip/arch/arm/mach-mmp/pm-pxa910.c
===================================================================
--- tip.orig/arch/arm/mach-mmp/pm-pxa910.c
+++ tip/arch/arm/mach-mmp/pm-pxa910.c
@@ -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 *dat
 		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) {



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 10/26] blackfin:Use generic /proc/interrupts implementation
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (7 preceding siblings ...)
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-02-26 10:00   ` Steven Miao
  2014-02-23 21:40   ` Thomas Gleixner
                   ` (16 subsequent siblings)
  25 siblings, 1 reply; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Steven Miao, bfin

[-- Attachment #1: blackfin-use-generic-irq-proc-mechanism.patch --]
[-- Type: text/plain, Size: 2408 bytes --]

There is nothing special in that blackfin code. Use the core
implementation.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Steven Miao <realmz6@gmail.com>
Cc: bfin <adi-buildroot-devel@lists.sourceforge.net>
---
 arch/blackfin/Kconfig          |    1 +
 arch/blackfin/kernel/irqchip.c |   36 +++++++-----------------------------
 2 files changed, 8 insertions(+), 29 deletions(-)

Index: tip/arch/blackfin/Kconfig
===================================================================
--- tip.orig/arch/blackfin/Kconfig
+++ tip/arch/blackfin/Kconfig
@@ -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
Index: tip/arch/blackfin/kernel/irqchip.c
===================================================================
--- tip.orig/arch/blackfin/kernel/irqchip.c
+++ tip/arch/blackfin/kernel/irqchip.c
@@ -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



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: linux-arm-kernel

An 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>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 11/26] genirq: Add a kstat helper to increment irq stats
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (10 preceding siblings ...)
  2014-02-23 21:40 ` [patch 12/26] mips: Use the core irq stats function Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-03-04 16:41   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                   ` (13 subsequent siblings)
  25 siblings, 1 reply; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra

[-- Attachment #1: genirq-add-stat-helper.patch --]
[-- Type: text/plain, Size: 1739 bytes --]

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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/kernel_stat.h |   12 +++++++-----
 kernel/irq/irqdesc.c        |    5 +++++
 2 files changed, 12 insertions(+), 5 deletions(-)

Index: tip/include/linux/kernel_stat.h
===================================================================
--- tip.orig/include/linux/kernel_stat.h
+++ tip/include/linux/kernel_stat.h
@@ -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)
 {
Index: tip/kernel/irq/irqdesc.c
===================================================================
--- tip.orig/kernel/irq/irqdesc.c
+++ tip/kernel/irq/irqdesc.c
@@ -489,6 +489,11 @@ void dynamic_irq_cleanup(unsigned int ir
 	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);



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 12/26] mips: Use the core irq stats function
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (9 preceding siblings ...)
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-03-04 16:41   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-02-23 21:40 ` [patch 11/26] genirq: Add a kstat helper to increment irq stats Thomas Gleixner
                   ` (14 subsequent siblings)
  25 siblings, 1 reply; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Ralf Baechle, mips

[-- Attachment #1: mips-use-core-irq-stats-function.patch --]
[-- Type: text/plain, Size: 2858 bytes --]

Let the core do the irq_desc resolution.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: mips <inux-mips@linux-mips.org>
---
 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(-)

Index: tip/arch/mips/kernel/smtc.c
===================================================================
--- tip.orig/arch/mips/kernel/smtc.c
+++ tip/arch/mips/kernel/smtc.c
@@ -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();
Index: tip/arch/mips/sgi-ip22/ip22-int.c
===================================================================
--- tip.orig/arch/mips/sgi-ip22/ip22-int.c
+++ tip/arch/mips/sgi-ip22/ip22-int.c
@@ -148,7 +148,7 @@ static void __irq_entry indy_buserror_ir
 	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();
 }
Index: tip/arch/mips/sgi-ip22/ip22-time.c
===================================================================
--- tip.orig/arch/mips/sgi-ip22/ip22-time.c
+++ tip/arch/mips/sgi-ip22/ip22-time.c
@@ -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();
Index: tip/arch/mips/sibyte/bcm1480/smp.c
===================================================================
--- tip.orig/arch/mips/sibyte/bcm1480/smp.c
+++ tip/arch/mips/sibyte/bcm1480/smp.c
@@ -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;
 
Index: tip/arch/mips/sibyte/sb1250/smp.c
===================================================================
--- tip.orig/arch/mips/sibyte/sb1250/smp.c
+++ tip/arch/mips/sibyte/sb1250/smp.c
@@ -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;
 



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 13/26] sparc: Use the core irq stats function
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, David S. Miller, sparc

[-- Attachment #1: sparc-use-core-irq-stats-function.patch --]
[-- Type: text/plain, Size: 728 bytes --]

Let the core do the irq_desc resolution.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparc <sparclinux@vger.kernel.org>
---
 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



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 13/26] sparc: Use the core irq stats function
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, David S. Miller, sparc

Let the core do the irq_desc resolution.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: sparc <sparclinux@vger.kernel.org>
---
 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



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 15/26] x86: xen: Use the core irq stats function
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Konrad Rzeszutek Wilk, Xen, x86

[-- Attachment #1: x86-xen-use-core-irq-stats-function.patch --]
[-- Type: text/plain, Size: 732 bytes --]

Let the core do the irq_desc resolution.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
Cc: x86 <x86@kernel.org>
---
 arch/x86/xen/spinlock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: tip/arch/x86/xen/spinlock.c
===================================================================
--- tip.orig/arch/x86/xen/spinlock.c
+++ tip/arch/x86/xen/spinlock.c
@@ -183,7 +183,7 @@ __visible void xen_lock_spinning(struct
 
 	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;



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 14/26] mn10300: Use the core irq stats function
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (12 preceding siblings ...)
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-03-04 16:42   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                   ` (11 subsequent siblings)
  25 siblings, 1 reply; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, David Howells, mn10300

[-- Attachment #1: mn10300-use-core-irq-stats-function.patch --]
[-- Type: text/plain, Size: 755 bytes --]

Let the core do the irq_desc resolution.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: David Howells <dhowells@redhat.com>
Cc: mn10300 <linux-am33-list@redhat.com>
---
 arch/mn10300/kernel/mn10300-watchdog.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: tip/arch/mn10300/kernel/mn10300-watchdog.c
===================================================================
--- tip.orig/arch/mn10300/kernel/mn10300-watchdog.c
+++ tip/arch/mn10300/kernel/mn10300-watchdog.c
@@ -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) {
 



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 15/26] x86: xen: Use the core irq stats function
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra, Xen, Ingo Molnar, x86

[-- Attachment #1: x86-xen-use-core-irq-stats-function.patch --]
[-- Type: text/plain, Size: 730 bytes --]

Let the core do the irq_desc resolution.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
Cc: x86 <x86@kernel.org>
---
 arch/x86/xen/spinlock.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: tip/arch/x86/xen/spinlock.c
===================================================================
--- tip.orig/arch/x86/xen/spinlock.c
+++ tip/arch/x86/xen/spinlock.c
@@ -183,7 +183,7 @@ __visible void xen_lock_spinning(struct
 
 	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;

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 16/26] s390: cio: Use the core irq stats function
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (15 preceding siblings ...)
  2014-02-23 21:40 ` [patch 17/26] ia64: " Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-03-04 16:42   ` [tip:irq/core] s390: Cio: " tip-bot for Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                   ` (8 subsequent siblings)
  25 siblings, 1 reply; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Martin Schwidefsky, s390

[-- Attachment #1: s390-cio-use-core-irq-stats-function.patch --]
[-- Type: text/plain, Size: 1209 bytes --]

Let the core do the irq_desc resolution.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: s390 <linux-s390@vger.kernel.org>
---
 drivers/s390/cio/cio.c |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

Index: tip/drivers/s390/cio/cio.c
===================================================================
--- tip.orig/drivers/s390/cio/cio.c
+++ tip/drivers/s390/cio/cio.c
@@ -584,8 +584,6 @@ static irqreturn_t do_cio_interrupt(int
 	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



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 17/26] ia64: Use the core irq stats function
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (14 preceding siblings ...)
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-03-04 16:42   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  2014-02-23 21:40 ` [patch 16/26] s390: cio: " Thomas Gleixner
                   ` (9 subsequent siblings)
  25 siblings, 1 reply; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Tony Luck, Fenghua Yu, ia64

[-- Attachment #1: ia64-use-core-irq-stats-function.patch --]
[-- Type: text/plain, Size: 1641 bytes --]

Let the core do the irq_desc resolution.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: ia64 <linux-ia64@vger.kernel.org>

---
 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);
 



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 18/26] xen: Use the proper irq functions
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Konrad Rzeszutek Wilk, Xen

[-- Attachment #1: xen-use-the-proper-functions.patch --]
[-- Type: text/plain, Size: 3239 bytes --]

I really can't understand why people keep adding irq_desc abuse. We
have enough proper interfaces. Delete another 14 lines of hackery.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
---
 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(-)

Index: tip/drivers/xen/events/events_2l.c
===================================================================
--- tip.orig/drivers/xen/events/events_2l.c
+++ tip/drivers/xen/events/events_2l.c
@@ -166,7 +166,6 @@ static void evtchn_2l_handle_events(unsi
 	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(unsi
 		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(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;
 
Index: tip/drivers/xen/events/events_base.c
===================================================================
--- tip.orig/drivers/xen/events/events_base.c
+++ tip/drivers/xen/events/events_base.c
@@ -336,9 +336,8 @@ static void bind_evtchn_to_cpu(unsigned
 
 	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);
Index: tip/drivers/xen/events/events_fifo.c
===================================================================
--- tip.orig/drivers/xen/events/events_fifo.c
+++ tip/drivers/xen/events/events_fifo.c
@@ -235,14 +235,10 @@ static uint32_t clear_linked(volatile ev
 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,



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 18/26] xen: Use the proper irq functions
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra, Xen, Ingo Molnar

[-- Attachment #1: xen-use-the-proper-functions.patch --]
[-- Type: text/plain, Size: 3237 bytes --]

I really can't understand why people keep adding irq_desc abuse. We
have enough proper interfaces. Delete another 14 lines of hackery.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
---
 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(-)

Index: tip/drivers/xen/events/events_2l.c
===================================================================
--- tip.orig/drivers/xen/events/events_2l.c
+++ tip/drivers/xen/events/events_2l.c
@@ -166,7 +166,6 @@ static void evtchn_2l_handle_events(unsi
 	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(unsi
 		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(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;
 
Index: tip/drivers/xen/events/events_base.c
===================================================================
--- tip.orig/drivers/xen/events/events_base.c
+++ tip/drivers/xen/events/events_base.c
@@ -336,9 +336,8 @@ static void bind_evtchn_to_cpu(unsigned
 
 	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);
Index: tip/drivers/xen/events/events_fifo.c
===================================================================
--- tip.orig/drivers/xen/events/events_fifo.c
+++ tip/drivers/xen/events/events_fifo.c
@@ -235,14 +235,10 @@ static uint32_t clear_linked(volatile ev
 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,

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 19/26] genirq: Provide irqd_irq_has_actions()
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (17 preceding siblings ...)
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-02-23 21:40 ` [patch 20/26] genirq: Provide irq_is_allocated() Thomas Gleixner
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Konrad Rzeszutek Wilk

[-- Attachment #1: genirq-provide-info-about-actions.patch --]
[-- Type: text/plain, Size: 2308 bytes --]

Xen has an oddball probing_irq() function. Provide a proper interface
unless Konrad decides that this probing_irq() function can be ripped
out completely.

Not-Yet-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 include/linux/irq.h |    7 +++++++
 kernel/irq/manage.c |    6 +++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

Index: tip/include/linux/irq.h
===================================================================
--- tip.orig/include/linux/irq.h
+++ tip/include/linux/irq.h
@@ -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(s
 	return 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
Index: tip/kernel/irq/manage.c
===================================================================
--- tip.orig/kernel/irq/manage.c
+++ tip/kernel/irq/manage.c
@@ -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 */



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 20/26] genirq: Provide irq_is_allocated()
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (18 preceding siblings ...)
  2014-02-23 21:40 ` [patch 19/26] genirq: Provide irqd_irq_has_actions() Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Konrad Rzeszutek Wilk

[-- Attachment #1: genirq-provide-irq-is-allocated.patch --]
[-- Type: text/plain, Size: 953 bytes --]

Another proper interface to replace Xen hackery. No idea why Xen needs
this, but I'm not masochistic enough to understand that mess.

Not-Yet-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 kernel/irq/irqdesc.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

Index: tip/kernel/irq/irqdesc.c
===================================================================
--- tip.orig/kernel/irq/irqdesc.c
+++ tip/kernel/irq/irqdesc.c
@@ -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



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 22/26] x86: Add proper vector accounting for HyperV
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (20 preceding siblings ...)
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-02-25 12:24   ` KY Srinivasan
                     ` (2 more replies)
  2014-02-23 21:40   ` Thomas Gleixner
                   ` (3 subsequent siblings)
  25 siblings, 3 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Zijlstra, x86, Konrad Rzeszutek Wilk,
	K. Y. Srinivasan

[-- Attachment #1: x86-add-a-proper-vector-accounting.patch --]
[-- Type: text/plain, Size: 1711 bytes --]

HyperV abuses a device interrupt to account for the
HYPERVISOR_CALLBACK_VECTOR.

Provide proper accounting as we have for the other vectors as well.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86 <x86@kernel.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
---
 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
===================================================================
--- tip.orig/arch/x86/include/asm/hardirq.h
+++ tip/arch/x86/include/asm/hardirq.h
@@ -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
===================================================================
--- tip.orig/arch/x86/kernel/irq.c
+++ tip/arch/x86/kernel/irq.c
@@ -125,6 +125,12 @@ int arch_show_interrupts(struct seq_file
 		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));



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 21/26] xen: Get rid of the last irq_desc abuse
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Konrad Rzeszutek Wilk, Xen

[-- Attachment #1: xen-get-rid-of-the-last-irq-to-desc-abuse.patch --]
[-- Type: text/plain, Size: 2315 bytes --]

I'd prefer to drop that completely but there seems to be some mystic
value to the error printout and the allocation check.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
---
 drivers/xen/events/events_base.c |   19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

Index: tip/drivers/xen/events/events_base.c
===================================================================
--- tip.orig/drivers/xen/events/events_base.c
+++ tip/drivers/xen/events/events_base.c
@@ -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_dat
 	eoi_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);
 	}
 }
 



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 21/26] xen: Get rid of the last irq_desc abuse
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra, Xen, Ingo Molnar

[-- Attachment #1: xen-get-rid-of-the-last-irq-to-desc-abuse.patch --]
[-- Type: text/plain, Size: 2311 bytes --]

I'd prefer to drop that completely but there seems to be some mystic
value to the error printout and the allocation check.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
---
 drivers/xen/events/events_base.c |   19 +++++--------------
 1 file changed, 5 insertions(+), 14 deletions(-)

Index: tip/drivers/xen/events/events_base.c
===================================================================
--- tip.orig/drivers/xen/events/events_base.c
+++ tip/drivers/xen/events/events_base.c
@@ -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_dat
 	eoi_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);
 	}
 }

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 24/26] genirq: Provide handle_percpu_simple_irq()
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (22 preceding siblings ...)
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-02-25 12:25   ` KY Srinivasan
  2014-02-23 21:40 ` [patch 25/26] x86: hyperv: Cleanup the irq mess Thomas Gleixner
  2014-02-23 21:40 ` [patch 26/26] genirq: Move kstats_inc_irqs_this_cpu() to core Thomas Gleixner
  25 siblings, 1 reply; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, K. Y. Srinivasan, Greg Kroah-Hartman

[-- Attachment #1: genirq-provide-simple-percpu-handler.patch --]
[-- Type: text/plain, Size: 1990 bytes --]

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

Not-Yet-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 include/linux/irq.h |    1 +
 kernel/irq/chip.c   |   15 +++++++++++++++
 2 files changed, 16 insertions(+)

Index: tip/include/linux/irq.h
===================================================================
--- tip.orig/include/linux/irq.h
+++ tip/include/linux/irq.h
@@ -423,6 +423,7 @@ extern void handle_edge_irq(unsigned int
 extern 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);
Index: tip/kernel/irq/chip.c
===================================================================
--- tip.orig/kernel/irq/chip.c
+++ tip/kernel/irq/chip.c
@@ -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



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 23/26] xen: Add proper irq accounting for HYPERCALL vector
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
@ 2014-02-23 21:40   ` Thomas Gleixner
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra, Konrad Rzeszutek Wilk, Xen

[-- Attachment #1: xen-use-vector-accounting.patch --]
[-- Type: text/plain, Size: 601 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
---
 drivers/xen/events/events_base.c |    1 +
 1 file changed, 1 insertion(+)

Index: tip/drivers/xen/events/events_base.c
===================================================================
--- tip.orig/drivers/xen/events/events_base.c
+++ tip/drivers/xen/events/events_base.c
@@ -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();
 



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 23/26] xen: Add proper irq accounting for HYPERCALL vector
@ 2014-02-23 21:40   ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra, Xen, Ingo Molnar

[-- Attachment #1: xen-use-vector-accounting.patch --]
[-- Type: text/plain, Size: 597 bytes --]

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
---
 drivers/xen/events/events_base.c |    1 +
 1 file changed, 1 insertion(+)

Index: tip/drivers/xen/events/events_base.c
===================================================================
--- tip.orig/drivers/xen/events/events_base.c
+++ tip/drivers/xen/events/events_base.c
@@ -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();

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 25/26] x86: hyperv: Cleanup the irq mess
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (23 preceding siblings ...)
  2014-02-23 21:40 ` [patch 24/26] genirq: Provide handle_percpu_simple_irq() Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-02-25 12:24   ` KY Srinivasan
  2014-03-04 16:42   ` [tip:irq/core] x86: Hyperv: " tip-bot for Thomas Gleixner
  2014-02-23 21:40 ` [patch 26/26] genirq: Move kstats_inc_irqs_this_cpu() to core Thomas Gleixner
  25 siblings, 2 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML
  Cc: Ingo Molnar, Peter Zijlstra, x86, K. Y. Srinivasan,
	Greg Kroah-Hartman, linuxdrivers

[-- Attachment #1: x86-hyperv-cleanup-the-irq-mess.patch --]
[-- Type: text/plain, Size: 7613 bytes --]

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.

  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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: x86 <x86@kernel.org>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxdrivers <devel@linuxdriverproject.org>

---
 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
===================================================================
--- tip.orig/arch/x86/include/asm/mshyperv.h
+++ tip/arch/x86/include/asm/mshyperv.h
@@ -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
Index: tip/arch/x86/kernel/cpu/mshyperv.c
===================================================================
--- tip.orig/arch/x86/kernel/cpu/mshyperv.c
+++ tip/arch/x86/kernel/cpu/mshyperv.c
@@ -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);
-
-	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
===================================================================
--- tip.orig/drivers/hv/vmbus_drv.c
+++ tip/drivers/hv/vmbus_drv.c
@@ -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();



^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 26/26] genirq: Move kstats_inc_irqs_this_cpu() to core
  2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
                   ` (24 preceding siblings ...)
  2014-02-23 21:40 ` [patch 25/26] x86: hyperv: Cleanup the irq mess Thomas Gleixner
@ 2014-02-23 21:40 ` Thomas Gleixner
  2014-03-04 16:43   ` [tip:irq/core] genirq: Move kstat_incr_irqs_this_cpu() " tip-bot for Thomas Gleixner
  25 siblings, 1 reply; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-23 21:40 UTC (permalink / raw)
  To: LKML; +Cc: Ingo Molnar, Peter Zijlstra

[-- Attachment #1: genirq-move-kstats-inc-irqs-to-core.patch --]
[-- Type: text/plain, Size: 1647 bytes --]

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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/kernel_stat.h |    8 --------
 kernel/irq/internals.h      |    7 +++++++
 2 files changed, 7 insertions(+), 8 deletions(-)

Index: tip/include/linux/kernel_stat.h
===================================================================
--- tip.orig/include/linux/kernel_stat.h
+++ tip/include/linux/kernel_stat.h
@@ -51,15 +51,7 @@ DECLARE_PER_CPU(struct kernel_cpustat, k
 
 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)
Index: tip/kernel/irq/internals.h
===================================================================
--- tip.orig/kernel/irq/internals.h
+++ tip/kernel/irq/internals.h
@@ -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);
+}



^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 22:26     ` Benjamin Herrenschmidt
  -1 siblings, 0 replies; 126+ messages in thread
From: Benjamin Herrenschmidt @ 2014-02-23 22:26 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Ingo Molnar, Peter Zijlstra, Gavin Shan, ppc

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.



^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc
@ 2014-02-23 22:26     ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 126+ messages in thread
From: Benjamin Herrenschmidt @ 2014-02-23 22:26 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Peter Zijlstra, Ingo Molnar, ppc, LKML, Gavin Shan

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.

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-02-23 23:17     ` Uwe Kleine-König
  -1 siblings, 0 replies; 126+ messages in thread
From: Uwe Kleine-König @ 2014-02-23 23:17 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Russell King, Peter Zijlstra, Haojian Zhuang, Eric Miao,
	Ingo Molnar, arm

Hi Thomas,

On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
> 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 supsend will mark the corresponding interrupt line as
s/supsend/suspend/ twice
> 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

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
@ 2014-02-23 23:17     ` Uwe Kleine-König
  0 siblings, 0 replies; 126+ messages in thread
From: Uwe Kleine-König @ 2014-02-23 23:17 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Thomas,

On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
> 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 supsend will mark the corresponding interrupt line as
s/supsend/suspend/ twice
> 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

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 04/26] xtensa: Use irq_set_affinity instead of homebrewn code
  2014-02-23 21:40 ` [patch 04/26] xtensa: Use irq_set_affinity instead of homebrewn code Thomas Gleixner
@ 2014-02-24  0:32   ` Max Filippov
  2014-03-04 16:43   ` [tip:irq/core] " tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 126+ messages in thread
From: Max Filippov @ 2014-02-24  0:32 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Ingo Molnar, Peter Zijlstra, Chris Zankel, xtensa

On Mon, Feb 24, 2014 at 1:40 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> 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()
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Chris Zankel <chris@zankel.net>
> Cc: xtensa <linux-xtensa@linux-xtensa.org>
> ---
>  arch/xtensa/kernel/irq.c |   20 +++-----------------
>  1 file changed, 3 insertions(+), 17 deletions(-)

Acked-by: Max Filippov <jcmvbkbc@gmail.com>

-- 
Thanks.
-- Max

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 08/26] arm: Replace various irq_desc accesses
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
@ 2014-02-24  2:55     ` Shawn Guo
  -1 siblings, 0 replies; 126+ messages in thread
From: Shawn Guo @ 2014-02-24  2:55 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Ingo Molnar, Peter Zijlstra, arm, omap, Tony Lindgren,
	Russell King

On Sun, Feb 23, 2014 at 09:40:12PM -0000, Thomas Gleixner wrote:
> Use the proper functions. There is no need to fiddle with irq_desc.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Shawn Guo <shawn.guo@linaro.org>
...
>  arch/arm/mach-imx/pm-imx6q.c        |    7 +++----

Acked-by: Shawn Guo <shawn.guo@linaro.org>


^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 08/26] arm: Replace various irq_desc accesses
@ 2014-02-24  2:55     ` Shawn Guo
  0 siblings, 0 replies; 126+ messages in thread
From: Shawn Guo @ 2014-02-24  2:55 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Peter Zijlstra, LKML, Tony Lindgren, Russell King, Ingo Molnar,
	omap, arm

On Sun, Feb 23, 2014 at 09:40:12PM -0000, Thomas Gleixner wrote:
> Use the proper functions. There is no need to fiddle with irq_desc.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Shawn Guo <shawn.guo@linaro.org>
...
>  arch/arm/mach-imx/pm-imx6q.c        |    7 +++----

Acked-by: Shawn Guo <shawn.guo@linaro.org>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 08/26] arm: Replace various irq_desc accesses
@ 2014-02-24  2:55     ` Shawn Guo
  0 siblings, 0 replies; 126+ messages in thread
From: Shawn Guo @ 2014-02-24  2:55 UTC (permalink / raw)
  To: linux-arm-kernel

On Sun, Feb 23, 2014 at 09:40:12PM -0000, Thomas Gleixner wrote:
> Use the proper functions. There is no need to fiddle with irq_desc.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Shawn Guo <shawn.guo@linaro.org>
...
>  arch/arm/mach-imx/pm-imx6q.c        |    7 +++----

Acked-by: Shawn Guo <shawn.guo@linaro.org>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
  2014-02-23 23:17     ` Uwe Kleine-König
@ 2014-02-24  6:07       ` Chao Xie
  -1 siblings, 0 replies; 126+ messages in thread
From: Chao Xie @ 2014-02-24  6:07 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: Thomas Gleixner, Eric Miao, Peter Zijlstra, LKML, Haojian Zhuang,
	Russell King, Ingo Molnar, arm

On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-König
<u.kleine-koenig@pengutronix.de> wrote:
> Hi Thomas,
>
> On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
>> 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 supsend will mark the corresponding interrupt line as
> s/supsend/suspend/ twice
>> 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.


> Uwe
>
> --
> Pengutronix e.K.                           | Uwe Kleine-König            |
> Industrial Linux Solutions                 | http://www.pengutronix.de/  |
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
@ 2014-02-24  6:07       ` Chao Xie
  0 siblings, 0 replies; 126+ messages in thread
From: Chao Xie @ 2014-02-24  6:07 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-K?nig
<u.kleine-koenig@pengutronix.de> wrote:
> Hi Thomas,
>
> On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
>> 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 supsend will mark the corresponding interrupt line as
> s/supsend/suspend/ twice
>> 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.


> 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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
  2014-02-24  6:07       ` Chao Xie
@ 2014-02-24  6:43         ` Haojian Zhuang
  -1 siblings, 0 replies; 126+ messages in thread
From: Haojian Zhuang @ 2014-02-24  6:43 UTC (permalink / raw)
  To: Chao Xie
  Cc: Uwe Kleine-König, Thomas Gleixner, Eric Miao,
	Peter Zijlstra, LKML, Russell King, Ingo Molnar, arm

On Mon, Feb 24, 2014 at 2:07 PM, Chao Xie <xiechao.mail@gmail.com> wrote:
> On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
>> Hi Thomas,
>>
>> On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
>>> 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 supsend will mark the corresponding interrupt line as
>> s/supsend/suspend/ twice
>>> 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.
>

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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
@ 2014-02-24  6:43         ` Haojian Zhuang
  0 siblings, 0 replies; 126+ messages in thread
From: Haojian Zhuang @ 2014-02-24  6:43 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Feb 24, 2014 at 2:07 PM, Chao Xie <xiechao.mail@gmail.com> wrote:
> On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-K?nig
> <u.kleine-koenig@pengutronix.de> wrote:
>> Hi Thomas,
>>
>> On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
>>> 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 supsend will mark the corresponding interrupt line as
>> s/supsend/suspend/ twice
>>> 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.
>

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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
  (?)
@ 2014-02-24  7:56   ` Gavin Shan
  2014-02-24 11:32       ` Thomas Gleixner
  -1 siblings, 1 reply; 126+ messages in thread
From: Gavin Shan @ 2014-02-24  7:56 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Gavin Shan, Peter Zijlstra, LKML, Ingo Molnar, ppc

On Sun, Feb 23, 2014 at 09:40:09PM -0000, Thomas Gleixner wrote:
>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.
>

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

>Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
>Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
>Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>Cc: ppc <linuxppc-dev@lists.ozlabs.org>
>---
> arch/powerpc/kernel/eeh_driver.c |   26 +++++++++++++++++++++-----
> 1 file changed, 21 insertions(+), 5 deletions(-)
>
>Index: tip/arch/powerpc/kernel/eeh_driver.c
>===================================================================
>--- tip.orig/arch/powerpc/kernel/eeh_driver.c
>+++ tip/arch/powerpc/kernel/eeh_driver.c
>@@ -143,15 +143,31 @@ static void eeh_disable_irq(struct pci_d
> 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);
>-	}
> }
>
> /**
>
>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
  2014-02-24  6:07       ` Chao Xie
@ 2014-02-24 11:27         ` Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 11:27 UTC (permalink / raw)
  To: Chao Xie
  Cc: Uwe Kleine-König, Eric Miao, Peter Zijlstra, LKML,
	Haojian Zhuang, Russell King, Ingo Molnar, arm

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2122 bytes --]

On Mon, 24 Feb 2014, Chao Xie wrote:

> On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-König
> <u.kleine-koenig@pengutronix.de> wrote:
> > Hi Thomas,
> >
> > On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
> >> 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 supsend will mark the corresponding interrupt line as
> > s/supsend/suspend/ twice
> >> 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.

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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
@ 2014-02-24 11:27         ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 11:27 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 24 Feb 2014, Chao Xie wrote:

> On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-K?nig
> <u.kleine-koenig@pengutronix.de> wrote:
> > Hi Thomas,
> >
> > On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
> >> 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 supsend will mark the corresponding interrupt line as
> > s/supsend/suspend/ twice
> >> 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.

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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
  2014-02-24  6:43         ` Haojian Zhuang
@ 2014-02-24 11:31           ` Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 11:31 UTC (permalink / raw)
  To: Haojian Zhuang
  Cc: Chao Xie, Uwe Kleine-König, Eric Miao, Peter Zijlstra, LKML,
	Russell King, Ingo Molnar, arm

[-- Attachment #1: Type: TEXT/PLAIN, Size: 2242 bytes --]

On Mon, 24 Feb 2014, Haojian Zhuang wrote:

> On Mon, Feb 24, 2014 at 2:07 PM, Chao Xie <xiechao.mail@gmail.com> wrote:
> > On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-König
> > <u.kleine-koenig@pengutronix.de> wrote:
> >> Hi Thomas,
> >>
> >> On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
> >>> 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 supsend will mark the corresponding interrupt line as
> >> s/supsend/suspend/ twice
> >>> 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.
> >
> 
> 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.

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


^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
@ 2014-02-24 11:31           ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 11:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, 24 Feb 2014, Haojian Zhuang wrote:

> On Mon, Feb 24, 2014 at 2:07 PM, Chao Xie <xiechao.mail@gmail.com> wrote:
> > On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-K?nig
> > <u.kleine-koenig@pengutronix.de> wrote:
> >> Hi Thomas,
> >>
> >> On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
> >>> 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 supsend will mark the corresponding interrupt line as
> >> s/supsend/suspend/ twice
> >>> 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.
> >
> 
> 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.

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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc
  2014-02-24  7:56   ` Gavin Shan
@ 2014-02-24 11:32       ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 11:32 UTC (permalink / raw)
  To: Gavin Shan; +Cc: LKML, Ingo Molnar, Peter Zijlstra, Benjamin Herrenschmidt, ppc

On Mon, 24 Feb 2014, Gavin Shan wrote:
> On Sun, Feb 23, 2014 at 09:40:09PM -0000, Thomas Gleixner wrote:
> >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.
> >
> 
> 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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc
@ 2014-02-24 11:32       ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 11:32 UTC (permalink / raw)
  To: Gavin Shan; +Cc: Peter Zijlstra, Ingo Molnar, ppc, LKML

On Mon, 24 Feb 2014, Gavin Shan wrote:
> On Sun, Feb 23, 2014 at 09:40:09PM -0000, Thomas Gleixner wrote:
> >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.
> >
> 
> 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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
  2014-02-23 21:40 ` [patch 06/26] metag: " Thomas Gleixner
@ 2014-02-24 13:24   ` James Hogan
  2014-02-24 14:24     ` Thomas Gleixner
  0 siblings, 1 reply; 126+ messages in thread
From: James Hogan @ 2014-02-24 13:24 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Ingo Molnar, Peter Zijlstra, metag

[-- Attachment #1: Type: text/plain, Size: 3038 bytes --]

Hi Thomas,

On 23/02/14 21:40, Thomas Gleixner wrote:
> 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

> 
> Use the core function instead and while at it switch to
> for_each_active_irq()
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: James Hogan <james.hogan@imgtec.com>
> Cc: metag <linux-metag@vger.kernel.org>
> ---
>  arch/metag/kernel/irq.c |   20 +++-----------------
>  1 file changed, 3 insertions(+), 17 deletions(-)
> 
> Index: tip/arch/metag/kernel/irq.c
> ===================================================================
> --- tip.orig/arch/metag/kernel/irq.c
> +++ tip/arch/metag/kernel/irq.c
> @@ -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 *d
>  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))
> @@ -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 */
> 
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [Xen-devel] [patch 15/26] x86: xen: Use the core irq stats function
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
  (?)
@ 2014-02-24 14:20   ` David Vrabel
  -1 siblings, 0 replies; 126+ messages in thread
From: David Vrabel @ 2014-02-24 14:20 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Peter Zijlstra, Xen, Ingo Molnar, x86

On 23/02/14 21:40, Thomas Gleixner wrote:
> Let the core do the irq_desc resolution.
> 
> No functional change.

Reviewed-by: David Vrabel <david.vrabel@citrix.com>

David

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 15/26] x86: xen: Use the core irq stats function
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
@ 2014-02-24 14:20   ` David Vrabel
  -1 siblings, 0 replies; 126+ messages in thread
From: David Vrabel @ 2014-02-24 14:20 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Peter Zijlstra, Xen, Ingo Molnar, x86, LKML

On 23/02/14 21:40, Thomas Gleixner wrote:
> Let the core do the irq_desc resolution.
> 
> No functional change.

Reviewed-by: David Vrabel <david.vrabel@citrix.com>

David

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [Xen-devel] [patch 18/26] xen: Use the proper irq functions
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
@ 2014-02-24 14:24   ` David Vrabel
  2014-02-24 21:13     ` Thomas Gleixner
  2014-02-24 21:13     ` [Xen-devel] " Thomas Gleixner
  -1 siblings, 2 replies; 126+ messages in thread
From: David Vrabel @ 2014-02-24 14:24 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Peter Zijlstra, Xen, Ingo Molnar

On 23/02/14 21:40, Thomas Gleixner wrote:
> I really can't understand why people keep adding irq_desc abuse. 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,

Reviewed-by: David Vrabel <david.vrabel@citrix.com>

David

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 18/26] xen: Use the proper irq functions
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
  (?)
@ 2014-02-24 14:24   ` David Vrabel
  -1 siblings, 0 replies; 126+ messages in thread
From: David Vrabel @ 2014-02-24 14:24 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Peter Zijlstra, Xen, Ingo Molnar, LKML

On 23/02/14 21:40, Thomas Gleixner wrote:
> I really can't understand why people keep adding irq_desc abuse. 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,

Reviewed-by: David Vrabel <david.vrabel@citrix.com>

David

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
  2014-02-24 13:24   ` James Hogan
@ 2014-02-24 14:24     ` Thomas Gleixner
  2014-02-25 18:56       ` Thomas Gleixner
  2014-02-25 21:57       ` James Hogan
  0 siblings, 2 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 14:24 UTC (permalink / raw)
  To: James Hogan; +Cc: LKML, Ingo Molnar, Peter Zijlstra, metag

On Mon, 24 Feb 2014, James Hogan wrote:

> Hi Thomas,
> 
> On 23/02/14 21:40, Thomas Gleixner wrote:
> > 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?

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

Index: tip/arch/metag/kernel/irq.c
===================================================================
--- tip.orig/arch/metag/kernel/irq.c
+++ tip/arch/metag/kernel/irq.c
@@ -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
===================================================================
--- tip.orig/drivers/irqchip/irq-metag.c
+++ tip/drivers/irqchip/irq-metag.c
@@ -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)),


    	  

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [Xen-devel] [patch 21/26] xen: Get rid of the last irq_desc abuse
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
  (?)
@ 2014-02-24 14:33   ` David Vrabel
  2014-02-24 21:12     ` Thomas Gleixner
  2014-02-24 21:12     ` [Xen-devel] " Thomas Gleixner
  -1 siblings, 2 replies; 126+ messages in thread
From: David Vrabel @ 2014-02-24 14:33 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Peter Zijlstra, Xen, Ingo Molnar

On 23/02/14 21:40, Thomas Gleixner wrote:
> 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.

> --- tip.orig/drivers/xen/events/events_base.c
> +++ tip/drivers/xen/events/events_base.c
[...]
> @@ -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.

>  		return 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);
>  
> -	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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 21/26] xen: Get rid of the last irq_desc abuse
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
@ 2014-02-24 14:33   ` David Vrabel
  -1 siblings, 0 replies; 126+ messages in thread
From: David Vrabel @ 2014-02-24 14:33 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Peter Zijlstra, Xen, Ingo Molnar, LKML

On 23/02/14 21:40, Thomas Gleixner wrote:
> 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.

> --- tip.orig/drivers/xen/events/events_base.c
> +++ tip/drivers/xen/events/events_base.c
[...]
> @@ -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.

>  		return 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);
>  
> -	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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [Xen-devel] [patch 23/26] xen: Add proper irq accounting for HYPERCALL vector
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
  (?)
@ 2014-02-24 14:48   ` David Vrabel
  -1 siblings, 0 replies; 126+ messages in thread
From: David Vrabel @ 2014-02-24 14:48 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Peter Zijlstra, Xen, Ingo Molnar

On 23/02/14 21:40, Thomas Gleixner wrote:
> --- tip.orig/drivers/xen/events/events_base.c
> +++ tip/drivers/xen/events/events_base.c
> @@ -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();

Reviewed-by: David Vrabel <david.vrabel@citrix.com>

David

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 23/26] xen: Add proper irq accounting for HYPERCALL vector
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
@ 2014-02-24 14:48   ` David Vrabel
  -1 siblings, 0 replies; 126+ messages in thread
From: David Vrabel @ 2014-02-24 14:48 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: Peter Zijlstra, Xen, Ingo Molnar, LKML

On 23/02/14 21:40, Thomas Gleixner wrote:
> --- tip.orig/drivers/xen/events/events_base.c
> +++ tip/drivers/xen/events/events_base.c
> @@ -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();

Reviewed-by: David Vrabel <david.vrabel@citrix.com>

David

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [Xen-devel] [patch 21/26] xen: Get rid of the last irq_desc abuse
  2014-02-24 14:33   ` [Xen-devel] " David Vrabel
  2014-02-24 21:12     ` Thomas Gleixner
@ 2014-02-24 21:12     ` Thomas Gleixner
  1 sibling, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 21:12 UTC (permalink / raw)
  To: David Vrabel; +Cc: LKML, Peter Zijlstra, Xen, Ingo Molnar

On Mon, 24 Feb 2014, David Vrabel wrote:
> On 23/02/14 21:40, Thomas Gleixner wrote:
> > 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.
> 
> > --- tip.orig/drivers/xen/events/events_base.c
> > +++ tip/drivers/xen/events/events_base.c
> [...]
> > @@ -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.

Sure, I understood the value of the printk, but I failed to see the
reason for probing_irq(). Will change it.
 
> >  		return 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);
> >  
> > -	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.
 
> I think this means you don't need to introduce the irqd_irq_has_action()
> and irq_is_allocated() helpers.

I just invented them in case xen really needs those tests.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 21/26] xen: Get rid of the last irq_desc abuse
  2014-02-24 14:33   ` [Xen-devel] " David Vrabel
@ 2014-02-24 21:12     ` Thomas Gleixner
  2014-02-24 21:12     ` [Xen-devel] " Thomas Gleixner
  1 sibling, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 21:12 UTC (permalink / raw)
  To: David Vrabel; +Cc: Peter Zijlstra, Xen, Ingo Molnar, LKML

On Mon, 24 Feb 2014, David Vrabel wrote:
> On 23/02/14 21:40, Thomas Gleixner wrote:
> > 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.
> 
> > --- tip.orig/drivers/xen/events/events_base.c
> > +++ tip/drivers/xen/events/events_base.c
> [...]
> > @@ -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.

Sure, I understood the value of the printk, but I failed to see the
reason for probing_irq(). Will change it.
 
> >  		return 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);
> >  
> > -	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.
 
> I think this means you don't need to introduce the irqd_irq_has_action()
> and irq_is_allocated() helpers.

I just invented them in case xen really needs those tests.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [Xen-devel] [patch 18/26] xen: Use the proper irq functions
  2014-02-24 14:24   ` [Xen-devel] " David Vrabel
  2014-02-24 21:13     ` Thomas Gleixner
@ 2014-02-24 21:13     ` Thomas Gleixner
  1 sibling, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 21:13 UTC (permalink / raw)
  To: David Vrabel; +Cc: LKML, Peter Zijlstra, Xen, Ingo Molnar

On Mon, 24 Feb 2014, David Vrabel wrote:

> On 23/02/14 21:40, Thomas Gleixner wrote:
> > I really can't understand why people keep adding irq_desc abuse. 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.

Fair enough. I was not really in the mood to come up with proper
changelogs :)

> Otherwise,
> 
> Reviewed-by: David Vrabel <david.vrabel@citrix.com>
> 
> David
> 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 18/26] xen: Use the proper irq functions
  2014-02-24 14:24   ` [Xen-devel] " David Vrabel
@ 2014-02-24 21:13     ` Thomas Gleixner
  2014-02-24 21:13     ` [Xen-devel] " Thomas Gleixner
  1 sibling, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-24 21:13 UTC (permalink / raw)
  To: David Vrabel; +Cc: Peter Zijlstra, Xen, Ingo Molnar, LKML

On Mon, 24 Feb 2014, David Vrabel wrote:

> On 23/02/14 21:40, Thomas Gleixner wrote:
> > I really can't understand why people keep adding irq_desc abuse. 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.

Fair enough. I was not really in the mood to come up with proper
changelogs :)

> Otherwise,
> 
> Reviewed-by: David Vrabel <david.vrabel@citrix.com>
> 
> David
> 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* RE: [patch 22/26] x86: Add proper vector accounting for HyperV
  2014-02-23 21:40 ` [patch 22/26] x86: Add proper vector accounting for HyperV Thomas Gleixner
@ 2014-02-25 12:24   ` KY Srinivasan
  2014-03-04 16:42   ` [tip:irq/core] x86: Add proper vector accounting for HYPERVISOR_CALLBACK_VECTOR tip-bot for Thomas Gleixner
  2014-09-22 21:03   ` [patch 22/26] x86: Add proper vector accounting for HyperV Elliott, Robert (Server Storage)
  2 siblings, 0 replies; 126+ messages in thread
From: KY Srinivasan @ 2014-02-25 12:24 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: Ingo Molnar, Peter Zijlstra, x86, Konrad Rzeszutek Wilk



> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> 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
> 
> 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
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: x86 <x86@kernel.org>
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> ---
>  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
> ==========================================================
> =========
> --- tip.orig/arch/x86/include/asm/hardirq.h
> +++ tip/arch/x86/include/asm/hardirq.h
> @@ -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
> ==========================================================
> =========
> --- tip.orig/arch/x86/kernel/irq.c
> +++ tip/arch/x86/kernel/irq.c
> @@ -125,6 +125,12 @@ int arch_show_interrupts(struct seq_file
>  		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));
> 


^ permalink raw reply	[flat|nested] 126+ messages in thread

* RE: [patch 25/26] x86: hyperv: Cleanup the irq mess
  2014-02-23 21:40 ` [patch 25/26] x86: hyperv: Cleanup the irq mess Thomas Gleixner
@ 2014-02-25 12:24   ` KY Srinivasan
  2014-02-25 19:10     ` Thomas Gleixner
  2014-03-04 16:42   ` [tip:irq/core] x86: Hyperv: " tip-bot for Thomas Gleixner
  1 sibling, 1 reply; 126+ messages in thread
From: KY Srinivasan @ 2014-02-25 12:24 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: Ingo Molnar, Peter Zijlstra, x86, Greg Kroah-Hartman, linuxdrivers



> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> 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 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.
> 
>   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.
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
> 
> 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.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: x86 <x86@kernel.org>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Cc: linuxdrivers <devel@linuxdriverproject.org>
> 
> ---
>  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
> ==========================================================
> =========
> --- tip.orig/arch/x86/include/asm/mshyperv.h
> +++ tip/arch/x86/include/asm/mshyperv.h
> @@ -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
> Index: tip/arch/x86/kernel/cpu/mshyperv.c
> ==========================================================
> =========
> --- tip.orig/arch/x86/kernel/cpu/mshyperv.c
> +++ tip/arch/x86/kernel/cpu/mshyperv.c
> @@ -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);
> -
> -	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
> ==========================================================
> =========
> --- tip.orig/drivers/hv/vmbus_drv.c
> +++ tip/drivers/hv/vmbus_drv.c
> @@ -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();
> 


^ permalink raw reply	[flat|nested] 126+ messages in thread

* RE: [patch 24/26] genirq: Provide handle_percpu_simple_irq()
  2014-02-23 21:40 ` [patch 24/26] genirq: Provide handle_percpu_simple_irq() Thomas Gleixner
@ 2014-02-25 12:25   ` KY Srinivasan
  0 siblings, 0 replies; 126+ messages in thread
From: KY Srinivasan @ 2014-02-25 12:25 UTC (permalink / raw)
  To: Thomas Gleixner, LKML; +Cc: Ingo Molnar, Peter Zijlstra, Greg Kroah-Hartman



> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> 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: Provide handle_percpu_simple_irq()
> 
> 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

> 
> Not-Yet-Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>  include/linux/irq.h |    1 +
>  kernel/irq/chip.c   |   15 +++++++++++++++
>  2 files changed, 16 insertions(+)
> 
> Index: tip/include/linux/irq.h
> ==========================================================
> =========
> --- tip.orig/include/linux/irq.h
> +++ tip/include/linux/irq.h
> @@ -423,6 +423,7 @@ extern void handle_edge_irq(unsigned int  extern
> 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);
> Index: tip/kernel/irq/chip.c
> ==========================================================
> =========
> --- tip.orig/kernel/irq/chip.c
> +++ tip/kernel/irq/chip.c
> @@ -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
> 


^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
  2014-02-24 14:24     ` Thomas Gleixner
@ 2014-02-25 18:56       ` Thomas Gleixner
  2014-02-25 21:57       ` James Hogan
  1 sibling, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-25 18:56 UTC (permalink / raw)
  To: James Hogan; +Cc: LKML, Ingo Molnar, Peter Zijlstra, metag

On Mon, 24 Feb 2014, Thomas Gleixner wrote:
> On Mon, 24 Feb 2014, James Hogan wrote:
> Delta patch below.

Does that fix your issue?

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 126+ messages in thread

* RE: [patch 25/26] x86: hyperv: Cleanup the irq mess
  2014-02-25 12:24   ` KY Srinivasan
@ 2014-02-25 19:10     ` Thomas Gleixner
  2014-02-28  2:50       ` KY Srinivasan
  0 siblings, 1 reply; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-25 19:10 UTC (permalink / raw)
  To: KY Srinivasan
  Cc: LKML, Ingo Molnar, Peter Zijlstra, x86, Greg Kroah-Hartman, linuxdrivers

On Tue, 25 Feb 2014, KY Srinivasan wrote:
> > -----Original Message-----
> > From: Thomas Gleixner [mailto:tglx@linutronix.de]
> > 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 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.
> > 
> >   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.
> 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(-)

Index: tip/arch/x86/include/asm/mshyperv.h
===================================================================
--- tip.orig/arch/x86/include/asm/mshyperv.h
+++ tip/arch/x86/include/asm/mshyperv.h
@@ -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
Index: tip/arch/x86/kernel/cpu/mshyperv.c
===================================================================
--- tip.orig/arch/x86/kernel/cpu/mshyperv.c
+++ tip/arch/x86/kernel/cpu/mshyperv.c
@@ -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);
-
-	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
===================================================================
--- tip.orig/drivers/hv/vmbus_drv.c
+++ tip/drivers/hv/vmbus_drv.c
@@ -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();








^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
  2014-02-24 14:24     ` Thomas Gleixner
  2014-02-25 18:56       ` Thomas Gleixner
@ 2014-02-25 21:57       ` James Hogan
  2014-02-27 10:59         ` Thomas Gleixner
  1 sibling, 1 reply; 126+ messages in thread
From: James Hogan @ 2014-02-25 21:57 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Ingo Molnar, Peter Zijlstra, metag

[-- Attachment #1: Type: text/plain, Size: 3743 bytes --]

Hi Thomas,

Sorry for delay, I didn't get a chance to try this earlier.

On Monday 24 February 2014 15:24:55 Thomas Gleixner wrote:
> On Mon, 24 Feb 2014, James Hogan wrote:
> > On 23/02/14 21:40, Thomas Gleixner wrote:
> > > 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?
> 
> Delta patch below.

Thanks, that does the trick although the same thing needs doing in 
drivers/irqchips/irq-metag-ext.c too.

> 
> 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....

... 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

> 
> 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
> 
> Index: tip/arch/metag/kernel/irq.c
> ===================================================================
> --- tip.orig/arch/metag/kernel/irq.c
> +++ tip/arch/metag/kernel/irq.c
> @@ -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
> ===================================================================
> --- tip.orig/drivers/irqchip/irq-metag.c
> +++ tip/drivers/irqchip/irq-metag.c
> @@ -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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 10/26] blackfin:Use generic /proc/interrupts implementation
  2014-02-23 21:40 ` [patch 10/26] blackfin:Use generic /proc/interrupts implementation Thomas Gleixner
@ 2014-02-26 10:00   ` Steven Miao
  0 siblings, 0 replies; 126+ messages in thread
From: Steven Miao @ 2014-02-26 10:00 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: LKML, Ingo Molnar, Peter Zijlstra, bfin

Hi Thomas,

On Mon, Feb 24, 2014 at 5:40 AM, Thomas Gleixner <tglx@linutronix.de> wrote:
> There is nothing special in that blackfin code. Use the core
> implementation.
>
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: Steven Miao <realmz6@gmail.com>
> Cc: bfin <adi-buildroot-devel@lists.sourceforge.net>
> ---
>  arch/blackfin/Kconfig          |    1 +
>  arch/blackfin/kernel/irqchip.c |   36 +++++++-----------------------------
>  2 files changed, 8 insertions(+), 29 deletions(-)
>
> Index: tip/arch/blackfin/Kconfig
> ===================================================================
> --- tip.orig/arch/blackfin/Kconfig
> +++ tip/arch/blackfin/Kconfig
> @@ -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
> Index: tip/arch/blackfin/kernel/irqchip.c
> ===================================================================
> --- tip.orig/arch/blackfin/kernel/irqchip.c
> +++ tip/arch/blackfin/kernel/irqchip.c
> @@ -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
>
>
Thanks. Applied.

-steven

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 08/26] arm: Replace various irq_desc accesses
  2014-02-24  2:55     ` Shawn Guo
@ 2014-02-26 17:05       ` Tony Lindgren
  -1 siblings, 0 replies; 126+ messages in thread
From: Tony Lindgren @ 2014-02-26 17:05 UTC (permalink / raw)
  To: Shawn Guo
  Cc: Thomas Gleixner, LKML, Ingo Molnar, Peter Zijlstra, arm, omap,
	Russell King

* Shawn Guo <shawn.guo@linaro.org> [140223 18:58]:
> On Sun, Feb 23, 2014 at 09:40:12PM -0000, Thomas Gleixner wrote:
> > Use the proper functions. There is no need to fiddle with irq_desc.
> > 
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Shawn Guo <shawn.guo@linaro.org>
> ...
> >  arch/arm/mach-imx/pm-imx6q.c        |    7 +++----
> 
> Acked-by: Shawn Guo <shawn.guo@linaro.org>

Acked-by: Tony Lindgren <tony@atomide.com> 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 08/26] arm: Replace various irq_desc accesses
@ 2014-02-26 17:05       ` Tony Lindgren
  0 siblings, 0 replies; 126+ messages in thread
From: Tony Lindgren @ 2014-02-26 17:05 UTC (permalink / raw)
  To: linux-arm-kernel

* Shawn Guo <shawn.guo@linaro.org> [140223 18:58]:
> On Sun, Feb 23, 2014 at 09:40:12PM -0000, Thomas Gleixner wrote:
> > Use the proper functions. There is no need to fiddle with irq_desc.
> > 
> > Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Shawn Guo <shawn.guo@linaro.org>
> ...
> >  arch/arm/mach-imx/pm-imx6q.c        |    7 +++----
> 
> Acked-by: Shawn Guo <shawn.guo@linaro.org>

Acked-by: Tony Lindgren <tony@atomide.com> 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
  2014-02-24 11:31           ` Thomas Gleixner
@ 2014-02-27  1:37             ` Chao Xie
  -1 siblings, 0 replies; 126+ messages in thread
From: Chao Xie @ 2014-02-27  1:37 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Haojian Zhuang, Uwe Kleine-König, Eric Miao, Peter Zijlstra,
	LKML, Russell King, Ingo Molnar, arm, fwu

On Mon, Feb 24, 2014 at 7:31 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Mon, 24 Feb 2014, Haojian Zhuang wrote:
>
>> On Mon, Feb 24, 2014 at 2:07 PM, Chao Xie <xiechao.mail@gmail.com> wrote:
>> > On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-König
>> > <u.kleine-koenig@pengutronix.de> wrote:
>> >> Hi Thomas,
>> >>
>> >> On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
>> >>> 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 supsend will mark the corresponding interrupt line as
>> >> s/supsend/suspend/ twice
>> >>> 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.
>> >
>>
>> 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.
>
> 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.

> 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.

> Thanks,
>
>         tglx
>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
@ 2014-02-27  1:37             ` Chao Xie
  0 siblings, 0 replies; 126+ messages in thread
From: Chao Xie @ 2014-02-27  1:37 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Feb 24, 2014 at 7:31 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
> On Mon, 24 Feb 2014, Haojian Zhuang wrote:
>
>> On Mon, Feb 24, 2014 at 2:07 PM, Chao Xie <xiechao.mail@gmail.com> wrote:
>> > On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-K?nig
>> > <u.kleine-koenig@pengutronix.de> wrote:
>> >> Hi Thomas,
>> >>
>> >> On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
>> >>> 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 supsend will mark the corresponding interrupt line as
>> >> s/supsend/suspend/ twice
>> >>> 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.
>> >
>>
>> 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.
>
> 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.

> 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.

> Thanks,
>
>         tglx
>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
  2014-02-27  1:37             ` Chao Xie
@ 2014-02-27  2:19               ` Haojian Zhuang
  -1 siblings, 0 replies; 126+ messages in thread
From: Haojian Zhuang @ 2014-02-27  2:19 UTC (permalink / raw)
  To: Chao Xie
  Cc: Thomas Gleixner, Uwe Kleine-König, Eric Miao,
	Peter Zijlstra, LKML, Russell King, Ingo Molnar, arm, fwu

On Thu, Feb 27, 2014 at 9:37 AM, Chao Xie <xiechao.mail@gmail.com> wrote:
> On Mon, Feb 24, 2014 at 7:31 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
>> On Mon, 24 Feb 2014, Haojian Zhuang wrote:
>>
>>> On Mon, Feb 24, 2014 at 2:07 PM, Chao Xie <xiechao.mail@gmail.com> wrote:
>>> > On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-König
>>> > <u.kleine-koenig@pengutronix.de> wrote:
>>> >> Hi Thomas,
>>> >>
>>> >> On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
>>> >>> 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 supsend will mark the corresponding interrupt line as
>>> >> s/supsend/suspend/ twice
>>> >>> 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.
>>> >
>>>
>>> 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.
>>
>> 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.
>
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.


>> 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.
>
>> Thanks,
>>
>>         tglx
>>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
@ 2014-02-27  2:19               ` Haojian Zhuang
  0 siblings, 0 replies; 126+ messages in thread
From: Haojian Zhuang @ 2014-02-27  2:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Feb 27, 2014 at 9:37 AM, Chao Xie <xiechao.mail@gmail.com> wrote:
> On Mon, Feb 24, 2014 at 7:31 PM, Thomas Gleixner <tglx@linutronix.de> wrote:
>> On Mon, 24 Feb 2014, Haojian Zhuang wrote:
>>
>>> On Mon, Feb 24, 2014 at 2:07 PM, Chao Xie <xiechao.mail@gmail.com> wrote:
>>> > On Mon, Feb 24, 2014 at 7:17 AM, Uwe Kleine-K?nig
>>> > <u.kleine-koenig@pengutronix.de> wrote:
>>> >> Hi Thomas,
>>> >>
>>> >> On Sun, Feb 23, 2014 at 09:40:13PM -0000, Thomas Gleixner wrote:
>>> >>> 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 supsend will mark the corresponding interrupt line as
>>> >> s/supsend/suspend/ twice
>>> >>> 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.
>>> >
>>>
>>> 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.
>>
>> 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.
>
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.


>> 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.
>
>> Thanks,
>>
>>         tglx
>>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 06/26] metag: Use irq_set_affinity instead of homebrewn code
  2014-02-25 21:57       ` James Hogan
@ 2014-02-27 10:59         ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-27 10:59 UTC (permalink / raw)
  To: James Hogan; +Cc: LKML, Ingo Molnar, Peter Zijlstra, metag

On Tue, 25 Feb 2014, James Hogan wrote:
> > 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....
> 
> ... 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).

Fine with me.

Thanks,

	tglx

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
  2014-02-27  2:19               ` Haojian Zhuang
@ 2014-02-27 11:28                 ` Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-27 11:28 UTC (permalink / raw)
  To: Haojian Zhuang
  Cc: Chao Xie, Uwe Kleine-König, Eric Miao, Peter Zijlstra, LKML,
	Russell King, Ingo Molnar, arm, fwu

On Thu, 27 Feb 2014, Haojian Zhuang wrote:
> 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.

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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals
@ 2014-02-27 11:28                 ` Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: Thomas Gleixner @ 2014-02-27 11:28 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, 27 Feb 2014, Haojian Zhuang wrote:
> 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.

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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* RE: [patch 25/26] x86: hyperv: Cleanup the irq mess
  2014-02-25 19:10     ` Thomas Gleixner
@ 2014-02-28  2:50       ` KY Srinivasan
  0 siblings, 0 replies; 126+ messages in thread
From: KY Srinivasan @ 2014-02-28  2:50 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: LKML, Ingo Molnar, Peter Zijlstra, x86, Greg Kroah-Hartman, linuxdrivers



> -----Original Message-----
> From: Thomas Gleixner [mailto:tglx@linutronix.de]
> 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 mess
> 
> On Tue, 25 Feb 2014, KY Srinivasan wrote:
> > > -----Original Message-----
> > > From: Thomas Gleixner [mailto:tglx@linutronix.de]
> > > 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 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.
> > >
> > >   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.
> > 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 Thomas.

Acked-by: K. Y. Srinivasan <kys@microsoft.com>

> 
> 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
> ==========================================================
> =========
> --- tip.orig/arch/x86/include/asm/mshyperv.h
> +++ tip/arch/x86/include/asm/mshyperv.h
> @@ -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
> Index: tip/arch/x86/kernel/cpu/mshyperv.c
> ==========================================================
> =========
> --- tip.orig/arch/x86/kernel/cpu/mshyperv.c
> +++ tip/arch/x86/kernel/cpu/mshyperv.c
> @@ -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);
> -
> -	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
> ==========================================================
> =========
> --- tip.orig/drivers/hv/vmbus_drv.c
> +++ tip/drivers/hv/vmbus_drv.c
> @@ -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();
> 
> 
> 
> 
> 
> 


^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] powerpc:eVh_pic: Kill irq_desc abuse
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-03-04 16:39     ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, linuxppc-dev, galak, peterz,
	ashish.kalra, benh, timur, tglx

Commit-ID:  c866cda47f2c6c8abb929933b7794e9a92d7c924
Gitweb:     http://git.kernel.org/tip/c866cda47f2c6c8abb929933b7794e9a92d7c924
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:08 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ashish Kalra <ashish.kalra@freescale.com>
Cc: Timur Tabi <timur@freescale.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
Link: http://lkml.kernel.org/r/20140223212736.451970660@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/powerpc/sysdev/ehv_pic.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/sysdev/ehv_pic.c b/arch/powerpc/sysdev/ehv_pic.c
index b74085c..2d20f10 100644
--- a/arch/powerpc/sysdev/ehv_pic.c
+++ b/arch/powerpc/sysdev/ehv_pic.c
@@ -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 = {

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] powerpc:eVh_pic: Kill irq_desc abuse
@ 2014-03-04 16:39     ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: timur, peterz, ashish.kalra, linux-kernel, hpa, tglx,
	linuxppc-dev, mingo

Commit-ID:  c866cda47f2c6c8abb929933b7794e9a92d7c924
Gitweb:     http://git.kernel.org/tip/c866cda47f2c6c8abb929933b7794e9a92d7c924
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:08 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Ashish Kalra <ashish.kalra@freescale.com>
Cc: Timur Tabi <timur@freescale.com>
Cc: Kumar Gala <galak@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
Link: http://lkml.kernel.org/r/20140223212736.451970660@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/powerpc/sysdev/ehv_pic.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/sysdev/ehv_pic.c b/arch/powerpc/sysdev/ehv_pic.c
index b74085c..2d20f10 100644
--- a/arch/powerpc/sysdev/ehv_pic.c
+++ b/arch/powerpc/sysdev/ehv_pic.c
@@ -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 = {

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] powerpc: Irq: Use generic_handle_irq
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-03-04 16:39     ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:39 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, benh, linuxppc-dev, peterz, tglx

Commit-ID:  a4e04c9f219d2c00764ffa7ba45500411815879d
Gitweb:     http://git.kernel.org/tip/a4e04c9f219d2c00764ffa7ba45500411815879d
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:08 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 4 Mar 2014 17:37:52 +0100

powerpc: Irq: Use generic_handle_irq

No functional change

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
Link: http://lkml.kernel.org/r/20140223212736.333718121@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/powerpc/kernel/irq.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 1d0848b..ca1cd74 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -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);
 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] powerpc: Irq: Use generic_handle_irq
@ 2014-03-04 16:39     ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:39 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: peterz, linux-kernel, hpa, tglx, linuxppc-dev, mingo

Commit-ID:  a4e04c9f219d2c00764ffa7ba45500411815879d
Gitweb:     http://git.kernel.org/tip/a4e04c9f219d2c00764ffa7ba45500411815879d
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:08 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 4 Mar 2014 17:37:52 +0100

powerpc: Irq: Use generic_handle_irq

No functional change

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
Link: http://lkml.kernel.org/r/20140223212736.333718121@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/powerpc/kernel/irq.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 1d0848b..ca1cd74 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -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);
 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] powerpc: Eeh: Kill another abuse of irq_desc
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-03-04 16:40     ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, linuxppc-dev, peterz, benh, tglx, shangw

Commit-ID:  b8a9a11b976810ba12a43c4fe699a14892c97e52
Gitweb:     http://git.kernel.org/tip/b8a9a11b976810ba12a43c4fe699a14892c97e52
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:09 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
Link: http://lkml.kernel.org/r/20140223212736.562906212@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/powerpc/kernel/eeh_driver.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index fdc679d..3e1d7de 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -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);
-	}
 }
 
 /**

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] powerpc: Eeh: Kill another abuse of irq_desc
@ 2014-03-04 16:40     ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: shangw, peterz, linux-kernel, hpa, tglx, linuxppc-dev, mingo

Commit-ID:  b8a9a11b976810ba12a43c4fe699a14892c97e52
Gitweb:     http://git.kernel.org/tip/b8a9a11b976810ba12a43c4fe699a14892c97e52
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:09 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Gavin Shan <shangw@linux.vnet.ibm.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: ppc <linuxppc-dev@lists.ozlabs.org>
Link: http://lkml.kernel.org/r/20140223212736.562906212@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/powerpc/kernel/eeh_driver.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/kernel/eeh_driver.c b/arch/powerpc/kernel/eeh_driver.c
index fdc679d..3e1d7de 100644
--- a/arch/powerpc/kernel/eeh_driver.c
+++ b/arch/powerpc/kernel/eeh_driver.c
@@ -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);
-	}
 }
 
 /**

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] pci: pcie-designware: Remove irq_desc abuse
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
@ 2014-03-04 16:40   ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, peterz, jg1.han, bhelgaas, mohit.kumar,
	tglx, linux-pci

Commit-ID:  f7bfca6db60a6ca0a73126918b2fb6f851065947
Gitweb:     http://git.kernel.org/tip/f7bfca6db60a6ca0a73126918b2fb6f851065947
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:11 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jingoo Han <jg1.han@samsung.com>
Cc: Mohit Kumar <mohit.kumar@st.com>
Cc: pci <linux-pci@vger.kernel.org>
Link: http://lkml.kernel.org/r/20140223212736.987803648@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/pci/host/pcie-designware.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pci/host/pcie-designware.c b/drivers/pci/host/pcie-designware.c
index 17ce88f..2e48ecf 100644
--- a/drivers/pci/host/pcie-designware.c
+++ b/drivers/pci/host/pcie-designware.c
@@ -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();

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] arm: Replace various irq_desc accesses
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
  (?)
@ 2014-03-04 16:40   ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, linux-arm-kernel, rmk+kernel, peterz,
	tony, tglx

Commit-ID:  8435cf757632a5559fbbf1cb79299716c8d5b651
Gitweb:     http://git.kernel.org/tip/8435cf757632a5559fbbf1cb79299716c8d5b651
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:12 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>C
Acked-by: Tony Lindgren <tony@atomide.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: arm <linux-arm-kernel@lists.infradead.org>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Link: http://lkml.kernel.org/r/20140223212737.099151500@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/arm/mach-imx/pm-imx6q.c        | 7 +++----
 arch/arm/mach-omap1/ams-delta-fiq.c | 7 ++-----
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-imx/pm-imx6q.c b/arch/arm/mach-imx/pm-imx6q.c
index 7a9b985..29e3fe6 100644
--- a/arch/arm/mach-imx/pm-imx6q.c
+++ b/arch/arm/mach-imx/pm-imx6q.c
@@ -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;
 }
diff --git a/arch/arm/mach-omap1/ams-delta-fiq.c b/arch/arm/mach-omap1/ams-delta-fiq.c
index f12a12a..2ebc514 100644
--- a/arch/arm/mach-omap1/ams-delta-fiq.c
+++ b/arch/arm/mach-omap1/ams-delta-fiq.c
@@ -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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] arm: mmp: Remove pointless fiddling with irq internals
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
  (?)
@ 2014-03-04 16:40   ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, linux-arm-kernel, peterz,
	haojian.zhuang, linux, eric.y.miao, tglx

Commit-ID:  49f3fbc7b8576fd578f3504c65aae9b8a212d0f6
Gitweb:     http://git.kernel.org/tip/49f3fbc7b8576fd578f3504c65aae9b8a212d0f6
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:13 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: arm <linux-arm-kernel@lists.infradead.org>
Cc: Eric Miao <eric.y.miao@gmail.com>
Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Link: http://lkml.kernel.org/r/20140223212737.214342433@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/arm/mach-mmp/pm-mmp2.c   | 16 +---------------
 arch/arm/mach-mmp/pm-pxa910.c | 20 ++++----------------
 2 files changed, 5 insertions(+), 31 deletions(-)

diff --git a/arch/arm/mach-mmp/pm-mmp2.c b/arch/arm/mach-mmp/pm-mmp2.c
index 461a191..43b1a51 100644
--- a/arch/arm/mach-mmp/pm-mmp2.c
+++ b/arch/arm/mach-mmp/pm-mmp2.c
@@ -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) {
diff --git a/arch/arm/mach-mmp/pm-pxa910.c b/arch/arm/mach-mmp/pm-pxa910.c
index 48981ca..04c9daf 100644
--- a/arch/arm/mach-mmp/pm-pxa910.c
+++ b/arch/arm/mach-mmp/pm-pxa910.c
@@ -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) {

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] xen: Use the proper irq functions
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-03-04 16:40     ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, konrad.wilk, peterz, xen-devel, tglx,
	david.vrabel

Commit-ID:  589d03e93f6cd595f68891e48f0804f2c8f38aae
Gitweb:     http://git.kernel.org/tip/589d03e93f6cd595f68891e48f0804f2c8f38aae
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:18 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
Link: http://lkml.kernel.org/r/20140223212738.222412125@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 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(-)

diff --git a/drivers/xen/events/events_2l.c b/drivers/xen/events/events_2l.c
index d7ff917..5db43fc 100644
--- a/drivers/xen/events/events_2l.c
+++ b/drivers/xen/events/events_2l.c
@@ -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;
 
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index f4a9e33..7fea02c 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -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);
diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c
index 1de2a19..96109a9 100644
--- a/drivers/xen/events/events_fifo.c
+++ b/drivers/xen/events/events_fifo.c
@@ -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,

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] xen: Use the proper irq functions
@ 2014-03-04 16:40     ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:40 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, linux-kernel, david.vrabel, hpa, xen-devel, tglx, mingo

Commit-ID:  589d03e93f6cd595f68891e48f0804f2c8f38aae
Gitweb:     http://git.kernel.org/tip/589d03e93f6cd595f68891e48f0804f2c8f38aae
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:18 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
Link: http://lkml.kernel.org/r/20140223212738.222412125@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 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(-)

diff --git a/drivers/xen/events/events_2l.c b/drivers/xen/events/events_2l.c
index d7ff917..5db43fc 100644
--- a/drivers/xen/events/events_2l.c
+++ b/drivers/xen/events/events_2l.c
@@ -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;
 
diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index f4a9e33..7fea02c 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -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);
diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c
index 1de2a19..96109a9 100644
--- a/drivers/xen/events/events_fifo.c
+++ b/drivers/xen/events/events_fifo.c
@@ -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,

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] xen: Get rid of the last irq_desc abuse
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (3 preceding siblings ...)
  (?)
@ 2014-03-04 16:41   ` tip-bot for Thomas Gleixner
  2014-03-04 17:16     ` David Vrabel
  2014-03-04 17:16     ` [Xen-devel] " David Vrabel
  -1 siblings, 2 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, konrad.wilk, peterz, xen-devel, tglx,
	david.vrabel

Commit-ID:  02893afdd310fab8f41f6afbe5233c6609ec19ed
Gitweb:     http://git.kernel.org/tip/02893afdd310fab8f41f6afbe5233c6609ec19ed
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:20 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
Cc: David Vrabel <david.vrabel@citrix.com>
Link: http://lkml.kernel.org/r/20140223212738.579581220@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/xen/events/events_base.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 7fea02c..5dd2ddf 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -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;

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] xen: Get rid of the last irq_desc abuse
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (2 preceding siblings ...)
  (?)
@ 2014-03-04 16:41   ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, linux-kernel, david.vrabel, hpa, xen-devel, tglx, mingo

Commit-ID:  02893afdd310fab8f41f6afbe5233c6609ec19ed
Gitweb:     http://git.kernel.org/tip/02893afdd310fab8f41f6afbe5233c6609ec19ed
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:20 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
Cc: David Vrabel <david.vrabel@citrix.com>
Link: http://lkml.kernel.org/r/20140223212738.579581220@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/xen/events/events_base.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 7fea02c..5dd2ddf 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -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;

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] genirq: Add a kstat helper to increment irq stats
  2014-02-23 21:40 ` [patch 11/26] genirq: Add a kstat helper to increment irq stats Thomas Gleixner
@ 2014-03-04 16:41   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:41 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx

Commit-ID:  792d0018a5fe31ef8ef9d07a7a02081d4abdf6b7
Gitweb:     http://git.kernel.org/tip/792d0018a5fe31ef8ef9d07a7a02081d4abdf6b7
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:14 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140223212737.422068876@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/kernel_stat.h | 12 +++++++-----
 kernel/irq/irqdesc.c        |  5 +++++
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index 51c72be..54ec7e0 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -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)
 {
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 8ab8e93..a7174617 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -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);

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] mips: Use the core irq stats function
  2014-02-23 21:40 ` [patch 12/26] mips: Use the core irq stats function Thomas Gleixner
@ 2014-03-04 16:41   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:41 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, inux-mips, ralf, peterz, tglx

Commit-ID:  310ff2c87e72208e4f04f33687abe9d208ffefe3
Gitweb:     http://git.kernel.org/tip/310ff2c87e72208e4f04f33687abe9d208ffefe3
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:14 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: mips <inux-mips@linux-mips.org>
Link: http://lkml.kernel.org/r/20140223212737.517340416@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 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(-)

diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
index dfc1b91..c1681d6 100644
--- a/arch/mips/kernel/smtc.c
+++ b/arch/mips/kernel/smtc.c
@@ -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();
diff --git a/arch/mips/sgi-ip22/ip22-int.c b/arch/mips/sgi-ip22/ip22-int.c
index 3db64d5..58b40ae 100644
--- a/arch/mips/sgi-ip22/ip22-int.c
+++ b/arch/mips/sgi-ip22/ip22-int.c
@@ -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();
 }
diff --git a/arch/mips/sgi-ip22/ip22-time.c b/arch/mips/sgi-ip22/ip22-time.c
index 6071924..045aa89 100644
--- a/arch/mips/sgi-ip22/ip22-time.c
+++ b/arch/mips/sgi-ip22/ip22-time.c
@@ -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();
diff --git a/arch/mips/sibyte/bcm1480/smp.c b/arch/mips/sibyte/bcm1480/smp.c
index 54e2c4d..70d9182 100644
--- a/arch/mips/sibyte/bcm1480/smp.c
+++ b/arch/mips/sibyte/bcm1480/smp.c
@@ -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;
 
diff --git a/arch/mips/sibyte/sb1250/smp.c b/arch/mips/sibyte/sb1250/smp.c
index d7b942d..db97611 100644
--- a/arch/mips/sibyte/sb1250/smp.c
+++ b/arch/mips/sibyte/sb1250/smp.c
@@ -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;
 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] sparc: Use the core irq stats function
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
@ 2014-03-04 16:41   ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:41 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx, davem

Commit-ID:  87a69ad6409b2c7a95e2e6e4ddbc380046cb7730
Gitweb:     http://git.kernel.org/tip/87a69ad6409b2c7a95e2e6e4ddbc380046cb7730
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:15 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: David S. Miller <davem@davemloft.net>
Link: http://lkml.kernel.org/r/20140223212737.635609567@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/sparc/kernel/time_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sparc/kernel/time_64.c b/arch/sparc/kernel/time_64.c
index c3d82b5..24e8b87 100644
--- a/arch/sparc/kernel/time_64.c
+++ b/arch/sparc/kernel/time_64.c
@@ -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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] x86: Xen: Use the core irq stats function
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (2 preceding siblings ...)
  (?)
@ 2014-03-04 16:41   ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, x86, hpa, mingo, konrad.wilk, peterz, xen-devel,
	tglx, david.vrabel

Commit-ID:  770144ea7beb3e0537277a96b104ba1daa965f76
Gitweb:     http://git.kernel.org/tip/770144ea7beb3e0537277a96b104ba1daa965f76
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:16 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
Cc: x86 <x86@kernel.org>
Link: http://lkml.kernel.org/r/20140223212737.869264085@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/xen/spinlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index 581521c..4d3acc3 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -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;

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] x86: Xen: Use the core irq stats function
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (3 preceding siblings ...)
  (?)
@ 2014-03-04 16:41   ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:41 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, x86, linux-kernel, david.vrabel, hpa, xen-devel, tglx, mingo

Commit-ID:  770144ea7beb3e0537277a96b104ba1daa965f76
Gitweb:     http://git.kernel.org/tip/770144ea7beb3e0537277a96b104ba1daa965f76
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:16 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
Cc: x86 <x86@kernel.org>
Link: http://lkml.kernel.org/r/20140223212737.869264085@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/xen/spinlock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/xen/spinlock.c b/arch/x86/xen/spinlock.c
index 581521c..4d3acc3 100644
--- a/arch/x86/xen/spinlock.c
+++ b/arch/x86/xen/spinlock.c
@@ -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;

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] mn10300: Use the core irq stats function
  2014-02-23 21:40 ` [patch 14/26] mn10300: " Thomas Gleixner
@ 2014-03-04 16:42   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, dhowells, peterz, linux-am33-list, tglx

Commit-ID:  a21748c93544901448777b5fa2abe1194c02c6dc
Gitweb:     http://git.kernel.org/tip/a21748c93544901448777b5fa2abe1194c02c6dc
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:16 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: David Howells <dhowells@redhat.com>
Cc: mn10300 <linux-am33-list@redhat.com>
Link: http://lkml.kernel.org/r/20140223212737.751487689@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/mn10300/kernel/mn10300-watchdog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mn10300/kernel/mn10300-watchdog.c b/arch/mn10300/kernel/mn10300-watchdog.c
index db64a71..a2d8e69 100644
--- a/arch/mn10300/kernel/mn10300-watchdog.c
+++ b/arch/mn10300/kernel/mn10300-watchdog.c
@@ -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) {
 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] s390: Cio: Use the core irq stats function
  2014-02-23 21:40 ` [patch 16/26] s390: cio: " Thomas Gleixner
@ 2014-03-04 16:42   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, schwidefsky, peterz, linux-s390, tglx

Commit-ID:  bc5dfcff65f24f15567f766d8bd081d594ef8cc2
Gitweb:     http://git.kernel.org/tip/bc5dfcff65f24f15567f766d8bd081d594ef8cc2
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:17 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: s390 <linux-s390@vger.kernel.org>
Link: http://lkml.kernel.org/r/20140223212737.983433636@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/s390/cio/cio.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/s390/cio/cio.c b/drivers/s390/cio/cio.c
index 8ee88c4..f711f0b 100644
--- a/drivers/s390/cio/cio.c
+++ b/drivers/s390/cio/cio.c
@@ -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

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] ia64: Use the core irq stats function
  2014-02-23 21:40 ` [patch 17/26] ia64: " Thomas Gleixner
@ 2014-03-04 16:42   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, peterz, tony.luck, linux-ia64,
	fenghua.yu, tglx

Commit-ID:  3611587aa15f4ff75a2af3483d6a02accada8ec8
Gitweb:     http://git.kernel.org/tip/3611587aa15f4ff75a2af3483d6a02accada8ec8
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:17 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: ia64 <linux-ia64@vger.kernel.org>
Link: http://lkml.kernel.org/r/20140223212738.099977064@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/ia64/kernel/irq_ia64.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/ia64/kernel/irq_ia64.c b/arch/ia64/kernel/irq_ia64.c
index 1034884..c8a576b 100644
--- a/arch/ia64/kernel/irq_ia64.c
+++ b/arch/ia64/kernel/irq_ia64.c
@@ -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);
 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] x86: Add proper vector accounting for HYPERVISOR_CALLBACK_VECTOR
  2014-02-23 21:40 ` [patch 22/26] x86: Add proper vector accounting for HyperV Thomas Gleixner
  2014-02-25 12:24   ` KY Srinivasan
@ 2014-03-04 16:42   ` tip-bot for Thomas Gleixner
  2014-09-22 21:03   ` [patch 22/26] x86: Add proper vector accounting for HyperV Elliott, Robert (Server Storage)
  2 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, x86, hpa, mingo, konrad.wilk, kys, peterz, tglx

Commit-ID:  929320e4b4c10708d3477d7e395f0ce7b0cc8744
Gitweb:     http://git.kernel.org/tip/929320e4b4c10708d3477d7e395f0ce7b0cc8744
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:20 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: K. Y. Srinivasan <kys@microsoft.com>
Cc: x86 <x86@kernel.org>
Link: http://lkml.kernel.org/r/20140223212738.681855582@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/hardirq.h | 3 +++
 arch/x86/kernel/irq.c          | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/arch/x86/include/asm/hardirq.h b/arch/x86/include/asm/hardirq.h
index ab0ae1a..afb6536 100644
--- a/arch/x86/include/asm/hardirq.h
+++ b/arch/x86/include/asm/hardirq.h
@@ -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);
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
index d99f31d..42805fa 100644
--- a/arch/x86/kernel/irq.c
+++ b/arch/x86/kernel/irq.c
@@ -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));

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] xen: Add proper irq accounting for HYPERCALL vector
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (2 preceding siblings ...)
  (?)
@ 2014-03-04 16:42   ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, konrad.wilk, peterz, xen-devel, tglx,
	david.vrabel

Commit-ID:  99c8b79d3c165f8e2a6247c14bfa1429e7efe51f
Gitweb:     http://git.kernel.org/tip/99c8b79d3c165f8e2a6247c14bfa1429e7efe51f
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:21 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 4 Mar 2014 17:37:54 +0100

xen: Add proper irq accounting for HYPERCALL vector

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
Link: http://lkml.kernel.org/r/20140223212738.808648133@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/xen/events/events_base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 5dd2ddf..8b91c256 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -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();
 

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] xen: Add proper irq accounting for HYPERCALL vector
  2014-02-23 21:40   ` Thomas Gleixner
                     ` (3 preceding siblings ...)
  (?)
@ 2014-03-04 16:42   ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, linux-kernel, david.vrabel, hpa, xen-devel, tglx, mingo

Commit-ID:  99c8b79d3c165f8e2a6247c14bfa1429e7efe51f
Gitweb:     http://git.kernel.org/tip/99c8b79d3c165f8e2a6247c14bfa1429e7efe51f
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:21 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue, 4 Mar 2014 17:37:54 +0100

xen: Add proper irq accounting for HYPERCALL vector

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: David Vrabel <david.vrabel@citrix.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Xen <xen-devel@lists.xenproject.org>
Link: http://lkml.kernel.org/r/20140223212738.808648133@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 drivers/xen/events/events_base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 5dd2ddf..8b91c256 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -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();

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] x86: Hyperv: Cleanup the irq mess
  2014-02-23 21:40 ` [patch 25/26] x86: hyperv: Cleanup the irq mess Thomas Gleixner
  2014-02-25 12:24   ` KY Srinivasan
@ 2014-03-04 16:42   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:42 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, x86, devel, hpa, mingo, peterz, kys, gregkh, tglx

Commit-ID:  1aec169673d7db113c37367bbc371c2ba8109f06
Gitweb:     http://git.kernel.org/tip/1aec169673d7db113c37367bbc371c2ba8109f06
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:22 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: K. Y. Srinivasan <kys@microsoft.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linuxdrivers <devel@linuxdriverproject.org>
Cc: x86 <x86@kernel.org>
Link: http://lkml.kernel.org/r/20140223212739.028307673@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 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(-)

diff --git a/arch/x86/include/asm/mshyperv.h b/arch/x86/include/asm/mshyperv.h
index cd9c419..e98f66f 100644
--- a/arch/x86/include/asm/mshyperv.h
+++ b/arch/x86/include/asm/mshyperv.h
@@ -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
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 9f7ca26..1bd316c 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -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 x86_hyper_ms_hyperv = {
 	.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);
-
-	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);
diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
index 077bb1b..5a6909f 100644
--- a/drivers/hv/vmbus_drv.c
+++ b/drivers/hv/vmbus_drv.c
@@ -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();

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] genirq: Move kstat_incr_irqs_this_cpu() to core
  2014-02-23 21:40 ` [patch 26/26] genirq: Move kstats_inc_irqs_this_cpu() to core Thomas Gleixner
@ 2014-03-04 16:43   ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:43 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx

Commit-ID:  8f945a3325bbe0dd651e2f496a53df9b06fc6d07
Gitweb:     http://git.kernel.org/tip/8f945a3325bbe0dd651e2f496a53df9b06fc6d07
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:23 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20140223212739.124207133@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/kernel_stat.h | 8 --------
 kernel/irq/internals.h      | 7 +++++++
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/include/linux/kernel_stat.h b/include/linux/kernel_stat.h
index 54ec7e0..c3fbda7 100644
--- a/include/linux/kernel_stat.h
+++ b/include/linux/kernel_stat.h
@@ -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)
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index d61ac29..17b6717 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -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);
+}

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] sh: Use irq_set_affinity instead of homebrewn code
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-03-04 16:43     ` tip-bot for Thomas Gleixner
  -1 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, linux-sh, hpa, mingo, peterz, lethal, tglx

Commit-ID:  6decf1a33c386d4addc2ed9d269c3868f08c70bb
Gitweb:     http://git.kernel.org/tip/6decf1a33c386d4addc2ed9d269c3868f08c70bb
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:10 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: sh <linux-sh@vger.kernel.org>
Link: http://lkml.kernel.org/r/20140223212736.774961401@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/sh/kernel/irq.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 0833736..65a1ecd 100644
--- a/arch/sh/kernel/irq.c
+++ b/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
@@ -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);
 		}
 	}
 }

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] sh: Use irq_set_affinity instead of homebrewn code
@ 2014-03-04 16:43     ` tip-bot for Thomas Gleixner
  0 siblings, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, linux-sh, hpa, mingo, peterz, lethal, tglx

Commit-ID:  6decf1a33c386d4addc2ed9d269c3868f08c70bb
Gitweb:     http://git.kernel.org/tip/6decf1a33c386d4addc2ed9d269c3868f08c70bb
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:10 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Paul Mundt <lethal@linux-sh.org>
Cc: sh <linux-sh@vger.kernel.org>
Link: http://lkml.kernel.org/r/20140223212736.774961401@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>

---
 arch/sh/kernel/irq.c | 18 +-----------------
 1 file changed, 1 insertion(+), 17 deletions(-)

diff --git a/arch/sh/kernel/irq.c b/arch/sh/kernel/irq.c
index 0833736..65a1ecd 100644
--- a/arch/sh/kernel/irq.c
+++ b/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
@@ -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);
 		}
 	}
 }

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [tip:irq/core] xtensa: Use irq_set_affinity instead of homebrewn code
  2014-02-23 21:40 ` [patch 04/26] xtensa: Use irq_set_affinity instead of homebrewn code Thomas Gleixner
  2014-02-24  0:32   ` Max Filippov
@ 2014-03-04 16:43   ` tip-bot for Thomas Gleixner
  1 sibling, 0 replies; 126+ messages in thread
From: tip-bot for Thomas Gleixner @ 2014-03-04 16:43 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, peterz, chris, tglx, linux-xtensa

Commit-ID:  b58d971da3433654787a88c40c6fca00f5bbaa04
Gitweb:     http://git.kernel.org/tip/b58d971da3433654787a88c40c6fca00f5bbaa04
Author:     Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Sun, 23 Feb 2014 21:40:10 +0000
Committer:  Thomas Gleixner <tglx@linutronix.de>
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()

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Chris Zankel <chris@zankel.net>
Cc: xtensa <linux-xtensa@linux-xtensa.org>
Link: http://lkml.kernel.org/r/20140223212736.664624945@linutronix.de
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/xtensa/kernel/irq.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/arch/xtensa/kernel/irq.c b/arch/xtensa/kernel/irq.c
index 482868a..3eee94f 100644
--- a/arch/xtensa/kernel/irq.c
+++ b/arch/xtensa/kernel/irq.c
@@ -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 */

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [Xen-devel] [tip:irq/core] xen: Get rid of the last irq_desc abuse
  2014-03-04 16:41   ` tip-bot for Thomas Gleixner
  2014-03-04 17:16     ` David Vrabel
@ 2014-03-04 17:16     ` David Vrabel
  1 sibling, 0 replies; 126+ messages in thread
From: David Vrabel @ 2014-03-04 17:16 UTC (permalink / raw)
  To: mingo, hpa, linux-kernel, konrad.wilk, peterz, xen-devel, tglx,
	david.vrabel
  Cc: tip-bot for Thomas Gleixner, linux-tip-commits

On 04/03/14 16:41, tip-bot for Thomas Gleixner wrote:
> Commit-ID:  02893afdd310fab8f41f6afbe5233c6609ec19ed
> Gitweb:     http://git.kernel.org/tip/02893afdd310fab8f41f6afbe5233c6609ec19ed
> Author:     Thomas Gleixner <tglx@linutronix.de>
> AuthorDate: Sun, 23 Feb 2014 21:40:20 +0000
> Committer:  Thomas Gleixner <tglx@linutronix.de>
> 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.

Reviewed-by: David Vrabel <david.vrabel@citrix.com>

Thanks.

David

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [tip:irq/core] xen: Get rid of the last irq_desc abuse
  2014-03-04 16:41   ` tip-bot for Thomas Gleixner
@ 2014-03-04 17:16     ` David Vrabel
  2014-03-04 17:16     ` [Xen-devel] " David Vrabel
  1 sibling, 0 replies; 126+ messages in thread
From: David Vrabel @ 2014-03-04 17:16 UTC (permalink / raw)
  To: mingo, hpa, linux-kernel, konrad.wilk, peterz, xen-devel, tglx,
	david.vrabel
  Cc: tip-bot for Thomas Gleixner, linux-tip-commits

On 04/03/14 16:41, tip-bot for Thomas Gleixner wrote:
> Commit-ID:  02893afdd310fab8f41f6afbe5233c6609ec19ed
> Gitweb:     http://git.kernel.org/tip/02893afdd310fab8f41f6afbe5233c6609ec19ed
> Author:     Thomas Gleixner <tglx@linutronix.de>
> AuthorDate: Sun, 23 Feb 2014 21:40:20 +0000
> Committer:  Thomas Gleixner <tglx@linutronix.de>
> 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.

Reviewed-by: David Vrabel <david.vrabel@citrix.com>

Thanks.

David

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 13/26] sparc: Use the core irq stats function
  2014-02-23 21:40   ` Thomas Gleixner
@ 2014-03-04 18:57     ` David Miller
  -1 siblings, 0 replies; 126+ messages in thread
From: David Miller @ 2014-03-04 18:57 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, mingo, peterz, sparclinux

From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 23 Feb 2014 21:40:15 -0000

> Let the core do the irq_desc resolution.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: sparc <sparclinux@vger.kernel.org>

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 13/26] sparc: Use the core irq stats function
@ 2014-03-04 18:57     ` David Miller
  0 siblings, 0 replies; 126+ messages in thread
From: David Miller @ 2014-03-04 18:57 UTC (permalink / raw)
  To: tglx; +Cc: linux-kernel, mingo, peterz, sparclinux

From: Thomas Gleixner <tglx@linutronix.de>
Date: Sun, 23 Feb 2014 21:40:15 -0000

> Let the core do the irq_desc resolution.
> 
> No functional change.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: sparc <sparclinux@vger.kernel.org>

Acked-by: David S. Miller <davem@davemloft.net>

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 08/26] arm: Replace various irq_desc accesses
  2014-02-23 21:40   ` Thomas Gleixner
  (?)
@ 2014-03-20 15:22     ` Arnd Bergmann
  -1 siblings, 0 replies; 126+ messages in thread
From: Arnd Bergmann @ 2014-03-20 15:22 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Thomas Gleixner, LKML, omap, Peter Zijlstra, Tony Lindgren,
	Russell King, Ingo Molnar, Shawn Guo

On Sunday 23 February 2014, Thomas Gleixner wrote:
> --- tip.orig/arch/arm/mach-omap1/ams-delta-fiq.c
> +++ tip/arch/arm/mach-omap1/ams-delta-fiq.c
> @@ -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));

I got a compile error because irq_get_irq_chip() doesn't exist. I suppose
you meant irq_get_chip.

	Arnd

^ permalink raw reply	[flat|nested] 126+ messages in thread

* Re: [patch 08/26] arm: Replace various irq_desc accesses
@ 2014-03-20 15:22     ` Arnd Bergmann
  0 siblings, 0 replies; 126+ messages in thread
From: Arnd Bergmann @ 2014-03-20 15:22 UTC (permalink / raw)
  To: linux-arm-kernel
  Cc: Shawn Guo, Peter Zijlstra, LKML, Tony Lindgren, Russell King,
	Thomas Gleixner, omap, Ingo Molnar

On Sunday 23 February 2014, Thomas Gleixner wrote:
> --- tip.orig/arch/arm/mach-omap1/ams-delta-fiq.c
> +++ tip/arch/arm/mach-omap1/ams-delta-fiq.c
> @@ -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));

I got a compile error because irq_get_irq_chip() doesn't exist. I suppose
you meant irq_get_chip.

	Arnd

^ permalink raw reply	[flat|nested] 126+ messages in thread

* [patch 08/26] arm: Replace various irq_desc accesses
@ 2014-03-20 15:22     ` Arnd Bergmann
  0 siblings, 0 replies; 126+ messages in thread
From: Arnd Bergmann @ 2014-03-20 15:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Sunday 23 February 2014, Thomas Gleixner wrote:
> --- tip.orig/arch/arm/mach-omap1/ams-delta-fiq.c
> +++ tip/arch/arm/mach-omap1/ams-delta-fiq.c
> @@ -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));

I got a compile error because irq_get_irq_chip() doesn't exist. I suppose
you meant irq_get_chip.

	Arnd

^ permalink raw reply	[flat|nested] 126+ messages in thread

* RE: [patch 22/26] x86: Add proper vector accounting for HyperV
  2014-02-23 21:40 ` [patch 22/26] x86: Add proper vector accounting for HyperV Thomas Gleixner
  2014-02-25 12:24   ` KY Srinivasan
  2014-03-04 16:42   ` [tip:irq/core] x86: Add proper vector accounting for HYPERVISOR_CALLBACK_VECTOR tip-bot for Thomas Gleixner
@ 2014-09-22 21:03   ` Elliott, Robert (Server Storage)
  2 siblings, 0 replies; 126+ messages in thread
From: Elliott, Robert (Server Storage) @ 2014-09-22 21:03 UTC (permalink / raw)
  To: Thomas Gleixner, LKML
  Cc: Ingo Molnar, Peter Zijlstra, x86, Konrad Rzeszutek Wilk,
	K. Y. Srinivasan

> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> owner@vger.kernel.org] 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 HyperV
> 
> HyperV abuses a device interrupt to account for the
> HYPERVISOR_CALLBACK_VECTOR.
> 
> Provide proper accounting as we have for the other vectors as well.
...
> Index: tip/arch/x86/kernel/irq.c
> ===================================================================
> --- tip.orig/arch/x86/kernel/irq.c
> +++ tip/arch/x86/kernel/irq.c
> @@ -125,6 +125,12 @@ int arch_show_interrupts(struct seq_file
>  		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
...

Should this have used a different short string than "THR",
which is already used for "Threshold APIC interrupts"?

---
Rob Elliott    HP Server Storage




^ permalink raw reply	[flat|nested] 126+ messages in thread

end of thread, other threads:[~2014-09-22 21:04 UTC | newest]

Thread overview: 126+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-23 21:40 [patch 00/26] genirq: Another round of tree wide cleanups Thomas Gleixner
2014-02-23 21:40 ` [patch 01/26] powerpc: irq: Use generic_handle_irq Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-03-04 16:39   ` [tip:irq/core] powerpc: Irq: " tip-bot for Thomas Gleixner
2014-03-04 16:39     ` tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 02/26] powerpc:evh_pic: Kill irq_desc abuse Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-03-04 16:39   ` [tip:irq/core] powerpc:eVh_pic: " tip-bot for Thomas Gleixner
2014-03-04 16:39     ` tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 03/26] powerpc: eeh: Kill another abuse of irq_desc Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-02-23 22:26   ` Benjamin Herrenschmidt
2014-02-23 22:26     ` Benjamin Herrenschmidt
2014-02-24  7:56   ` Gavin Shan
2014-02-24 11:32     ` Thomas Gleixner
2014-02-24 11:32       ` Thomas Gleixner
2014-03-04 16:40   ` [tip:irq/core] powerpc: Eeh: " tip-bot for Thomas Gleixner
2014-03-04 16:40     ` tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 04/26] xtensa: Use irq_set_affinity instead of homebrewn code Thomas Gleixner
2014-02-24  0:32   ` Max Filippov
2014-03-04 16:43   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 05/26] sh: " Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-03-04 16:43   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-04 16:43     ` tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 06/26] metag: " Thomas Gleixner
2014-02-24 13:24   ` James Hogan
2014-02-24 14:24     ` Thomas Gleixner
2014-02-25 18:56       ` Thomas Gleixner
2014-02-25 21:57       ` James Hogan
2014-02-27 10:59         ` Thomas Gleixner
2014-02-23 21:40 ` [patch 07/26] pci: pcie-designware: Remove irq_desc abuse Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-03-04 16:40   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 08/26] arm: Replace various irq_desc accesses Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-02-24  2:55   ` Shawn Guo
2014-02-24  2:55     ` Shawn Guo
2014-02-24  2:55     ` Shawn Guo
2014-02-26 17:05     ` Tony Lindgren
2014-02-26 17:05       ` Tony Lindgren
2014-03-04 16:40   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-20 15:22   ` [patch 08/26] " Arnd Bergmann
2014-03-20 15:22     ` Arnd Bergmann
2014-03-20 15:22     ` Arnd Bergmann
2014-02-23 21:40 ` [patch 10/26] blackfin:Use generic /proc/interrupts implementation Thomas Gleixner
2014-02-26 10:00   ` Steven Miao
2014-02-23 21:40 ` [patch 09/26] arm: mmp: Remove pointless fiddling with irq internals Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-02-23 23:17   ` Uwe Kleine-König
2014-02-23 23:17     ` Uwe Kleine-König
2014-02-24  6:07     ` Chao Xie
2014-02-24  6:07       ` Chao Xie
2014-02-24  6:43       ` Haojian Zhuang
2014-02-24  6:43         ` Haojian Zhuang
2014-02-24 11:31         ` Thomas Gleixner
2014-02-24 11:31           ` Thomas Gleixner
2014-02-27  1:37           ` Chao Xie
2014-02-27  1:37             ` Chao Xie
2014-02-27  2:19             ` Haojian Zhuang
2014-02-27  2:19               ` Haojian Zhuang
2014-02-27 11:28               ` Thomas Gleixner
2014-02-27 11:28                 ` Thomas Gleixner
2014-02-24 11:27       ` Thomas Gleixner
2014-02-24 11:27         ` Thomas Gleixner
2014-03-04 16:40   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 12/26] mips: Use the core irq stats function Thomas Gleixner
2014-03-04 16:41   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 11/26] genirq: Add a kstat helper to increment irq stats Thomas Gleixner
2014-03-04 16:41   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 13/26] sparc: Use the core irq stats function Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-03-04 16:41   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-04 18:57   ` [patch 13/26] " David Miller
2014-03-04 18:57     ` David Miller
2014-02-23 21:40 ` [patch 14/26] mn10300: " Thomas Gleixner
2014-03-04 16:42   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 15/26] x86: xen: " Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-02-24 14:20   ` David Vrabel
2014-02-24 14:20   ` [Xen-devel] " David Vrabel
2014-03-04 16:41   ` [tip:irq/core] x86: Xen: " tip-bot for Thomas Gleixner
2014-03-04 16:41   ` tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 17/26] ia64: " Thomas Gleixner
2014-03-04 16:42   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 16/26] s390: cio: " Thomas Gleixner
2014-03-04 16:42   ` [tip:irq/core] s390: Cio: " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 18/26] xen: Use the proper irq functions Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-02-24 14:24   ` [Xen-devel] " David Vrabel
2014-02-24 21:13     ` Thomas Gleixner
2014-02-24 21:13     ` [Xen-devel] " Thomas Gleixner
2014-02-24 14:24   ` David Vrabel
2014-03-04 16:40   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-04 16:40     ` tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 19/26] genirq: Provide irqd_irq_has_actions() Thomas Gleixner
2014-02-23 21:40 ` [patch 20/26] genirq: Provide irq_is_allocated() Thomas Gleixner
2014-02-23 21:40 ` [patch 21/26] xen: Get rid of the last irq_desc abuse Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-02-24 14:33   ` David Vrabel
2014-02-24 14:33   ` [Xen-devel] " David Vrabel
2014-02-24 21:12     ` Thomas Gleixner
2014-02-24 21:12     ` [Xen-devel] " Thomas Gleixner
2014-03-04 16:41   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-04 16:41   ` tip-bot for Thomas Gleixner
2014-03-04 17:16     ` David Vrabel
2014-03-04 17:16     ` [Xen-devel] " David Vrabel
2014-02-23 21:40 ` [patch 22/26] x86: Add proper vector accounting for HyperV Thomas Gleixner
2014-02-25 12:24   ` KY Srinivasan
2014-03-04 16:42   ` [tip:irq/core] x86: Add proper vector accounting for HYPERVISOR_CALLBACK_VECTOR tip-bot for Thomas Gleixner
2014-09-22 21:03   ` [patch 22/26] x86: Add proper vector accounting for HyperV Elliott, Robert (Server Storage)
2014-02-23 21:40 ` [patch 23/26] xen: Add proper irq accounting for HYPERCALL vector Thomas Gleixner
2014-02-23 21:40   ` Thomas Gleixner
2014-02-24 14:48   ` David Vrabel
2014-02-24 14:48   ` [Xen-devel] " David Vrabel
2014-03-04 16:42   ` [tip:irq/core] " tip-bot for Thomas Gleixner
2014-03-04 16:42   ` tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 24/26] genirq: Provide handle_percpu_simple_irq() Thomas Gleixner
2014-02-25 12:25   ` KY Srinivasan
2014-02-23 21:40 ` [patch 25/26] x86: hyperv: Cleanup the irq mess Thomas Gleixner
2014-02-25 12:24   ` KY Srinivasan
2014-02-25 19:10     ` Thomas Gleixner
2014-02-28  2:50       ` KY Srinivasan
2014-03-04 16:42   ` [tip:irq/core] x86: Hyperv: " tip-bot for Thomas Gleixner
2014-02-23 21:40 ` [patch 26/26] genirq: Move kstats_inc_irqs_this_cpu() to core Thomas Gleixner
2014-03-04 16:43   ` [tip:irq/core] genirq: Move kstat_incr_irqs_this_cpu() " tip-bot for Thomas Gleixner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.