Re: [PATCH v3] sh: avoid using IRQ0 on SH3/4

From: Rob Landley
Date: Mon May 02 2022 - 16:02:38 EST


On 5/2/22 03:37, Geert Uytterhoeven wrote:
> Hi Rob,
...
> Until I tried "ifconfig eth0 up", which causes a lock-up.
> Interestingly, the 8139 irq was 112 with and without Sergey's patch,
> so there must be an irq remapping missing.

Yup, that's it.

> I also test regularly on landisk, where 8139 Ethernet works fine.
> Turns out landisk uses arch/sh/drivers/pci/fixups-landisk.c to fixup
> the irq...

I didn't think the patch was wrong per se, just that something broke when
jiggled. :(

> arch/sh/include/mach-common/mach/r2d.h has:
> #define R2D_FPGA_IRQ_BASE 100
> Subtracting 16 here does not help.
>
> With this (gmail-whitespace-damaged) patch:
>
> --- a/arch/sh/drivers/pci/fixups-rts7751r2d.c
> +++ b/arch/sh/drivers/pci/fixups-rts7751r2d.c
> @@ -31,9 +31,9 @@ static char lboxre2_irq_tab[] = {
> int pcibios_map_platform_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
> {
> if (mach_is_lboxre2())
> - return lboxre2_irq_tab[slot];
> + return lboxre2_irq_tab[slot] - 16;
> else
> - return rts7751r2d_irq_tab[slot];
> + return rts7751r2d_irq_tab[slot] - 16;
> }
>
> int pci_fixup_pcic(struct pci_channel *chan)
>
> it no longer crashes, but ifconfig still fails:
>
> / # ifconfig eth0 up
> ifconfig: ioctl 0x8914 failed: Invalid argument

Sounds like it's now outside of the IRQ range allocation, but I can't find where
that's requested when registering the controller? (What is a "swizzle" anyway?)

I'm looking at kernel/cpu/sh4/setup-sh7750.c but I don't understand why it might
work for landisk but not there. (Bit out of my depth in this plumbing.
Head-scratching at include/linux/sh_intc.h #defining DECLARE_INTC_DESC()... hard
to work backwards to find where this stuff STARTS...)

> Note that there are more implementations of pcibios_map_platform_irq()
> that do not use evt2irq(), and thus are probably broken by this patch.

Yup. Sounds like something could be consolidated. Unfortunately I only have 4
test systems for this platform, only 2 of which are easy to cycle...

> Gr{oetje,eeting}s,
>
> Geert

I can try sticking printk() into this to track it down if you haven't got any
more time to look at it. I don't understand this plumbing very well but "error
return code comes from here, that tested this variable, which was set here..."
is generally a deterministic approach, if glacial.

Rob