mbox series

[v3,00/38] Kconfig: Introduce HAS_IOPORT config option

Message ID 20230314121216.413434-1-schnelle@linux.ibm.com (mailing list archive)
Headers show
Series Kconfig: Introduce HAS_IOPORT config option | expand

Message

Niklas Schnelle March 14, 2023, 12:11 p.m. UTC
Hello Kernel Hackers,

Some platforms such as s390 do not support PCI I/O spaces. On such platforms
I/O space accessors like inb()/outb() are stubs that can never actually work.
The way these stubs are implemented in asm-generic/io.h leads to compiler
warnings because any use will be a NULL pointer access on these platforms. In
a previous patch we tried handling this with a run-time warning on access. This
approach however was rejected by Linus[0] with the argument that this really
should be a compile-time check and, though a much more invasive change, we
believe that is indeed the right approach.

This patch series aims to do exactly that by introducing a HAS_IOPORT config
option akin to the existing HAS_IOMEM. When this is unset inb()/outb() and
friends may not be defined. This is also the same approach originally planned by
Uwe Kleine-König as mentioned in commit ce816fa88cca ("Kconfig: rename
HAS_IOPORT to HAS_IOPORT_MAP").

This series builds heavily on an original patch for demonstating the concept by
Arnd Bergmann[1] and incoporates feedback of previous RFC versions [2] and [3].

This version is based on v6.3-rc1 and is also available on my kernel.org tree
in the has_ioport_v3 branch with the PGP signed tag has_ioport_v3_signed:

https://git.kernel.org/pub/scm/linux/kernel/git/niks/linux.git

Thanks,
Niklas Schnelle

Changes from RFC v2:
- Rebased on v6.3-rc1
- Fixed a NULL pointer dereference in set_io_from_upio() due to accidentially
  expanded #ifdef CONFIG_SERIAL_8250_RT288X (kernel test robot)
- Dropped "ACPI: add dependency on HAS_IOPORT" (Bjorn Helgaas)
- Reworded commit message and moved ifdefs for "PCI/sysfs: Make I/O resource
  depend on HAS_IOPORT" (Bjorn Helgaas)
- Instead of complete removal inb() etc. are marked with __compiletime_error()
  when HAS_IOPORT is unset allowing for better error reporting (Ahmad Fatoum)
- Removed HAS_IOPORT dependency from PCMCIA as I/O port use is optional in at
  least PC Card. Instead added HAS_IOPORT on a per driver basis. (Bjorn
  Helgaas)
- Made uhci_has_pci_registers() constant 0 if HAS_IOPORT is not defined (Alan
  Stern)

Changes from RFC v1:
- Completely dropped the LEGACY_PCI option and replaced its dependencies with
  HAS_IOPORT as appropriate
- In the usb subsystem patch I incorporated the feedback from v1 by Alan Stern:
  - Used a local macro to nop in*()/out*() in the helpers
  - Removed an unnecessary further restriction on CONFIG_USB_UHCI_HCD
- Added a few more subsystems including wireless, ptp, and, mISDN that I had
  previously missed due to a blanket !S390.
- Removed blanket !S390 dependencies where they are added due to the I/O port
  problem
- In the sound system SND_OPL3_LIB needed to use "depends on" instead of
  "select" because of its added HAS_IOPORT dependency
- In the drm subsystem the bochs driver gets #ifdefs instead of a blanket
  dependency because its MMIO capable device variant should work without
  HAS_IOPORT.

[0] https://lore.kernel.org/lkml/CAHk-=wg80je=K7madF4e7WrRNp37e3qh6y10Svhdc7O8SZ_-8g@mail.gmail.com/
[1] https://lore.kernel.org/lkml/CAK8P3a0MNbx-iuzW_-=0ab6-TTZzwV-PT_6gAC1Gp5PgYyHcrA@mail.gmail.com/
[2] https://yhbt.net/lore/all/20211227164317.4146918-1-schnelle@linux.ibm.com/
[3] https://lore.kernel.org/all/20220429135108.2781579-1-schnelle@linux.ibm.com/

Niklas Schnelle (38):
  Kconfig: introduce HAS_IOPORT option and select it as necessary
  ata: add HAS_IOPORT dependencies
  char: impi, tpm: depend on HAS_IOPORT
  comedi: add HAS_IOPORT dependencies
  counter: add HAS_IOPORT dependencies
  /dev/port: don't compile file operations without CONFIG_DEVPORT
  drm: handle HAS_IOPORT dependencies
  firmware: dmi-sysfs: handle HAS_IOPORT=n
  gpio: add HAS_IOPORT dependencies
  hwmon: add HAS_IOPORT dependencies
  i2c: add HAS_IOPORT dependencies
  iio: ad7606: Kconfig: add HAS_IOPORT dependencies
  Input: add HAS_IOPORT dependencies
  Input: gameport: add ISA and HAS_IOPORT dependencies
  leds: add HAS_IOPORT dependencies
  media: add HAS_IOPORT dependencies
  misc: add HAS_IOPORT dependencies
  mISDN: add HAS_IOPORT dependencies
  mpt fusion: add HAS_IOPORT dependencies
  net: handle HAS_IOPORT dependencies
  parport: PC style parport depends on HAS_IOPORT
  PCI: Make quirk using inw() depend on HAS_IOPORT
  PCI/sysfs: Make I/O resource depend on HAS_IOPORT
  pcmcia: add HAS_IOPORT dependencies
  platform: add HAS_IOPORT dependencies
  pnp: add HAS_IOPORT dependencies
  power: add HAS_IOPORT dependencies
  rtc: add HAS_IOPORT dependencies
  scsi: add HAS_IOPORT dependencies
  sound: add HAS_IOPORT dependencies
  speakup: add HAS_IOPORT dependency for SPEAKUP_SERIALIO
  staging: add HAS_IOPORT dependencies
  tty: serial: handle HAS_IOPORT dependencies
  usb: handle HAS_IOPORT dependencies
  video: handle HAS_IOPORT dependencies
  watchdog: add HAS_IOPORT dependencies
  wireless: add HAS_IOPORT dependencies
  asm-generic/io.h: drop inb() etc for HAS_IOPORT=n

 arch/alpha/Kconfig                           |   1 +
 arch/arm/Kconfig                             |   1 +
 arch/arm64/Kconfig                           |   1 +
 arch/ia64/Kconfig                            |   1 +
 arch/m68k/Kconfig                            |   1 +
 arch/microblaze/Kconfig                      |   1 +
 arch/mips/Kconfig                            |   2 +
 arch/parisc/Kconfig                          |   2 +
 arch/powerpc/Kconfig                         |   2 +-
 arch/riscv/Kconfig                           |   1 +
 arch/sh/Kconfig                              |   1 +
 arch/sparc/Kconfig                           |   1 +
 arch/um/Kconfig                              |   1 +
 arch/x86/Kconfig                             |   2 +
 drivers/accessibility/speakup/Kconfig        |   1 +
 drivers/ata/Kconfig                          |   1 +
 drivers/bus/Kconfig                          |   2 +-
 drivers/char/Kconfig                         |   3 +-
 drivers/char/ipmi/Makefile                   |  11 +-
 drivers/char/ipmi/ipmi_si_intf.c             |   3 +-
 drivers/char/ipmi/ipmi_si_pci.c              |   3 +
 drivers/char/mem.c                           |   6 +-
 drivers/char/pcmcia/Kconfig                  |   8 +-
 drivers/char/tpm/Kconfig                     |   1 +
 drivers/char/tpm/tpm_infineon.c              |  14 ++-
 drivers/char/tpm/tpm_tis_core.c              |  19 ++-
 drivers/comedi/Kconfig                       | 103 +++++++++------
 drivers/counter/Kconfig                      |   1 +
 drivers/eisa/Kconfig                         |   1 +
 drivers/firmware/dmi-sysfs.c                 |   4 +
 drivers/gpio/Kconfig                         |   2 +-
 drivers/gpu/drm/qxl/Kconfig                  |   1 +
 drivers/gpu/drm/tiny/bochs.c                 |  19 +++
 drivers/gpu/drm/tiny/cirrus.c                |   2 +
 drivers/hwmon/Kconfig                        |  21 +++-
 drivers/i2c/busses/Kconfig                   |  31 ++---
 drivers/iio/adc/Kconfig                      |   2 +-
 drivers/input/gameport/Kconfig               |   4 +-
 drivers/input/serio/Kconfig                  |   2 +
 drivers/input/touchscreen/Kconfig            |   1 +
 drivers/isdn/Kconfig                         |   1 -
 drivers/isdn/hardware/mISDN/Kconfig          |  12 +-
 drivers/leds/Kconfig                         |   2 +-
 drivers/media/pci/dm1105/Kconfig             |   2 +-
 drivers/media/radio/Kconfig                  |  14 ++-
 drivers/media/rc/Kconfig                     |   6 +
 drivers/message/fusion/Kconfig               |   2 +-
 drivers/misc/altera-stapl/Makefile           |   3 +-
 drivers/misc/altera-stapl/altera.c           |   6 +-
 drivers/net/Kconfig                          |   2 +-
 drivers/net/arcnet/Kconfig                   |   2 +-
 drivers/net/can/cc770/Kconfig                |   1 +
 drivers/net/can/sja1000/Kconfig              |   1 +
 drivers/net/ethernet/3com/Kconfig            |   4 +-
 drivers/net/ethernet/8390/Kconfig            |   6 +-
 drivers/net/ethernet/amd/Kconfig             |   4 +-
 drivers/net/ethernet/fujitsu/Kconfig         |   2 +-
 drivers/net/ethernet/intel/Kconfig           |   2 +-
 drivers/net/ethernet/sis/Kconfig             |   4 +-
 drivers/net/ethernet/smsc/Kconfig            |   2 +-
 drivers/net/ethernet/ti/Kconfig              |   2 +-
 drivers/net/ethernet/via/Kconfig             |   1 +
 drivers/net/ethernet/xircom/Kconfig          |   2 +-
 drivers/net/fddi/Kconfig                     |   2 +-
 drivers/net/fddi/defxx.c                     |   2 +-
 drivers/net/hamradio/Kconfig                 |   6 +-
 drivers/net/wan/Kconfig                      |   2 +-
 drivers/net/wireless/atmel/Kconfig           |   2 +-
 drivers/net/wireless/intersil/hostap/Kconfig |   2 +-
 drivers/parport/Kconfig                      |   4 +-
 drivers/pci/pci-sysfs.c                      |   4 +
 drivers/pci/quirks.c                         |   2 +
 drivers/pcmcia/Kconfig                       |   5 +-
 drivers/platform/chrome/Kconfig              |   1 +
 drivers/platform/chrome/wilco_ec/Kconfig     |   1 +
 drivers/pnp/isapnp/Kconfig                   |   2 +-
 drivers/power/reset/Kconfig                  |   1 +
 drivers/rtc/Kconfig                          |   4 +-
 drivers/scsi/Kconfig                         |  25 ++--
 drivers/scsi/aic7xxx/Kconfig.aic79xx         |   2 +-
 drivers/scsi/aic7xxx/Kconfig.aic7xxx         |   2 +-
 drivers/scsi/aic94xx/Kconfig                 |   2 +-
 drivers/scsi/megaraid/Kconfig.megaraid       |   6 +-
 drivers/scsi/mvsas/Kconfig                   |   2 +-
 drivers/scsi/pcmcia/Kconfig                  |   6 +-
 drivers/scsi/qla2xxx/Kconfig                 |   2 +-
 drivers/staging/sm750fb/Kconfig              |   2 +-
 drivers/staging/vt6655/Kconfig               |   2 +-
 drivers/tty/Kconfig                          |   2 +-
 drivers/tty/serial/8250/8250_early.c         |   4 +
 drivers/tty/serial/8250/8250_pci.c           |  14 +++
 drivers/tty/serial/8250/8250_port.c          |  44 +++++--
 drivers/tty/serial/8250/Kconfig              |   5 +-
 drivers/tty/serial/Kconfig                   |   2 +-
 drivers/usb/core/hcd-pci.c                   |   2 +
 drivers/usb/host/Kconfig                     |   4 +-
 drivers/usb/host/pci-quirks.c                | 125 ++++++++++---------
 drivers/usb/host/pci-quirks.h                |  31 +++--
 drivers/usb/host/uhci-hcd.c                  |   2 +-
 drivers/usb/host/uhci-hcd.h                  |  36 ++++--
 drivers/video/console/Kconfig                |   1 +
 drivers/video/fbdev/Kconfig                  |  25 ++--
 drivers/watchdog/Kconfig                     |   6 +-
 include/asm-generic/io.h                     |  60 +++++++++
 include/linux/gameport.h                     |   9 +-
 include/linux/parport.h                      |   2 +-
 include/video/vga.h                          |   8 ++
 lib/Kconfig                                  |   4 +
 lib/Kconfig.kgdb                             |   3 +-
 net/ax25/Kconfig                             |   2 +-
 sound/drivers/Kconfig                        |   3 +
 sound/isa/Kconfig                            |  31 ++++-
 sound/pci/Kconfig                            |  45 +++++--
 sound/pcmcia/Kconfig                         |   2 +
 114 files changed, 649 insertions(+), 281 deletions(-)


base-commit: eeac8ede17557680855031c6f305ece2378af326

Comments

Johannes Berg March 14, 2023, 12:37 p.m. UTC | #1
On Tue, 2023-03-14 at 13:11 +0100, Niklas Schnelle wrote:
> --- a/arch/um/Kconfig
> +++ b/arch/um/Kconfig
> @@ -56,6 +56,7 @@ config NO_IOPORT_MAP
>  
>  config ISA
>  	bool
> +	depends on HAS_IOPORT
> 

config ISA here is already unselectable, and nothing ever does "select
ISA" (only in some other architectures), so is there much point in this?

I'm not even sure why this exists at all.

But anyway, adding a dependency to a always-false symbol doesn't make it
less always-false :-)

