2022-09-06 10:09:43

by Alexander Sverdlin

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Alexander Sverdlin <[email protected]>
---
drivers/of/irq.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index d22f605..45e4392 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -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


2022-09-06 10:21:43

by Alexander Sverdlin

[permalink] [raw]
Subject: [PATCH] MIPS: OCTEON: irq: Fix octeon_irq_force_ciu_mapping()

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.

Signed-off-by: Alexander Sverdlin <[email protected]>
---
arch/mips/cavium-octeon/octeon-irq.c | 10 ++++++++++
1 file changed, 10 insertions(+)

diff --git a/arch/mips/cavium-octeon/octeon-irq.c b/arch/mips/cavium-octeon/octeon-irq.c
index 9cb9ed4..fd8043f 100644
--- a/arch/mips/cavium-octeon/octeon-irq.c
+++ b/arch/mips/cavium-octeon/octeon-irq.c
@@ -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);
}

--
2.10.2

2022-09-06 10:24:25

by Alexander Sverdlin

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Alexander Sverdlin <[email protected]>
---
arch/mips/Kconfig | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index ec21f89..79cfa1c 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -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"
--
2.10.2

2022-09-06 18:06:18

by Rob Herring

[permalink] [raw]
Subject: Re: [PATCH] of: irq: Report individual failures in of_irq_init()

On Tue, Sep 6, 2022 at 4:59 AM Alexander A Sverdlin
<[email protected]> wrote:
>
> 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.

>
> Signed-off-by: Alexander Sverdlin <[email protected]>
> ---
> drivers/of/irq.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index d22f605..45e4392 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -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
>

2022-09-07 13:38:42

by Thomas Bogendoerfer

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

On Tue, Sep 06, 2022 at 11:59:43AM +0200, Alexander A Sverdlin wrote:
> 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.
>
> Signed-off-by: Alexander Sverdlin <[email protected]>
> ---
> arch/mips/cavium-octeon/octeon-irq.c | 10 ++++++++++
> 1 file changed, 10 insertions(+)

applied to mips-fixes.

Thomas.

--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]

2022-09-08 22:34:52

by Thomas Bogendoerfer

[permalink] [raw]
Subject: Re: [PATCH] mips: Select SPARSEMEM_EXTREME for CAVIUM_OCTEON_SOC

On Tue, Sep 06, 2022 at 11:59:42AM +0200, Alexander A Sverdlin wrote:
> 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.
>
> Signed-off-by: Alexander Sverdlin <[email protected]>
> ---
> arch/mips/Kconfig | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index ec21f89..79cfa1c 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -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.

--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]