public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/22] Reduce the scope of 'nr_irqs'
@ 2024-10-15 19:09 Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
                   ` (21 more replies)
  0 siblings, 22 replies; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche

Hi Thomas,

In addition to the global 'nr_irqs' variable, there are plenty of local
variables with the same name. This makes reviewing kernel patches and
auditing kernel source code harder than necessary. Hence this patch series
that reduces the scope of the global 'nr_irqs' variable to file scope and
that introduces functions for retrieving and setting the value of this
variable.

Accesses of the global variable 'nr_irqs' have been identified with
Coccinelle.

Please consider this patch series for the next merge window.

Thanks,

Bart.

Changes compared to v2:
 - Changed "This patch prepares" into "Prepare" in the several patch
   descriptions.
 - Changed the type of 'nr_irqs' from 'int' into 'unsigned int'.

Changes compared to v1:
 - Renamed the accessor functions: number_of_interrupts() has been renamed into
   irq_get_nr_irqs() and set_number_of_interrupts() has been renamed into
   set_number_of_interrupts().
 - Made the description of patch 01 more detailed. It is now explained in
   detail why it is useful to introduce accessor functions for 'nr_irqs'.
 - Cache the irq_get_nr_irqs() return value if it is used as a loop upper bound
   or inside a loop body instead of relying on CSE (common subexpression
   elimination) by the compiler.
 - Changed the return type of the accessor functions from 'int' into
   'unsigned int'.
 - Split the hamradio patch into two patches - one patch per driver.

Bart Van Assche (22):
  genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs()
  ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs()
  LoongArch: Switch to irq_set_nr_irqs()
  powerpc/cell: Switch to irq_get_nr_irqs()
  s390/irq: Switch to irq_get_nr_irqs()
  x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs()
  hpet: Switch to irq_get_nr_irqs()
  net: 3com: 3c59x: Switch to irq_get_nr_irqs()
  net: hamradio: baycom_ser_fdx: Switch to irq_get_nr_irqs()
  net: hamradio: scc: Switch to irq_get_nr_irqs()
  scsi: aha152x: Switch to irq_get_nr_irqs()
  serial: core: Switch to irq_get_nr_irqs()
  serial: 8250: Switch to irq_get_nr_irqs()
  serial: amba-pl010: Switch to irq_get_nr_irqs()
  serial: amba-pl011: Switch to irq_get_nr_irqs()
  serial: cpm_uart: Switch to irq_get_nr_irqs()
  serial: ucc_uart: Switch to irq_get_nr_irqs()
  sh: intc: Switch to irq_get_nr_irqs()
  xen/events: Switch to irq_get_nr_irqs()
  fs/procfs: Switch to irq_get_nr_irqs()
  genirq: Switch to irq_get_nr_irqs()
  genirq: Unexport nr_irqs

 arch/arm/kernel/irq.c                  |  5 ++--
 arch/loongarch/kernel/irq.c            |  4 +--
 arch/powerpc/platforms/cell/axon_msi.c |  2 +-
 arch/s390/kernel/irq.c                 |  2 +-
 arch/x86/kernel/acpi/boot.c            |  6 +++--
 arch/x86/kernel/apic/vector.c          |  8 +++---
 drivers/char/hpet.c                    |  1 +
 drivers/net/ethernet/3com/3c59x.c      |  2 +-
 drivers/net/hamradio/baycom_ser_fdx.c  |  1 +
 drivers/net/hamradio/scc.c             |  4 ++-
 drivers/scsi/aha152x.c                 |  2 +-
 drivers/sh/intc/virq-debugfs.c         |  1 +
 drivers/tty/serial/8250/8250_port.c    |  2 +-
 drivers/tty/serial/amba-pl010.c        |  2 +-
 drivers/tty/serial/amba-pl011.c        |  2 +-
 drivers/tty/serial/cpm_uart.c          |  2 +-
 drivers/tty/serial/serial_core.c       |  2 +-
 drivers/tty/serial/ucc_uart.c          |  2 +-
 drivers/xen/events/events_base.c       |  2 +-
 fs/proc/interrupts.c                   |  4 +--
 fs/proc/stat.c                         |  4 +--
 include/linux/irqnr.h                  | 36 +++++++++++++++-----------
 kernel/irq/irqdesc.c                   | 26 +++++++++++++++++--
 kernel/irq/irqdomain.c                 |  2 +-
 kernel/irq/proc.c                      |  3 ++-
 25 files changed, 81 insertions(+), 46 deletions(-)


^ permalink raw reply	[flat|nested] 46+ messages in thread

* [PATCH v3 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 02/22] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs() Bart Van Assche
                   ` (20 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche

Prepare for changing 'nr_irqs' from an exported global variable into a
variable with file scope. This will prevent accidental changes of
assignments to a local variable 'nr_irqs' into assignments to the global
'nr_irqs' variable. Suppose that a patch would be submitted for review that
removes a declaration of a local variable with the name 'nr_irqs' and that
that patch does not remove all assignments to that local variable. Such a
patch converts an assignment to a local variable into an assignment into a
global variable. If the 'nr_irqs' assignment is more than three lines away
from other changes, the assignment won't be included in the diff context
lines and hence won't be visible without inspecting the modified file. With
this patch series applied, such accidental conversions from assignments to
a local variable into an assignment to a global variable are converted into
a compilation error.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/linux/irqnr.h |  2 ++
 kernel/irq/irqdesc.c  | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 3496baa0b07f..7419b807b71b 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -6,6 +6,8 @@
 
 
 extern int nr_irqs;
+unsigned int irq_get_nr_irqs(void) __pure;
+unsigned int irq_set_nr_irqs(unsigned int nr);
 extern struct irq_desc *irq_to_desc(unsigned int irq);
 unsigned int irq_get_next_irq(unsigned int offset);
 
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 1dee88ba0ae4..b0733959f8ae 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -141,6 +141,29 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
 int nr_irqs = NR_IRQS;
 EXPORT_SYMBOL_GPL(nr_irqs);
 
+/**
+ * irq_get_nr_irqs() - Number of interrupts supported by the system.
+ */
+unsigned int irq_get_nr_irqs(void)
+{
+	return nr_irqs;
+}
+EXPORT_SYMBOL_GPL(irq_get_nr_irqs);
+
+/**
+ * irq_set_nr_irqs() - Set the number of interrupts supported by the system.
+ * @nr: New number of interrupts.
+ *
+ * Return: @nr.
+ */
+unsigned int irq_set_nr_irqs(unsigned int nr)
+{
+	nr_irqs = nr;
+
+	return nr;
+}
+EXPORT_SYMBOL_GPL(irq_set_nr_irqs);
+
 static DEFINE_MUTEX(sparse_irq_lock);
 static struct maple_tree sparse_irqs = MTREE_INIT_EXT(sparse_irqs,
 					MT_FLAGS_ALLOC_RANGE |

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 02/22] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 03/22] LoongArch: Switch to irq_set_nr_irqs() Bart Van Assche
                   ` (19 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche

Use the irq_get_nr_irqs() and irq_set_nr_irqs() functions instead of the
global variable 'nr_irqs'. Prepare for changing 'nr_irqs' from an
exported global variable into a variable with file scope.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 arch/arm/kernel/irq.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index dab42d066d06..e1993e28a9ec 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -111,7 +111,7 @@ void handle_IRQ(unsigned int irq, struct pt_regs *regs)
 	 * Some hardware gives randomly wrong interrupts.  Rather
 	 * than crashing, do something sensible.
 	 */
-	if (unlikely(!irq || irq >= nr_irqs))
+	if (unlikely(!irq || irq >= irq_get_nr_irqs()))
 		desc = NULL;
 	else
 		desc = irq_to_desc(irq);
@@ -151,7 +151,6 @@ void __init init_IRQ(void)
 #ifdef CONFIG_SPARSE_IRQ
 int __init arch_probe_nr_irqs(void)
 {
-	nr_irqs = machine_desc->nr_irqs ? machine_desc->nr_irqs : NR_IRQS;
-	return nr_irqs;
+	return irq_set_nr_irqs(machine_desc->nr_irqs ? : NR_IRQS);
 }
 #endif

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 03/22] LoongArch: Switch to irq_set_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 02/22] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs() Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 04/22] powerpc/cell: Switch to irq_get_nr_irqs() Bart Van Assche
                   ` (18 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Huacai Chen, WANG Xuerui

Use the irq_set_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: WANG Xuerui <kernel@xen0n.name>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 arch/loongarch/kernel/irq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/loongarch/kernel/irq.c b/arch/loongarch/kernel/irq.c
index d129039b368b..80946cafaec1 100644
--- a/arch/loongarch/kernel/irq.c
+++ b/arch/loongarch/kernel/irq.c
@@ -92,9 +92,9 @@ int __init arch_probe_nr_irqs(void)
 	int nr_io_pics = bitmap_weight(loongson_sysconf.cores_io_master, NR_CPUS);
 
 	if (!cpu_has_avecint)
-		nr_irqs = (64 + NR_VECTORS * nr_io_pics);
+		irq_set_nr_irqs(64 + NR_VECTORS * nr_io_pics);
 	else
-		nr_irqs = (64 + NR_VECTORS * (nr_cpu_ids + nr_io_pics));
+		irq_set_nr_irqs(64 + NR_VECTORS * (nr_cpu_ids + nr_io_pics));
 
 	return NR_IRQS_LEGACY;
 }

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 04/22] powerpc/cell: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (2 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 03/22] LoongArch: Switch to irq_set_nr_irqs() Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-15 23:36   ` Michael Ellerman
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 05/22] s390/irq: " Bart Van Assche
                   ` (17 subsequent siblings)
  21 siblings, 2 replies; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	linuxppc-dev

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 arch/powerpc/platforms/cell/axon_msi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
index 28dc86744cac..d243f7fd8982 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -112,7 +112,7 @@ static void axon_msi_cascade(struct irq_desc *desc)
 		pr_devel("axon_msi: woff %x roff %x msi %x\n",
 			  write_offset, msic->read_offset, msi);
 
-		if (msi < nr_irqs && irq_get_chip_data(msi) == msic) {
+		if (msi < irq_get_nr_irqs() && irq_get_chip_data(msi) == msic) {
 			generic_handle_irq(msi);
 			msic->fifo_virt[idx] = cpu_to_le32(0xffffffff);
 		} else {

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 05/22] s390/irq: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (3 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 04/22] powerpc/cell: Switch to irq_get_nr_irqs() Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
                   ` (16 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Heiko Carstens

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 arch/s390/kernel/irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index 2639a3d12736..a2c867181b5a 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -253,7 +253,7 @@ int show_interrupts(struct seq_file *p, void *v)
 		seq_putc(p, '\n');
 		goto out;
 	}
-	if (index < nr_irqs) {
+	if (index < irq_get_nr_irqs()) {
 		show_msi_interrupt(p, index);
 		goto out;
 	}

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (4 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 05/22] s390/irq: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 07/22] hpet: Switch to irq_get_nr_irqs() Bart Van Assche
                   ` (15 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Ingo Molnar, Borislav Petkov, Rafael J. Wysocki

Use the irq_get_nr_irqs() and irq_set_nr_irqs() functions instead of the
global variable 'nr_irqs'. Prepare for changing 'nr_irqs' from an
exported global variable into a variable with file scope.

Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 arch/x86/kernel/acpi/boot.c   | 6 ++++--
 arch/x86/kernel/apic/vector.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 4efecac49863..3a44a9dc3fb7 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1171,7 +1171,8 @@ static int __init acpi_parse_madt_ioapic_entries(void)
 	}
 
 	count = acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE,
-				      acpi_parse_int_src_ovr, nr_irqs);
+				      acpi_parse_int_src_ovr,
+				      irq_get_nr_irqs());
 	if (count < 0) {
 		pr_err("Error parsing interrupt source overrides entry\n");
 		/* TBD: Cleanup to allow fallback to MPS */
@@ -1191,7 +1192,8 @@ static int __init acpi_parse_madt_ioapic_entries(void)
 	mp_config_acpi_legacy_irqs();
 
 	count = acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE,
-				      acpi_parse_nmi_src, nr_irqs);
+				      acpi_parse_nmi_src,
+				      irq_get_nr_irqs());
 	if (count < 0) {
 		pr_err("Error parsing NMI SRC entry\n");
 		/* TBD: Cleanup to allow fallback to MPS */
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 557318145038..736f62812f5c 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -712,8 +712,8 @@ int __init arch_probe_nr_irqs(void)
 {
 	int nr;
 
-	if (nr_irqs > (NR_VECTORS * nr_cpu_ids))
-		nr_irqs = NR_VECTORS * nr_cpu_ids;
+	if (irq_get_nr_irqs() > NR_VECTORS * nr_cpu_ids)
+		irq_set_nr_irqs(NR_VECTORS * nr_cpu_ids);
 
 	nr = (gsi_top + nr_legacy_irqs()) + 8 * nr_cpu_ids;
 #if defined(CONFIG_PCI_MSI)
@@ -725,8 +725,8 @@ int __init arch_probe_nr_irqs(void)
 	else
 		nr += gsi_top * 16;
 #endif
-	if (nr < nr_irqs)
-		nr_irqs = nr;
+	if (nr < irq_get_nr_irqs())
+		irq_set_nr_irqs(nr);
 
 	/*
 	 * We don't know if PIC is present at this point so we need to do

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 07/22] hpet: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (5 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 08/22] net: 3com: 3c59x: " Bart Van Assche
                   ` (14 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Clemens Ladisch

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Clemens Ladisch <clemens@ladisch.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/char/hpet.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index e904e476e49a..48fe96ab4649 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -162,6 +162,7 @@ static irqreturn_t hpet_interrupt(int irq, void *data)
 
 static void hpet_timer_set_irq(struct hpet_dev *devp)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	unsigned long v;
 	int irq, gsi;
 	struct hpet_timer __iomem *timer;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 08/22] net: 3com: 3c59x: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (6 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 07/22] hpet: Switch to irq_get_nr_irqs() Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 09/22] net: hamradio: baycom_ser_fdx: " Bart Van Assche
                   ` (13 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Steffen Klassert

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Steffen Klassert <klassert@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/net/ethernet/3com/3c59x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c
index 082388bb6169..790270912913 100644
--- a/drivers/net/ethernet/3com/3c59x.c
+++ b/drivers/net/ethernet/3com/3c59x.c
@@ -1302,7 +1302,7 @@ static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
 	if (print_info)
 		pr_cont(", IRQ %d\n", dev->irq);
 	/* Tell them about an invalid IRQ. */
-	if (dev->irq <= 0 || dev->irq >= nr_irqs)
+	if (dev->irq <= 0 || dev->irq >= irq_get_nr_irqs())
 		pr_warn(" *** Warning: IRQ %d is unlikely to work! ***\n",
 			dev->irq);
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 09/22] net: hamradio: baycom_ser_fdx: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (7 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 08/22] net: 3com: 3c59x: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 10/22] net: hamradio: scc: " Bart Van Assche
                   ` (12 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Thomas Sailer

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Thomas Sailer <t.sailer@alumni.ethz.ch>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/net/hamradio/baycom_ser_fdx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
index 646f605e358f..799f8ece7824 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -373,6 +373,7 @@ static enum uart ser12_check_uart(unsigned int iobase)
 
 static int ser12_open(struct net_device *dev)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	struct baycom_state *bc = netdev_priv(dev);
 	enum uart u;
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 10/22] net: hamradio: scc: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (8 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 09/22] net: hamradio: baycom_ser_fdx: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 11/22] scsi: aha152x: " Bart Van Assche
                   ` (11 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Joerg Reuter

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Joerg Reuter <jreuter@yaina.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/net/hamradio/scc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index a9184a78650b..c71e52249289 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -1460,6 +1460,7 @@ scc_start_calibrate(struct scc_channel *scc, int duration, unsigned char pattern
 
 static void z8530_init(void)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	struct scc_channel *scc;
 	int chip, k;
 	unsigned long flags;
@@ -1735,7 +1736,7 @@ static int scc_net_siocdevprivate(struct net_device *dev,
 
 			if (hwcfg.irq == 2) hwcfg.irq = 9;
 
-			if (hwcfg.irq < 0 || hwcfg.irq >= nr_irqs)
+			if (hwcfg.irq < 0 || hwcfg.irq >= irq_get_nr_irqs())
 				return -EINVAL;
 				
 			if (!Ivec[hwcfg.irq].used && hwcfg.irq)
@@ -2117,6 +2118,7 @@ static int __init scc_init_driver (void)
 
 static void __exit scc_cleanup_driver(void)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	io_port ctrl;
 	int k;
 	struct scc_channel *scc;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 11/22] scsi: aha152x: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (9 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 10/22] net: hamradio: scc: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 12/22] serial: core: " Bart Van Assche
                   ` (10 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Juergen E. Fischer

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Juergen E. Fischer <fischer@norbit.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/scsi/aha152x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index a0fb330b8df5..4276f868cd91 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -295,7 +295,7 @@ CMD_INC_RESID(struct scsi_cmnd *cmd, int inc)
 #else
 #define IRQ_MIN 9
 #if defined(__PPC)
-#define IRQ_MAX (nr_irqs-1)
+#define IRQ_MAX (irq_get_nr_irqs()-1)
 #else
 #define IRQ_MAX 12
 #endif

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 12/22] serial: core: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (10 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 11/22] scsi: aha152x: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 13/22] serial: 8250: " Bart Van Assche
                   ` (9 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/tty/serial/serial_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d94d73e45fb6..74fa02b23772 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -919,7 +919,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
 	if (uport->ops->verify_port)
 		retval = uport->ops->verify_port(uport, new_info);
 
-	if ((new_info->irq >= nr_irqs) || (new_info->irq < 0) ||
+	if ((new_info->irq >= irq_get_nr_irqs()) || (new_info->irq < 0) ||
 	    (new_info->baud_base < 9600))
 		retval = -EINVAL;
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 13/22] serial: 8250: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (11 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 12/22] serial: core: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 14/22] serial: amba-pl010: " Bart Van Assche
                   ` (8 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/tty/serial/8250/8250_port.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 3509af7dc52b..0b886c0924da 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -3176,7 +3176,7 @@ static void serial8250_config_port(struct uart_port *port, int flags)
 static int
 serial8250_verify_port(struct uart_port *port, struct serial_struct *ser)
 {
-	if (ser->irq >= nr_irqs || ser->irq < 0 ||
+	if (ser->irq >= irq_get_nr_irqs() || ser->irq < 0 ||
 	    ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
 	    ser->type >= ARRAY_SIZE(uart_config) || ser->type == PORT_CIRRUS ||
 	    ser->type == PORT_STARTECH)

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 14/22] serial: amba-pl010: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (12 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 13/22] serial: 8250: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 15/22] serial: amba-pl011: " Bart Van Assche
                   ` (7 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/tty/serial/amba-pl010.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index eabbf8afc9b5..c3a7fad02ac9 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -499,7 +499,7 @@ static int pl010_verify_port(struct uart_port *port, struct serial_struct *ser)
 	int ret = 0;
 	if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA)
 		ret = -EINVAL;
-	if (ser->irq < 0 || ser->irq >= nr_irqs)
+	if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
 		ret = -EINVAL;
 	if (ser->baud_base < 9600)
 		ret = -EINVAL;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 15/22] serial: amba-pl011: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (13 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 14/22] serial: amba-pl010: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 16/22] serial: cpm_uart: " Bart Van Assche
                   ` (6 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/tty/serial/amba-pl011.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 7d0134ecd82f..1c60850030b1 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2202,7 +2202,7 @@ static int pl011_verify_port(struct uart_port *port, struct serial_struct *ser)
 
 	if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA)
 		ret = -EINVAL;
-	if (ser->irq < 0 || ser->irq >= nr_irqs)
+	if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
 		ret = -EINVAL;
 	if (ser->baud_base < 9600)
 		ret = -EINVAL;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 16/22] serial: cpm_uart: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (14 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 15/22] serial: amba-pl011: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 17/22] serial: ucc_uart: " Bart Van Assche
                   ` (5 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/tty/serial/cpm_uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/cpm_uart.c b/drivers/tty/serial/cpm_uart.c
index a927478f581d..6eb8625de435 100644
--- a/drivers/tty/serial/cpm_uart.c
+++ b/drivers/tty/serial/cpm_uart.c
@@ -631,7 +631,7 @@ static int cpm_uart_verify_port(struct uart_port *port,
 
 	if (ser->type != PORT_UNKNOWN && ser->type != PORT_CPM)
 		ret = -EINVAL;
-	if (ser->irq < 0 || ser->irq >= nr_irqs)
+	if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
 		ret = -EINVAL;
 	if (ser->baud_base < 9600)
 		ret = -EINVAL;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 17/22] serial: ucc_uart: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (15 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 16/22] serial: cpm_uart: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 18/22] sh: intc: " Bart Van Assche
                   ` (4 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Timur Tabi

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Timur Tabi <timur@kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/tty/serial/ucc_uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index 53bb8c5ef499..4eed909468ff 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -1045,7 +1045,7 @@ static int qe_uart_verify_port(struct uart_port *port,
 	if (ser->type != PORT_UNKNOWN && ser->type != PORT_CPM)
 		return -EINVAL;
 
-	if (ser->irq < 0 || ser->irq >= nr_irqs)
+	if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
 		return -EINVAL;
 
 	if (ser->baud_base < 9600)

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 18/22] sh: intc: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (16 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 17/22] serial: ucc_uart: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 19/22] xen/events: " Bart Van Assche
                   ` (3 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Yoshinori Sato

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/sh/intc/virq-debugfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/sh/intc/virq-debugfs.c b/drivers/sh/intc/virq-debugfs.c
index 939915a07d99..5dd8febe6da5 100644
--- a/drivers/sh/intc/virq-debugfs.c
+++ b/drivers/sh/intc/virq-debugfs.c
@@ -18,6 +18,7 @@
 
 static int intc_irq_xlate_show(struct seq_file *m, void *priv)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	int i;
 
 	seq_printf(m, "%-5s  %-7s  %-15s\n", "irq", "enum", "chip name");

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 19/22] xen/events: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (17 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 18/22] sh: intc: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 20/22] fs/procfs: " Bart Van Assche
                   ` (2 subsequent siblings)
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Juergen Gross

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Juergen Gross <jgross@suse.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/xen/events/events_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 81effbd53dc5..985e155ebe4b 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -411,7 +411,7 @@ static evtchn_port_t evtchn_from_irq(unsigned int irq)
 {
 	const struct irq_info *info = NULL;
 
-	if (likely(irq < nr_irqs))
+	if (likely(irq < irq_get_nr_irqs()))
 		info = info_for_irq(irq);
 	if (!info)
 		return 0;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 20/22] fs/procfs: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (18 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 19/22] xen/events: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 21/22] genirq: " Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 22/22] genirq: Unexport nr_irqs Bart Van Assche
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	Alexey Dobriyan

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Cc: Alexey Dobriyan <adobriyan@gmail.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 fs/proc/interrupts.c | 4 ++--
 fs/proc/stat.c       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
index cb0edc7cbf09..714a22ded8a8 100644
--- a/fs/proc/interrupts.c
+++ b/fs/proc/interrupts.c
@@ -11,13 +11,13 @@
  */
 static void *int_seq_start(struct seq_file *f, loff_t *pos)
 {
-	return (*pos <= nr_irqs) ? pos : NULL;
+	return *pos <= irq_get_nr_irqs() ? pos : NULL;
 }
 
 static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos)
 {
 	(*pos)++;
-	if (*pos > nr_irqs)
+	if (*pos > irq_get_nr_irqs())
 		return NULL;
 	return pos;
 }
diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index da60956b2915..8b444e862319 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -76,7 +76,7 @@ static void show_all_irqs(struct seq_file *p)
 		seq_put_decimal_ull(p, " ", kstat_irqs_usr(i));
 		next = i + 1;
 	}
-	show_irq_gap(p, nr_irqs - next);
+	show_irq_gap(p, irq_get_nr_irqs() - next);
 }
 
 static int show_stat(struct seq_file *p, void *v)
@@ -196,7 +196,7 @@ static int stat_open(struct inode *inode, struct file *file)
 	unsigned int size = 1024 + 128 * num_online_cpus();
 
 	/* minimum size to display an interrupt count : 2 bytes */
-	size += 2 * nr_irqs;
+	size += 2 * irq_get_nr_irqs();
 	return single_open_size(file, show_stat, NULL, size);
 }
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 21/22] genirq: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (19 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 20/22] fs/procfs: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  2024-10-15 19:09 ` [PATCH v3 22/22] genirq: Unexport nr_irqs Bart Van Assche
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Cache the result of this function in a local variable in
order not to rely on CSE (common subexpression elimination). Prepare
for changing 'nr_irqs' from an exported global variable into a variable
with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/linux/irqnr.h  | 33 +++++++++++++++++++--------------
 kernel/irq/irqdomain.c |  2 +-
 kernel/irq/proc.c      |  3 ++-
 3 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 7419b807b71b..a33088d27c54 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -11,26 +11,31 @@ unsigned int irq_set_nr_irqs(unsigned int nr);
 extern struct irq_desc *irq_to_desc(unsigned int irq);
 unsigned int irq_get_next_irq(unsigned int offset);
 
