linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Milton Miller <miltonm@bga.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: Thomas Gleixner <tglx@linutronix.de>, linux-kernel@vger.kernel.org
Subject: Re: genirq: Ensure we locate the passed IRQ in irq_alloc_descs()
Date: Fri, 03 Jun 2011 04:24:02 -0500	[thread overview]
Message-ID: <nack-locate@mdm.bga.com> (raw)
In-Reply-To: <1307037313-15733-1-git-send-email-broonie@opensource.wolfsonmicro.com>

On Thu, 02 Jun 2011 17:55:13 -0000, Mark Brown wrote:
> When irq_alloc_descs() is called with no base IRQ specified then it will
> search for a range of IRQs starting from a specified base address. In the
> case where an IRQ is specified it still does this search in order to ensure
> that none of the requested range is already allocated and it still uses the
> from parameter to specify the base for the search. This means that in the
> case where a base is specified but from is zero (which is reasonable as
> any IRQ number is in the range specified by a zero from) the function will
> get confused and try to allocate the first suitably sized block of free IRQs
> it finds.
> 
> Instead use a specified IRQ as the base address for the search, and insist
> that any from that is specified can support that IRQ.
> 
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> 
> ---
> kernel/irq/irqdesc.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> 
> diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
> index 886e803..bb53d6c 100644
> --- a/kernel/irq/irqdesc.c
> +++ b/kernel/irq/irqdesc.c
> @@ -346,6 +346,12 @@ irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
>  	if (!cnt)
>  		return -EINVAL;
>  
> +	if (irq >= 0) {
> +		if (from > irq)
> +			return -EINVAL;
> +		from = irq;
> +	}
> +
>  	mutex_lock(&sparse_irq_lock);
>  
>  	start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS,

and then right after this the code continues:

        ret = -EEXIST;
        if (irq >=0 && start != irq)
                goto err;


This patch enables exactly the calls I want to forbid !  Why do
you need to verify that there are no irqs between from and irq ?
What is your use case?

Change your caller to specify the irq twice if you need a specific irq
block, or if you only need one then use the helper irq_alloc_desc_at.

If you want to change irq_alloc_descs, please make it return -EINVAL
if irq >=0 && from != irq (like I did).

See http://lkml.indiana.edu/hypermail/linux/kernel/1105.3/00739.html
[PATCH RFC 4/4] irq: allow a per-allocation upper limit when allocating irqs

(and yes, I have made the changes based on the feedback but haven't
had time to get back to the series).

Thanks,
milton
QUIT

  reply	other threads:[~2011-06-03  9:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-02 17:55 [PATCH] genirq: Ensure we locate the passed IRQ in irq_alloc_descs() Mark Brown
2011-06-03  9:24 ` Milton Miller [this message]
2011-06-03 10:42   ` Mark Brown
2011-06-03 14:43     ` Milton Miller
2011-06-03 15:06       ` Mark Brown
2011-06-03 16:25       ` Thomas Gleixner
2011-06-04  0:23         ` Milton Miller
2011-06-04  9:51           ` Mark Brown
2011-06-06 19:42             ` Grant Likely
2011-06-06 20:57               ` Mark Brown
2011-06-06 21:33                 ` Grant Likely
2011-06-03 12:59 ` [tip:irq/urgent] " tip-bot for Mark Brown

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=nack-locate@mdm.bga.com \
    --to=miltonm@bga.com \
    --cc=broonie@opensource.wolfsonmicro.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    /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).