All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] irq: handle irq0 special only on x86
@ 2009-12-09  9:20 Uwe Kleine-König
  2009-12-09  9:28 ` Américo Wang
  2010-01-12 15:59 ` Uwe Kleine-König
  0 siblings, 2 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2009-12-09  9:20 UTC (permalink / raw)
  To: x86; +Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin

I just noticed this when digging in the irq handling.  At least for arm
this doesn't make sense.  Not sure if x86 is the only arch this test
is valid for, but probably it is.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
---
 kernel/irq/spurious.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
index 22b0a6e..4996b66 100644
--- a/kernel/irq/spurious.c
+++ b/kernel/irq/spurious.c
@@ -199,8 +199,10 @@ try_misrouted_irq(unsigned int irq, struct irq_desc *desc,
 	if (irqfixup < 2)
 		return 0;
 
+#if defined(CONFIG_ARCH_X86)
 	if (!irq)
 		return 1;
+#endif
 
 	/*
 	 * Since we don't get the descriptor lock, "action" can
-- 
1.6.5.2


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

* Re: [PATCH] irq: handle irq0 special only on x86
  2009-12-09  9:20 [PATCH] irq: handle irq0 special only on x86 Uwe Kleine-König
@ 2009-12-09  9:28 ` Américo Wang
  2009-12-09  9:35   ` Uwe Kleine-König
  2009-12-09  9:41   ` David Miller
  2010-01-12 15:59 ` Uwe Kleine-König
  1 sibling, 2 replies; 10+ messages in thread
From: Américo Wang @ 2009-12-09  9:28 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: x86, linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin

2009/12/9 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> I just noticed this when digging in the irq handling.  At least for arm
> this doesn't make sense.  Not sure if x86 is the only arch this test
> is valid for, but probably it is.

No, it is not.

Try grep -Inr 'irq0' arch/*/kernel.


>
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> ---
>  kernel/irq/spurious.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
>
> diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
> index 22b0a6e..4996b66 100644
> --- a/kernel/irq/spurious.c
> +++ b/kernel/irq/spurious.c
> @@ -199,8 +199,10 @@ try_misrouted_irq(unsigned int irq, struct irq_desc *desc,
>        if (irqfixup < 2)
>                return 0;
>
> +#if defined(CONFIG_ARCH_X86)
>        if (!irq)
>                return 1;
> +#endif
>
>        /*
>         * Since we don't get the descriptor lock, "action" can

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

* Re: [PATCH] irq: handle irq0 special only on x86
  2009-12-09  9:28 ` Américo Wang
@ 2009-12-09  9:35   ` Uwe Kleine-König
  2009-12-09  9:41   ` David Miller
  1 sibling, 0 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2009-12-09  9:35 UTC (permalink / raw)
  To: Américo Wang
  Cc: x86, linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin

Hello,

On Wed, Dec 09, 2009 at 05:28:09PM +0800, Américo Wang wrote:
> 2009/12/9 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> > I just noticed this when digging in the irq handling.  At least for arm
> > this doesn't make sense.  Not sure if x86 is the only arch this test
> > is valid for, but probably it is.
> 
> No, it is not.
> 
> Try grep -Inr 'irq0' arch/*/kernel.
Some hits are unrelated, some others are usage of an irq0.  AFAIK irq0
is reported on x86 for misrouted irqs[1].  I think on other archs it's just
an ordinary irq.  If you still think I missed something in the output of
your grep, please be a bit more specific.

Thanks
Uwe

[1] I don't really know x86, so this might be complete non-sense.

> > Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> > Cc: Thomas Gleixner <tglx@linutronix.de>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: H. Peter Anvin <hpa@zytor.com>
> > ---
> >  kernel/irq/spurious.c |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> >
> > diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
> > index 22b0a6e..4996b66 100644
> > --- a/kernel/irq/spurious.c
> > +++ b/kernel/irq/spurious.c
> > @@ -199,8 +199,10 @@ try_misrouted_irq(unsigned int irq, struct irq_desc *desc,
> >        if (irqfixup < 2)
> >                return 0;
> >
> > +#if defined(CONFIG_ARCH_X86)
> >        if (!irq)
> >                return 1;
> > +#endif
> >
> >        /*
> >         * Since we don't get the descriptor lock, "action" can
> 

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

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

* Re: [PATCH] irq: handle irq0 special only on x86
  2009-12-09  9:28 ` Américo Wang
  2009-12-09  9:35   ` Uwe Kleine-König
@ 2009-12-09  9:41   ` David Miller
  2009-12-10  8:24     ` Uwe Kleine-König
  1 sibling, 1 reply; 10+ messages in thread
From: David Miller @ 2009-12-09  9:41 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: u.kleine-koenig, x86, linux-kernel, tglx, mingo, hpa

From: Am^[$(D+1^[(Brico Wang <xiyou.wangcong@gmail.com>
Date: Wed, 9 Dec 2009 17:28:09 +0800

> 2009/12/9 Uwe Kleine-K^[$(D+S^[(Bnig <u.kleine-koenig@pengutronix.de>:
>> I just noticed this when digging in the irq handling. ^[,A ^[(BAt least for arm
>> this doesn't make sense. ^[,A ^[(BNot sure if x86 is the only arch this test
>> is valid for, but probably it is.
> 
> No, it is not.
> 
> Try grep -Inr 'irq0' arch/*/kernel.

The edict was sent down long ago that IRQ number zero is
special across the entire kernel tree.

If IRQ zero can happen, you should offset the IRQ values you publish
to the rest of the kernel, and translate them back when you process
them internally.

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

* Re: [PATCH] irq: handle irq0 special only on x86
  2009-12-09  9:41   ` David Miller
@ 2009-12-10  8:24     ` Uwe Kleine-König
  2009-12-10 16:40       ` H. Peter Anvin
  0 siblings, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2009-12-10  8:24 UTC (permalink / raw)
  To: David Miller; +Cc: xiyou.wangcong, x86, linux-kernel, tglx, mingo, hpa

Hi David,

On Wed, Dec 09, 2009 at 01:41:51AM -0800, David Miller wrote:
> From: Américo Wang <xiyou.wangcong@gmail.com>
> Date: Wed, 9 Dec 2009 17:28:09 +0800
> 
> > 2009/12/9 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> >> I just noticed this when digging in the irq handling. ^[,A At least for arm
> >> this doesn't make sense. ^[,A Not sure if x86 is the only arch this test
> >> is valid for, but probably it is.
> > 
> > No, it is not.
> > 
> > Try grep -Inr 'irq0' arch/*/kernel.
> 
> The edict was sent down long ago that IRQ number zero is
> special across the entire kernel tree.
This doesn't help here.  x86 uses irq0 for timing and AFAIK it's some
kind of catch-it-all interrupt---I don't know the exact details though.

> If IRQ zero can happen, you should offset the IRQ values you publish
> to the rest of the kernel, and translate them back when you process
> them internally.
Even if x86 will do that the problem remains.  After it does an offset
of 1 (say) the code will read as follows after adaption:

	/*
	 * But for 'irqfixup == 2' we also do it for handled interrupts if
	 * they are marked as IRQF_IRQPOLL (or for irq zero, which is the
	 * traditional PC timer interrupt.. Legacy)
	 */
	if (irqfixup < 2)
		return 0;

	if (irq == 1)
		return 1;

So try_misrouted_irq hard codes the value of the timer irq (be it zero
or one) and this is wrong for other archs like ARM where irq0 is used on
some machines, too.  There it's just an ordinary irq.

BTW I don't see a reason to forbid irq0 if you don't need to doubt of
it's validity even in driver code.

So if the resources of a platform device specify:

	struct resource mydevicesresources[] = {
		...
		{
			.start = 0,
			.end = 0,
			.flags = IORESOURCE_IRQ,
		},
		...
	};

I'd like to use the returned value by platform_get_irq for this device.

Note, I fully agree to use 0 for NO_IRQ if you have an int-sized value
that holds either NO_IRQ or a valid irq number.  But in practise I'd not
recommend to use this idiom.

Best regards
Uwe

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

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

* Re: [PATCH] irq: handle irq0 special only on x86
  2009-12-10  8:24     ` Uwe Kleine-König
@ 2009-12-10 16:40       ` H. Peter Anvin
  2009-12-13  0:34         ` Maciej W. Rozycki
  2009-12-16 14:04         ` Uwe Kleine-König
  0 siblings, 2 replies; 10+ messages in thread
From: H. Peter Anvin @ 2009-12-10 16:40 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: David Miller, xiyou.wangcong, x86, linux-kernel, tglx, mingo

On 12/10/2009 12:24 AM, Uwe Kleine-König wrote:
> 
> Note, I fully agree to use 0 for NO_IRQ if you have an int-sized value
> that holds either NO_IRQ or a valid irq number.  But in practise I'd not
> recommend to use this idiom.
> 

You're tilting at windmills about something that was settled long ago,
like it or not.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


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

* Re: [PATCH] irq: handle irq0 special only on x86
  2009-12-10 16:40       ` H. Peter Anvin
@ 2009-12-13  0:34         ` Maciej W. Rozycki
  2009-12-16 14:04         ` Uwe Kleine-König
  1 sibling, 0 replies; 10+ messages in thread
From: Maciej W. Rozycki @ 2009-12-13  0:34 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: Uwe Kleine-König, David Miller, xiyou.wangcong, x86,
	linux-kernel, tglx, mingo

On Thu, 10 Dec 2009, H. Peter Anvin wrote:

> > Note, I fully agree to use 0 for NO_IRQ if you have an int-sized value
> > that holds either NO_IRQ or a valid irq number.  But in practise I'd not
> > recommend to use this idiom.
> > 
> 
> You're tilting at windmills about something that was settled long ago,
> like it or not.

 This is nothing that couldn't be changed; my personal preference would be 
quite the obvious choice of something along the lines of:

#define NO_IRQ -1U

that would also have the benefit of forcing all the relevant places to use 
the macro rather than an expression like !irq, improving code readability 
and greppability.

 My motivation to push any such change at the moment is rather weak though 
-- it's been a while since I was last pissed off by the weirdness of 
assumptions about IRQ 0 in Linux.

  Maciej

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

* Re: [PATCH] irq: handle irq0 special only on x86
  2009-12-10 16:40       ` H. Peter Anvin
  2009-12-13  0:34         ` Maciej W. Rozycki
@ 2009-12-16 14:04         ` Uwe Kleine-König
  1 sibling, 0 replies; 10+ messages in thread
From: Uwe Kleine-König @ 2009-12-16 14:04 UTC (permalink / raw)
  To: H. Peter Anvin
  Cc: David Miller, xiyou.wangcong, x86, linux-kernel, tglx, mingo

On Thu, Dec 10, 2009 at 08:40:11AM -0800, H. Peter Anvin wrote:
> On 12/10/2009 12:24 AM, Uwe Kleine-König wrote:
> > 
> > Note, I fully agree to use 0 for NO_IRQ if you have an int-sized value
> > that holds either NO_IRQ or a valid irq number.  But in practise I'd not
> > recommend to use this idiom.
> > 
> 
> You're tilting at windmills about something that was settled long ago,
> like it or not.
And what about the patch, not judging my comments about irq0 in general?

AFAICT the check in try_misrouted_irq for irq being not zero does only
make sense on x86, doesn't it?

The comment a few lines above the check reads:

	But for 'irqfixup == 2' we also do it for handled interrupts if
	they are marked as IRQF_IRQPOLL (or for irq zero, which is the
	traditional PC timer interrupt.. Legacy)

So I think the patch is justified.

Best regards
Uwe

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

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

* Re: [PATCH] irq: handle irq0 special only on x86
  2009-12-09  9:20 [PATCH] irq: handle irq0 special only on x86 Uwe Kleine-König
  2009-12-09  9:28 ` Américo Wang
@ 2010-01-12 15:59 ` Uwe Kleine-König
  2010-01-13  4:59   ` H. Peter Anvin
  1 sibling, 1 reply; 10+ messages in thread
From: Uwe Kleine-König @ 2010-01-12 15:59 UTC (permalink / raw)
  To: x86, linux-arch
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin

Hello,

On Wed, Dec 09, 2009 at 10:20:01AM +0100, Uwe Kleine-König wrote:
> I just noticed this when digging in the irq handling.  At least for arm
> this doesn't make sense.  Not sure if x86 is the only arch this test
> is valid for, but probably it is.
... so I added linux-arch@vger.kernel.org
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: H. Peter Anvin <hpa@zytor.com>
> ---
>  kernel/irq/spurious.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/kernel/irq/spurious.c b/kernel/irq/spurious.c
> index 22b0a6e..4996b66 100644
> --- a/kernel/irq/spurious.c
> +++ b/kernel/irq/spurious.c
> @@ -199,8 +199,10 @@ try_misrouted_irq(unsigned int irq, struct irq_desc *desc,
>  	if (irqfixup < 2)
>  		return 0;
>  
> +#if defined(CONFIG_ARCH_X86)
>  	if (!irq)
>  		return 1;
> +#endif
>  
>  	/*
>  	 * Since we don't get the descriptor lock, "action" can
the feed-back I have got up to now wasn't helpfull.  (Only some "irq0 is
evil---no it's not" discussion.) So what do you think?  I admit the
#ifdef isn't nice, but if the semantic is OK I'm willing to rework it
into something more pretty.

Best regards
Uwe

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

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

* Re: [PATCH] irq: handle irq0 special only on x86
  2010-01-12 15:59 ` Uwe Kleine-König
@ 2010-01-13  4:59   ` H. Peter Anvin
  0 siblings, 0 replies; 10+ messages in thread
From: H. Peter Anvin @ 2010-01-13  4:59 UTC (permalink / raw)
  To: Uwe Kleine-König
  Cc: x86, linux-arch, linux-kernel, Thomas Gleixner, Ingo Molnar

On 01/12/2010 07:59 AM, Uwe Kleine-König wrote:
> the feed-back I have got up to now wasn't helpfull.  (Only some "irq0 is
> evil---no it's not" discussion.) So what do you think?  I admit the
> #ifdef isn't nice, but if the semantic is OK I'm willing to rework it
> into something more pretty.

There was a debate on this a long time ago, and the outcome was that IRQ
0 is invalid, across the kernel, and that it is up to each architecture
to carry exceptions (like IRQ 0 for the timer interrupt in x86.)  Hinc
dictat Linus, so you would have to convince him before any of the arch
maintainer could realistically even consider this change.

	-hpa

-- 
H. Peter Anvin, Intel Open Source Technology Center
I work for Intel.  I don't speak on their behalf.


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

end of thread, other threads:[~2010-01-13  5:11 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-09  9:20 [PATCH] irq: handle irq0 special only on x86 Uwe Kleine-König
2009-12-09  9:28 ` Américo Wang
2009-12-09  9:35   ` Uwe Kleine-König
2009-12-09  9:41   ` David Miller
2009-12-10  8:24     ` Uwe Kleine-König
2009-12-10 16:40       ` H. Peter Anvin
2009-12-13  0:34         ` Maciej W. Rozycki
2009-12-16 14:04         ` Uwe Kleine-König
2010-01-12 15:59 ` Uwe Kleine-König
2010-01-13  4:59   ` H. Peter Anvin

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.