-# define for_each_irq_desc(irq, desc)					\
-	for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs;		\
-	     irq++, desc = irq_to_desc(irq))				\
-		if (!desc)						\
-			;						\
-		else
-
+#define for_each_irq_desc(irq, desc)                                      \
+	for (unsigned int __nr_irqs__ = irq_get_nr_irqs(); __nr_irqs__;   \
+	     __nr_irqs__ = 0)                                             \
+		for (irq = 0, desc = irq_to_desc(irq); irq < __nr_irqs__; \
+		     irq++, desc = irq_to_desc(irq))                      \
+			if (!desc)                                        \
+				;                                         \
+			else
 
 # define for_each_irq_desc_reverse(irq, desc)				\
-	for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0;	\
-	     irq--, desc = irq_to_desc(irq))				\
+	for (irq = irq_get_nr_irqs() - 1, desc = irq_to_desc(irq);	\
+	     irq >= 0; irq--, desc = irq_to_desc(irq))			\
 		if (!desc)						\
 			;						\
 		else
 
-# define for_each_active_irq(irq)			\
-	for (irq = irq_get_next_irq(0); irq < nr_irqs;	\
-	     irq = irq_get_next_irq(irq + 1))
+#define for_each_active_irq(irq)                                        \
+	for (unsigned int __nr_irqs__ = irq_get_nr_irqs(); __nr_irqs__; \
+	     __nr_irqs__ = 0)                                           \
+		for (irq = irq_get_next_irq(0); irq < __nr_irqs__;      \
+		     irq = irq_get_next_irq(irq + 1))
 
