public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: David Miller <davem@davemloft.net>
Cc: xiyou.wangcong@gmail.com, x86@kernel.org,
	linux-kernel@vger.kernel.org, tglx@linutronix.de,
	mingo@redhat.com, hpa@zytor.com
Subject: Re: [PATCH] irq: handle irq0 special only on x86
Date: Thu, 10 Dec 2009 09:24:52 +0100	[thread overview]
Message-ID: <20091210082452.GA2420@pengutronix.de> (raw)
In-Reply-To: <20091209.014151.140337246.davem@davemloft.net>

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

  reply	other threads:[~2009-12-10  8:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091210082452.GA2420@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=davem@davemloft.net \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox