All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Arnd Bergmann <arnd@arndb.de>,
	Richard Cochran <richardcochran@gmail.com>
Cc: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
	"Bjorn Helgaas" <bhelgaas@google.com>,
	"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
	"Mauro Carvalho Chehab" <mchehab@kernel.org>,
	"Alan Stern" <stern@rowland.harvard.edu>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Geert Uytterhoeven" <geert@linux-m68k.org>,
	"Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	linux-pci@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH v4 00/41] treewide: Remove I/O port accessors for HAS_IOPORT=n
Date: Tue, 16 May 2023 12:59:56 +0200	[thread overview]
Message-ID: <20230516110038.2413224-1-schnelle@linux.ibm.com> (raw)

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 does exactly that by utilizing the HAS_IOPORT Kconfig option
introduced in v6.4-rc1 via the spun out first patch[1] of a previous version. With
the final patch of this series HAS_IOPORT=n means that inb()/outb() and friends
are not 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"). With the HAS_IOPORT Kconfig option merged already
per-subsystem patches can now also be merged independently and only the last
patch needs to wait.

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

This version is based on v6.4-rc2 and is also available on my kernel.org tree
in the has_ioport_v4:

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

Thanks,
Niklas Schnelle

Changes from v3:
- Rebased on v6.4-rc2 which includes the Kconfig HAS_IOPORT option
- Fixed some wrong #ifdef HAS_IOPORT to #ifdef CONFIG_HAS_IOPORT
- Split the usb subsystem patch into 3 parts (Arnd)
- Removed unneeded HAS_IOPORT dependency for SERIO_PARKBD (Geert Uytterhoeven)
- Removed no-op I/O access from FB_ATY (Ville Syrjälä)
- Simplified HAS_IOPORT dependencies for the sound subsystem (Takashi Iwai)
- Slightly reworded the subject line of the last patch which removes
  the I/O port accessor functions.

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/20230323163354.1454196-1-schnelle@linux.ibm.com/
[2] https://lore.kernel.org/lkml/CAK8P3a0MNbx-iuzW_-=0ab6-TTZzwV-PT_6gAC1Gp5PgYyHcrA@mail.gmail.com/
[3] https://yhbt.net/lore/all/20211227164317.4146918-1-schnelle@linux.ibm.com/
[4] https://lore.kernel.org/all/20220429135108.2781579-1-schnelle@linux.ibm.com/
[5] https://lore.kernel.org/lkml/20230314121216.413434-1-schnelle@linux.ibm.com/

Niklas Schnelle (41):
  kgdb: add HAS_IOPORT dependency
  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: add HAS_IOPORT dependencies
  usb: uhci: handle HAS_IOPORT dependencies
  usb: pci-quirks: handle HAS_IOPORT dependencies
  fbdev: atyfb: Remove unused clock determination
  video: handle HAS_IOPORT dependencies
  watchdog: add HAS_IOPORT dependencies
  wireless: add HAS_IOPORT dependencies
  asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n

 drivers/accessibility/speakup/Kconfig        |   1 +
 drivers/ata/Kconfig                          |  28 ++---
 drivers/ata/ata_generic.c                    |   2 +
 drivers/ata/libata-sff.c                     |   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/tpm/Kconfig                     |   1 +
 drivers/char/tpm/tpm_infineon.c              |  16 ++-
 drivers/char/tpm/tpm_tis_core.c              |  19 ++-
 drivers/comedi/Kconfig                       | 103 +++++++++------
 drivers/counter/Kconfig                      |   1 +
 drivers/firmware/dmi-sysfs.c                 |   4 +
 drivers/gpio/Kconfig                         |  26 ++--
 drivers/gpu/drm/qxl/Kconfig                  |   1 +
 drivers/gpu/drm/tiny/bochs.c                 |  17 +++
 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                  |   1 +
 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/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                      |   3 +-
 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                          |   4 +-
 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/Kconfig                          |  10 ++
 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                |  30 +++--
 drivers/usb/host/uhci-hcd.c                  |   2 +-
 drivers/usb/host/uhci-hcd.h                  |  36 ++++--
 drivers/video/console/Kconfig                |   1 +
 drivers/video/fbdev/Kconfig                  |  21 ++--
 drivers/video/fbdev/aty/atyfb_base.c         |   5 -
 drivers/watchdog/Kconfig                     |   6 +-
 include/asm-generic/io.h                     |  60 +++++++++
 include/linux/gameport.h                     |   9 +-
 include/linux/libata.h                       |   2 +
 include/linux/parport.h                      |   2 +-
 include/video/vga.h                          |   8 ++
 lib/Kconfig.kgdb                             |   1 +
 net/ax25/Kconfig                             |   2 +-
 sound/drivers/Kconfig                        |   3 +
 sound/isa/Kconfig                            |   1 +
 sound/pci/Kconfig                            |  45 +++++--
 sound/pcmcia/Kconfig                         |   1 +
 100 files changed, 631 insertions(+), 298 deletions(-)