Acked-by: Johannes Berg <johannes@sipsolutions.net> # for ARCH=um


Certainly will be nice to get rid of this cruft for architectures that
don't have it.

johannes
Geert Uytterhoeven March 14, 2023, 12:48 p.m. UTC | #2
On Tue, Mar 14, 2023 at 1:13 PM Niklas Schnelle <schnelle@linux.ibm.com> wrote:
> We introduce a new HAS_IOPORT Kconfig option to indicate support for I/O
> Port access. In a future patch HAS_IOPORT=n will disable compilation of
> the I/O accessor functions inb()/outb() and friends on architectures
> which can not meaningfully support legacy I/O spaces such as s390. Also
> add dependencies on HAS_IOPORT for the ISA and HAVE_EISA config options
> as these busses always go along with HAS_IOPORT.
>
> The "depends on" relations on HAS_IOPORT in drivers as well as ifdefs
> for HAS_IOPORT specific sections will be added in subsequent patches on
> a per subsystem basis.
>
> Co-developed-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>

>  arch/m68k/Kconfig       | 1 +

Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert
Arnd Bergmann March 14, 2023, 1:29 p.m. UTC | #3
On Tue, Mar 14, 2023, at 13:11, Niklas Schnelle wrote:
> We introduce a new HAS_IOPORT Kconfig option to indicate support for I/O
> Port access. In a future patch HAS_IOPORT=n will disable compilation of
> the I/O accessor functions inb()/outb() and friends on architectures
> which can not meaningfully support legacy I/O spaces such as s390. Also
> add dependencies on HAS_IOPORT for the ISA and HAVE_EISA config options
> as these busses always go along with HAS_IOPORT.
>
> The "depends on" relations on HAS_IOPORT in drivers as well as ifdefs
> for HAS_IOPORT specific sections will be added in subsequent patches on
> a per subsystem basis.

I think it would be helpful to enumerate which architectures
do not get HAS_IOPORT added, as they will be affected more.

> Co-developed-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>

If there are no objections, I could send this first patch for the
asm-generic tree as a preparation for 6.3, so we are able to merge
the other patches through subsystem maintainer tree for 6.4.

arch/loongarch/ will now also need to select HAS_IOPORT
uncontitionally, this architecture was added after you
sent v2.

> diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
> index a98940e64243..5eeacc72e4da 100644
> --- a/arch/parisc/Kconfig
> +++ b/arch/parisc/Kconfig
> @@ -47,6 +47,7 @@ config PARISC
>  	select MODULES_USE_ELF_RELA
>  	select CLONE_BACKWARDS
>  	select TTY # Needed for pdc_cons.c
> +	select HAS_IOPORT if PCI

It's also needed for EISA and I think you should select it
from CONFIG_GSC in drivers/parisc/Kconfig for this purpose.

This could also be 'select HAS_IOPORT if PCI || EISA', but
that would require removing the 'depends on HAS_IOPORT'
under drivers/eisa/.

>  	select HAVE_DEBUG_STACKOVERFLOW
>  	select HAVE_ARCH_AUDITSYSCALL
>  	select HAVE_ARCH_HASH
> @@ -131,6 +132,7 @@ config STACKTRACE_SUPPORT
> 
>  config ISA_DMA_API
>  	bool
> +	depends on HAS_IOPORT
> 

This line is not really needed since there is no way to
enable ISA_DMA_API.

> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index a6c4407d3ec8..f7de646c074a 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -188,6 +188,7 @@ config PPC
>  	select GENERIC_SMP_IDLE_THREAD
>  	select GENERIC_TIME_VSYSCALL
>  	select GENERIC_VDSO_TIME_NS
> +	select HAS_IOPORT			if PCI
>  	select HAVE_ARCH_AUDITSYSCALL
>  	select HAVE_ARCH_HUGE_VMALLOC		if HAVE_ARCH_HUGE_VMAP
>  	select HAVE_ARCH_HUGE_VMAP		if PPC_RADIX_MMU || PPC_8xx
> @@ -1070,7 +1071,6 @@ menu "Bus options"
> 
>  config ISA
>  	bool "Support for ISA-bus hardware"
> -	depends on PPC_CHRP
>  	select PPC_I8259
>  	help
>  	  Find out whether you have ISA slots on your motherboard.  ISA is the

This line looks wrong, I think we should keep that dependency.
Did you get a circular dependency if you leave it in?

> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index a825bf031f49..634dd42532f3 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -162,6 +162,7 @@ config X86
>  	select GUP_GET_PXX_LOW_HIGH		if X86_PAE
>  	select HARDIRQS_SW_RESEND
>  	select HARDLOCKUP_CHECK_TIMESTAMP	if X86_64
> +	select HAS_IOPORT
>  	select HAVE_ACPI_APEI			if ACPI
>  	select HAVE_ACPI_APEI_NMI		if ACPI
>  	select HAVE_ALIGNED_STRUCT_PAGE		if SLUB
> @@ -2893,6 +2894,7 @@ if X86_32
> 
>  config ISA
>  	bool "ISA support"
> +	depends on HAS_IOPORT
>  	help

