All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] x86: io_apic: Move and reenable irq only when CONFIG_GENERIC_PENDING_IRQ=y
@ 2012-03-20 14:19 Alexander Gordeev
  2012-03-23 12:35 ` Ingo Molnar
  2012-03-23 19:46 ` [tip:x86/urgent] x86/io_apic: " tip-bot for Alexander Gordeev
  0 siblings, 2 replies; 5+ messages in thread
From: Alexander Gordeev @ 2012-03-20 14:19 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel

When CONFIG_GENERIC_PENDING_IRQ=n irq move and reenable code is never
get executed, nor do_unmask_irq variable updates its init value. Move
the code under CONFIG_GENERIC_PENDING_IRQ macro.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
---
 arch/x86/kernel/apic/io_apic.c |  101 ++++++++++++++++++++++++----------------
 1 files changed, 61 insertions(+), 40 deletions(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index fb07275..8cd6360 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2512,21 +2512,73 @@ static void ack_apic_edge(struct irq_data *data)
 
 atomic_t irq_mis_count;
 
-static void ack_apic_level(struct irq_data *data)
-{
-	struct irq_cfg *cfg = data->chip_data;
-	int i, do_unmask_irq = 0, irq = data->irq;
-	unsigned long v;
-
-	irq_complete_move(cfg);
 #ifdef CONFIG_GENERIC_PENDING_IRQ
+static inline bool ioapic_irqd_mask(struct irq_data *data, struct irq_cfg *cfg)
+{
 	/* If we are moving the irq we need to mask it */
 	if (unlikely(irqd_is_setaffinity_pending(data))) {
-		do_unmask_irq = 1;
 		mask_ioapic(cfg);
+		return true;
 	}
+	return false;
+}
+
+static inline void ioapic_irqd_unmask(struct irq_data *data,
+				      struct irq_cfg *cfg, bool masked)
+{
+	if (unlikely(masked)) {
+		/* Only migrate the irq if the ack has been received.
+		 *
+		 * On rare occasions the broadcast level triggered ack gets
+		 * delayed going to ioapics, and if we reprogram the
+		 * vector while Remote IRR is still set the irq will never
+		 * fire again.
+		 *
+		 * To prevent this scenario we read the Remote IRR bit
+		 * of the ioapic.  This has two effects.
+		 * - On any sane system the read of the ioapic will
+		 *   flush writes (and acks) going to the ioapic from
+		 *   this cpu.
+		 * - We get to see if the ACK has actually been delivered.
+		 *
+		 * Based on failed experiments of reprogramming the
+		 * ioapic entry from outside of irq context starting
+		 * with masking the ioapic entry and then polling until
+		 * Remote IRR was clear before reprogramming the
+		 * ioapic I don't trust the Remote IRR bit to be
+		 * completey accurate.
+		 *
+		 * However there appears to be no other way to plug
+		 * this race, so if the Remote IRR bit is not
+		 * accurate and is causing problems then it is a hardware bug
+		 * and you can go talk to the chipset vendor about it.
+		 */
+		if (!io_apic_level_ack_pending(cfg))
+			irq_move_masked_irq(data);
+		unmask_ioapic(cfg);
+	}
+}
+#else
+static inline bool ioapic_irqd_mask(struct irq_data *data, struct irq_cfg *cfg)
+{
+	return false;
+}
+static inline void ioapic_irqd_unmask(struct irq_data *data,
+				      struct irq_cfg *cfg, bool masked)
+{
+}
 #endif
 
+static void ack_apic_level(struct irq_data *data)
+{
+	struct irq_cfg *cfg = data->chip_data;
+	int i, irq = data->irq;
+	unsigned long v;
+	bool masked;
+
+	irq_complete_move(cfg);
+	masked = ioapic_irqd_mask(data, cfg);
+
 	/*
 	 * It appears there is an erratum which affects at least version 0x11
 	 * of I/O APIC (that's the 82093AA and cores integrated into various
@@ -2581,38 +2633,7 @@ static void ack_apic_level(struct irq_data *data)
 		eoi_ioapic_irq(irq, cfg);
 	}
 
-	/* Now we can move and renable the irq */
-	if (unlikely(do_unmask_irq)) {
-		/* Only migrate the irq if the ack has been received.
-		 *
-		 * On rare occasions the broadcast level triggered ack gets
-		 * delayed going to ioapics, and if we reprogram the
-		 * vector while Remote IRR is still set the irq will never
-		 * fire again.
-		 *
-		 * To prevent this scenario we read the Remote IRR bit
-		 * of the ioapic.  This has two effects.
-		 * - On any sane system the read of the ioapic will
-		 *   flush writes (and acks) going to the ioapic from
-		 *   this cpu.
-		 * - We get to see if the ACK has actually been delivered.
-		 *
-		 * Based on failed experiments of reprogramming the
-		 * ioapic entry from outside of irq context starting
-		 * with masking the ioapic entry and then polling until
-		 * Remote IRR was clear before reprogramming the
-		 * ioapic I don't trust the Remote IRR bit to be
-		 * completey accurate.
-		 *
-		 * However there appears to be no other way to plug
-		 * this race, so if the Remote IRR bit is not
-		 * accurate and is causing problems then it is a hardware bug
-		 * and you can go talk to the chipset vendor about it.
-		 */
-		if (!io_apic_level_ack_pending(cfg))
-			irq_move_masked_irq(data);
-		unmask_ioapic(cfg);
-	}
+	ioapic_irqd_unmask(data, cfg, masked);
 }
 
 #ifdef CONFIG_IRQ_REMAP
-- 
1.7.7.6


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

* Re: [PATCH V2] x86: io_apic: Move and reenable irq only when CONFIG_GENERIC_PENDING_IRQ=y
  2012-03-20 14:19 [PATCH V2] x86: io_apic: Move and reenable irq only when CONFIG_GENERIC_PENDING_IRQ=y Alexander Gordeev
@ 2012-03-23 12:35 ` Ingo Molnar
  2012-03-23 12:45   ` Alexander Gordeev
  2012-03-23 19:46 ` [tip:x86/urgent] x86/io_apic: " tip-bot for Alexander Gordeev
  1 sibling, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2012-03-23 12:35 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: Ingo Molnar, linux-kernel


* Alexander Gordeev <agordeev@redhat.com> wrote:

> When CONFIG_GENERIC_PENDING_IRQ=n irq move and reenable code 
> is never get executed, nor do_unmask_irq variable updates its 
> init value. Move the code under CONFIG_GENERIC_PENDING_IRQ 
> macro.

It's not clear from the changelog what it does though, and the
#ifdefs are quite a mess. Does the patch fix some real bug? Or 
does it remove dead code from certain .config variations?

Thanks,

	Ingo

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

* Re: [PATCH V2] x86: io_apic: Move and reenable irq only when CONFIG_GENERIC_PENDING_IRQ=y
  2012-03-23 12:35 ` Ingo Molnar
@ 2012-03-23 12:45   ` Alexander Gordeev
  2012-03-23 12:46     ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Gordeev @ 2012-03-23 12:45 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Ingo Molnar, linux-kernel

On Fri, Mar 23, 2012 at 01:35:03PM +0100, Ingo Molnar wrote:
> 
> * Alexander Gordeev <agordeev@redhat.com> wrote:
> 
> > When CONFIG_GENERIC_PENDING_IRQ=n irq move and reenable code 
> > is never get executed, nor do_unmask_irq variable updates its 
> > init value. Move the code under CONFIG_GENERIC_PENDING_IRQ 
> > macro.
> 
> It's not clear from the changelog what it does though, and the
> #ifdefs are quite a mess. Does the patch fix some real bug? Or 
> does it remove dead code from certain .config variations?

It just removes a dead code. Can reword if it worth it.

> Thanks,
> 
> 	Ingo

-- 
Regards,
Alexander Gordeev
agordeev@redhat.com

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

* Re: [PATCH V2] x86: io_apic: Move and reenable irq only when CONFIG_GENERIC_PENDING_IRQ=y
  2012-03-23 12:45   ` Alexander Gordeev
@ 2012-03-23 12:46     ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2012-03-23 12:46 UTC (permalink / raw)
  To: Alexander Gordeev; +Cc: Ingo Molnar, linux-kernel


* Alexander Gordeev <agordeev@redhat.com> wrote:

> On Fri, Mar 23, 2012 at 01:35:03PM +0100, Ingo Molnar wrote:
> > 
> > * Alexander Gordeev <agordeev@redhat.com> wrote:
> > 
> > > When CONFIG_GENERIC_PENDING_IRQ=n irq move and reenable code 
> > > is never get executed, nor do_unmask_irq variable updates its 
> > > init value. Move the code under CONFIG_GENERIC_PENDING_IRQ 
> > > macro.
> > 
> > It's not clear from the changelog what it does though, and the
> > #ifdefs are quite a mess. Does the patch fix some real bug? Or 
> > does it remove dead code from certain .config variations?
> 
> It just removes a dead code. Can reword if it worth it.

No need to resend, I'll add this detail.

Thanks,

	Ingo

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

* [tip:x86/urgent] x86/io_apic: Move and reenable irq only when CONFIG_GENERIC_PENDING_IRQ=y
  2012-03-20 14:19 [PATCH V2] x86: io_apic: Move and reenable irq only when CONFIG_GENERIC_PENDING_IRQ=y Alexander Gordeev
  2012-03-23 12:35 ` Ingo Molnar
@ 2012-03-23 19:46 ` tip-bot for Alexander Gordeev
  1 sibling, 0 replies; 5+ messages in thread
From: tip-bot for Alexander Gordeev @ 2012-03-23 19:46 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, agordeev, hpa, mingo, tglx

Commit-ID:  4da7072ad6831a35a11341097ce477e18651bedd
Gitweb:     http://git.kernel.org/tip/4da7072ad6831a35a11341097ce477e18651bedd
Author:     Alexander Gordeev <agordeev@redhat.com>
AuthorDate: Tue, 20 Mar 2012 15:19:36 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 23 Mar 2012 13:47:25 +0100

x86/io_apic: Move and reenable irq only when CONFIG_GENERIC_PENDING_IRQ=y

This patch removes dead code from certain .config variations.

When CONFIG_GENERIC_PENDING_IRQ=n irq move and reenable code is
never get executed, nor do_unmask_irq variable updates its init
value. Move the code under CONFIG_GENERIC_PENDING_IRQ macro.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Link: http://lkml.kernel.org/r/20120320141935.GA24806@dhcp-26-207.brq.redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/apic/io_apic.c |  101 ++++++++++++++++++++++++----------------
 1 files changed, 61 insertions(+), 40 deletions(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 6d10a66..2c428c5 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -2512,21 +2512,73 @@ static void ack_apic_edge(struct irq_data *data)
 
 atomic_t irq_mis_count;
 
-static void ack_apic_level(struct irq_data *data)
-{
-	struct irq_cfg *cfg = data->chip_data;
-	int i, do_unmask_irq = 0, irq = data->irq;
-	unsigned long v;
-
-	irq_complete_move(cfg);
 #ifdef CONFIG_GENERIC_PENDING_IRQ
+static inline bool ioapic_irqd_mask(struct irq_data *data, struct irq_cfg *cfg)
+{
 	/* If we are moving the irq we need to mask it */
 	if (unlikely(irqd_is_setaffinity_pending(data))) {
-		do_unmask_irq = 1;
 		mask_ioapic(cfg);
+		return true;
 	}
+	return false;
+}
+
+static inline void ioapic_irqd_unmask(struct irq_data *data,
+				      struct irq_cfg *cfg, bool masked)
+{
+	if (unlikely(masked)) {
+		/* Only migrate the irq if the ack has been received.
+		 *
+		 * On rare occasions the broadcast level triggered ack gets
+		 * delayed going to ioapics, and if we reprogram the
+		 * vector while Remote IRR is still set the irq will never
+		 * fire again.
+		 *
+		 * To prevent this scenario we read the Remote IRR bit
+		 * of the ioapic.  This has two effects.
+		 * - On any sane system the read of the ioapic will
+		 *   flush writes (and acks) going to the ioapic from
+		 *   this cpu.
+		 * - We get to see if the ACK has actually been delivered.
+		 *
+		 * Based on failed experiments of reprogramming the
+		 * ioapic entry from outside of irq context starting
+		 * with masking the ioapic entry and then polling until
+		 * Remote IRR was clear before reprogramming the
+		 * ioapic I don't trust the Remote IRR bit to be
+		 * completey accurate.
+		 *
+		 * However there appears to be no other way to plug
+		 * this race, so if the Remote IRR bit is not
+		 * accurate and is causing problems then it is a hardware bug
+		 * and you can go talk to the chipset vendor about it.
+		 */
+		if (!io_apic_level_ack_pending(cfg))
+			irq_move_masked_irq(data);
+		unmask_ioapic(cfg);
+	}
+}
+#else
+static inline bool ioapic_irqd_mask(struct irq_data *data, struct irq_cfg *cfg)
+{
+	return false;
+}
+static inline void ioapic_irqd_unmask(struct irq_data *data,
+				      struct irq_cfg *cfg, bool masked)
+{
+}
 #endif
 
+static void ack_apic_level(struct irq_data *data)
+{
+	struct irq_cfg *cfg = data->chip_data;
+	int i, irq = data->irq;
+	unsigned long v;
+	bool masked;
+
+	irq_complete_move(cfg);
+	masked = ioapic_irqd_mask(data, cfg);
+
 	/*
 	 * It appears there is an erratum which affects at least version 0x11
 	 * of I/O APIC (that's the 82093AA and cores integrated into various
@@ -2581,38 +2633,7 @@ static void ack_apic_level(struct irq_data *data)
 		eoi_ioapic_irq(irq, cfg);
 	}
 
-	/* Now we can move and renable the irq */
-	if (unlikely(do_unmask_irq)) {
-		/* Only migrate the irq if the ack has been received.
-		 *
-		 * On rare occasions the broadcast level triggered ack gets
-		 * delayed going to ioapics, and if we reprogram the
-		 * vector while Remote IRR is still set the irq will never
-		 * fire again.
-		 *
-		 * To prevent this scenario we read the Remote IRR bit
-		 * of the ioapic.  This has two effects.
-		 * - On any sane system the read of the ioapic will
-		 *   flush writes (and acks) going to the ioapic from
-		 *   this cpu.
-		 * - We get to see if the ACK has actually been delivered.
-		 *
-		 * Based on failed experiments of reprogramming the
-		 * ioapic entry from outside of irq context starting
-		 * with masking the ioapic entry and then polling until
-		 * Remote IRR was clear before reprogramming the
-		 * ioapic I don't trust the Remote IRR bit to be
-		 * completey accurate.
-		 *
-		 * However there appears to be no other way to plug
-		 * this race, so if the Remote IRR bit is not
-		 * accurate and is causing problems then it is a hardware bug
-		 * and you can go talk to the chipset vendor about it.
-		 */
-		if (!io_apic_level_ack_pending(cfg))
-			irq_move_masked_irq(data);
-		unmask_ioapic(cfg);
-	}
+	ioapic_irqd_unmask(data, cfg, masked);
 }
 
 #ifdef CONFIG_IRQ_REMAP

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

end of thread, other threads:[~2012-03-23 19:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-20 14:19 [PATCH V2] x86: io_apic: Move and reenable irq only when CONFIG_GENERIC_PENDING_IRQ=y Alexander Gordeev
2012-03-23 12:35 ` Ingo Molnar
2012-03-23 12:45   ` Alexander Gordeev
2012-03-23 12:46     ` Ingo Molnar
2012-03-23 19:46 ` [tip:x86/urgent] x86/io_apic: " tip-bot for Alexander Gordeev

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.