Skip to contentSkip to conversation

of: irq: Report individual failures in of_irq_init()

PATCH Superseded Alexander A Sverdlin 3 participants 6 messages Sep 6, 2022 – Sep 8, 2022

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 of: irq: Report individual failures in of_irq_init()

From: Alexander Sverdlin <[email protected]>

Rewrite pr_debug() as pr_err() to faciliate debugging.

This change was inspired by a long lasting debugging of the octeon_irq_init_ciu() which fails completely silently and leaves the interrupt controller half-way configured which in turn had very non-obvious effects.

---
 drivers/of/irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/of/irq.c +3 -3
index d22f605..45e4392 100644
@@ -586,12 +586,12 @@ void __init of_irq_init(const struct of_device_id *matches)
 
 			of_node_set_flag(desc->dev, OF_POPULATED);
 
-			pr_debug("of_irq_init: init %pOF (%p), parent %p\n",
-				 desc->dev,
-				 desc->dev, desc->interrupt_parent);
 			ret = desc->irq_init_cb(desc->dev,
 						desc->interrupt_parent);
 			if (ret) {
+				pr_err("%s: Failed to init %pOF (%p), parent %p\n",
+				       __func__, desc->dev, desc->dev,
+				       desc->interrupt_parent);
 				of_node_clear_flag(desc->dev, OF_POPULATED);
 				kfree(desc);
 				continue;
Signature · 1 line
2.10.2
#1 lore raw

PATCH 1/1 mips: Select SPARSEMEM_EXTREME for CAVIUM_OCTEON_SOC

From: Alexander Sverdlin <[email protected]>

Commit c46173183657 ("MIPS: Add NUMA support for Loongson-3") has increased .bss size of the Octeon kernel from 16k to 16M. Providing the conditions for SPARSEMEM_EXTREME avoids the waste of memory.

---
 arch/mips/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/Kconfig +1 -1
index ec21f89..79cfa1c 100644
@@ -2669,7 +2669,7 @@ config ARCH_FLATMEM_ENABLE
 
 config ARCH_SPARSEMEM_ENABLE
 	bool
-	select SPARSEMEM_STATIC if !SGI_IP27
+	select SPARSEMEM_STATIC if MACH_LOONGSON64
 
 config NUMA
 	bool "NUMA Support"
Signature · 1 line
2.10.2
#2 lore raw

Re: [PATCH] mips: Select SPARSEMEM_EXTREME for CAVIUM_OCTEON_SOC

Quoted 16 lines · Alexander A Sverdlin

From: Alexander Sverdlin <[email protected]>

Commit c46173183657 ("MIPS: Add NUMA support for Loongson-3") has increased .bss size of the Octeon kernel from 16k to 16M. Providing the conditions for SPARSEMEM_EXTREME avoids the waste of memory.

---
 arch/mips/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/Kconfig +0 -0
index ec21f89..79cfa1c 100644

arch/mips/Kconfig config ARCH_FLATMEM_ENABLE · line 2672

Quoted 5 lines
arch/mips/Kconfig +1 -1
@@ -2669,7 +2669,7 @@ config ARCH_FLATMEM_ENABLE
 
 config ARCH_SPARSEMEM_ENABLE
 	bool
-	select SPARSEMEM_STATIC if !SGI_IP27
+	select SPARSEMEM_STATIC if MACH_LOONGSON64

removing the statement completely gives

text data bss total filename

  11874896    6019382   17304160   35198438 vmlinux-sparsemem_static
  11935172    6019702     526944   18481818 vmlinux

for a loogsoon64 kernel. And the kernel boots and works just fine. Can you respin your patch and remove the select SPARSEMEM_STATIC ?

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#3 lore raw

PATCH 1/1 MIPS: OCTEON: irq: Fix octeon_irq_force_ciu_mapping()

In reply to Alexander A Sverdlin

From: Alexander Sverdlin <[email protected]>

For irq_domain_associate() to work the virq descriptor has to be pre-allocated in advance. Otherwise the following happens:

WARNING: CPU: 0 PID: 0 at .../kernel/irq/irqdomain.c:527 irq_domain_associate+0x298/0x2e8
error: virq128 is not allocated
Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.19.78-... #1
        ...
Call Trace:
[<ffffffff801344c4>] show_stack+0x9c/0x130
[<ffffffff80769550>] dump_stack+0x90/0xd0
[<ffffffff801576d0>] __warn+0x118/0x130
[<ffffffff80157734>] warn_slowpath_fmt+0x4c/0x70
[<ffffffff801b83c0>] irq_domain_associate+0x298/0x2e8
[<ffffffff80a43bb8>] octeon_irq_init_ciu+0x4c8/0x53c
[<ffffffff80a76cbc>] of_irq_init+0x1e0/0x388
[<ffffffff80a452cc>] init_IRQ+0x4c/0xf4
[<ffffffff80a3cc00>] start_kernel+0x404/0x698

Use irq_alloc_desc_at() to avoid the above problem.

---
 arch/mips/cavium-octeon/octeon-irq.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/mips/cavium-octeon/octeon-irq.c +10 -0
index 9cb9ed4..fd8043f 100644
@@ -127,6 +127,16 @@ static void octeon_irq_free_cd(struct irq_domain *d, unsigned int irq)
 static int octeon_irq_force_ciu_mapping(struct irq_domain *domain,
 					int irq, int line, int bit)
 {
+	struct device_node *of_node;
+	int ret;
+
+	of_node = irq_domain_get_of_node(domain);
+	if (!of_node)
+		return -EINVAL;
+	ret = irq_alloc_desc_at(irq, of_node_to_nid(of_node));
+	if (ret < 0)
+		return ret;
+
 	return irq_domain_associate(domain, irq, line << 6 | bit);
 }
 
Signature · 1 line
2.10.2
maintainer Applied
#4 lore raw

Re: [PATCH] MIPS: OCTEON: irq: Fix octeon_irq_force_ciu_mapping()

Quoted 21 lines · Alexander A Sverdlin

From: Alexander Sverdlin <[email protected]>

For irq_domain_associate() to work the virq descriptor has to be pre-allocated in advance. Otherwise the following happens:

WARNING: CPU: 0 PID: 0 at .../kernel/irq/irqdomain.c:527 irq_domain_associate+0x298/0x2e8
error: virq128 is not allocated
Modules linked in:
CPU: 0 PID: 0 Comm: swapper/0 Not tainted 4.19.78-... #1
        ...
Call Trace:
[<ffffffff801344c4>] show_stack+0x9c/0x130
[<ffffffff80769550>] dump_stack+0x90/0xd0
[<ffffffff801576d0>] __warn+0x118/0x130
[<ffffffff80157734>] warn_slowpath_fmt+0x4c/0x70
[<ffffffff801b83c0>] irq_domain_associate+0x298/0x2e8
[<ffffffff80a43bb8>] octeon_irq_init_ciu+0x4c8/0x53c
[<ffffffff80a76cbc>] of_irq_init+0x1e0/0x388
[<ffffffff80a452cc>] init_IRQ+0x4c/0xf4
[<ffffffff80a3cc00>] start_kernel+0x404/0x698
Quoted 6 lines

Use irq_alloc_desc_at() to avoid the above problem.

---
 arch/mips/cavium-octeon/octeon-irq.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

applied to mips-fixes.

Thomas.

Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea.                                                [ RFC1925, 2.3 ]
#5 lore raw
In reply to Alexander A Sverdlin
Quoted 9 lines · Alexander A Sverdlin

From: Alexander Sverdlin <[email protected]>

Rewrite pr_debug() as pr_err() to faciliate debugging.

This change was inspired by a long lasting debugging of the octeon_irq_init_ciu() which fails completely silently and leaves the interrupt controller half-way configured which in turn had very non-obvious effects.

With this, if a node skipped completely won't be obvious. Please keep the debug line and just add the error print.

Quoted 29 lines
---
 drivers/of/irq.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/of/irq.c +3 -4
index d22f605..45e4392 100644
@@ -586,12 +586,12 @@ void __init of_irq_init(const struct of_device_id *matches)
 
                        of_node_set_flag(desc->dev, OF_POPULATED);
 
-                       pr_debug("of_irq_init: init %pOF (%p), parent %p\n",
-                                desc->dev,
-                                desc->dev, desc->interrupt_parent);
                        ret = desc->irq_init_cb(desc->dev,
                                                desc->interrupt_parent);
                        if (ret) {
+                               pr_err("%s: Failed to init %pOF (%p), parent %p\n",
+                                      __func__, desc->dev, desc->dev,
+                                      desc->interrupt_parent);
                                of_node_clear_flag(desc->dev, OF_POPULATED);
                                kfree(desc);
                                continue;
--

2.10.2