HAS_IOPORT is selected unconditionally already, so this doesn't
really do anything.

> diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb
> index 3b9a44008433..c68e4d9dcecb 100644
> --- a/lib/Kconfig.kgdb
> +++ b/lib/Kconfig.kgdb
> @@ -121,7 +121,8 @@ config KDB_DEFAULT_ENABLE
> 
>  config KDB_KEYBOARD
>  	bool "KGDB_KDB: keyboard as input device"
> -	depends on VT && KGDB_KDB && !PARISC
> +	depends on HAS_IOPORT
> +	depends on VT && KGDB_KDB
>  	default n

This loses the !PARISC dependency, which I don't think is
intentional. The added HAS_IOPORT dependency makes sense
here, but I think this should be in a different patch
and not in the preparation.

    Arnd
Arnd Bergmann March 14, 2023, 2:05 p.m. UTC | #4
On Tue, Mar 14, 2023, at 13:11, Niklas Schnelle wrote:
> Hello Kernel Hackers,
>
> Some platforms such as s390 do not support PCI I/O spaces. On such platforms
> I/O space accessors like inb()/outb() are stubs that can never actually work.
> The way these stubs are implemented in asm-generic/io.h leads to compiler
> warnings because any use will be a NULL pointer access on these platforms. In
> a previous patch we tried handling this with a run-time warning on access. This
> approach however was rejected by Linus[0] with the argument that this really
> should be a compile-time check and, though a much more invasive change, we
> believe that is indeed the right approach.
>
> This patch series aims to do exactly that by introducing a HAS_IOPORT config
> option akin to the existing HAS_IOMEM. When this is unset inb()/outb() and
> friends may not be defined. This is also the same approach originally planned by
> Uwe Kleine-König as mentioned in commit ce816fa88cca ("Kconfig: rename
> HAS_IOPORT to HAS_IOPORT_MAP").
>
> This series builds heavily on an original patch for demonstating the concept by
> Arnd Bergmann[1] and incoporates feedback of previous RFC versions [2] and [3].
>
> This version is based on v6.3-rc1 and is also available on my kernel.org tree
> in the has_ioport_v3 branch with the PGP signed tag has_ioport_v3_signed:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/niks/linux.git

Thanks a lot for the rebase, hopefully we can finally get this merged.
I'll go through all patches and note everything I spot that should
be improved. I'd like to make sure that at least the first patch
can get merged quickly so we can continue on the rest.

Since this is all related to asm-generic/io.h and cross-architecture
work, I can pick up anything that has nobody else maintaining it
through the asm-generic tree.

   Arnd
Niklas Schnelle March 14, 2023, 4:11 p.m. UTC | #5
On Tue, 2023-03-14 at 14:29 +0100, Arnd Bergmann wrote:
> On Tue, Mar 14, 2023, at 13:11, Niklas Schnelle wrote:
> > We introduce a new HAS_IOPORT Kconfig option to indicate support for I/O
> > Port access. In a future patch HAS_IOPORT=n will disable compilation of
> > the I/O accessor functions inb()/outb() and friends on architectures
> > which can not meaningfully support legacy I/O spaces such as s390. Also
> > add dependencies on HAS_IOPORT for the ISA and HAVE_EISA config options
> > as these busses always go along with HAS_IOPORT.
> > 
> > The "depends on" relations on HAS_IOPORT in drivers as well as ifdefs
> > for HAS_IOPORT specific sections will be added in subsequent patches on
> > a per subsystem basis.
> 
> I think it would be helpful to enumerate which architectures
> do not get HAS_IOPORT added, as they will be affected more.
> 
> > Co-developed-by: Arnd Bergmann <arnd@kernel.org>
> > Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> 
> If there are no objections, I could send this first patch for the
> asm-generic tree as a preparation for 6.3, so we are able to merge
> the other patches through subsystem maintainer tree for 6.4.
> 
> arch/loongarch/ will now also need to select HAS_IOPORT
> uncontitionally, this architecture was added after you
> sent v2.

Ah right. Added "select HAS_IOPORT" for LoongArch.

> 
> > diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
> > index a98940e64243..5eeacc72e4da 100644
> > --- a/arch/parisc/Kconfig
> > +++ b/arch/parisc/Kconfig
> > @@ -47,6 +47,7 @@ config PARISC
> >  	select MODULES_USE_ELF_RELA
> >  	select CLONE_BACKWARDS
> >  	select TTY # Needed for pdc_cons.c
> > +	select HAS_IOPORT if PCI
> 
> It's also needed for EISA and I think you should select it
> from CONFIG_GSC in drivers/parisc/Kconfig for this purpose.
> 
> This could also be 'select HAS_IOPORT if PCI || EISA', but
> that would require removing the 'depends on HAS_IOPORT'
> under drivers/eisa/.

I did use "select HAS_IOPORT if PCI || ISA || ATARI_ROM_ISA" in m68k so
I think ideally we would handle both in the same way. I don't have a
strong preference but I think the "select HAS_IOPORT if ..." puts it
all in a single place which is nice. Also I think this would make it
more similar architectures with unconditional HAS_IOPORT that thus
don't need "depends on HAS_IOPORT" in their "config ISA" either. As
also pointed by your comment below for x86. So will try to go this
route.

> 
> >  	select HAVE_DEBUG_STACKOVERFLOW
> >  	select HAVE_ARCH_AUDITSYSCALL
> >  	select HAVE_ARCH_HASH
> > @@ -131,6 +132,7 @@ config STACKTRACE_SUPPORT
> > 
> >  config ISA_DMA_API
> >  	bool
> > +	depends on HAS_IOPORT
> > 
> 
> This line is not really needed since there is no way to
> enable ISA_DMA_API.

Removed

> 
> > diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> > index a6c4407d3ec8..f7de646c074a 100644
> > --- a/arch/powerpc/Kconfig
> > +++ b/arch/powerpc/Kconfig
> > @@ -188,6 +188,7 @@ config PPC
> >  	select GENERIC_SMP_IDLE_THREAD
> >  	select GENERIC_TIME_VSYSCALL
> >  	select GENERIC_VDSO_TIME_NS
> > +	select HAS_IOPORT			if PCI
> >  	select HAVE_ARCH_AUDITSYSCALL
> >  	select HAVE_ARCH_HUGE_VMALLOC		if HAVE_ARCH_HUGE_VMAP
> >  	select HAVE_ARCH_HUGE_VMAP		if PPC_RADIX_MMU || PPC_8xx
> > @@ -1070,7 +1071,6 @@ menu "Bus options"
> > 
> >  config ISA
> >  	bool "Support for ISA-bus hardware"
> > -	depends on PPC_CHRP
> >  	select PPC_I8259
> >  	help
> >  	  Find out whether you have ISA slots on your motherboard.  ISA is the
> 
> This line looks wrong, I think we should keep that dependency.
> Did you get a circular dependency if you leave it in?

I don't recall why this was removed. I guess it happened when I was
experimenting with adding "depends on HAS_IOPORT" for the ISA config
options but that ultimately lead to circular dependencies, must have
messed up when removing this here.

> 
> > diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> > index a825bf031f49..634dd42532f3 100644
> > --- a/arch/x86/Kconfig
> > +++ b/arch/x86/Kconfig
> > @@ -162,6 +162,7 @@ config X86
> >  	select GUP_GET_PXX_LOW_HIGH		if X86_PAE
> >  	select HARDIRQS_SW_RESEND
> >  	select HARDLOCKUP_CHECK_TIMESTAMP	if X86_64
> > +	select HAS_IOPORT
> >  	select HAVE_ACPI_APEI			if ACPI
> >  	select HAVE_ACPI_APEI_NMI		if ACPI
> >  	select HAVE_ALIGNED_STRUCT_PAGE		if SLUB
> > @@ -2893,6 +2894,7 @@ if X86_32
> > 
> >  config ISA
> >  	bool "ISA support"
> > +	depends on HAS_IOPORT
> >  	help
> 
> HAS_IOPORT is selected unconditionally already, so this doesn't
> really do anything.

Removed.

> 
> > diff --git a/lib/Kconfig.kgdb b/lib/Kconfig.kgdb
> > index 3b9a44008433..c68e4d9dcecb 100644
> > --- a/lib/Kconfig.kgdb
> > +++ b/lib/Kconfig.kgdb
> > @@ -121,7 +121,8 @@ config KDB_DEFAULT_ENABLE
> > 
> >  config KDB_KEYBOARD
> >  	bool "KGDB_KDB: keyboard as input device"
> > -	depends on VT && KGDB_KDB && !PARISC
> > +	depends on HAS_IOPORT
> > +	depends on VT && KGDB_KDB
> >  	default n
> 
> This loses the !PARISC dependency, which I don't think is
> intentional. The added HAS_IOPORT dependency makes sense
> here, but I think this should be in a different patch
> and not in the preparation.
> 
>     Arnd

Agree will put into its own patch and re-add the !PARISC
Niklas Schnelle March 23, 2023, 1:23 p.m. UTC | #6
On Tue, 2023-03-14 at 13:37 +0100, Johannes Berg wrote:
> On Tue, 2023-03-14 at 13:11 +0100, Niklas Schnelle wrote:
> > --- a/arch/um/Kconfig
> > +++ b/arch/um/Kconfig
> > @@ -56,6 +56,7 @@ config NO_IOPORT_MAP
> >  
> >  config ISA
> >  	bool
> > +	depends on HAS_IOPORT
> > 
> 
> config ISA here is already unselectable, and nothing ever does "select
> ISA" (only in some other architectures), so is there much point in this?
> 
> I'm not even sure why this exists at all.

You're right there's not much point and I dropped this for v4. I agree
that probably the whole "config ISA" could be removed if it's always
false anyway but that seems out of scope for this patch.

> 
> But anyway, adding a dependency to a always-false symbol doesn't make it
> less always-false :-)
> 
> Acked-by: Johannes Berg <johannes@sipsolutions.net> # for ARCH=um

Thanks

> 
> 
> Certainly will be nice to get rid of this cruft for architectures that
> don't have it.
> 
> johannes

Yes, also, for s390 the broken NULL + port number access in the generic
inb()/outb() currently causes the only remaining clang warning on
defconfig builds.