linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: Baruch Siach <baruch@tkos.co.il>
Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	grant.likely@secretlab.ca
Subject: Re: [BUG] irq_dispose_mapping after irq request failure
Date: Mon, 11 Feb 2013 17:19:49 +1100	[thread overview]
Message-ID: <20130211061949.GA5561@concordia> (raw)
In-Reply-To: <20130211053100.GB18462@sapphire.tkos.co.il>

On Mon, Feb 11, 2013 at 07:31:00AM +0200, Baruch Siach wrote:
> Hi lkml,

Hi Baruch,

> The drivers/edac/mpc85xx_edac.c driver contains the following (abbreviated)
> code snippet it its .probe:

You dropped an important detail which is the preceeding line:

	pdata->irq = irq_of_parse_and_map(op->dev.of_node, 0);

> 		res = devm_request_irq(&op->dev, pdata->irq,
> 				       mpc85xx_pci_isr, IRQF_DISABLED,
> 				       "[EDAC] PCI err", pci);
> 		if (res < 0) {
> 			irq_dispose_mapping(pdata->irq);
> 			goto err2;
> 		}
> 
> Now, since the requested irq is already in use, and IRQF_SHARED is not set,
> devm_request_irq errors() out, which is OK. Less OK is the
> irq_dispose_mapping() call, which gives me this:
> 
> EDAC PCI1: Giving out device to module 'MPC85xx_edac' controller 'mpc85xx_pci_err': DEV 'ffe0a000.pcie' (INTERRUPT)
> genirq: Flags mismatch irq 16. 00000020 ([EDAC] PCI err) vs. 00000020 ([EDAC] PCI err)

The hint here is to notice which other irq you're clashing with          ^^
ie. yourself. Which is odd, that is the root of the problem.

The badness you're getting from irq_dispose_mapping() is caused because you're
disposing of that mapping which is currently still in use, by the same interrupt.

That is caused by a "feature" in the irq mapping code, where if you ask to map an
already mapped hwirq, it will give you back the same virq. So in your case when
you called irq_of_parse_and_map() it noticed that someone had already mapped
that hwirq, and gave you back an existing (in use) virq.

> mpc85xx_pci_err_probe: Unable to requiest irq 16 for MPC85xx PCI err
                                       ^
While you're there, can you fix the typo :)


> So, is irq_dispose_mapping() the right thing to do when irq request fails?

It's the right thing to do to undo the effect of irq_create_mapping(), or in your case irq_of_parse_and_map().

It just falls down in this case, because you're inadvertently disposing of something that's still in use.

> A simple grep shows that irq_dispose_mapping() calls are mostly limited to
> powerpc code. Is there a reason for that?

That's because the irq domain code began life as powerpc specific code. It's now become generic and will start to appear in more places.

cheers

  reply	other threads:[~2013-02-11  6:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-11  5:31 [BUG] irq_dispose_mapping after irq request failure Baruch Siach
2013-02-11  6:19 ` Michael Ellerman [this message]
2013-02-11  6:44   ` Baruch Siach
2013-02-11 20:52   ` Grant Likely
2013-02-12  0:51     ` Benjamin Herrenschmidt
2013-02-12  6:18       ` Michael Ellerman
2013-02-12  8:53         ` Benjamin Herrenschmidt

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=20130211061949.GA5561@concordia \
    --to=michael@ellerman.id.au \
    --cc=baruch@tkos.co.il \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /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;
as well as URLs for NNTP newsgroup(s).