Re: [RFC v2 01/39] Kconfig: introduce HAS_IOPORT option and select it as necessary

From: John Garry
Date: Fri May 06 2022 - 07:07:40 EST


On 06/05/2022 10:38, Niklas Schnelle wrote:
Another argument I see is that as shown by POWER9 we might start to see
more platforms that just can't do I/O port access. E.g. I would also be
surprised if Apple's M1 has I/O port access. Sooner or later I expect
distributions on some platforms to only support such systems. For
example on ppc a server distribution might only support IBM POWER
without I/O port support before too long. Then having HAS_IOPORT allows
to get rid of drivers that won't work anyway.

There are also reports of probing a driver with I/O ports causing a
system crash on systems without I/O port support. For example in this
answer by John Garry (added so he may supply more information):

https://lore.kernel.org/lkml/db043b76-880d-5fad-69cf-96abcd9cd34f@xxxxxxxxxx/

.

That issue is that drivers like hwmon f71805f use inb/outb accessors with hardcoded IO port addresses to probe the driver. On archs like arm64 or powerpc - which do not natively support inb et al - this may crash the system when no PCI IO space is mapped [0]. Indeed, when PCI IO space is mapped, it is preferable these those drivers still would not access these ports.

So this series from Niklas could be used as a basis to solve that problem, in that we could also introduce something like HARDCODED_IOPORT [1] to stop those drivers being built at all for arm64.

[0] https://lore.kernel.org/linux-input/20210112055129.7840-1-song.bao.hua@xxxxxxxxxxxxx/T/#mf86445470160c44ac110e9d200b09245169dc5b6
[1] https://lore.kernel.org/lkml/CAK8P3a3HHeP+Gw_k2P7Qtig0OmErf0HN30G22+qHic_uZTh11Q@xxxxxxxxxxxxxx/

Thanks,
John