-#define for_each_irq_nr(irq)                   \
-       for (irq = 0; irq < nr_irqs; irq++)
+#define for_each_irq_nr(irq)                                            \
+	for (unsigned int __nr_irqs__ = irq_get_nr_irqs(); __nr_irqs__; \
+	     __nr_irqs__ = 0)                                           \
+		for (irq = 0; irq < __nr_irqs__; irq++)
 
 #endif
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index e0bff21f30e0..ec6d8e72d980 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1225,7 +1225,7 @@ int irq_domain_alloc_descs(int virq, unsigned int cnt, irq_hw_number_t hwirq,
 		virq = __irq_alloc_descs(virq, virq, cnt, node, THIS_MODULE,
 					 affinity);
 	} else {
-		hint = hwirq % nr_irqs;
+		hint = hwirq % irq_get_nr_irqs();
 		if (hint == 0)
 			hint++;
 		virq = __irq_alloc_descs(-1, hint, cnt, node, THIS_MODULE,
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 9081ada81c3d..d226282c5b66 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -457,11 +457,12 @@ int __weak arch_show_interrupts(struct seq_file *p, int prec)
 }
 
 #ifndef ACTUAL_NR_IRQS
-# define ACTUAL_NR_IRQS nr_irqs
+# define ACTUAL_NR_IRQS irq_get_nr_irqs()
 #endif
 
 int show_interrupts(struct seq_file *p, void *v)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	static int prec;
 
 	int i = *(loff_t *) v, j;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [PATCH v3 22/22] genirq: Unexport nr_irqs
  2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
                   ` (20 preceding siblings ...)
  2024-10-15 19:09 ` [PATCH v3 21/22] genirq: " Bart Van Assche
@ 2024-10-15 19:09 ` Bart Van Assche
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  21 siblings, 1 reply; 46+ messages in thread
From: Bart Van Assche @ 2024-10-15 19:09 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche

Unexport nr_irqs and declare it static now that all code that reads or
modifies nr_irqs has been converted to number_of_interrupts() /
set_number_of_interrupts(). Change the type of 'nr_irqs' from 'int' into
'unsigned int' to match the return type and argument type of the
irq_get_nr_iqs() / irq_set_nr_irqs() functions.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 include/linux/irqnr.h | 1 -
 kernel/irq/irqdesc.c  | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index a33088d27c54..e97206c721a0 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -5,7 +5,6 @@
 #include <uapi/linux/irqnr.h>
 
 
-extern int nr_irqs;
 unsigned int irq_get_nr_irqs(void) __pure;
 unsigned int irq_set_nr_irqs(unsigned int nr);
 extern struct irq_desc *irq_to_desc(unsigned int irq);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index b0733959f8ae..479cf1caa610 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -138,8 +138,7 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
 	desc_smp_init(desc, node, affinity);
 }
 
-int nr_irqs = NR_IRQS;
-EXPORT_SYMBOL_GPL(nr_irqs);
+static unsigned int nr_irqs = NR_IRQS;
 
 /**
  * irq_get_nr_irqs() - Number of interrupts supported by the system.

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* Re: [PATCH v3 04/22] powerpc/cell: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 04/22] powerpc/cell: Switch to irq_get_nr_irqs() Bart Van Assche
@ 2024-10-15 23:36   ` Michael Ellerman
  2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
  1 sibling, 0 replies; 46+ messages in thread
From: Michael Ellerman @ 2024-10-15 23:36 UTC (permalink / raw)
  To: Bart Van Assche, Thomas Gleixner
  Cc: Greg Kroah-Hartman, Russell King, linux-kernel, Bart Van Assche,
	linuxppc-dev

Bart Van Assche <bvanassche@acm.org> writes:
> Use the irq_get_nr_irqs() function instead of the global variable
> 'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
> variable into a variable with file scope.
>
> Cc: linuxppc-dev@lists.ozlabs.org
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  arch/powerpc/platforms/cell/axon_msi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)

cheers

> diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
> index 28dc86744cac..d243f7fd8982 100644
> --- a/arch/powerpc/platforms/cell/axon_msi.c
> +++ b/arch/powerpc/platforms/cell/axon_msi.c
> @@ -112,7 +112,7 @@ static void axon_msi_cascade(struct irq_desc *desc)
>  		pr_devel("axon_msi: woff %x roff %x msi %x\n",
>  			  write_offset, msic->read_offset, msi);
>  
> -		if (msi < nr_irqs && irq_get_chip_data(msi) == msic) {
> +		if (msi < irq_get_nr_irqs() && irq_get_chip_data(msi) == msic) {
>  			generic_handle_irq(msi);
>  			msic->fifo_virt[idx] = cpu_to_le32(0xffffffff);
>  		} else {

^ permalink raw reply	[flat|nested] 46+ messages in thread

* [tip: irq/core] genirq: Unexport nr_irqs
  2024-10-15 19:09 ` [PATCH v3 22/22] genirq: Unexport nr_irqs Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     ef4c675dc2961ee533bdc1ea20390761df0af5be
Gitweb:        https://git.kernel.org/tip/ef4c675dc2961ee533bdc1ea20390761df0af5be
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:53 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:59 +02:00

genirq: Unexport nr_irqs

Unexport nr_irqs and declare it static now that all code that reads or
modifies nr_irqs has been converted to number_of_interrupts() /
set_number_of_interrupts(). Change the type of 'nr_irqs' from 'int' into
'unsigned int' to match the return type and argument type of the
irq_get_nr_iqs() / irq_set_nr_irqs() functions.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-23-bvanassche@acm.org

---
 include/linux/irqnr.h | 1 -
 kernel/irq/irqdesc.c  | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index a33088d..e97206c 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -5,7 +5,6 @@
 #include <uapi/linux/irqnr.h>
 
 
-extern int nr_irqs;
 unsigned int irq_get_nr_irqs(void) __pure;
 unsigned int irq_set_nr_irqs(unsigned int nr);
 extern struct irq_desc *irq_to_desc(unsigned int irq);
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index b073395..479cf1c 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -138,8 +138,7 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
 	desc_smp_init(desc, node, affinity);
 }
 
-int nr_irqs = NR_IRQS;
-EXPORT_SYMBOL_GPL(nr_irqs);
+static unsigned int nr_irqs = NR_IRQS;
 
 /**
  * irq_get_nr_irqs() - Number of interrupts supported by the system.

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] genirq: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 21/22] genirq: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     1ad2048bf7146efb83bc033147ca1611a7fe8494
Gitweb:        https://git.kernel.org/tip/1ad2048bf7146efb83bc033147ca1611a7fe8494
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:52 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:59 +02:00

genirq: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Cache the result of this function in a local variable in
order not to rely on CSE (common subexpression elimination). Prepare
for changing 'nr_irqs' from an exported global variable into a variable
with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-22-bvanassche@acm.org

---
 include/linux/irqnr.h  | 33 +++++++++++++++++++--------------
 kernel/irq/irqdomain.c |  2 +-
 kernel/irq/proc.c      |  3 ++-
 3 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 7419b80..a33088d 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -11,26 +11,31 @@ unsigned int irq_set_nr_irqs(unsigned int nr);
 extern struct irq_desc *irq_to_desc(unsigned int irq);
 unsigned int irq_get_next_irq(unsigned int offset);
 
-# define for_each_irq_desc(irq, desc)					\
-	for (irq = 0, desc = irq_to_desc(irq); irq < nr_irqs;		\
-	     irq++, desc = irq_to_desc(irq))				\
-		if (!desc)						\
-			;						\
-		else
-
+#define for_each_irq_desc(irq, desc)                                      \
+	for (unsigned int __nr_irqs__ = irq_get_nr_irqs(); __nr_irqs__;   \
+	     __nr_irqs__ = 0)                                             \
+		for (irq = 0, desc = irq_to_desc(irq); irq < __nr_irqs__; \
+		     irq++, desc = irq_to_desc(irq))                      \
+			if (!desc)                                        \
+				;                                         \
+			else
 
 # define for_each_irq_desc_reverse(irq, desc)				\
-	for (irq = nr_irqs - 1, desc = irq_to_desc(irq); irq >= 0;	\
-	     irq--, desc = irq_to_desc(irq))				\
+	for (irq = irq_get_nr_irqs() - 1, desc = irq_to_desc(irq);	\
+	     irq >= 0; irq--, desc = irq_to_desc(irq))			\
 		if (!desc)						\
 			;						\
 		else
 
-# define for_each_active_irq(irq)			\
-	for (irq = irq_get_next_irq(0); irq < nr_irqs;	\
-	     irq = irq_get_next_irq(irq + 1))
+#define for_each_active_irq(irq)                                        \
+	for (unsigned int __nr_irqs__ = irq_get_nr_irqs(); __nr_irqs__; \
+	     __nr_irqs__ = 0)                                           \
+		for (irq = irq_get_next_irq(0); irq < __nr_irqs__;      \
+		     irq = irq_get_next_irq(irq + 1))
 
-#define for_each_irq_nr(irq)                   \
-       for (irq = 0; irq < nr_irqs; irq++)
+#define for_each_irq_nr(irq)                                            \
+	for (unsigned int __nr_irqs__ = irq_get_nr_irqs(); __nr_irqs__; \
+	     __nr_irqs__ = 0)                                           \
+		for (irq = 0; irq < __nr_irqs__; irq++)
 
 #endif
diff --git a/kernel/irq/irqdomain.c b/kernel/irq/irqdomain.c
index e0bff21..ec6d8e7 100644
--- a/kernel/irq/irqdomain.c
+++ b/kernel/irq/irqdomain.c
@@ -1225,7 +1225,7 @@ int irq_domain_alloc_descs(int virq, unsigned int cnt, irq_hw_number_t hwirq,
 		virq = __irq_alloc_descs(virq, virq, cnt, node, THIS_MODULE,
 					 affinity);
 	} else {
-		hint = hwirq % nr_irqs;
+		hint = hwirq % irq_get_nr_irqs();
 		if (hint == 0)
 			hint++;
 		virq = __irq_alloc_descs(-1, hint, cnt, node, THIS_MODULE,
diff --git a/kernel/irq/proc.c b/kernel/irq/proc.c
index 9081ada..d226282 100644
--- a/kernel/irq/proc.c
+++ b/kernel/irq/proc.c
@@ -457,11 +457,12 @@ int __weak arch_show_interrupts(struct seq_file *p, int prec)
 }
 
 #ifndef ACTUAL_NR_IRQS
-# define ACTUAL_NR_IRQS nr_irqs
+# define ACTUAL_NR_IRQS irq_get_nr_irqs()
 #endif
 
 int show_interrupts(struct seq_file *p, void *v)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	static int prec;
 
 	int i = *(loff_t *) v, j;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] fs/procfs: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 20/22] fs/procfs: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     f4dd946c775e85e4f9aa460cd3dba197c35e43f1
Gitweb:        https://git.kernel.org/tip/f4dd946c775e85e4f9aa460cd3dba197c35e43f1
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:51 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:59 +02:00

fs/procfs: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-21-bvanassche@acm.org

---
 fs/proc/interrupts.c | 4 ++--
 fs/proc/stat.c       | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
index cb0edc7..714a22d 100644
--- a/fs/proc/interrupts.c
+++ b/fs/proc/interrupts.c
@@ -11,13 +11,13 @@
  */
 static void *int_seq_start(struct seq_file *f, loff_t *pos)
 {
-	return (*pos <= nr_irqs) ? pos : NULL;
+	return *pos <= irq_get_nr_irqs() ? pos : NULL;
 }
 
 static void *int_seq_next(struct seq_file *f, void *v, loff_t *pos)
 {
 	(*pos)++;
-	if (*pos > nr_irqs)
+	if (*pos > irq_get_nr_irqs())
 		return NULL;
 	return pos;
 }
diff --git a/fs/proc/stat.c b/fs/proc/stat.c
index da60956..8b444e8 100644
--- a/fs/proc/stat.c
+++ b/fs/proc/stat.c
@@ -76,7 +76,7 @@ static void show_all_irqs(struct seq_file *p)
 		seq_put_decimal_ull(p, " ", kstat_irqs_usr(i));
 		next = i + 1;
 	}
-	show_irq_gap(p, nr_irqs - next);
+	show_irq_gap(p, irq_get_nr_irqs() - next);
 }
 
 static int show_stat(struct seq_file *p, void *v)
@@ -196,7 +196,7 @@ static int stat_open(struct inode *inode, struct file *file)
 	unsigned int size = 1024 + 128 * num_online_cpus();
 
 	/* minimum size to display an interrupt count : 2 bytes */
-	size += 2 * nr_irqs;
+	size += 2 * irq_get_nr_irqs();
 	return single_open_size(file, show_stat, NULL, size);
 }
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] xen/events: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 19/22] xen/events: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     3e48fa2ecf4de8baf8a368987f8ea8ffb64ac7af
Gitweb:        https://git.kernel.org/tip/3e48fa2ecf4de8baf8a368987f8ea8ffb64ac7af
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:50 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:59 +02:00

xen/events: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-20-bvanassche@acm.org

---
 drivers/xen/events/events_base.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 81effbd..985e155 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -411,7 +411,7 @@ static evtchn_port_t evtchn_from_irq(unsigned int irq)
 {
 	const struct irq_info *info = NULL;
 
-	if (likely(irq < nr_irqs))
+	if (likely(irq < irq_get_nr_irqs()))
 		info = info_for_irq(irq);
 	if (!info)
 		return 0;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] sh: intc: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 18/22] sh: intc: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     d0c62d51ede0718203502c192665e1d379fbf207
Gitweb:        https://git.kernel.org/tip/d0c62d51ede0718203502c192665e1d379fbf207
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:49 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:58 +02:00

sh: intc: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-19-bvanassche@acm.org

---
 drivers/sh/intc/virq-debugfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/sh/intc/virq-debugfs.c b/drivers/sh/intc/virq-debugfs.c
index 939915a..5dd8feb 100644
--- a/drivers/sh/intc/virq-debugfs.c
+++ b/drivers/sh/intc/virq-debugfs.c
@@ -18,6 +18,7 @@
 
 static int intc_irq_xlate_show(struct seq_file *m, void *priv)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	int i;
 
 	seq_printf(m, "%-5s  %-7s  %-15s\n", "irq", "enum", "chip name");

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] serial: ucc_uart: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 17/22] serial: ucc_uart: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     18444d339914a6080d832d9e8998ec243f7c3e9e
Gitweb:        https://git.kernel.org/tip/18444d339914a6080d832d9e8998ec243f7c3e9e
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:48 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:58 +02:00

serial: ucc_uart: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-18-bvanassche@acm.org

---
 drivers/tty/serial/ucc_uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index 53bb8c5..4eed909 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -1045,7 +1045,7 @@ static int qe_uart_verify_port(struct uart_port *port,
 	if (ser->type != PORT_UNKNOWN && ser->type != PORT_CPM)
 		return -EINVAL;
 
-	if (ser->irq < 0 || ser->irq >= nr_irqs)
+	if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
 		return -EINVAL;
 
 	if (ser->baud_base < 9600)

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] serial: cpm_uart: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 16/22] serial: cpm_uart: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     b9b5df2986c1195504a0c8d1c44691ec099815df
Gitweb:        https://git.kernel.org/tip/b9b5df2986c1195504a0c8d1c44691ec099815df
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:47 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:58 +02:00

serial: cpm_uart: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-17-bvanassche@acm.org

---
 drivers/tty/serial/cpm_uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/cpm_uart.c b/drivers/tty/serial/cpm_uart.c
index a927478..6eb8625 100644
--- a/drivers/tty/serial/cpm_uart.c
+++ b/drivers/tty/serial/cpm_uart.c
@@ -631,7 +631,7 @@ static int cpm_uart_verify_port(struct uart_port *port,
 
 	if (ser->type != PORT_UNKNOWN && ser->type != PORT_CPM)
 		ret = -EINVAL;
-	if (ser->irq < 0 || ser->irq >= nr_irqs)
+	if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
 		ret = -EINVAL;
 	if (ser->baud_base < 9600)
 		ret = -EINVAL;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] serial: amba-pl011: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 15/22] serial: amba-pl011: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     d1a9a2f4ca62c35cc0ffab653241ef686a6a7526
Gitweb:        https://git.kernel.org/tip/d1a9a2f4ca62c35cc0ffab653241ef686a6a7526
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:46 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:58 +02:00

serial: amba-pl011: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-16-bvanassche@acm.org

---
 drivers/tty/serial/amba-pl011.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/amba-pl011.c b/drivers/tty/serial/amba-pl011.c
index 7d0134e..1c60850 100644
--- a/drivers/tty/serial/amba-pl011.c
+++ b/drivers/tty/serial/amba-pl011.c
@@ -2202,7 +2202,7 @@ static int pl011_verify_port(struct uart_port *port, struct serial_struct *ser)
 
 	if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA)
 		ret = -EINVAL;
-	if (ser->irq < 0 || ser->irq >= nr_irqs)
+	if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
 		ret = -EINVAL;
 	if (ser->baud_base < 9600)
 		ret = -EINVAL;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] serial: amba-pl010: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 14/22] serial: amba-pl010: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     3905fb8738ca3474982a4d230e9493a409837388
Gitweb:        https://git.kernel.org/tip/3905fb8738ca3474982a4d230e9493a409837388
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:45 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:58 +02:00

serial: amba-pl010: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-15-bvanassche@acm.org

---
 drivers/tty/serial/amba-pl010.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/amba-pl010.c b/drivers/tty/serial/amba-pl010.c
index eabbf8a..c3a7fad 100644
--- a/drivers/tty/serial/amba-pl010.c
+++ b/drivers/tty/serial/amba-pl010.c
@@ -499,7 +499,7 @@ static int pl010_verify_port(struct uart_port *port, struct serial_struct *ser)
 	int ret = 0;
 	if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA)
 		ret = -EINVAL;
-	if (ser->irq < 0 || ser->irq >= nr_irqs)
+	if (ser->irq < 0 || ser->irq >= irq_get_nr_irqs())
 		ret = -EINVAL;
 	if (ser->baud_base < 9600)
 		ret = -EINVAL;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] serial: 8250: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 13/22] serial: 8250: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     4846c4c17e292537d4fedd9995432d3a0d78d355
Gitweb:        https://git.kernel.org/tip/4846c4c17e292537d4fedd9995432d3a0d78d355
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:44 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:58 +02:00

serial: 8250: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-14-bvanassche@acm.org

---
 drivers/tty/serial/8250/8250_port.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 3509af7..0b886c0 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -3176,7 +3176,7 @@ static void serial8250_config_port(struct uart_port *port, int flags)
 static int
 serial8250_verify_port(struct uart_port *port, struct serial_struct *ser)
 {
-	if (ser->irq >= nr_irqs || ser->irq < 0 ||
+	if (ser->irq >= irq_get_nr_irqs() || ser->irq < 0 ||
 	    ser->baud_base < 9600 || ser->type < PORT_UNKNOWN ||
 	    ser->type >= ARRAY_SIZE(uart_config) || ser->type == PORT_CIRRUS ||
 	    ser->type == PORT_STARTECH)

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] serial: core: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 12/22] serial: core: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     5732a63bada9923b4edcf90860fb8697d7c1231b
Gitweb:        https://git.kernel.org/tip/5732a63bada9923b4edcf90860fb8697d7c1231b
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:43 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:58 +02:00

serial: core: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-13-bvanassche@acm.org

---
 drivers/tty/serial/serial_core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index d94d73e..74fa02b 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -919,7 +919,7 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port,
 	if (uport->ops->verify_port)
 		retval = uport->ops->verify_port(uport, new_info);
 
-	if ((new_info->irq >= nr_irqs) || (new_info->irq < 0) ||
+	if ((new_info->irq >= irq_get_nr_irqs()) || (new_info->irq < 0) ||
 	    (new_info->baud_base < 9600))
 		retval = -EINVAL;
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] scsi: aha152x: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 11/22] scsi: aha152x: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     03f039def8332fef5efd93795291ad13cb187d65
Gitweb:        https://git.kernel.org/tip/03f039def8332fef5efd93795291ad13cb187d65
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:42 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:58 +02:00

scsi: aha152x: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-12-bvanassche@acm.org

---
 drivers/scsi/aha152x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/aha152x.c b/drivers/scsi/aha152x.c
index a0fb330..4276f86 100644
--- a/drivers/scsi/aha152x.c
+++ b/drivers/scsi/aha152x.c
@@ -295,7 +295,7 @@ CMD_INC_RESID(struct scsi_cmnd *cmd, int inc)
 #else
 #define IRQ_MIN 9
 #if defined(__PPC)
-#define IRQ_MAX (nr_irqs-1)
+#define IRQ_MAX (irq_get_nr_irqs()-1)
 #else
 #define IRQ_MAX 12
 #endif

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] net: hamradio: scc: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 10/22] net: hamradio: scc: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     4e69f13167f5618b5d487aa88db4800d0934a994
Gitweb:        https://git.kernel.org/tip/4e69f13167f5618b5d487aa88db4800d0934a994
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:41 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:57 +02:00

net: hamradio: scc: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-11-bvanassche@acm.org

---
 drivers/net/hamradio/scc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c
index a9184a7..c71e522 100644
--- a/drivers/net/hamradio/scc.c
+++ b/drivers/net/hamradio/scc.c
@@ -1460,6 +1460,7 @@ scc_start_calibrate(struct scc_channel *scc, int duration, unsigned char pattern
 
 static void z8530_init(void)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	struct scc_channel *scc;
 	int chip, k;
 	unsigned long flags;
@@ -1735,7 +1736,7 @@ static int scc_net_siocdevprivate(struct net_device *dev,
 
 			if (hwcfg.irq == 2) hwcfg.irq = 9;
 
-			if (hwcfg.irq < 0 || hwcfg.irq >= nr_irqs)
+			if (hwcfg.irq < 0 || hwcfg.irq >= irq_get_nr_irqs())
 				return -EINVAL;
 				
 			if (!Ivec[hwcfg.irq].used && hwcfg.irq)
@@ -2117,6 +2118,7 @@ static int __init scc_init_driver (void)
 
 static void __exit scc_cleanup_driver(void)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	io_port ctrl;
 	int k;
 	struct scc_channel *scc;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] net: hamradio: baycom_ser_fdx: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 09/22] net: hamradio: baycom_ser_fdx: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     bc6e6f07ebeda52e9cd515a11f62c6a6abb6f50a
Gitweb:        https://git.kernel.org/tip/bc6e6f07ebeda52e9cd515a11f62c6a6abb6f50a
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:40 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:57 +02:00

net: hamradio: baycom_ser_fdx: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-10-bvanassche@acm.org

---
 drivers/net/hamradio/baycom_ser_fdx.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c
index 646f605..799f8ec 100644
--- a/drivers/net/hamradio/baycom_ser_fdx.c
+++ b/drivers/net/hamradio/baycom_ser_fdx.c
@@ -373,6 +373,7 @@ static enum uart ser12_check_uart(unsigned int iobase)
 
 static int ser12_open(struct net_device *dev)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	struct baycom_state *bc = netdev_priv(dev);
 	enum uart u;
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] net: 3com: 3c59x: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 08/22] net: 3com: 3c59x: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     fb474ac2f4898b3c63ec9439219c0665c0773bb1
Gitweb:        https://git.kernel.org/tip/fb474ac2f4898b3c63ec9439219c0665c0773bb1
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:39 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:57 +02:00

net: 3com: 3c59x: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-9-bvanassche@acm.org

---
 drivers/net/ethernet/3com/3c59x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c
index 082388b..7902709 100644
--- a/drivers/net/ethernet/3com/3c59x.c
+++ b/drivers/net/ethernet/3com/3c59x.c
@@ -1302,7 +1302,7 @@ static int vortex_probe1(struct device *gendev, void __iomem *ioaddr, int irq,
 	if (print_info)
 		pr_cont(", IRQ %d\n", dev->irq);
 	/* Tell them about an invalid IRQ. */
-	if (dev->irq <= 0 || dev->irq >= nr_irqs)
+	if (dev->irq <= 0 || dev->irq >= irq_get_nr_irqs())
 		pr_warn(" *** Warning: IRQ %d is unlikely to work! ***\n",
 			dev->irq);
 

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] hpet: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 07/22] hpet: Switch to irq_get_nr_irqs() Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     ce1fa22a659dad1a14ae9ede2063e5bc6c9a86fb
Gitweb:        https://git.kernel.org/tip/ce1fa22a659dad1a14ae9ede2063e5bc6c9a86fb
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:38 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:57 +02:00

hpet: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-8-bvanassche@acm.org

---
 drivers/char/hpet.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
index e904e47..48fe96a 100644
--- a/drivers/char/hpet.c
+++ b/drivers/char/hpet.c
@@ -162,6 +162,7 @@ static irqreturn_t hpet_interrupt(int irq, void *data)
 
 static void hpet_timer_set_irq(struct hpet_dev *devp)
 {
+	const unsigned int nr_irqs = irq_get_nr_irqs();
 	unsigned long v;
 	int irq, gsi;
 	struct hpet_timer __iomem *timer;

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     f642974c0b772a18675602f2a366aa49d07baf8c
Gitweb:        https://git.kernel.org/tip/f642974c0b772a18675602f2a366aa49d07baf8c
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:37 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:57 +02:00

x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs()

Use the irq_get_nr_irqs() and irq_set_nr_irqs() functions instead of the
global variable 'nr_irqs'. Prepare for changing 'nr_irqs' from an
exported global variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-7-bvanassche@acm.org

---
 arch/x86/kernel/acpi/boot.c   | 6 ++++--
 arch/x86/kernel/apic/vector.c | 8 ++++----
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
index 4efecac..3a44a9d 100644
--- a/arch/x86/kernel/acpi/boot.c
+++ b/arch/x86/kernel/acpi/boot.c
@@ -1171,7 +1171,8 @@ static int __init acpi_parse_madt_ioapic_entries(void)
 	}
 
 	count = acpi_table_parse_madt(ACPI_MADT_TYPE_INTERRUPT_OVERRIDE,
-				      acpi_parse_int_src_ovr, nr_irqs);
+				      acpi_parse_int_src_ovr,
+				      irq_get_nr_irqs());
 	if (count < 0) {
 		pr_err("Error parsing interrupt source overrides entry\n");
 		/* TBD: Cleanup to allow fallback to MPS */
@@ -1191,7 +1192,8 @@ static int __init acpi_parse_madt_ioapic_entries(void)
 	mp_config_acpi_legacy_irqs();
 
 	count = acpi_table_parse_madt(ACPI_MADT_TYPE_NMI_SOURCE,
-				      acpi_parse_nmi_src, nr_irqs);
+				      acpi_parse_nmi_src,
+				      irq_get_nr_irqs());
 	if (count < 0) {
 		pr_err("Error parsing NMI SRC entry\n");
 		/* TBD: Cleanup to allow fallback to MPS */
diff --git a/arch/x86/kernel/apic/vector.c b/arch/x86/kernel/apic/vector.c
index 5573181..736f628 100644
--- a/arch/x86/kernel/apic/vector.c
+++ b/arch/x86/kernel/apic/vector.c
@@ -712,8 +712,8 @@ int __init arch_probe_nr_irqs(void)
 {
 	int nr;
 
-	if (nr_irqs > (NR_VECTORS * nr_cpu_ids))
-		nr_irqs = NR_VECTORS * nr_cpu_ids;
+	if (irq_get_nr_irqs() > NR_VECTORS * nr_cpu_ids)
+		irq_set_nr_irqs(NR_VECTORS * nr_cpu_ids);
 
 	nr = (gsi_top + nr_legacy_irqs()) + 8 * nr_cpu_ids;
 #if defined(CONFIG_PCI_MSI)
@@ -725,8 +725,8 @@ int __init arch_probe_nr_irqs(void)
 	else
 		nr += gsi_top * 16;
 #endif
-	if (nr < nr_irqs)
-		nr_irqs = nr;
+	if (nr < irq_get_nr_irqs())
+		irq_set_nr_irqs(nr);
 
 	/*
 	 * We don't know if PIC is present at this point so we need to do

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] s390/irq: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 05/22] s390/irq: " Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     951248383a9029f236e80c3e408012f6e280fb2f
Gitweb:        https://git.kernel.org/tip/951248383a9029f236e80c3e408012f6e280fb2f
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:36 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:57 +02:00

s390/irq: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-6-bvanassche@acm.org

---
 arch/s390/kernel/irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kernel/irq.c b/arch/s390/kernel/irq.c
index 2639a3d..a2c8671 100644
--- a/arch/s390/kernel/irq.c
+++ b/arch/s390/kernel/irq.c
@@ -253,7 +253,7 @@ int show_interrupts(struct seq_file *p, void *v)
 		seq_putc(p, '\n');
 		goto out;
 	}
-	if (index < nr_irqs) {
+	if (index < irq_get_nr_irqs()) {
 		show_msi_interrupt(p, index);
 		goto out;
 	}

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] powerpc/cell: Switch to irq_get_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 04/22] powerpc/cell: Switch to irq_get_nr_irqs() Bart Van Assche
  2024-10-15 23:36   ` Michael Ellerman
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  1 sibling, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, Michael Ellerman, x86,
	linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     29f42eb1a3cbaa48c6fae1e36d97162e1f6ab1ae
Gitweb:        https://git.kernel.org/tip/29f42eb1a3cbaa48c6fae1e36d97162e1f6ab1ae
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:35 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:57 +02:00

powerpc/cell: Switch to irq_get_nr_irqs()

Use the irq_get_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
Link: https://lore.kernel.org/all/20241015190953.1266194-5-bvanassche@acm.org

---
 arch/powerpc/platforms/cell/axon_msi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c
index 28dc867..d243f7f 100644
--- a/arch/powerpc/platforms/cell/axon_msi.c
+++ b/arch/powerpc/platforms/cell/axon_msi.c
@@ -112,7 +112,7 @@ static void axon_msi_cascade(struct irq_desc *desc)
 		pr_devel("axon_msi: woff %x roff %x msi %x\n",
 			  write_offset, msic->read_offset, msi);
 
-		if (msi < nr_irqs && irq_get_chip_data(msi) == msic) {
+		if (msi < irq_get_nr_irqs() && irq_get_chip_data(msi) == msic) {
 			generic_handle_irq(msi);
 			msic->fifo_virt[idx] = cpu_to_le32(0xffffffff);
 		} else {

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] LoongArch: Switch to irq_set_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 03/22] LoongArch: Switch to irq_set_nr_irqs() Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     f90ff314a92f2eee5c00590a17e99f7f8bd7a32d
Gitweb:        https://git.kernel.org/tip/f90ff314a92f2eee5c00590a17e99f7f8bd7a32d
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:34 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:56 +02:00

LoongArch: Switch to irq_set_nr_irqs()

Use the irq_set_nr_irqs() function instead of the global variable
'nr_irqs'. Prepare for changing 'nr_irqs' from an exported global
variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-4-bvanassche@acm.org

---
 arch/loongarch/kernel/irq.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/loongarch/kernel/irq.c b/arch/loongarch/kernel/irq.c
index d129039..80946ca 100644
--- a/arch/loongarch/kernel/irq.c
+++ b/arch/loongarch/kernel/irq.c
@@ -92,9 +92,9 @@ int __init arch_probe_nr_irqs(void)
 	int nr_io_pics = bitmap_weight(loongson_sysconf.cores_io_master, NR_CPUS);
 
 	if (!cpu_has_avecint)
-		nr_irqs = (64 + NR_VECTORS * nr_io_pics);
+		irq_set_nr_irqs(64 + NR_VECTORS * nr_io_pics);
 	else
-		nr_irqs = (64 + NR_VECTORS * (nr_cpu_ids + nr_io_pics));
+		irq_set_nr_irqs(64 + NR_VECTORS * (nr_cpu_ids + nr_io_pics));
 
 	return NR_IRQS_LEGACY;
 }

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 02/22] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs() Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     bc033158a0e691428b6acc9bc8ab16566651ec0c
Gitweb:        https://git.kernel.org/tip/bc033158a0e691428b6acc9bc8ab16566651ec0c
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:33 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:56 +02:00

ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs()

