sh: avoid using IRQ0 on SH3/4
PATCH v3 1/1 sh: avoid using IRQ0 on SH3/4
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.
The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
[1] https://lore.kernel.org/all/[email protected]/
---
The patch is against Linus Torvalds' 'linux.git' repo.
Changes in version 3:
- added an appropriate Fixes: tag and added a passage about it to the patch description;
- added actual cases of the boards using IRQ0 to the patch description;
- added Geert Uytterhoeven's and John Paul Adrian Glaubitz's tags;
- updated the link to point to the version 2 of the patch.
Changes in version 2:
- changed cmp/ge to cmp/hs in the assembly code.
arch/sh/kernel/cpu/sh3/entry.S | 4 ++-- include/linux/sh_intc.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-)
arch/sh/kernel/cpu/sh3/entry.S +2 -2
@@ -470,9 +470,9 @@ ENTRY(handle_interrupt) mov r4, r0 ! save vector->jmp table offset for later shlr2 r4 ! vector to IRQ# conversion - add #-0x10, r4 - cmp/pz r4 ! is it a valid IRQ? + mov #0x10, r5 + cmp/hs r5, r4 ! is it a valid IRQ? bt 10f /*
include/linux/sh_intc.h +3 -3
@@ -13,9 +13,9 @@/* * Convert back and forth between INTEVT and IRQ values. */ -#ifdef CONFIG_CPU_HAS_INTEVT -#define evt2irq (evt) (((evt) >> 5) - 16) -#define irq2evt (irq) (((irq) + 16) << 5) +#ifdef CONFIG_CPU_HAS_INTEVT /* Avoid IRQ0 (invalid for platform devices) */ +#define evt2irq (evt) ((evt) >> 5) +#define irq2evt (irq) ((irq) << 5)#else #define evt2irq (evt) (evt)#define irq2evt (irq) (irq)
Quoted 2 lines · Sergey Shtylyov
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you
Oops, it's platform_get_irq(). :-/
Quoted 6 lines
see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.
The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
Quoted 7 lines
[1] https://lore.kernel.org/all/[email protected]/
Fixes a85a6c86c25b ("driver core: platform: Clarify that IRQ 0 is invalid")Signed-off-by Sergey Shtylyov <[email protected]>Reviewed-by Geert Uytterhoeven <[email protected]>Tested-by Geert Uytterhoeven <[email protected]>
[...]
MBR, Sergey
John Paul Adrian Glaubitz
maintainerHi Sergey!
Quoted 7 lines · Sergey Shtylyov
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
Maybe try getting it landed through Andrew Morton's tree?
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Quoted 8 lines · John Paul Adrian Glaubitz
Hi Sergey!
Quoted 5 lines · Sergey Shtylyov
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.
Quoted 4 lines
Quoted 2 lines
The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
Maybe try getting it landed through Andrew Morton's tree?
I can take it if needed, why does sh patches go through Andrew's tree? Is there no sh maintainer tree anymore?
thanks,
greg k-h
Rich Felker
maintainerQuoted 8 lines · John Paul Adrian Glaubitz
Hi Sergey!
Quoted 5 lines · Sergey Shtylyov
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.
Quoted 4 lines
Quoted 2 lines
The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
Maybe try getting it landed through Andrew Morton's tree?
Hi. I'm alive and looking at it. If it needs to go in for this cycle I will send a pull request for just this and anything else critical. Was trying to get to it last night but had some unpleasant surprises come up that took me away from the computer.
Rich
On 4/29/22 8:16 PM, Rich Felker wrote:
[...]
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
Maybe try getting it landed through Andrew Morton's tree?
Hi. I'm alive and looking at it. If it needs to go in for this cycle I will send a pull request for just this and anything else critical. Was
Well, now using IRQ0 just causes a WARNing in platform_get_irq() -- I don't
think fixing it is critical enough. Starting from 5.19-rc1 the SMSC91xx driver should stop working on the mentioned boards.
But let me look at the SMSC driver itself, I haven't done this yet...
Quoted 2 lines
trying to get to it last night but had some unpleasant surprises come up that took me away from the computer.
:-(
Quoted 1 line
Rich
MBR, Sergey
On 5/1/22 8:58 PM, Sergey Shtylyov wrote:
[...]
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 7 lines
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
Maybe try getting it landed through Andrew Morton's tree?
Quoted 7 lines
Quoted 2 lines
Hi. I'm alive and looking at it. If it needs to go in for this cycle I will send a pull request for just this and anything else critical. Was
Well, now using IRQ0 just causes a WARNing in
platform_get_irq()-- I don't
think fixing it is critical enough. Starting from 5.19-rc1 the SMSC91xx driver should stop working on the mentioned boards.
But let me look at the SMSC driver itself, I haven't done this yet...
Looks like these boards were borked back in 2015 by this commit:
It stopped accepting IRQ0 for no apparent reason. :-/
[...]
Quoted 1 line
Quoted 1 line
Rich
MBR, Sergey
Quoted 8 lines · John Paul Adrian Glaubitz
Hi Sergey!
Quoted 5 lines · Sergey Shtylyov
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.
Quoted 4 lines
Quoted 2 lines
The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
Maybe try getting it landed through Andrew Morton's tree?
As I told him in IRC, the problem is still that sh4 never gives me a shell prompt with this patch applied. I just reconfirmed it against current git:
Freeing unused kernel image (initmem) memory: 124K
This architecture does not have kernel memory protection. Run /init as init process
mountpoint: dev/pts: No such file or directory
8139cp 0000:00:02.0 eth0: link up, 100Mbps, full-duplex, lpa 0x05E1
It makes it partway through the init script, but it hangs with qemu-system-sh4 stuck in a CPU-eating loop before finishing. Without the patch, I get a shell prompt.
If you don't want to build the userspace from source with mkroot, the last release's binary tarball is 4 megs and reproduced the problem just fine. First, confirm it works as-shipped:
$ wget https://landley.net/toybox/downloads/binaries/mkroot/latest/sh4.tgz ... $ tar xvf sh4.tgz ... $ cd sh4 $ ./qemu-sh4.sh ... printk: console [netcon0] enabled netconsole: network logging started Freeing unused kernel image (initmem) memory: 116K This architecture does not have kernel memory protection. Run /init as init process 8139cp 0000:00:02.0 eth0: link up, 100Mbps, full-duplex, lpa 0x05E1 random: fast init done Type exit when done. # exit reboot: Restarting system
landley@driftwood:~/sub/sh4$
Once you've confirmed that works with your qemu-system-sh4 install, replace the kernel using the config in that directory:
$ git clone ~/linux/linux linux ... $ cd linux $ patch -p1 -i ~/linux/sh4irq.eml ... $ CROSS_COMPILE=~/mcm/ccc/sh4-linux-musl-cross/bin/sh4-linux-musl- make \ ARCH=sh allnoconfig KCONFIG_ALLCONFIG=../miniconfig-sh4 ... $ CROSS_COMPILE=~/mcm/ccc/sh4-linux-musl-cross/bin/sh4-linux-musl- make \ ARCH=sh -j $(nproc) ... $ cp arch/sh/boot/zImage .. $ cd .. $ ./qemu-*.sh ...
and it hangs without ever saying "random: fast init done" or giving a prompt.
(You could also use the linux-fullconfig file to build your kernel, but you'll have to say "n" to a bunch of make oldconfig questions.)
Quoted 1 line
Adrian
Rob
John Paul Adrian Glaubitz
maintainerHi Rob!
Quoted 11 lines · Rob Landley
Quoted 1 line
Maybe try getting it landed through Andrew Morton's tree?
As I told him in IRC, the problem is still that sh4 never gives me a shell prompt with this patch applied. I just reconfirmed it against current git:
Freeing unused kernel image (initmem) memory: 124K
This architecture does not have kernel memory protection. Run /init as init process
mountpoint: dev/pts: No such file or directory
8139cp 0000:00:02.0 eth0: link up, 100Mbps, full-duplex, lpa0x05E1
Quoted 3 lines
It makes it partway through the init script, but it hangs with qemu-system-sh4 stuck in a CPU-eating loop before finishing. Without the patch, I get a shell prompt.
Oh, I wasn't aware of that. I did not experience the issue on my SH7785LCR but I can retest against current git with the patch applied on top.
Adrian
Signature · 4 lines
.''`. John Paul Adrian Glaubitz : :' : Debian Developer `. `' Physicist `- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Hi Rob,
Quoted 19 lines · Rob Landley
Quoted 8 lines · John Paul Adrian Glaubitz
Quoted 7 lines · Sergey Shtylyov
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
As I told him in IRC, the problem is still that sh4 never gives me a shell prompt with this patch applied. I just reconfirmed it against current git:
Freeing unused kernel image (initmem) memory: 124K
This architecture does not have kernel memory protection. Run /init as init process
mountpoint: dev/pts: No such file or directory
8139cp 0000:00:02.0 eth0: link up, 100Mbps, full-duplex, lpa0x05E1
Quoted 3 lines
It makes it partway through the init script, but it hangs with qemu-system-sh4 stuck in a CPU-eating loop before finishing. Without the patch, I get a shell prompt.
I regularly test on qemu rts7751r2d, but couldn't produce your issue. 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.
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...
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:
arch/sh/drivers/pci/fixups-rts7751r2d.c +2 -2
@@ -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
Note that there are more implementations of pcibios_map_platform_irq() that do not use evt2irq(), and thus are probably broken by this patch.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 1 line · Geert Uytterhoeven
Hi Rob,
...
Quoted 3 lines
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.
Quoted 3 lines
I also test regularly on landisk, where 8139 Ethernet works fine. Turns out landisk uses
arch/sh/drivers/pci/fixups-landisk.cto fixup the irq...
I didn't think the patch was wrong per se, just that something broke when jiggled. :(
Quoted 21 lines
arch/sh/include/mach-common/mach/r2d.hhas:
#defineR2D_FPGA_IRQ_BASE100
Subtracting 16 here does not help.With this (gmail-whitespace-damaged) patch:
arch/sh/drivers/pci/fixups-rts7751r2d.c +2
-2@@ -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)
Quoted 4 lines
it no longer crashes, but ifconfig still fails:
/ # ifconfig eth0 up
ifconfig: ioctl0x8914failed: 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...)
Quoted 2 lines
Note that there are more implementations of
pcibios_map_platform_irq()that do not useevt2irq(), 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...
Quoted 3 lines
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
Hi Rob,
Quoted 2 lines · Rob Landley
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?)
PCI slots have 4 interrupts (#A, #B, #C, #D). In machines with multiple slots, the interrupts lines are "swizzled", to avoid that all cards using a single interrupt are mapped to the same host interrupt.
Typically, the mapping is:
host_irq = bus_irqs[(slot + irq_pin) % 4];
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Quoted 6 lines · Geert Uytterhoeven
Quoted 2 lines
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?)
PCI slots have 4 interrupts (#A, #B, #C, #D). In machines with multiple slots, the interrupts lines are "swizzled", to avoid that all cards using a single interrupt are mapped to the same host interrupt.
Especially as single-function devices are required to use INTA.
Maciej
On 5/2/22 11:37 AM, Geert Uytterhoeven wrote:
[...]
Quoted 26 lines
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
As I told him in IRC, the problem is still that sh4 never gives me a shell prompt with this patch applied. I just reconfirmed it against current git:
Freeing unused kernel image (initmem) memory: 124K
This architecture does not have kernel memory protection. Run /init as init process
mountpoint: dev/pts: No such file or directory
8139cp 0000:00:02.0 eth0: link up, 100Mbps, full-duplex, lpa0x05E1Quoted 3 lines
It makes it partway through the init script, but it hangs with qemu-system-sh4 stuck in a CPU-eating loop before finishing. Without the patch, I get a shell prompt.
I regularly test on qemu rts7751r2d, but couldn't produce your issue. 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.
Quoted 7 lines
I also test regularly on landisk, where 8139 Ethernet works fine. Turns out landisk uses
arch/sh/drivers/pci/fixups-landisk.cto fixup the irq...
arch/sh/include/mach-common/mach/r2d.hhas:
#defineR2D_FPGA_IRQ_BASE100
Subtracting 16 here does not help.
Why subtract when you contrariwise need to add? :-)
arch/sh/drivers/pci/fixups-rts7751r2d.c static char lboxre2_irq_tab[] = { · line 34
Quoted 10 lines
With this (gmail-whitespace-damaged) patch:
arch/sh/drivers/pci/fixups-rts7751r2d.c +1
-1@@ -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 ;
This table contains the values #define'd via evt2irq(), so
shouldn't need to subtract anything...
arch/sh/drivers/pci/fixups-rts7751r2d.c static char lboxre2_irq_tab[] = { · line 36
Quoted 3 lines
arch/sh/drivers/pci/fixups-rts7751r2d.c +1
-1else -return rts7751r2d_irq_tab[slot]; +return rts7751r2d_irq_tab[slot] -16 ;
How about + 16?
Quoted 8 lines
arch/sh/drivers/pci/fixups-rts7751r2d.c +0
-0}int pci_fixup_pcic (struct pci_channel *chan)it no longer crashes, but ifconfig still fails:
/ # ifconfig eth0 up
ifconfig: ioctl0x8914failed: Invalid argument
I'm still not sure you used the correct IRQ #s...
Quoted 2 lines
Note that there are more implementations of
pcibios_map_platform_irq()that do not useevt2irq(), and thus are probably broken by this patch.
That doesn't sound encouraging... :-/
Quoted 3 lines
Gr{oetje,eeting}s,
Geert
MBR, Sergey
Hi Sergey,
Quoted 31 lines · Sergey Shtylyov
Quoted 30 lines · Geert Uytterhoeven
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
As I told him in IRC, the problem is still that sh4 never gives me a shell prompt with this patch applied. I just reconfirmed it against current git:
Freeing unused kernel image (initmem) memory: 124K
This architecture does not have kernel memory protection. Run /init as init process
mountpoint: dev/pts: No such file or directory
8139cp 0000:00:02.0 eth0: link up, 100Mbps, full-duplex, lpa0x05E1Quoted 3 lines
It makes it partway through the init script, but it hangs with qemu-system-sh4 stuck in a CPU-eating loop before finishing. Without the patch, I get a shell prompt.
I regularly test on qemu rts7751r2d, but couldn't produce your issue. 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.
I also test regularly on landisk, where 8139 Ethernet works fine. Turns out landisk uses
arch/sh/drivers/pci/fixups-landisk.cto fixup the irq...
Quoted 5 lines
Quoted 3 lines
arch/sh/include/mach-common/mach/r2d.hhas:
#defineR2D_FPGA_IRQ_BASE100
Subtracting 16 here does not help.Why subtract when you contrariwise need to add? :-)
Thanks, adding 16 here fixed the issue:
/ # ifconfig eth0 up
8139cp 0000:00:02.0 eth0: link up, 100Mbps, full-duplex, lpa 0x05E1
Quoted 14 lines
arch/sh/drivers/pci/fixups-rts7751r2d.c static char lboxre2_irq_tab[] = { · line 34
Quoted 10 lines
With this (gmail-whitespace-damaged) patch:
arch/sh/drivers/pci/fixups-rts7751r2d.c +1
-1@@ -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 ;This table contains the values #define'd via
evt2irq(), so
shouldn't need to subtract anything...
Quoted 5 lines
arch/sh/drivers/pci/fixups-rts7751r2d.c static char lboxre2_irq_tab[] = { · line 36
Quoted 3 lines
arch/sh/drivers/pci/fixups-rts7751r2d.c +1
-1else -return rts7751r2d_irq_tab[slot]; +return rts7751r2d_irq_tab[slot] -16 ;How about + 16?
Doesn't work, but changing R2D_FPGA_IRQ_BASE does work, see above.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
On 5/2/22 11:56 PM, Sergey Shtylyov wrote:
[...]
Quoted 65 lines
Quoted 26 lines
Quoted 17 lines
Quoted 7 lines
Quoted 7 lines
Using IRQ0 by the platform devices is going to be disallowed soon (see [1]) and even now, when IRQ0 is about to be returned by
platfrom_get_irq(), you see a big warning. The code supporting SH3/4 SoCs maps the IRQ #s starting at 0 -- modify that code to start the IRQ #s from 16 instead.The patch should mostly affect the AP-SH4A-3A/AP-SH4AD-0A boards as they indeed use IRQ0 for the SMSC911x compatible Ethernet chip...
As I told him in IRC, the problem is still that sh4 never gives me a shell prompt with this patch applied. I just reconfirmed it against current git:
Freeing unused kernel image (initmem) memory: 124K
This architecture does not have kernel memory protection. Run /init as init process
mountpoint: dev/pts: No such file or directory
8139cp 0000:00:02.0 eth0: link up, 100Mbps, full-duplex, lpa0x05E1Quoted 3 lines
It makes it partway through the init script, but it hangs with qemu-system-sh4 stuck in a CPU-eating loop before finishing. Without the patch, I get a shell prompt.
I regularly test on qemu rts7751r2d, but couldn't produce your issue. 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.
Quoted 7 lines
I also test regularly on landisk, where 8139 Ethernet works fine. Turns out landisk uses
arch/sh/drivers/pci/fixups-landisk.cto fixup the irq...
arch/sh/include/mach-common/mach/r2d.hhas:
#defineR2D_FPGA_IRQ_BASE100
Subtracting 16 here does not help.Why subtract when you contrariwise need to add? :-)
arch/sh/drivers/pci/fixups-rts7751r2d.c static char lboxre2_irq_tab[] = { · line 34
Quoted 10 lines
With this (gmail-whitespace-damaged) patch:
arch/sh/drivers/pci/fixups-rts7751r2d.c +1
-1@@ -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 ;This table contains the values #define'd via
evt2irq(), so
shouldn't need to subtract anything...arch/sh/drivers/pci/fixups-rts7751r2d.c static char lboxre2_irq_tab[] = { · line 36
Quoted 3 lines
arch/sh/drivers/pci/fixups-rts7751r2d.c +1
-1else -return rts7751r2d_irq_tab[slot]; +return rts7751r2d_irq_tab[slot] -16 ;How about + 16?Quoted 8 lines
arch/sh/drivers/pci/fixups-rts7751r2d.c +0
-0}int pci_fixup_pcic (struct pci_channel *chan)it no longer crashes, but ifconfig still fails:
/ # ifconfig eth0 up
ifconfig: ioctl0x8914failed: Invalid argument
Quoted 6 lines
I'm still not sure you used the correct IRQ #s...
Quoted 2 lines
Note that there are more implementations of
pcibios_map_platform_irq()that do not useevt2irq(), and thus are probably broken by this patch.That doesn't sound encouraging... :-/
Actually, of those only Dreamcast didn't use evt2irq()...
Now I'm wondering whether all #define *_IRQ_BASE should be visited as well...
Quoted 3 lines
Quoted 3 lines
Gr{oetje,eeting}s,
Geert
MBR, Sergey