Re: [PATCH 2/9] ARM: PXA: Kill use of irq_create_strict_mappings()

From: Guenter Roeck
Date: Tue Apr 27 2021 - 08:56:44 EST


On 4/27/21 1:30 AM, Marc Zyngier wrote:
> Hi Guenter,
>
> Thanks for the heads up.
>
> On Mon, 26 Apr 2021 23:39:42 +0100,
> Guenter Roeck <linux@xxxxxxxxxxxx> wrote:
>>
>> On Tue, Apr 06, 2021 at 10:35:50AM +0100, Marc Zyngier wrote:
>>> irq_create_strict_mappings() is a poor way to allow the use of
>>> a linear IRQ domain as a legacy one. Let's be upfront about
>>> it and use a legacy domain when appropriate.
>>>
>>> Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
>>> ---
>>
>> When running the "mainstone" qemu emulation, this patch results
>> in many (32, actually) runtime warnings such as the following.
>>
>> [ 0.528272] ------------[ cut here ]------------
>> [ 0.528285] WARNING: CPU: 0 PID: 1 at kernel/irq/irqdomain.c:550 irq_domain_associate+0x194/0x1f0
>> [ 0.528315] error: virq335 is not allocated
>
> [...]
>
> This looks like a case of CONFIG_SPARSE_IRQ, combined with a lack of
> brain engagement. I've come up with the following patch, which lets
> the kernel boot in QEMU without screaming (other than the lack of a
> rootfs...).
>
> Please let me know if this helps.
>

It does.

Tested-by: Guenter Roeck <linux@xxxxxxxxxxxx>

Thanks,
Guenter

> Thanks,
>
> M.
>
> From 4d7f6ddbbfdff1c9f029bafca79020d3294dc32c Mon Sep 17 00:00:00 2001
> From: Marc Zyngier <maz@xxxxxxxxxx>
> Date: Tue, 27 Apr 2021 09:00:28 +0100
> Subject: [PATCH] ARM: PXA: Fix cplds irqdesc allocation when using legacy mode
>
> The Mainstone PXA platform uses CONFIG_SPARSE_IRQ, and thus we
> cannot rely on the irq descriptors to be readilly allocated
> before creating the irqdomain in legacy mode. The kernel then
> complains loudly about not being able to associate the interrupt
> in the domain -- can't blame it.
>
> Fix it by allocating the irqdescs upfront in the legacy case.
>
> Fixes: b68761da0111 ("ARM: PXA: Kill use of irq_create_strict_mappings()")
> Reported-by: Guenter Roeck <linux@xxxxxxxxxxxx>
> Signed-off-by: Marc Zyngier <maz@xxxxxxxxxx>
> ---
> arch/arm/mach-pxa/pxa_cplds_irqs.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-pxa/pxa_cplds_irqs.c b/arch/arm/mach-pxa/pxa_cplds_irqs.c
> index ec0d9b094744..bddfc7cd5d40 100644
> --- a/arch/arm/mach-pxa/pxa_cplds_irqs.c
> +++ b/arch/arm/mach-pxa/pxa_cplds_irqs.c
> @@ -121,8 +121,13 @@ static int cplds_probe(struct platform_device *pdev)
> return fpga->irq;
>
> base_irq = platform_get_irq(pdev, 1);
> - if (base_irq < 0)
> + if (base_irq < 0) {
> base_irq = 0;
> + } else {
> + ret = devm_irq_alloc_descs(&pdev->dev, base_irq, base_irq, CPLDS_NB_IRQ, 0);
> + if (ret < 0)
> + return ret;
> + }
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> fpga->base = devm_ioremap_resource(&pdev->dev, res);
>