mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thomas Gleixner <tglx@linutronix.de>
To: Milton Miller <miltonm@bga.com>
Cc: linux-kernel@vger.kernel.org, Grant Likely <grant.likely@secretlab.ca>
Subject: Re: [PATCH RFC 4/4] irq: allow a per-allocation upper limit when allocating irqs
Date: Wed, 25 May 2011 10:32:54 +0200 (CEST)	[thread overview]
Message-ID: <alpine.LFD.2.02.1105251022390.3078@ionos> (raw)
In-Reply-To: <alloc-irq-range-v2@mdm.bga.com>

On Wed, 25 May 2011, Milton Miller wrote:
>  
> +int irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)

You might want this to be inline :)

> +{
> +	if (irq < 0)
> +		return irq_alloc_descs_range(from, 0, cnt, node);
> +	/* fail if specified start at 4 and obtain 6 */

  -ENOPARSE

> +	if (irq != from)
> +		return -EEXIST;

  -EINVAL perhaps ?

> +	return irq_alloc_descs_range(from, from + cnt, cnt, node);
> +}
> +
>  static inline int irq_alloc_desc(int node)
>  {
>  	return irq_alloc_descs(-1, 0, 1, node);
> Index: work.git/kernel/irq/irqdesc.c
> ===================================================================
> --- work.git.orig/kernel/irq/irqdesc.c	2011-05-25 01:02:11.454480436 -0500
> +++ work.git/kernel/irq/irqdesc.c	2011-05-25 01:04:03.441480315 -0500
> @@ -343,27 +343,37 @@ void irq_free_descs(unsigned int from, u
>  EXPORT_SYMBOL_GPL(irq_free_descs);
>  
>  /**
> - * irq_alloc_descs - allocate and initialize a range of irq descriptors
> - * @irq:	Allocate for specific irq number if irq >= 0
> + * irq_alloc_descs_range - allocate and initialize a range of irq descriptors
>   * @from:	Start the search from this irq number
> + * @limit:	Unless zero, all irq numbers must be less than this value
>   * @cnt:	Number of consecutive irqs to allocate.
>   * @node:	Preferred node on which the irq descriptor should be allocated
>   *
>   * Returns the first irq number or error code
>   */
> -int irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node)
> +int irq_alloc_descs_range(unsigned int from, unsigned int limit,
> +		unsigned int cnt, int node)
>  {
> -	int start, ret;
> +	unsigned int start, end;
> +	int ret;
>  
>  	if (!cnt)
>  		return -EINVAL;
> +	if (limit) {

Why 0 ? Just use UINT_MAX (or something like IRQ_ALLOC_ANY) for the
limit when you want an unlimited allocation.

> +		if (cnt > limit)
> +			return -ENOMEM;
> +		if (from > limit - cnt)
> +			return -EINVAL;
> +		end = min_t(unsigned int, limit, IRQ_BITMAP_BITS);
> +	} else {
> +		end = IRQ_BITMAP_BITS;
> +	}
>  
>  	mutex_lock(&sparse_irq_lock);
>  
> -	start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS,
> -					   from, cnt, 0);
> +	start = bitmap_find_next_zero_area(allocated_irqs, end, from, cnt, 0);
>  	ret = -EEXIST;
> -	if (irq >=0 && start != irq)
> +	if (start >= end)
>  		goto err;

Otherwise I like the approach in general.

Thanks,

	tglx

  parent reply	other threads:[~2011-05-25  8:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <generic-irq-changes@mdm.bga.com>
2011-05-25  6:34 ` [PATCH 2/4] irq: radix_tree_insert can fail Milton Miller
2011-05-25  8:18   ` Thomas Gleixner
2011-05-25 10:48     ` Milton Miller
2011-05-25  6:34 ` [PATCH RFC 4/4] irq: allow a per-allocation upper limit when allocating irqs Milton Miller
2011-05-25  7:55   ` Ingo Molnar
2011-05-25  8:32   ` Thomas Gleixner [this message]
2011-05-27  3:38   ` Grant Likely
2011-05-25  6:34 ` [PATCH 3/4] irq: remove unnecessary __ref on irq_alloc_descs Milton Miller
2011-05-25  6:34 ` [PATCH 1/4] sparse irq: protect irq_to_desc against irq_free_descs Milton Miller
2011-05-25  8:14   ` Thomas Gleixner
2011-05-25 10:49     ` Milton Miller
2011-05-25 10:54       ` Thomas Gleixner

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=alpine.LFD.2.02.1105251022390.3078@ionos \
    --to=tglx@linutronix.de \
    --cc=grant.likely@secretlab.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miltonm@bga.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

all inboxes | Powered by JetHome®