From: Shanker Donthineni <sdonthineni@nvidia.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Marc Zyngier <maz@kernel.org>, Michael Walle <michael@walle.cc>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Hans de Goede <hdegoede@redhat.com>,
Wolfram Sang <wsa+renesas@sang-engineering.com>,
Shanker Donthineni <sdonthineni@nvidia.com>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH 3/5] genirq: Introduce two helper functions
Date: Sun, 29 Jan 2023 18:57:23 -0600 [thread overview]
Message-ID: <20230130005725.3517597-4-sdonthineni@nvidia.com> (raw)
In-Reply-To: <20230130005725.3517597-1-sdonthineni@nvidia.com>
Introduce helper functions irq_find_free_area() and irq_find_next_irq().
The first function is used to locate available free space for a new IRQ,
and the second one is used to find the next valid IRQ.
These helper functions will be later modified to utilize the Maple data
structure in a later patch. Additionally, in order to align the moving
to the new data structure, the IRQ_BITMAP_BITS is renamed to
MAX_SPARSE_IRQS.
Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>
---
kernel/irq/internals.h | 4 ++--
kernel/irq/irqdesc.c | 28 +++++++++++++++++++---------
2 files changed, 21 insertions(+), 11 deletions(-)
diff --git a/kernel/irq/internals.h b/kernel/irq/internals.h
index 2fd17057ed4b..5d741b0e7d5e 100644
--- a/kernel/irq/internals.h
+++ b/kernel/irq/internals.h
@@ -12,9 +12,9 @@
#include <linux/sched/clock.h>
#ifdef CONFIG_SPARSE_IRQ
-# define IRQ_BITMAP_BITS (NR_IRQS + 8196)
+# define MAX_SPARSE_IRQS (NR_IRQS + 8196)
#else
-# define IRQ_BITMAP_BITS NR_IRQS
+# define MAX_SPARSE_IRQS NR_IRQS
#endif
#define istate core_internal_state__do_not_mess_with_it
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index a4911f7ebb07..aacfb4826c5e 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -131,7 +131,18 @@ int nr_irqs = NR_IRQS;
EXPORT_SYMBOL_GPL(nr_irqs);
static DEFINE_MUTEX(sparse_irq_lock);
-static DECLARE_BITMAP(allocated_irqs, IRQ_BITMAP_BITS);
+static DECLARE_BITMAP(allocated_irqs, MAX_SPARSE_IRQS);
+
+static int irq_find_free_area(unsigned int from, unsigned int cnt)
+{
+ return bitmap_find_next_zero_area(allocated_irqs, MAX_SPARSE_IRQS,
+ from, cnt, 0);
+}
+
+static unsigned int irq_find_next_irq(unsigned int offset)
+{
+ return find_next_bit(allocated_irqs, nr_irqs, offset);
+}
#ifdef CONFIG_SPARSE_IRQ
@@ -519,7 +530,7 @@ static int alloc_descs(unsigned int start, unsigned int cnt, int node,
static int irq_expand_nr_irqs(unsigned int nr)
{
- if (nr > IRQ_BITMAP_BITS)
+ if (nr > MAX_SPARSE_IRQS)
return -ENOMEM;
nr_irqs = nr;
return 0;
@@ -537,11 +548,11 @@ int __init early_irq_init(void)
printk(KERN_INFO "NR_IRQS: %d, nr_irqs: %d, preallocated irqs: %d\n",
NR_IRQS, nr_irqs, initcnt);
- if (WARN_ON(nr_irqs > IRQ_BITMAP_BITS))
- nr_irqs = IRQ_BITMAP_BITS;
+ if (WARN_ON(nr_irqs > MAX_SPARSE_IRQS))
+ nr_irqs = MAX_SPARSE_IRQS;
- if (WARN_ON(initcnt > IRQ_BITMAP_BITS))
- initcnt = IRQ_BITMAP_BITS;
+ if (WARN_ON(initcnt > MAX_SPARSE_IRQS))
+ initcnt = MAX_SPARSE_IRQS;
if (initcnt > nr_irqs)
nr_irqs = initcnt;
@@ -813,8 +824,7 @@ __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node,
mutex_lock(&sparse_irq_lock);
- start = bitmap_find_next_zero_area(allocated_irqs, IRQ_BITMAP_BITS,
- from, cnt, 0);
+ start = irq_find_free_area(from, cnt);
ret = -EEXIST;
if (irq >=0 && start != irq)
goto unlock;
@@ -839,7 +849,7 @@ EXPORT_SYMBOL_GPL(__irq_alloc_descs);
*/
unsigned int irq_get_next_irq(unsigned int offset)
{
- return find_next_bit(allocated_irqs, nr_irqs, offset);
+ return irq_find_next_irq(offset);
}
struct irq_desc *
--
2.25.1
next prev parent reply other threads:[~2023-01-30 0:57 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 0:57 [PATCH 0/5] Increase the number of IRQ descriptors for SPARSEIRQ Shanker Donthineni
2023-01-30 0:57 ` [PATCH 1/5] genirq: Use hlist for managing resend handlers Shanker Donthineni
2023-01-31 8:59 ` Thomas Gleixner
2023-01-31 16:17 ` Shanker Donthineni
2023-01-31 17:06 ` Shanker Donthineni
2023-01-30 0:57 ` [PATCH 2/5] genirq: Allocate IRQ descriptors at boot time for !SPARSEIRQ Shanker Donthineni
2023-01-31 9:16 ` Thomas Gleixner
2023-01-31 16:41 ` Shanker Donthineni
2023-02-07 10:28 ` Thomas Gleixner
2023-01-30 0:57 ` Shanker Donthineni [this message]
2023-01-31 9:20 ` [PATCH 3/5] genirq: Introduce two helper functions Thomas Gleixner
2023-01-31 16:42 ` Shanker Donthineni
2023-01-30 0:57 ` [PATCH 4/5] genirq: Use the common function irq_expand_nr_irqs() Shanker Donthineni
2023-01-31 9:35 ` Thomas Gleixner
2023-01-31 16:43 ` Shanker Donthineni
2023-02-07 10:29 ` Thomas Gleixner
2023-01-30 0:57 ` [PATCH 5/5] genirq: Use the maple tree for IRQ descriptors management Shanker Donthineni
2023-01-31 9:52 ` Thomas Gleixner
2023-01-31 16:45 ` Shanker Donthineni
2023-02-01 6:02 ` kernel test robot
2023-02-01 13:27 ` Thomas Gleixner
2023-02-06 14:24 ` Vlastimil Babka
2023-02-06 18:10 ` Thomas Gleixner
2023-02-07 10:30 ` Thomas Gleixner
2023-02-07 14:16 ` mm, slab/slub: Ensure kmem_cache_alloc_bulk() is available early Thomas Gleixner
2023-02-07 14:45 ` Vlastimil Babka
2023-02-07 14:47 ` Vlastimil Babka
2023-02-07 18:20 ` Thomas Gleixner
2023-02-08 9:15 ` Vlastimil Babka
2023-02-08 20:46 ` Thomas Gleixner
2023-02-09 20:28 ` Matthew Wilcox
2023-02-09 23:19 ` Thomas Gleixner
2023-02-08 13:20 ` Hyeonggon Yoo
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=20230130005725.3517597-4-sdonthineni@nvidia.com \
--to=sdonthineni@nvidia.com \
--cc=bigeasy@linutronix.de \
--cc=hdegoede@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=michael@walle.cc \
--cc=tglx@linutronix.de \
--cc=wsa+renesas@sang-engineering.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
Powered by JetHome