* [PATCH v8 0/5] treewide: Remove I/O port accessors for HAS_IOPORT=n
@ 2024-10-08 12:39 Niklas Schnelle
2024-10-08 12:39 ` [PATCH v8 1/5] hexagon: Don't select GENERIC_IOMAP without HAS_IOPORT support Niklas Schnelle
` (4 more replies)
0 siblings, 5 replies; 15+ messages in thread
From: Niklas Schnelle @ 2024-10-08 12:39 UTC (permalink / raw)
To: Brian Cain, Marcel Holtmann, Luiz Augusto von Dentz,
Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann,
Maciej W. Rozycki, Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, linux-arch,
Niklas Schnelle, Arnd Bergmann
Hi All,
This is a follow up in my long running effort of making inb()/outb() and
similar I/O port accessors compile-time optional. After initially
sending this as a treewide series with the latest revision at[0]
we switched to per subsystem series. Now though as we're left with only
5 patches left I'm going back to a single series with Arnd planning
to take this via the the asm-generic tree.
This series may also be viewed for your convenience on my git.kernel.org
tree[1] under the b4/has_ioport branch. As for compile-time vs runtime
see Linus' reply to my first attempt[2].
Thanks,
Niklas
[0] https://lore.kernel.org/all/20230522105049.1467313-1-schnelle@linux.ibm.com/
[1] https://git.kernel.org/pub/scm/linux/kernel/git/niks/linux.git
[2] https://lore.kernel.org/lkml/CAHk-=wg80je=K7madF4e7WrRNp37e3qh6y10Svhdc7O8SZ_-8g@mail.gmail.com/
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
Changes in v8:
- Don't remove "depends on !S390" for SERIAL_8250
- Link to v7: https://lore.kernel.org/r/20241008-b4-has_ioport-v7-0-8624c09a4d77@linux.ibm.com
Changes in v7:
- Renamed serial_8250_need_ioport() helper to
serial_8250_warn_need_ioport() and move it to 8250_pcilib.c so it can
be used in serial8250_pci_setup_port()
- Flattened if in serial8250_pci_setup_port() (Maciej)
- Removed gratuituous changes (Maciej)
- Removed is_upf_fourport() helper in favor of zeroing UPF_FOURPORT
if CONFIG_HAS_IOPORT is not set (Maciej)
- Link to v6: https://lore.kernel.org/r/20241007-b4-has_ioport-v6-0-03f7240da6e5@linux.ibm.com
Changes since v5 / per subsystem patches:
drm:
- Add HAS_IOPORT dependency for GMA500
tty: serial:
- Make 8250 PCI driver emit an error message when trying to use devices
which require I/O ports without CONFIG_HAS_IOPORT (Maciej)
- Use early returns + dead code elimination to skip inb()/outb() uses
in quirks (Arnd)
- In 8250 PCI driver also handle fintek and moxi quirks
- In 8250 ports code handle um's defined(__i385__) &&
defined(CONFIG_HAS_IOPORT) case
- Use IS_ENABLED() early return also in is_upf_fourport()
__always_inline to force constant folding
---
Niklas Schnelle (5):
hexagon: Don't select GENERIC_IOMAP without HAS_IOPORT support
Bluetooth: add HAS_IOPORT dependencies
drm: handle HAS_IOPORT dependencies
tty: serial: handle HAS_IOPORT dependencies
asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n
arch/hexagon/Kconfig | 1 -
drivers/bluetooth/Kconfig | 6 ++--
drivers/gpu/drm/gma500/Kconfig | 2 +-
drivers/gpu/drm/qxl/Kconfig | 1 +
drivers/gpu/drm/tiny/bochs.c | 17 ++++++++++
drivers/gpu/drm/tiny/cirrus.c | 2 ++
drivers/gpu/drm/xe/Kconfig | 2 +-
drivers/tty/Kconfig | 4 +--
drivers/tty/serial/8250/8250_early.c | 4 +++
drivers/tty/serial/8250/8250_pci.c | 40 +++++++++++++++++++++++
drivers/tty/serial/8250/8250_pcilib.c | 12 ++++++-
drivers/tty/serial/8250/8250_pcilib.h | 2 ++
drivers/tty/serial/8250/8250_port.c | 27 +++++++++++++---
drivers/tty/serial/8250/Kconfig | 4 +--
drivers/tty/serial/Kconfig | 2 +-
include/asm-generic/io.h | 60 +++++++++++++++++++++++++++++++++++
include/linux/serial_core.h | 4 +++
17 files changed, 174 insertions(+), 16 deletions(-)
---
base-commit: 8cf0b93919e13d1e8d4466eb4080a4c4d9d66d7b
change-id: 20241004-b4-has_ioport-60ac6ce1deb6
Best regards,
--
Niklas Schnelle
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v8 1/5] hexagon: Don't select GENERIC_IOMAP without HAS_IOPORT support
2024-10-08 12:39 [PATCH v8 0/5] treewide: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle
@ 2024-10-08 12:39 ` Niklas Schnelle
2024-10-08 12:39 ` [PATCH v8 2/5] Bluetooth: add HAS_IOPORT dependencies Niklas Schnelle
` (3 subsequent siblings)
4 siblings, 0 replies; 15+ messages in thread
From: Niklas Schnelle @ 2024-10-08 12:39 UTC (permalink / raw)
To: Brian Cain, Marcel Holtmann, Luiz Augusto von Dentz,
Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann,
Maciej W. Rozycki, Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, linux-arch,
Niklas Schnelle, Arnd Bergmann
In a future patch HAS_IOPORT=n will disable inb()/outb() and friends at
compile time. As hexagon does not support I/O port access it also
the GENERIC_IOMAP mechanism of dynamically choosing between I/O port and
MMIO access doesn't work so don't select it.
Reviewed-by: Brian Cain <bcain@quicinc.com>
Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
arch/hexagon/Kconfig | 1 -
1 file changed, 1 deletion(-)
diff --git a/arch/hexagon/Kconfig b/arch/hexagon/Kconfig
index e233b5efa2761e35c416cbc147f6b6422a7c5b8f..5ea1bf4b7d4f5471a9c39ee9fb5c701455d21342 100644
--- a/arch/hexagon/Kconfig
+++ b/arch/hexagon/Kconfig
@@ -31,7 +31,6 @@ config HEXAGON
select HAVE_ARCH_TRACEHOOK
select NEED_SG_DMA_LENGTH
select NO_IOPORT_MAP
- select GENERIC_IOMAP
select GENERIC_IOREMAP
select GENERIC_SMP_IDLE_THREAD
select STACKTRACE_SUPPORT
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v8 2/5] Bluetooth: add HAS_IOPORT dependencies
2024-10-08 12:39 [PATCH v8 0/5] treewide: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle
2024-10-08 12:39 ` [PATCH v8 1/5] hexagon: Don't select GENERIC_IOMAP without HAS_IOPORT support Niklas Schnelle
@ 2024-10-08 12:39 ` Niklas Schnelle
2024-10-08 12:39 ` [PATCH v8 3/5] drm: handle " Niklas Schnelle
` (2 subsequent siblings)
4 siblings, 0 replies; 15+ messages in thread
From: Niklas Schnelle @ 2024-10-08 12:39 UTC (permalink / raw)
To: Brian Cain, Marcel Holtmann, Luiz Augusto von Dentz,
Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann,
Maciej W. Rozycki, Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, linux-arch,
Niklas Schnelle, Arnd Bergmann
In a future patch HAS_IOPORT=n will disable inb()/outb() and friends at
compile time. We thus need to add HAS_IOPORT as dependency for those
drivers using them.
Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
drivers/bluetooth/Kconfig | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/bluetooth/Kconfig b/drivers/bluetooth/Kconfig
index 18767b54df352e929692850dc789d9377839e094..4ab32abf0f48644715d4c27ec0d2fdaccef62b76 100644
--- a/drivers/bluetooth/Kconfig
+++ b/drivers/bluetooth/Kconfig
@@ -336,7 +336,7 @@ config BT_HCIBFUSB
config BT_HCIDTL1
tristate "HCI DTL1 (PC Card) driver"
- depends on PCMCIA
+ depends on PCMCIA && HAS_IOPORT
help
Bluetooth HCI DTL1 (PC Card) driver.
This driver provides support for Bluetooth PCMCIA devices with
@@ -349,7 +349,7 @@ config BT_HCIDTL1
config BT_HCIBT3C
tristate "HCI BT3C (PC Card) driver"
- depends on PCMCIA
+ depends on PCMCIA && HAS_IOPORT
select FW_LOADER
help
Bluetooth HCI BT3C (PC Card) driver.
@@ -363,7 +363,7 @@ config BT_HCIBT3C
config BT_HCIBLUECARD
tristate "HCI BlueCard (PC Card) driver"
- depends on PCMCIA
+ depends on PCMCIA && HAS_IOPORT
help
Bluetooth HCI BlueCard (PC Card) driver.
This driver provides support for Bluetooth PCMCIA devices with
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v8 3/5] drm: handle HAS_IOPORT dependencies
2024-10-08 12:39 [PATCH v8 0/5] treewide: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle
2024-10-08 12:39 ` [PATCH v8 1/5] hexagon: Don't select GENERIC_IOMAP without HAS_IOPORT support Niklas Schnelle
2024-10-08 12:39 ` [PATCH v8 2/5] Bluetooth: add HAS_IOPORT dependencies Niklas Schnelle
@ 2024-10-08 12:39 ` Niklas Schnelle
2024-10-21 7:52 ` Thomas Zimmermann
2024-10-08 12:39 ` [PATCH v8 4/5] tty: serial: " Niklas Schnelle
2024-10-08 12:39 ` [PATCH v8 5/5] asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle
4 siblings, 1 reply; 15+ messages in thread
From: Niklas Schnelle @ 2024-10-08 12:39 UTC (permalink / raw)
To: Brian Cain, Marcel Holtmann, Luiz Augusto von Dentz,
Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann,
Maciej W. Rozycki, Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, linux-arch,
Niklas Schnelle, Arnd Bergmann
In a future patch HAS_IOPORT=n will disable inb()/outb() and friends at
compile time. We thus need to add HAS_IOPORT as dependency for those
drivers using them. In the bochs driver there is optional MMIO support
detected at runtime, warn if this isn't taken when HAS_IOPORT is not
defined.
There is also a direct and hard coded use in cirrus.c which according to
the comment is only necessary during resume. Let's just skip this as
for example s390 which doesn't have I/O port support also doesen't
support suspend/resume.
Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
drivers/gpu/drm/gma500/Kconfig | 2 +-
drivers/gpu/drm/qxl/Kconfig | 1 +
drivers/gpu/drm/tiny/bochs.c | 17 +++++++++++++++++
drivers/gpu/drm/tiny/cirrus.c | 2 ++
drivers/gpu/drm/xe/Kconfig | 2 +-
5 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/gma500/Kconfig b/drivers/gpu/drm/gma500/Kconfig
index efb4a2dd2f80885cb59c925d09401002278d7d61..23b7c14de5e29238ece939d5822d8a9ffc4675cc 100644
--- a/drivers/gpu/drm/gma500/Kconfig
+++ b/drivers/gpu/drm/gma500/Kconfig
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0-only
config DRM_GMA500
tristate "Intel GMA500/600/3600/3650 KMS Framebuffer"
- depends on DRM && PCI && X86 && MMU
+ depends on DRM && PCI && X86 && MMU && HAS_IOPORT
select DRM_KMS_HELPER
select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
select I2C
diff --git a/drivers/gpu/drm/qxl/Kconfig b/drivers/gpu/drm/qxl/Kconfig
index ca3f51c2a8fe1a383f8a2479f04b5c0b3fb14e44..d0e0d440c8d96564cb7b8ffd2385c44fc43f873d 100644
--- a/drivers/gpu/drm/qxl/Kconfig
+++ b/drivers/gpu/drm/qxl/Kconfig
@@ -2,6 +2,7 @@
config DRM_QXL
tristate "QXL virtual GPU"
depends on DRM && PCI && MMU
+ depends on HAS_IOPORT
select DRM_KMS_HELPER
select DRM_TTM
select DRM_TTM_HELPER
diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
index 31fc5d839e106ea4d5c8fe42d1bfc3c70291e3fb..0ed78d3d5774778f91de972ac27056938036e722 100644
--- a/drivers/gpu/drm/tiny/bochs.c
+++ b/drivers/gpu/drm/tiny/bochs.c
@@ -2,6 +2,7 @@
#include <linux/module.h>
#include <linux/pci.h>
+#include <linux/bug.h>
#include <drm/drm_aperture.h>
#include <drm/drm_atomic_helper.h>
@@ -105,7 +106,9 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
writeb(val, bochs->mmio + offset);
} else {
+#ifdef CONFIG_HAS_IOPORT
outb(val, ioport);
+#endif
}
}
@@ -119,7 +122,11 @@ static u8 bochs_vga_readb(struct bochs_device *bochs, u16 ioport)
return readb(bochs->mmio + offset);
} else {
+#ifdef CONFIG_HAS_IOPORT
return inb(ioport);
+#else
+ return 0xff;
+#endif
}
}
@@ -132,8 +139,12 @@ static u16 bochs_dispi_read(struct bochs_device *bochs, u16 reg)
ret = readw(bochs->mmio + offset);
} else {
+#ifdef CONFIG_HAS_IOPORT
outw(reg, VBE_DISPI_IOPORT_INDEX);
ret = inw(VBE_DISPI_IOPORT_DATA);
+#else
+ ret = 0xffff;
+#endif
}
return ret;
}
@@ -145,8 +156,10 @@ static void bochs_dispi_write(struct bochs_device *bochs, u16 reg, u16 val)
writew(val, bochs->mmio + offset);
} else {
+#ifdef CONFIG_HAS_IOPORT
outw(reg, VBE_DISPI_IOPORT_INDEX);
outw(val, VBE_DISPI_IOPORT_DATA);
+#endif
}
}
@@ -229,6 +242,10 @@ static int bochs_hw_init(struct drm_device *dev)
return -ENOMEM;
}
} else {
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT)) {
+ DRM_ERROR("I/O ports are not supported\n");
+ return -EIO;
+ }
ioaddr = VBE_DISPI_IOPORT_INDEX;
iosize = 2;
if (!request_region(ioaddr, iosize, "bochs-drm")) {
diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
index 751326e3d9c374baf72115492aeefff2b73869f0..e31e1df029ab0272c4a1ff0ab3eb026ca679b560 100644
--- a/drivers/gpu/drm/tiny/cirrus.c
+++ b/drivers/gpu/drm/tiny/cirrus.c
@@ -509,8 +509,10 @@ static void cirrus_crtc_helper_atomic_enable(struct drm_crtc *crtc,
cirrus_mode_set(cirrus, &crtc_state->mode);
+#ifdef CONFIG_HAS_IOPORT
/* Unblank (needed on S3 resume, vgabios doesn't do it then) */
outb(VGA_AR_ENABLE_DISPLAY, VGA_ATT_W);
+#endif
drm_dev_exit(idx);
}
diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig
index 7bbe46a98ff1f449bc2af30686585a00e9e8af93..116f58774135fc3a9f37d6d72d41340f5c812297 100644
--- a/drivers/gpu/drm/xe/Kconfig
+++ b/drivers/gpu/drm/xe/Kconfig
@@ -49,7 +49,7 @@ config DRM_XE
config DRM_XE_DISPLAY
bool "Enable display support"
- depends on DRM_XE && DRM_XE=m
+ depends on DRM_XE && DRM_XE=m && HAS_IOPORT
select FB_IOMEM_HELPERS
select I2C
select I2C_ALGOBIT
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v8 4/5] tty: serial: handle HAS_IOPORT dependencies
2024-10-08 12:39 [PATCH v8 0/5] treewide: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle
` (2 preceding siblings ...)
2024-10-08 12:39 ` [PATCH v8 3/5] drm: handle " Niklas Schnelle
@ 2024-10-08 12:39 ` Niklas Schnelle
2024-10-11 6:09 ` Greg Kroah-Hartman
2024-10-13 14:53 ` Maciej W. Rozycki
2024-10-08 12:39 ` [PATCH v8 5/5] asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle
4 siblings, 2 replies; 15+ messages in thread
From: Niklas Schnelle @ 2024-10-08 12:39 UTC (permalink / raw)
To: Brian Cain, Marcel Holtmann, Luiz Augusto von Dentz,
Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann,
Maciej W. Rozycki, Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, linux-arch,
Niklas Schnelle, Arnd Bergmann
In a future patch HAS_IOPORT=n will disable inb()/outb() and friends at
compile time. We thus need to add HAS_IOPORT as dependency for those
drivers using them unconditionally. Some 8250 serial drivers support
MMIO only use, so fence only the parts requiring I/O ports and print an
error message if a device can't be supported with the current
configuration.
Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
drivers/tty/Kconfig | 4 ++--
drivers/tty/serial/8250/8250_early.c | 4 ++++
drivers/tty/serial/8250/8250_pci.c | 40 +++++++++++++++++++++++++++++++++++
drivers/tty/serial/8250/8250_pcilib.c | 12 ++++++++++-
drivers/tty/serial/8250/8250_pcilib.h | 2 ++
drivers/tty/serial/8250/8250_port.c | 27 +++++++++++++++++++----
drivers/tty/serial/8250/Kconfig | 4 ++--
drivers/tty/serial/Kconfig | 2 +-
include/linux/serial_core.h | 4 ++++
9 files changed, 89 insertions(+), 10 deletions(-)
diff --git a/drivers/tty/Kconfig b/drivers/tty/Kconfig
index a45d423ad10f02c3a818021bbb18655a8b690500..63a494d36a1fdceba5a7b39f4516060e48af0cc6 100644
--- a/drivers/tty/Kconfig
+++ b/drivers/tty/Kconfig
@@ -220,7 +220,7 @@ config MOXA_INTELLIO
config MOXA_SMARTIO
tristate "Moxa SmartIO support v. 2.0"
- depends on SERIAL_NONSTANDARD && PCI
+ depends on SERIAL_NONSTANDARD && PCI && HAS_IOPORT
help
Say Y here if you have a Moxa SmartIO multiport serial card and/or
want to help develop a new version of this driver.
@@ -302,7 +302,7 @@ config GOLDFISH_TTY_EARLY_CONSOLE
config IPWIRELESS
tristate "IPWireless 3G UMTS PCMCIA card support"
- depends on PCMCIA && NETDEVICES
+ depends on PCMCIA && NETDEVICES && HAS_IOPORT
select PPP
help
This is a driver for 3G UMTS PCMCIA card from IPWireless company. In
diff --git a/drivers/tty/serial/8250/8250_early.c b/drivers/tty/serial/8250/8250_early.c
index 6176083d0341ca10edebe5c4eebfffc922a61472..84242292176570cd2c92afbd4755d303827a4abc 100644
--- a/drivers/tty/serial/8250/8250_early.c
+++ b/drivers/tty/serial/8250/8250_early.c
@@ -46,8 +46,10 @@ static unsigned int serial8250_early_in(struct uart_port *port, int offset)
return readl(port->membase + offset);
case UPIO_MEM32BE:
return ioread32be(port->membase + offset);
+#ifdef CONFIG_HAS_IOPORT
case UPIO_PORT:
return inb(port->iobase + offset);
+#endif
default:
return 0;
}
@@ -70,9 +72,11 @@ static void serial8250_early_out(struct uart_port *port, int offset, int value)
case UPIO_MEM32BE:
iowrite32be(value, port->membase + offset);
break;
+#ifdef CONFIG_HAS_IOPORT
case UPIO_PORT:
outb(value, port->iobase + offset);
break;
+#endif
}
}
diff --git a/drivers/tty/serial/8250/8250_pci.c b/drivers/tty/serial/8250/8250_pci.c
index 6709b6a5f3011db38acc58dc7223158fe4fcf72e..7d7a6d62c09ceabcf4094d539c565ed09c153561 100644
--- a/drivers/tty/serial/8250/8250_pci.c
+++ b/drivers/tty/serial/8250/8250_pci.c
@@ -964,6 +964,9 @@ static int pci_ite887x_init(struct pci_dev *dev)
struct resource *iobase = NULL;
u32 miscr, uartbar, ioport;
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(dev);
+
/* search for the base-ioport */
for (i = 0; i < ARRAY_SIZE(inta_addr); i++) {
iobase = request_region(inta_addr[i], ITE_887x_IOSIZE,
@@ -1514,6 +1517,9 @@ static int pci_quatech_init(struct pci_dev *dev)
const struct pci_device_id *match;
bool amcc = false;
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(dev);
+
match = pci_match_id(quatech_cards, dev);
if (match)
amcc = match->driver_data;
@@ -1538,6 +1544,9 @@ static int pci_quatech_setup(struct serial_private *priv,
const struct pciserial_board *board,
struct uart_8250_port *port, int idx)
{
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(priv->dev);
+
/* Needed by pci_quatech calls below */
port->port.iobase = pci_resource_start(priv->dev, FL_GET_BASE(board->flags));
/* Set up the clocking */
@@ -1655,6 +1664,9 @@ static int pci_fintek_setup(struct serial_private *priv,
u8 config_base;
u16 iobase;
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(pdev);
+
config_base = 0x40 + 0x08 * idx;
/* Get the io address from configuration space */
@@ -1686,6 +1698,9 @@ static int pci_fintek_init(struct pci_dev *dev)
u8 config_base;
struct serial_private *priv = pci_get_drvdata(dev);
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(dev);
+
if (!(pci_resource_flags(dev, 5) & IORESOURCE_IO) ||
!(pci_resource_flags(dev, 4) & IORESOURCE_IO) ||
!(pci_resource_flags(dev, 3) & IORESOURCE_IO))
@@ -1864,6 +1879,9 @@ static int kt_serial_setup(struct serial_private *priv,
const struct pciserial_board *board,
struct uart_8250_port *port, int idx)
{
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(priv->dev);
+
port->port.flags |= UPF_BUG_THRE;
port->port.serial_in = kt_serial_in;
port->port.handle_break = kt_handle_break;
@@ -1884,6 +1902,9 @@ pci_wch_ch353_setup(struct serial_private *priv,
const struct pciserial_board *board,
struct uart_8250_port *port, int idx)
{
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(priv->dev);
+
port->port.flags |= UPF_FIXED_TYPE;
port->port.type = PORT_16550A;
return pci_default_setup(priv, board, port, idx);
@@ -1894,6 +1915,9 @@ pci_wch_ch355_setup(struct serial_private *priv,
const struct pciserial_board *board,
struct uart_8250_port *port, int idx)
{
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(priv->dev);
+
port->port.flags |= UPF_FIXED_TYPE;
port->port.type = PORT_16550A;
return pci_default_setup(priv, board, port, idx);
@@ -1904,6 +1928,9 @@ pci_wch_ch38x_setup(struct serial_private *priv,
const struct pciserial_board *board,
struct uart_8250_port *port, int idx)
{
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(priv->dev);
+
port->port.flags |= UPF_FIXED_TYPE;
port->port.type = PORT_16850;
return pci_default_setup(priv, board, port, idx);
@@ -1918,6 +1945,8 @@ static int pci_wch_ch38x_init(struct pci_dev *dev)
int max_port;
unsigned long iobase;
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(dev);
switch (dev->device) {
case 0x3853: /* 8 ports */
@@ -1937,6 +1966,11 @@ static void pci_wch_ch38x_exit(struct pci_dev *dev)
{
unsigned long iobase;
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT)) {
+ serial_8250_warn_need_ioport(dev);
+ return;
+ }
+
iobase = pci_resource_start(dev, 0);
outb(0x0, iobase + CH384_XINT_ENABLE_REG);
}
@@ -2052,6 +2086,9 @@ static int pci_moxa_init(struct pci_dev *dev)
unsigned int i, num_ports = moxa_get_nports(device);
u8 val, init_mode = MOXA_RS232;
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(dev);
+
if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232)) {
init_mode = MOXA_RS422;
}
@@ -2084,6 +2121,9 @@ pci_moxa_setup(struct serial_private *priv,
unsigned int bar = FL_GET_BASE(board->flags);
int offset;
+ if (!IS_ENABLED(CONFIG_HAS_IOPORT))
+ return serial_8250_warn_need_ioport(priv->dev);
+
if (board->num_ports == 4 && idx == 3)
offset = 7 * board->uart_offset;
else
diff --git a/drivers/tty/serial/8250/8250_pcilib.c b/drivers/tty/serial/8250/8250_pcilib.c
index ea906d721b2c3eac15c9e8d62cc6fa56c3ef6150..ec4d041778027a0c9f27facbb97c2b74819cfda3 100644
--- a/drivers/tty/serial/8250/8250_pcilib.c
+++ b/drivers/tty/serial/8250/8250_pcilib.c
@@ -12,6 +12,14 @@
#include "8250.h"
#include "8250_pcilib.h"
+int serial_8250_warn_need_ioport(struct pci_dev *dev)
+{
+ dev_warn(&dev->dev,
+ "Serial port not supported because of missing I/O resource\n");
+
+ return -ENXIO;
+}
+
int serial8250_pci_setup_port(struct pci_dev *dev, struct uart_8250_port *port,
u8 bar, unsigned int offset, int regshift)
{
@@ -27,12 +35,14 @@ int serial8250_pci_setup_port(struct pci_dev *dev, struct uart_8250_port *port,
port->port.mapbase = pci_resource_start(dev, bar) + offset;
port->port.membase = pcim_iomap_table(dev)[bar] + offset;
port->port.regshift = regshift;
- } else {
+ } else if (IS_ENABLED(CONFIG_HAS_IOPORT)) {
port->port.iotype = UPIO_PORT;
port->port.iobase = pci_resource_start(dev, bar) + offset;
port->port.mapbase = 0;
port->port.membase = NULL;
port->port.regshift = 0;
+ } else {
+ return serial_8250_warn_need_ioport(dev);
}
return 0;
}
diff --git a/drivers/tty/serial/8250/8250_pcilib.h b/drivers/tty/serial/8250/8250_pcilib.h
index 1aaf1b50ce9cc9d78c098e0495838c17eb8752cd..16a274574cdef938fe7700d30b19e75dbbd9b748 100644
--- a/drivers/tty/serial/8250/8250_pcilib.h
+++ b/drivers/tty/serial/8250/8250_pcilib.h
@@ -13,3 +13,5 @@ struct uart_8250_port;
int serial8250_pci_setup_port(struct pci_dev *dev, struct uart_8250_port *port, u8 bar,
unsigned int offset, int regshift);
+
+int serial_8250_warn_need_ioport(struct pci_dev *dev);
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 3509af7dc52b8816f2f5ab58f0d999696f7483e7..91369f542b0bc7fc1d044f24db9a4ac98b394660 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -338,6 +338,7 @@ static void default_serial_dl_write(struct uart_8250_port *up, u32 value)
serial_out(up, UART_DLM, value >> 8 & 0xff);
}
+#ifdef CONFIG_HAS_IOPORT
static unsigned int hub6_serial_in(struct uart_port *p, int offset)
{
offset = offset << p->regshift;
@@ -351,6 +352,7 @@ static void hub6_serial_out(struct uart_port *p, int offset, int value)
outb(p->hub6 - 1 + offset, p->iobase);
outb(value, p->iobase + 1);
}
+#endif /* CONFIG_HAS_IOPORT */
static unsigned int mem_serial_in(struct uart_port *p, int offset)
{
@@ -400,6 +402,7 @@ static unsigned int mem32be_serial_in(struct uart_port *p, int offset)
return ioread32be(p->membase + offset);
}
+#ifdef CONFIG_HAS_IOPORT
static unsigned int io_serial_in(struct uart_port *p, int offset)
{
offset = offset << p->regshift;
@@ -411,6 +414,15 @@ static void io_serial_out(struct uart_port *p, int offset, int value)
offset = offset << p->regshift;
outb(value, p->iobase + offset);
}
+#endif
+static unsigned int no_serial_in(struct uart_port *p, int offset)
+{
+ return (unsigned int)-1;
+}
+
+static void no_serial_out(struct uart_port *p, int offset, int value)
+{
+}
static int serial8250_default_handle_irq(struct uart_port *port);
@@ -422,10 +434,12 @@ static void set_io_from_upio(struct uart_port *p)
up->dl_write = default_serial_dl_write;
switch (p->iotype) {
+#ifdef CONFIG_HAS_IOPORT
case UPIO_HUB6:
p->serial_in = hub6_serial_in;
p->serial_out = hub6_serial_out;
break;
+#endif
case UPIO_MEM:
p->serial_in = mem_serial_in;
@@ -446,11 +460,16 @@ static void set_io_from_upio(struct uart_port *p)
p->serial_in = mem32be_serial_in;
p->serial_out = mem32be_serial_out;
break;
-
- default:
+#ifdef CONFIG_HAS_IOPORT
+ case UPIO_PORT:
p->serial_in = io_serial_in;
p->serial_out = io_serial_out;
break;
+#endif
+ default:
+ WARN(1, "Unsupported UART type %x\n", p->iotype);
+ p->serial_in = no_serial_in;
+ p->serial_out = no_serial_out;
}
/* Remember loaded iotype */
up->cur_iotype = p->iotype;
@@ -1174,7 +1193,7 @@ static void autoconfig(struct uart_8250_port *up)
*/
scratch = serial_in(up, UART_IER);
serial_out(up, UART_IER, 0);
-#ifdef __i386__
+#if defined(__i386__) && defined(CONFIG_HAS_IOPORT)
outb(0xff, 0x080);
#endif
/*
@@ -1183,7 +1202,7 @@ static void autoconfig(struct uart_8250_port *up)
*/
scratch2 = serial_in(up, UART_IER) & UART_IER_ALL_INTR;
serial_out(up, UART_IER, UART_IER_ALL_INTR);
-#ifdef __i386__
+#if defined(__i386__) && defined(CONFIG_HAS_IOPORT)
outb(0, 0x080);
#endif
scratch3 = serial_in(up, UART_IER) & UART_IER_ALL_INTR;
diff --git a/drivers/tty/serial/8250/Kconfig b/drivers/tty/serial/8250/Kconfig
index 47ff50763c048c89b19b7c9f13f462bc5368ab43..1eb20350fcf432d41cb416bed3be72ed8ab129bb 100644
--- a/drivers/tty/serial/8250/Kconfig
+++ b/drivers/tty/serial/8250/Kconfig
@@ -72,7 +72,7 @@ config SERIAL_8250_16550A_VARIANTS
config SERIAL_8250_FINTEK
bool "Support for Fintek variants"
- depends on SERIAL_8250
+ depends on SERIAL_8250 && HAS_IOPORT
help
Selecting this option will add support for the RS232 and RS485
capabilities of the Fintek F81216A LPC to 4 UART as well similar
@@ -163,7 +163,7 @@ config SERIAL_8250_HP300
config SERIAL_8250_CS
tristate "8250/16550 PCMCIA device support"
- depends on PCMCIA && SERIAL_8250
+ depends on PCMCIA && SERIAL_8250 && HAS_IOPORT
help
Say Y here to enable support for 16-bit PCMCIA serial devices,
including serial port cards, modems, and the modem functions of
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 28e4beeabf8f373fc76e09ea7d1c9d55a66f4964..45f0f779fbf960e9fa66375dbc44c379edc63bef 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -877,7 +877,7 @@ config SERIAL_TXX9_STDSERIAL
config SERIAL_JSM
tristate "Digi International NEO and Classic PCI Support"
- depends on PCI
+ depends on PCI && HAS_IOPORT
select SERIAL_CORE
help
This is a driver for Digi International's Neo and Classic series
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 4ab65874a850b4402ca3a7d3bdda597d7d5093f9..743b4afaad4c89a6028e592be2cae2643614c89b 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -505,7 +505,11 @@ struct uart_port {
* The remaining bits are serial-core specific and not modifiable by
* userspace.
*/
+#ifdef CONFIG_HAS_IOPORT
#define UPF_FOURPORT ((__force upf_t) ASYNC_FOURPORT /* 1 */ )
+#else
+#define UPF_FOURPORT 0
+#endif
#define UPF_SAK ((__force upf_t) ASYNC_SAK /* 2 */ )
#define UPF_SPD_HI ((__force upf_t) ASYNC_SPD_HI /* 4 */ )
#define UPF_SPD_VHI ((__force upf_t) ASYNC_SPD_VHI /* 5 */ )
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH v8 5/5] asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n
2024-10-08 12:39 [PATCH v8 0/5] treewide: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle
` (3 preceding siblings ...)
2024-10-08 12:39 ` [PATCH v8 4/5] tty: serial: " Niklas Schnelle
@ 2024-10-08 12:39 ` Niklas Schnelle
4 siblings, 0 replies; 15+ messages in thread
From: Niklas Schnelle @ 2024-10-08 12:39 UTC (permalink / raw)
To: Brian Cain, Marcel Holtmann, Luiz Augusto von Dentz,
Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann,
Maciej W. Rozycki, Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, linux-arch,
Niklas Schnelle, Arnd Bergmann
With all subsystems and drivers either declaring their dependence on
HAS_IOPORT or fencing I/O port specific code sections we can finally
make inb()/outb() and friends compile-time dependent on HAS_IOPORT as
suggested by Linus in the linked mail. The main benefit of this is that
on platforms such as s390 which have no meaningful way of implementing
inb()/outb() their use without the proper HAS_IOPORT dependency will
result in easy to catch and fix compile-time errors instead of compiling
code that can never work.
Link: https://lore.kernel.org/lkml/CAHk-=wg80je=K7madF4e7WrRNp37e3qh6y10Svhdc7O8SZ_-8g@mail.gmail.com/
Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
---
include/asm-generic/io.h | 60 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h
index 80de699bf6af4b7b77f582c0469c43e978f67a43..1027be6a62bcbcd5f6797e0fa42035208d0ca79f 100644
--- a/include/asm-generic/io.h
+++ b/include/asm-generic/io.h
@@ -540,6 +540,7 @@ static inline void writesq(volatile void __iomem *addr, const void *buffer,
#if !defined(inb) && !defined(_inb)
#define _inb _inb
+#ifdef CONFIG_HAS_IOPORT
static inline u8 _inb(unsigned long addr)
{
u8 val;
@@ -549,10 +550,15 @@ static inline u8 _inb(unsigned long addr)
__io_par(val);
return val;
}
+#else
+u8 _inb(unsigned long addr)
+ __compiletime_error("inb()) requires CONFIG_HAS_IOPORT");
+#endif
#endif
#if !defined(inw) && !defined(_inw)
#define _inw _inw
+#ifdef CONFIG_HAS_IOPORT
static inline u16 _inw(unsigned long addr)
{
u16 val;
@@ -562,10 +568,15 @@ static inline u16 _inw(unsigned long addr)
__io_par(val);
return val;
}
+#else
+u16 _inw(unsigned long addr)
+ __compiletime_error("inw() requires CONFIG_HAS_IOPORT");
+#endif
#endif
#if !defined(inl) && !defined(_inl)
#define _inl _inl
+#ifdef CONFIG_HAS_IOPORT
static inline u32 _inl(unsigned long addr)
{
u32 val;
@@ -575,36 +586,55 @@ static inline u32 _inl(unsigned long addr)
__io_par(val);
return val;
}
+#else
+u32 _inl(unsigned long addr)
+ __compiletime_error("inl() requires CONFIG_HAS_IOPORT");
+#endif
#endif
#if !defined(outb) && !defined(_outb)
#define _outb _outb
+#ifdef CONFIG_HAS_IOPORT
static inline void _outb(u8 value, unsigned long addr)
{
__io_pbw();
__raw_writeb(value, PCI_IOBASE + addr);
__io_paw();
}
+#else
+void _outb(u8 value, unsigned long addr)
+ __compiletime_error("outb() requires CONFIG_HAS_IOPORT");
+#endif
#endif
#if !defined(outw) && !defined(_outw)
#define _outw _outw
+#ifdef CONFIG_HAS_IOPORT
static inline void _outw(u16 value, unsigned long addr)
{
__io_pbw();
__raw_writew((u16 __force)cpu_to_le16(value), PCI_IOBASE + addr);
__io_paw();
}
+#else
+void _outw(u16 value, unsigned long addr)
+ __compiletime_error("outw() requires CONFIG_HAS_IOPORT");
+#endif
#endif
#if !defined(outl) && !defined(_outl)
#define _outl _outl
+#ifdef CONFIG_HAS_IOPORT
static inline void _outl(u32 value, unsigned long addr)
{
__io_pbw();
__raw_writel((u32 __force)cpu_to_le32(value), PCI_IOBASE + addr);
__io_paw();
}
+#else
+void _outl(u32 value, unsigned long addr)
+ __compiletime_error("outl() requires CONFIG_HAS_IOPORT");
+#endif
#endif
#include <linux/logic_pio.h>
@@ -688,53 +718,83 @@ static inline void outl_p(u32 value, unsigned long addr)
#ifndef insb
#define insb insb
+#ifdef CONFIG_HAS_IOPORT
static inline void insb(unsigned long addr, void *buffer, unsigned int count)
{
readsb(PCI_IOBASE + addr, buffer, count);
}
+#else
+void insb(unsigned long addr, void *buffer, unsigned int count)
+ __compiletime_error("insb() requires HAS_IOPORT");
+#endif
#endif
#ifndef insw
#define insw insw
+#ifdef CONFIG_HAS_IOPORT
static inline void insw(unsigned long addr, void *buffer, unsigned int count)
{
readsw(PCI_IOBASE + addr, buffer, count);
}
+#else
+void insw(unsigned long addr, void *buffer, unsigned int count)
+ __compiletime_error("insw() requires HAS_IOPORT");
+#endif
#endif
#ifndef insl
#define insl insl
+#ifdef CONFIG_HAS_IOPORT
static inline void insl(unsigned long addr, void *buffer, unsigned int count)
{
readsl(PCI_IOBASE + addr, buffer, count);
}
+#else
+void insl(unsigned long addr, void *buffer, unsigned int count)
+ __compiletime_error("insl() requires HAS_IOPORT");
+#endif
#endif
#ifndef outsb
#define outsb outsb
+#ifdef CONFIG_HAS_IOPORT
static inline void outsb(unsigned long addr, const void *buffer,
unsigned int count)
{
writesb(PCI_IOBASE + addr, buffer, count);
}
+#else
+void outsb(unsigned long addr, const void *buffer, unsigned int count)
+ __compiletime_error("outsb() requires HAS_IOPORT");
+#endif
#endif
#ifndef outsw
#define outsw outsw
+#ifdef CONFIG_HAS_IOPORT
static inline void outsw(unsigned long addr, const void *buffer,
unsigned int count)
{
writesw(PCI_IOBASE + addr, buffer, count);
}
+#else
+void outsw(unsigned long addr, const void *buffer, unsigned int count)
+ __compiletime_error("outsw() requires HAS_IOPORT");
+#endif
#endif
#ifndef outsl
#define outsl outsl
+#ifdef CONFIG_HAS_IOPORT
static inline void outsl(unsigned long addr, const void *buffer,
unsigned int count)
{
writesl(PCI_IOBASE + addr, buffer, count);
}
+#else
+void outsl(unsigned long addr, const void *buffer, unsigned int count)
+ __compiletime_error("outsl() requires HAS_IOPORT");
+#endif
#endif
#ifndef insb_p
--
2.43.0
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v8 4/5] tty: serial: handle HAS_IOPORT dependencies
2024-10-08 12:39 ` [PATCH v8 4/5] tty: serial: " Niklas Schnelle
@ 2024-10-11 6:09 ` Greg Kroah-Hartman
2024-10-13 14:53 ` Maciej W. Rozycki
1 sibling, 0 replies; 15+ messages in thread
From: Greg Kroah-Hartman @ 2024-10-11 6:09 UTC (permalink / raw)
To: Niklas Schnelle
Cc: Brian Cain, Marcel Holtmann, Luiz Augusto von Dentz,
Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Jiri Slaby, Arnd Bergmann, Maciej W. Rozycki,
Heiko Carstens, linux-kernel, linux-hexagon, linux-bluetooth,
dri-devel, virtualization, spice-devel, intel-xe, linux-serial,
linux-arch, Arnd Bergmann
On Tue, Oct 08, 2024 at 02:39:45PM +0200, Niklas Schnelle wrote:
> In a future patch HAS_IOPORT=n will disable inb()/outb() and friends at
> compile time. We thus need to add HAS_IOPORT as dependency for those
> drivers using them unconditionally. Some 8250 serial drivers support
> MMIO only use, so fence only the parts requiring I/O ports and print an
> error message if a device can't be supported with the current
> configuration.
>
> Co-developed-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> ---
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v8 4/5] tty: serial: handle HAS_IOPORT dependencies
2024-10-08 12:39 ` [PATCH v8 4/5] tty: serial: " Niklas Schnelle
2024-10-11 6:09 ` Greg Kroah-Hartman
@ 2024-10-13 14:53 ` Maciej W. Rozycki
1 sibling, 0 replies; 15+ messages in thread
From: Maciej W. Rozycki @ 2024-10-13 14:53 UTC (permalink / raw)
To: Niklas Schnelle
Cc: Brian Cain, Marcel Holtmann, Luiz Augusto von Dentz,
Patrik Jakobsson, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann,
Heiko Carstens, linux-kernel, linux-hexagon, linux-bluetooth,
dri-devel, virtualization, spice-devel, intel-xe, linux-serial,
linux-arch, Arnd Bergmann
On Tue, 8 Oct 2024, Niklas Schnelle wrote:
> In a future patch HAS_IOPORT=n will disable inb()/outb() and friends at
> compile time. We thus need to add HAS_IOPORT as dependency for those
> drivers using them unconditionally. Some 8250 serial drivers support
> MMIO only use, so fence only the parts requiring I/O ports and print an
> error message if a device can't be supported with the current
> configuration.
>
> Co-developed-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> ---
Reviewed-by: Maciej W. Rozycki <macro@orcam.me.uk>
Maciej
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v8 3/5] drm: handle HAS_IOPORT dependencies
2024-10-08 12:39 ` [PATCH v8 3/5] drm: handle " Niklas Schnelle
@ 2024-10-21 7:52 ` Thomas Zimmermann
2024-10-21 10:08 ` Arnd Bergmann
0 siblings, 1 reply; 15+ messages in thread
From: Thomas Zimmermann @ 2024-10-21 7:52 UTC (permalink / raw)
To: Niklas Schnelle, Brian Cain, Marcel Holtmann,
Luiz Augusto von Dentz, Patrik Jakobsson, Maarten Lankhorst,
Maxime Ripard, David Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Arnd Bergmann,
Maciej W. Rozycki, Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, linux-arch,
Arnd Bergmann
Hi
Am 08.10.24 um 14:39 schrieb Niklas Schnelle:
> In a future patch HAS_IOPORT=n will disable inb()/outb() and friends at
> compile time. We thus need to add HAS_IOPORT as dependency for those
> drivers using them. In the bochs driver there is optional MMIO support
> detected at runtime, warn if this isn't taken when HAS_IOPORT is not
> defined.
>
> There is also a direct and hard coded use in cirrus.c which according to
> the comment is only necessary during resume. Let's just skip this as
> for example s390 which doesn't have I/O port support also doesen't
> support suspend/resume.
>
> Co-developed-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
I feel like I reviewed this before, but can't find it.
> ---
> drivers/gpu/drm/gma500/Kconfig | 2 +-
> drivers/gpu/drm/qxl/Kconfig | 1 +
> drivers/gpu/drm/tiny/bochs.c | 17 +++++++++++++++++
> drivers/gpu/drm/tiny/cirrus.c | 2 ++
> drivers/gpu/drm/xe/Kconfig | 2 +-
> 5 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/Kconfig b/drivers/gpu/drm/gma500/Kconfig
> index efb4a2dd2f80885cb59c925d09401002278d7d61..23b7c14de5e29238ece939d5822d8a9ffc4675cc 100644
> --- a/drivers/gpu/drm/gma500/Kconfig
> +++ b/drivers/gpu/drm/gma500/Kconfig
> @@ -1,7 +1,7 @@
> # SPDX-License-Identifier: GPL-2.0-only
> config DRM_GMA500
> tristate "Intel GMA500/600/3600/3650 KMS Framebuffer"
> - depends on DRM && PCI && X86 && MMU
> + depends on DRM && PCI && X86 && MMU && HAS_IOPORT
> select DRM_KMS_HELPER
> select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
> select I2C
> diff --git a/drivers/gpu/drm/qxl/Kconfig b/drivers/gpu/drm/qxl/Kconfig
> index ca3f51c2a8fe1a383f8a2479f04b5c0b3fb14e44..d0e0d440c8d96564cb7b8ffd2385c44fc43f873d 100644
> --- a/drivers/gpu/drm/qxl/Kconfig
> +++ b/drivers/gpu/drm/qxl/Kconfig
> @@ -2,6 +2,7 @@
> config DRM_QXL
> tristate "QXL virtual GPU"
> depends on DRM && PCI && MMU
> + depends on HAS_IOPORT
Is there a difference between this style (multiple 'depends on') and the
one used for gma500 (&& && &&)?
> select DRM_KMS_HELPER
> select DRM_TTM
> select DRM_TTM_HELPER
> diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
> index 31fc5d839e106ea4d5c8fe42d1bfc3c70291e3fb..0ed78d3d5774778f91de972ac27056938036e722 100644
> --- a/drivers/gpu/drm/tiny/bochs.c
> +++ b/drivers/gpu/drm/tiny/bochs.c
> @@ -2,6 +2,7 @@
>
> #include <linux/module.h>
> #include <linux/pci.h>
> +#include <linux/bug.h>
Alphabetic sorting please.
>
> #include <drm/drm_aperture.h>
> #include <drm/drm_atomic_helper.h>
> @@ -105,7 +106,9 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
>
> writeb(val, bochs->mmio + offset);
> } else {
> +#ifdef CONFIG_HAS_IOPORT
> outb(val, ioport);
> +#endif
Could you provide empty defines for the out() interfaces at the top of
the file?
> }
> }
>
> @@ -119,7 +122,11 @@ static u8 bochs_vga_readb(struct bochs_device *bochs, u16 ioport)
>
> return readb(bochs->mmio + offset);
> } else {
> +#ifdef CONFIG_HAS_IOPORT
> return inb(ioport);
> +#else
> + return 0xff;
> +#endif
And the in() interfaces could be defined to 0xff[ff].
I assume that you don't want to provide such empty macros in the
kernel's io.h header?
> }
> }
>
> @@ -132,8 +139,12 @@ static u16 bochs_dispi_read(struct bochs_device *bochs, u16 reg)
>
> ret = readw(bochs->mmio + offset);
> } else {
> +#ifdef CONFIG_HAS_IOPORT
> outw(reg, VBE_DISPI_IOPORT_INDEX);
> ret = inw(VBE_DISPI_IOPORT_DATA);
> +#else
> + ret = 0xffff;
> +#endif
> }
> return ret;
> }
> @@ -145,8 +156,10 @@ static void bochs_dispi_write(struct bochs_device *bochs, u16 reg, u16 val)
>
> writew(val, bochs->mmio + offset);
> } else {
> +#ifdef CONFIG_HAS_IOPORT
> outw(reg, VBE_DISPI_IOPORT_INDEX);
> outw(val, VBE_DISPI_IOPORT_DATA);
> +#endif
> }
> }
>
> @@ -229,6 +242,10 @@ static int bochs_hw_init(struct drm_device *dev)
> return -ENOMEM;
> }
> } else {
> + if (!IS_ENABLED(CONFIG_HAS_IOPORT)) {
> + DRM_ERROR("I/O ports are not supported\n");
> + return -EIO;
> + }
It would be nicer to use an "} else if(IOPORT) {" here and put the
"return -EIO" into a trailing else branch.
If you want to add an error message, please don't use DRM_ERROR(). In
this case, dev_err(dev->dev, "...\n") seems appropriate.
Best regards
Thomas
> ioaddr = VBE_DISPI_IOPORT_INDEX;
> iosize = 2;
> if (!request_region(ioaddr, iosize, "bochs-drm")) {
> diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c
> index 751326e3d9c374baf72115492aeefff2b73869f0..e31e1df029ab0272c4a1ff0ab3eb026ca679b560 100644
> --- a/drivers/gpu/drm/tiny/cirrus.c
> +++ b/drivers/gpu/drm/tiny/cirrus.c
> @@ -509,8 +509,10 @@ static void cirrus_crtc_helper_atomic_enable(struct drm_crtc *crtc,
>
> cirrus_mode_set(cirrus, &crtc_state->mode);
>
> +#ifdef CONFIG_HAS_IOPORT
> /* Unblank (needed on S3 resume, vgabios doesn't do it then) */
> outb(VGA_AR_ENABLE_DISPLAY, VGA_ATT_W);
> +#endif
>
> drm_dev_exit(idx);
> }
> diff --git a/drivers/gpu/drm/xe/Kconfig b/drivers/gpu/drm/xe/Kconfig
> index 7bbe46a98ff1f449bc2af30686585a00e9e8af93..116f58774135fc3a9f37d6d72d41340f5c812297 100644
> --- a/drivers/gpu/drm/xe/Kconfig
> +++ b/drivers/gpu/drm/xe/Kconfig
> @@ -49,7 +49,7 @@ config DRM_XE
>
> config DRM_XE_DISPLAY
> bool "Enable display support"
> - depends on DRM_XE && DRM_XE=m
> + depends on DRM_XE && DRM_XE=m && HAS_IOPORT
> select FB_IOMEM_HELPERS
> select I2C
> select I2C_ALGOBIT
>
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v8 3/5] drm: handle HAS_IOPORT dependencies
2024-10-21 7:52 ` Thomas Zimmermann
@ 2024-10-21 10:08 ` Arnd Bergmann
2024-10-21 10:58 ` Thomas Zimmermann
0 siblings, 1 reply; 15+ messages in thread
From: Arnd Bergmann @ 2024-10-21 10:08 UTC (permalink / raw)
To: Thomas Zimmermann, Niklas Schnelle, Brian Cain, Marcel Holtmann,
Luiz Augusto von Dentz, Patrik Jakobsson, Maarten Lankhorst,
Maxime Ripard, Dave Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Maciej W. Rozycki,
Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, Linux-Arch,
Arnd Bergmann
On Mon, Oct 21, 2024, at 07:52, Thomas Zimmermann wrote:
> Am 08.10.24 um 14:39 schrieb Niklas Schnelle:
d 100644
>> --- a/drivers/gpu/drm/qxl/Kconfig
>> +++ b/drivers/gpu/drm/qxl/Kconfig
>> @@ -2,6 +2,7 @@
>> config DRM_QXL
>> tristate "QXL virtual GPU"
>> depends on DRM && PCI && MMU
>> + depends on HAS_IOPORT
>
> Is there a difference between this style (multiple 'depends on') and the
> one used for gma500 (&& && &&)?
No, it's the same. Doing it in one line is mainly useful
if you have some '||' as well.
>> @@ -105,7 +106,9 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
>>
>> writeb(val, bochs->mmio + offset);
>> } else {
>> +#ifdef CONFIG_HAS_IOPORT
>> outb(val, ioport);
>> +#endif
>
> Could you provide empty defines for the out() interfaces at the top of
> the file?
That no longer works since there are now __compiletime_error()
versions of these funcitons. However we can do it more nicely like:
diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
index 9b337f948434..034af6e32200 100644
--- a/drivers/gpu/drm/tiny/bochs.c
+++ b/drivers/gpu/drm/tiny/bochs.c
@@ -112,14 +112,12 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df))
return;
- if (bochs->mmio) {
+ if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
int offset = ioport - 0x3c0 + 0x400;
writeb(val, bochs->mmio + offset);
} else {
-#ifdef CONFIG_HAS_IOPORT
outb(val, ioport);
-#endif
}
}
@@ -128,16 +126,12 @@ static u8 bochs_vga_readb(struct bochs_device *bochs, u16 ioport)
if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df))
return 0xff;
- if (bochs->mmio) {
+ if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
int offset = ioport - 0x3c0 + 0x400;
return readb(bochs->mmio + offset);
} else {
-#ifdef CONFIG_HAS_IOPORT
return inb(ioport);
-#else
- return 0xff;
-#endif
}
}
@@ -145,32 +139,26 @@ static u16 bochs_dispi_read(struct bochs_device *bochs, u16 reg)
{
u16 ret = 0;
- if (bochs->mmio) {
+ if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
int offset = 0x500 + (reg << 1);
ret = readw(bochs->mmio + offset);
} else {
-#ifdef CONFIG_HAS_IOPORT
outw(reg, VBE_DISPI_IOPORT_INDEX);
ret = inw(VBE_DISPI_IOPORT_DATA);
-#else
- ret = 0xffff;
-#endif
}
return ret;
}
static void bochs_dispi_write(struct bochs_device *bochs, u16 reg, u16 val)
{
- if (bochs->mmio) {
+ if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
int offset = 0x500 + (reg << 1);
writew(val, bochs->mmio + offset);
} else {
-#ifdef CONFIG_HAS_IOPORT
outw(reg, VBE_DISPI_IOPORT_INDEX);
outw(val, VBE_DISPI_IOPORT_DATA);
-#endif
}
}
> And the in() interfaces could be defined to 0xff[ff].
>
> I assume that you don't want to provide such empty macros in the
> kernel's io.h header?
That was the original idea many years ago, but Linus rejected
my pull request for it, so Niklas worked through all drivers
individually to add the dependencies instead.
Arnd
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH v8 3/5] drm: handle HAS_IOPORT dependencies
2024-10-21 10:08 ` Arnd Bergmann
@ 2024-10-21 10:58 ` Thomas Zimmermann
2024-10-21 11:01 ` Thomas Zimmermann
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Thomas Zimmermann @ 2024-10-21 10:58 UTC (permalink / raw)
To: Arnd Bergmann, Niklas Schnelle, Brian Cain, Marcel Holtmann,
Luiz Augusto von Dentz, Patrik Jakobsson, Maarten Lankhorst,
Maxime Ripard, Dave Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Maciej W. Rozycki,
Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, Linux-Arch,
Arnd Bergmann
Hi
Am 21.10.24 um 12:08 schrieb Arnd Bergmann:
> On Mon, Oct 21, 2024, at 07:52, Thomas Zimmermann wrote:
>> Am 08.10.24 um 14:39 schrieb Niklas Schnelle:
> d 100644
>>> --- a/drivers/gpu/drm/qxl/Kconfig
>>> +++ b/drivers/gpu/drm/qxl/Kconfig
>>> @@ -2,6 +2,7 @@
>>> config DRM_QXL
>>> tristate "QXL virtual GPU"
>>> depends on DRM && PCI && MMU
>>> + depends on HAS_IOPORT
>> Is there a difference between this style (multiple 'depends on') and the
>> one used for gma500 (&& && &&)?
> No, it's the same. Doing it in one line is mainly useful
> if you have some '||' as well.
>
>>> @@ -105,7 +106,9 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
>>>
>>> writeb(val, bochs->mmio + offset);
>>> } else {
>>> +#ifdef CONFIG_HAS_IOPORT
>>> outb(val, ioport);
>>> +#endif
>> Could you provide empty defines for the out() interfaces at the top of
>> the file?
> That no longer works since there are now __compiletime_error()
> versions of these funcitons. However we can do it more nicely like:
>
> diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
> index 9b337f948434..034af6e32200 100644
> --- a/drivers/gpu/drm/tiny/bochs.c
> +++ b/drivers/gpu/drm/tiny/bochs.c
> @@ -112,14 +112,12 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
> if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df))
> return;
>
> - if (bochs->mmio) {
> + if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
> int offset = ioport - 0x3c0 + 0x400;
>
> writeb(val, bochs->mmio + offset);
> } else {
> -#ifdef CONFIG_HAS_IOPORT
> outb(val, ioport);
> -#endif
> }
For all functions with such a pattern, could we use:
bool bochs_uses_mmio(bochs)
{
return !IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio
}
void writeb_func()
{
if (bochs_uses_mmio()) {
writeb()
#if CONFIG_HAS_IOPORT
} else {
outb()
#endif
}
}
u8 readb_func()
{
u8 ret = 0xff
if (bochs_uses_mmio()) {
ret = readb()
#if CONFIG_HAS_IOPORT
} else {
ret = inb()
#endif
}
return ret;
}
?
The code in bochs_uses_mmio() could then also print a drm_warn_once if
we have neither MMIO nor I/O ports.
I'd review a separate series for such a change.
> }
>
> @@ -128,16 +126,12 @@ static u8 bochs_vga_readb(struct bochs_device *bochs, u16 ioport)
> if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df))
> return 0xff;
>
> - if (bochs->mmio) {
> + if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
> int offset = ioport - 0x3c0 + 0x400;
>
> return readb(bochs->mmio + offset);
> } else {
> -#ifdef CONFIG_HAS_IOPORT
> return inb(ioport);
> -#else
> - return 0xff;
> -#endif
> }
> }
>
> @@ -145,32 +139,26 @@ static u16 bochs_dispi_read(struct bochs_device *bochs, u16 reg)
> {
> u16 ret = 0;
>
> - if (bochs->mmio) {
> + if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
> int offset = 0x500 + (reg << 1);
>
> ret = readw(bochs->mmio + offset);
> } else {
> -#ifdef CONFIG_HAS_IOPORT
> outw(reg, VBE_DISPI_IOPORT_INDEX);
> ret = inw(VBE_DISPI_IOPORT_DATA);
> -#else
> - ret = 0xffff;
> -#endif
> }
> return ret;
> }
>
> static void bochs_dispi_write(struct bochs_device *bochs, u16 reg, u16 val)
> {
> - if (bochs->mmio) {
> + if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
> int offset = 0x500 + (reg << 1);
>
> writew(val, bochs->mmio + offset);
> } else {
> -#ifdef CONFIG_HAS_IOPORT
> outw(reg, VBE_DISPI_IOPORT_INDEX);
> outw(val, VBE_DISPI_IOPORT_DATA);
> -#endif
> }
> }
>
>> And the in() interfaces could be defined to 0xff[ff].
>>
>> I assume that you don't want to provide such empty macros in the
>> kernel's io.h header?
> That was the original idea many years ago, but Linus rejected
> my pull request for it, so Niklas worked through all drivers
> individually to add the dependencies instead.
I see.
Best regards
Thomas
>
> Arnd
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v8 3/5] drm: handle HAS_IOPORT dependencies
2024-10-21 10:58 ` Thomas Zimmermann
@ 2024-10-21 11:01 ` Thomas Zimmermann
2024-10-21 11:18 ` Niklas Schnelle
2024-10-21 11:21 ` Arnd Bergmann
2 siblings, 0 replies; 15+ messages in thread
From: Thomas Zimmermann @ 2024-10-21 11:01 UTC (permalink / raw)
To: Arnd Bergmann, Niklas Schnelle, Brian Cain, Marcel Holtmann,
Luiz Augusto von Dentz, Patrik Jakobsson, Maarten Lankhorst,
Maxime Ripard, Dave Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Maciej W. Rozycki,
Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, Linux-Arch,
Arnd Bergmann
>
> I'd review a separate series for such a change.
Could also be a single patch here, of course.
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v8 3/5] drm: handle HAS_IOPORT dependencies
2024-10-21 10:58 ` Thomas Zimmermann
2024-10-21 11:01 ` Thomas Zimmermann
@ 2024-10-21 11:18 ` Niklas Schnelle
2024-10-24 9:30 ` Niklas Schnelle
2024-10-21 11:21 ` Arnd Bergmann
2 siblings, 1 reply; 15+ messages in thread
From: Niklas Schnelle @ 2024-10-21 11:18 UTC (permalink / raw)
To: Thomas Zimmermann, Arnd Bergmann, Brian Cain, Marcel Holtmann,
Luiz Augusto von Dentz, Patrik Jakobsson, Maarten Lankhorst,
Maxime Ripard, Dave Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Maciej W. Rozycki,
Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, Linux-Arch,
Arnd Bergmann
On Mon, 2024-10-21 at 12:58 +0200, Thomas Zimmermann wrote:
> Hi
>
> Am 21.10.24 um 12:08 schrieb Arnd Bergmann:
> > On Mon, Oct 21, 2024, at 07:52, Thomas Zimmermann wrote:
> > > Am 08.10.24 um 14:39 schrieb Niklas Schnelle:
> > d 100644
> > > > --- a/drivers/gpu/drm/qxl/Kconfig
> > > > +++ b/drivers/gpu/drm/qxl/Kconfig
> > > > @@ -2,6 +2,7 @@
> > > > config DRM_QXL
> > > > tristate "QXL virtual GPU"
> > > > depends on DRM && PCI && MMU
> > > > + depends on HAS_IOPORT
> > > Is there a difference between this style (multiple 'depends on') and the
> > > one used for gma500 (&& && &&)?
> > No, it's the same. Doing it in one line is mainly useful
> > if you have some '||' as well.
> >
> > > > @@ -105,7 +106,9 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
> > > >
> > > > writeb(val, bochs->mmio + offset);
> > > > } else {
> > > > +#ifdef CONFIG_HAS_IOPORT
> > > > outb(val, ioport);
> > > > +#endif
> > > Could you provide empty defines for the out() interfaces at the top of
> > > the file?
> > That no longer works since there are now __compiletime_error()
> > versions of these funcitons. However we can do it more nicely like:
> >
> > diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
> > index 9b337f948434..034af6e32200 100644
> > --- a/drivers/gpu/drm/tiny/bochs.c
> > +++ b/drivers/gpu/drm/tiny/bochs.c
> > @@ -112,14 +112,12 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
> > if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df))
> > return;
> >
> > - if (bochs->mmio) {
> > + if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
> > int offset = ioport - 0x3c0 + 0x400;
> >
> > writeb(val, bochs->mmio + offset);
> > } else {
> > -#ifdef CONFIG_HAS_IOPORT
> > outb(val, ioport);
> > -#endif
> > }
>
> For all functions with such a pattern, could we use:
>
> bool bochs_uses_mmio(bochs)
> {
> return !IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio
> }
>
> void writeb_func()
> {
> if (bochs_uses_mmio()) {
> writeb()
> #if CONFIG_HAS_IOPORT
> } else {
> outb()
> #endif
> }
> }
>
I think if the helper were __always_inline we could still take
advantage of the dead code elimination and combine this with Arnd's
approach. Though I feel like it is a bit odd to try to do the MMIO
approach despite bochs->mmio being false on !HAS_IOPORT systems.
Is that what you wanted to correct by keeping the #ifdef
CONFIG_HAS_IOPORT around the else? And yes the warning makes sense to
me too.
Thanks,
Niklas
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v8 3/5] drm: handle HAS_IOPORT dependencies
2024-10-21 10:58 ` Thomas Zimmermann
2024-10-21 11:01 ` Thomas Zimmermann
2024-10-21 11:18 ` Niklas Schnelle
@ 2024-10-21 11:21 ` Arnd Bergmann
2 siblings, 0 replies; 15+ messages in thread
From: Arnd Bergmann @ 2024-10-21 11:21 UTC (permalink / raw)
To: Thomas Zimmermann, Niklas Schnelle, Brian Cain, Marcel Holtmann,
Luiz Augusto von Dentz, Patrik Jakobsson, Maarten Lankhorst,
Maxime Ripard, Dave Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Maciej W. Rozycki,
Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, Linux-Arch,
Arnd Bergmann
On Mon, Oct 21, 2024, at 10:58, Thomas Zimmermann wrote:
> Am 21.10.24 um 12:08 schrieb Arnd Bergmann:
>> On Mon, Oct 21, 2024, at 07:52, Thomas Zimmermann wrote:
>> --- a/drivers/gpu/drm/tiny/bochs.c
>> +++ b/drivers/gpu/drm/tiny/bochs.c
>> @@ -112,14 +112,12 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
>> if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df))
>> return;
>>
>> - if (bochs->mmio) {
>> + if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
I meant IS_ENABLED() of course.
> For all functions with such a pattern, could we use:
>
> bool bochs_uses_mmio(bochs)
> {
> return !IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio
> }
>
> void writeb_func()
> {
> if (bochs_uses_mmio()) {
> writeb()
> #if CONFIG_HAS_IOPORT
> } else {
> outb()
> #endif
> }
Yes, that helper function look fine, but it should then
be either __always_inline or a macro. With that, the
#ifdef is not needed since gcc only warns if there is
a path that leads to outb() actually getting called.
Arnd
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH v8 3/5] drm: handle HAS_IOPORT dependencies
2024-10-21 11:18 ` Niklas Schnelle
@ 2024-10-24 9:30 ` Niklas Schnelle
0 siblings, 0 replies; 15+ messages in thread
From: Niklas Schnelle @ 2024-10-24 9:30 UTC (permalink / raw)
To: Thomas Zimmermann, Arnd Bergmann, Brian Cain, Marcel Holtmann,
Luiz Augusto von Dentz, Patrik Jakobsson, Maarten Lankhorst,
Maxime Ripard, Dave Airlie, Simona Vetter, Dave Airlie,
Gerd Hoffmann, Lucas De Marchi, Thomas Hellström,
Rodrigo Vivi, Greg Kroah-Hartman, Jiri Slaby, Maciej W. Rozycki,
Heiko Carstens
Cc: linux-kernel, linux-hexagon, linux-bluetooth, dri-devel,
virtualization, spice-devel, intel-xe, linux-serial, Linux-Arch,
Arnd Bergmann
On Mon, Oct 21, 2024 at 01:18:20PM +0200, Niklas Schnelle wrote:
> On Mon, 2024-10-21 at 12:58 +0200, Thomas Zimmermann wrote:
> > Hi
> >
> > Am 21.10.24 um 12:08 schrieb Arnd Bergmann:
> > > On Mon, Oct 21, 2024, at 07:52, Thomas Zimmermann wrote:
> > > > Am 08.10.24 um 14:39 schrieb Niklas Schnelle:
> > > d 100644
> > > > > --- a/drivers/gpu/drm/qxl/Kconfig
> > > > > +++ b/drivers/gpu/drm/qxl/Kconfig
> > > > > @@ -2,6 +2,7 @@
> > > > > config DRM_QXL
> > > > > tristate "QXL virtual GPU"
> > > > > depends on DRM && PCI && MMU
> > > > > + depends on HAS_IOPORT
> > > > Is there a difference between this style (multiple 'depends on') and the
> > > > one used for gma500 (&& && &&)?
> > > No, it's the same. Doing it in one line is mainly useful
> > > if you have some '||' as well.
> > >
> > > > > @@ -105,7 +106,9 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
> > > > >
> > > > > writeb(val, bochs->mmio + offset);
> > > > > } else {
> > > > > +#ifdef CONFIG_HAS_IOPORT
> > > > > outb(val, ioport);
> > > > > +#endif
> > > > Could you provide empty defines for the out() interfaces at the top of
> > > > the file?
> > > That no longer works since there are now __compiletime_error()
> > > versions of these funcitons. However we can do it more nicely like:
> > >
> > > diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c
> > > index 9b337f948434..034af6e32200 100644
> > > --- a/drivers/gpu/drm/tiny/bochs.c
> > > +++ b/drivers/gpu/drm/tiny/bochs.c
> > > @@ -112,14 +112,12 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
> > > if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df))
> > > return;
> > >
> > > - if (bochs->mmio) {
> > > + if (!IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio) {
> > > int offset = ioport - 0x3c0 + 0x400;
> > >
> > > writeb(val, bochs->mmio + offset);
> > > } else {
> > > -#ifdef CONFIG_HAS_IOPORT
> > > outb(val, ioport);
> > > -#endif
> > > }
> >
> > For all functions with such a pattern, could we use:
> >
> > bool bochs_uses_mmio(bochs)
> > {
> > return !IS_DEFINED(CONFIG_HAS_IOPORT) || bochs->mmio
> > }
> >
> > void writeb_func()
> > {
> > if (bochs_uses_mmio()) {
> > writeb()
> > #if CONFIG_HAS_IOPORT
> > } else {
> > outb()
> > #endif
> > }
> > }
> >
>
> I think if the helper were __always_inline we could still take
> advantage of the dead code elimination and combine this with Arnd's
> approach. Though I feel like it is a bit odd to try to do the MMIO
> approach despite bochs->mmio being false on !HAS_IOPORT systems.
> Is that what you wanted to correct by keeping the #ifdef
> CONFIG_HAS_IOPORT around the else? And yes the warning makes sense to
> me too.
Working on this now, I think we don't need a warning in the bochs_uses_mmio()
helper because we should never get here with !IS_ENABLED(CONFIG_HAS_IOPORT)
at runtime thanks to the check added in bochs_hw_init(). This also takes
care of my original worry that we might try writeb()/readb() with an invalid
bochs->mmio value. I'll sent a v9 with the helper added and #ifdefs's removed.
Thanks,
Niklas
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2024-10-24 9:31 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-08 12:39 [PATCH v8 0/5] treewide: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle
2024-10-08 12:39 ` [PATCH v8 1/5] hexagon: Don't select GENERIC_IOMAP without HAS_IOPORT support Niklas Schnelle
2024-10-08 12:39 ` [PATCH v8 2/5] Bluetooth: add HAS_IOPORT dependencies Niklas Schnelle
2024-10-08 12:39 ` [PATCH v8 3/5] drm: handle " Niklas Schnelle
2024-10-21 7:52 ` Thomas Zimmermann
2024-10-21 10:08 ` Arnd Bergmann
2024-10-21 10:58 ` Thomas Zimmermann
2024-10-21 11:01 ` Thomas Zimmermann
2024-10-21 11:18 ` Niklas Schnelle
2024-10-24 9:30 ` Niklas Schnelle
2024-10-21 11:21 ` Arnd Bergmann
2024-10-08 12:39 ` [PATCH v8 4/5] tty: serial: " Niklas Schnelle
2024-10-11 6:09 ` Greg Kroah-Hartman
2024-10-13 14:53 ` Maciej W. Rozycki
2024-10-08 12:39 ` [PATCH v8 5/5] asm-generic/io.h: Remove I/O port accessors for HAS_IOPORT=n Niklas Schnelle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).