Use the irq_get_nr_irqs() and irq_set_nr_irqs() functions instead of the
global variable 'nr_irqs'. Prepare for changing 'nr_irqs' from an
exported global variable into a variable with file scope.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-3-bvanassche@acm.org

---
 arch/arm/kernel/irq.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c
index dab42d0..e1993e2 100644
--- a/arch/arm/kernel/irq.c
+++ b/arch/arm/kernel/irq.c
@@ -111,7 +111,7 @@ void handle_IRQ(unsigned int irq, struct pt_regs *regs)
 	 * Some hardware gives randomly wrong interrupts.  Rather
 	 * than crashing, do something sensible.
 	 */
-	if (unlikely(!irq || irq >= nr_irqs))
+	if (unlikely(!irq || irq >= irq_get_nr_irqs()))
 		desc = NULL;
 	else
 		desc = irq_to_desc(irq);
@@ -151,7 +151,6 @@ void __init init_IRQ(void)
 #ifdef CONFIG_SPARSE_IRQ
 int __init arch_probe_nr_irqs(void)
 {
-	nr_irqs = machine_desc->nr_irqs ? machine_desc->nr_irqs : NR_IRQS;
-	return nr_irqs;
+	return irq_set_nr_irqs(machine_desc->nr_irqs ? : NR_IRQS);
 }
 #endif