base-commit: f1fcbaa18b28dec10281551dfe6ed3a3ed80e3d6
-- 
2.39.2


             reply	other threads:[~2023-05-16 11:01 UTC|newest]

Thread overview: 101+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 10:59 Niklas Schnelle [this message]
2023-05-16 10:59 ` [PATCH v4 01/41] kgdb: add HAS_IOPORT dependency Niklas Schnelle
2023-05-16 10:59 ` [PATCH v4 02/41] ata: add HAS_IOPORT dependencies Niklas Schnelle
2023-05-16 13:18   ` Damien Le Moal
2023-05-16 13:23     ` Damien Le Moal
2023-05-19 12:46       ` Niklas Schnelle
2023-05-30 20:51   ` Sergey Shtylyov
2023-05-16 10:59 ` [PATCH v4 03/41] char: impi, tpm: depend on HAS_IOPORT Niklas Schnelle
2023-05-16 11:06   ` Paul Menzel
2023-05-16 11:39     ` Niklas Schnelle
2023-05-16 11:46   ` Greg Kroah-Hartman
2023-05-16 12:35     ` Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 04/41] comedi: add HAS_IOPORT dependencies Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 05/41] counter: " Niklas Schnelle
2023-05-19  1:26   ` William Breathitt Gray
2023-05-19 13:17     ` Niklas Schnelle
2023-05-19 13:38       ` Niklas Schnelle
2023-05-19 13:39         ` Niklas Schnelle
2023-05-19 14:21           ` William Breathitt Gray
2023-05-22 10:42             ` Niklas Schnelle
2023-05-22 11:15               ` William Breathitt Gray
2023-05-16 11:00 ` [PATCH v4 06/41] /dev/port: don't compile file operations without CONFIG_DEVPORT Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 07/41] drm: handle HAS_IOPORT dependencies Niklas Schnelle
2023-05-16 11:00   ` Niklas Schnelle
2023-05-16 17:13   ` Thomas Zimmermann
2023-05-16 17:13     ` Thomas Zimmermann
2023-05-16 17:13     ` Thomas Zimmermann
2023-05-16 17:47     ` Arnd Bergmann
2023-05-16 17:47       ` Arnd Bergmann
2023-05-16 17:47       ` Arnd Bergmann
2023-05-16 11:00 ` [PATCH v4 08/41] firmware: dmi-sysfs: handle HAS_IOPORT=n Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 09/41] gpio: add HAS_IOPORT dependencies Niklas Schnelle
2023-05-16 12:57   ` Linus Walleij
2023-05-17 14:15   ` Bartosz Golaszewski
2023-05-16 11:00 ` [PATCH v4 10/41] hwmon: " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 11/41] i2c: " Niklas Schnelle
2023-06-05 10:12   ` Wolfram Sang
2023-06-05 12:01     ` Niklas Schnelle
2023-06-05 20:05       ` Wolfram Sang
2023-06-05 12:01     ` Uwe Kleine-König
2023-06-05 12:55       ` Wolfram Sang
2023-05-16 11:00 ` [PATCH v4 12/41] iio: ad7606: Kconfig: " Niklas Schnelle
2023-05-20 15:40   ` Jonathan Cameron
2023-05-16 11:00 ` [PATCH v4 13/41] Input: " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 14/41] Input: gameport: add ISA and " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 15/41] leds: add " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 16/41] media: " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 17/41] misc: " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 18/41] mISDN: " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 19/41] mpt fusion: " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 20/41] net: handle " Niklas Schnelle
2023-05-16 11:00   ` [Intel-wired-lan] " Niklas Schnelle
2023-05-16 15:48   ` Maciej W. Rozycki
2023-05-16 15:48     ` Maciej W. Rozycki
2023-05-16 11:00 ` [PATCH v4 21/41] parport: PC style parport depends on HAS_IOPORT Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 22/41] PCI: Make quirk using inw() depend " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 23/41] PCI/sysfs: Make I/O resource " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 24/41] pcmcia: add HAS_IOPORT dependencies Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 25/41] platform: " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 26/41] pnp: " Niklas Schnelle
2023-05-16 11:55   ` Rafael J. Wysocki
2023-05-16 11:00 ` [PATCH v4 27/41] power: " Niklas Schnelle
2023-05-16 20:03   ` Sebastian Reichel
2023-05-16 11:00 ` [PATCH v4 28/41] rtc: " Niklas Schnelle
2023-05-16 15:49   ` Maciej W. Rozycki
2023-05-17  8:15     ` Niklas Schnelle
2023-05-17  9:53       ` Maciej W. Rozycki
2023-05-16 11:00 ` [PATCH v4 29/41] scsi: " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 30/41] sound: " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 31/41] speakup: add HAS_IOPORT dependency for SPEAKUP_SERIALIO Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 32/41] staging: add HAS_IOPORT dependencies Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 33/41] tty: serial: handle " Niklas Schnelle
2023-05-30 10:48   ` Greg Kroah-Hartman
2023-05-30 11:53     ` Arnd Bergmann
2023-05-30 14:31       ` Greg Kroah-Hartman
2023-05-16 11:00 ` [PATCH v4 34/41] usb: add " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 35/41] usb: uhci: handle " Niklas Schnelle
2023-05-16 16:29   ` Greg Kroah-Hartman
2023-05-16 16:44     ` Arnd Bergmann
2023-05-16 19:51       ` Alan Stern
2023-05-17  8:29         ` Niklas Schnelle
2023-05-16 20:17     ` Alan Stern
2023-05-17 12:17       ` Arnd Bergmann
2023-05-19 11:31         ` Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 36/41] usb: pci-quirks: " Niklas Schnelle
2023-05-30 11:00   ` Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 37/41] fbdev: atyfb: Remove unused clock determination Niklas Schnelle
2023-05-16 11:00   ` Niklas Schnelle
2023-05-16 12:24   ` Ville Syrjälä
2023-05-16 12:24     ` Ville Syrjälä
2023-05-19 14:49     ` Helge Deller
2023-05-19 14:49       ` Helge Deller
2023-05-16 11:00 ` [PATCH v4 38/41] video: handle HAS_IOPORT dependencies Niklas Schnelle
2023-05-16 11:00   ` Niklas Schnelle
2023-05-16 17:21   ` Thomas Zimmermann
2023-05-16 17:21     ` Thomas Zimmermann
2023-05-17 12:41     ` Niklas Schnelle
2023-05-17 12:41       ` Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 39/41] watchdog: add " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 40/41] wireless: " Niklas Schnelle
2023-05-16 11:00 ` [PATCH v4 41/41] asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230516110038.2413224-1-schnelle@linux.ibm.com \
    --to=schnelle@linux.ibm.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=bhelgaas@google.com \
    --cc=geert@linux-m68k.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=rafael@kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=stern@rowland.harvard.edu \
    --cc=u.kleine-koenig@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.