^ permalink raw reply related	[flat|nested] 46+ messages in thread

* [tip: irq/core] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs()
  2024-10-15 19:09 ` [PATCH v3 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
@ 2024-10-16 20:04   ` tip-bot2 for Bart Van Assche
  0 siblings, 0 replies; 46+ messages in thread
From: tip-bot2 for Bart Van Assche @ 2024-10-16 20:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Bart Van Assche, Thomas Gleixner, x86, linux-kernel, maz

The following commit has been merged into the irq/core branch of tip:

Commit-ID:     5280a14a6079040205a1d968cd80f20448d047c7
Gitweb:        https://git.kernel.org/tip/5280a14a6079040205a1d968cd80f20448d047c7
Author:        Bart Van Assche <bvanassche@acm.org>
AuthorDate:    Tue, 15 Oct 2024 12:09:32 -07:00
Committer:     Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 16 Oct 2024 21:56:56 +02:00

genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs()

Prepare for changing 'nr_irqs' from an exported global variable into a
variable with file scope.

This will prevent accidental changes of assignments to a local variable
'nr_irqs' into assignments to the global 'nr_irqs' variable.

Suppose that a patch would be submitted for review that removes a
declaration of a local variable with the name 'nr_irqs' and that that patch
does not remove all assignments to that local variable. Such a patch
converts an assignment to a local variable into an assignment into a global
variable. If the 'nr_irqs' assignment is more than three lines away from
other changes, the assignment won't be included in the diff context lines
and hence won't be visible without inspecting the modified file.

With these abstraction series applied, such accidental conversions from
assignments to a local variable into an assignment to a global variable are
converted into a compilation error.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/all/20241015190953.1266194-2-bvanassche@acm.org
---
 include/linux/irqnr.h |  2 ++
 kernel/irq/irqdesc.c  | 23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)

diff --git a/include/linux/irqnr.h b/include/linux/irqnr.h
index 3496baa..7419b80 100644
--- a/include/linux/irqnr.h
+++ b/include/linux/irqnr.h
@@ -6,6 +6,8 @@
 
 
 extern int nr_irqs;
+unsigned int irq_get_nr_irqs(void) __pure;
+unsigned int irq_set_nr_irqs(unsigned int nr);
 extern struct irq_desc *irq_to_desc(unsigned int irq);
 unsigned int irq_get_next_irq(unsigned int offset);
 
diff --git a/kernel/irq/irqdesc.c b/kernel/irq/irqdesc.c
index 1dee88b..b073395 100644
--- a/kernel/irq/irqdesc.c
+++ b/kernel/irq/irqdesc.c
@@ -141,6 +141,29 @@ static void desc_set_defaults(unsigned int irq, struct irq_desc *desc, int node,
 int nr_irqs = NR_IRQS;
 EXPORT_SYMBOL_GPL(nr_irqs);
 
+/**
+ * irq_get_nr_irqs() - Number of interrupts supported by the system.
+ */
+unsigned int irq_get_nr_irqs(void)
+{
+	return nr_irqs;
+}
+EXPORT_SYMBOL_GPL(irq_get_nr_irqs);
+
+/**
+ * irq_set_nr_irqs() - Set the number of interrupts supported by the system.
+ * @nr: New number of interrupts.
+ *
+ * Return: @nr.
+ */
+unsigned int irq_set_nr_irqs(unsigned int nr)
+{
+	nr_irqs = nr;
+
+	return nr;
+}
+EXPORT_SYMBOL_GPL(irq_set_nr_irqs);
+
 static DEFINE_MUTEX(sparse_irq_lock);
 static struct maple_tree sparse_irqs = MTREE_INIT_EXT(sparse_irqs,
 					MT_FLAGS_ALLOC_RANGE |

^ permalink raw reply related	[flat|nested] 46+ messages in thread

end of thread, other threads:[~2024-10-16 20:04 UTC | newest]

Thread overview: 46+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 19:09 [PATCH v3 00/22] Reduce the scope of 'nr_irqs' Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 01/22] genirq: Introduce irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 02/22] ARM: Switch to irq_get_nr_irqs() / irq_set_nr_irqs() Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 03/22] LoongArch: Switch to irq_set_nr_irqs() Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 04/22] powerpc/cell: Switch to irq_get_nr_irqs() Bart Van Assche
2024-10-15 23:36   ` Michael Ellerman
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 05/22] s390/irq: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 06/22] x86/acpi: Switch to irq_get_nr_irqs() and irq_set_nr_irqs() Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 07/22] hpet: Switch to irq_get_nr_irqs() Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 08/22] net: 3com: 3c59x: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 09/22] net: hamradio: baycom_ser_fdx: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 10/22] net: hamradio: scc: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 11/22] scsi: aha152x: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 12/22] serial: core: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 13/22] serial: 8250: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 14/22] serial: amba-pl010: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 15/22] serial: amba-pl011: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 16/22] serial: cpm_uart: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 17/22] serial: ucc_uart: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 18/22] sh: intc: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 19/22] xen/events: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 20/22] fs/procfs: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 21/22] genirq: " Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche
2024-10-15 19:09 ` [PATCH v3 22/22] genirq: Unexport nr_irqs Bart Van Assche
2024-10-16 20:04   ` [tip: irq/core] " tip-bot2 for Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox