Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: handle HAS_IOPORT dependencies

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>
Acked-by: Lucas De Marchi <lucas.demarchi@intel.com> # xe
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>

authored by

Niklas Schnelle and committed by
Arnd Bergmann
f663c6ae f062b6ec

+19 -8
+1 -1
drivers/gpu/drm/gma500/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 config DRM_GMA500 3 3 tristate "Intel GMA500/600/3600/3650 KMS Framebuffer" 4 - depends on DRM && PCI && X86 && MMU 4 + depends on DRM && PCI && X86 && MMU && HAS_IOPORT 5 5 select DRM_KMS_HELPER 6 6 select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION 7 7 select I2C
+1 -1
drivers/gpu/drm/qxl/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 2 config DRM_QXL 3 3 tristate "QXL virtual GPU" 4 - depends on DRM && PCI && MMU 4 + depends on DRM && PCI && MMU && HAS_IOPORT 5 5 select DRM_KMS_HELPER 6 6 select DRM_TTM 7 7 select DRM_TTM_HELPER
+14 -5
drivers/gpu/drm/tiny/bochs.c
··· 1 1 // SPDX-License-Identifier: GPL-2.0-or-later 2 2 3 + #include <linux/bug.h> 3 4 #include <linux/module.h> 4 5 #include <linux/pci.h> 5 6 ··· 96 95 97 96 /* ---------------------------------------------------------------------- */ 98 97 98 + static __always_inline bool bochs_uses_mmio(struct bochs_device *bochs) 99 + { 100 + return !IS_ENABLED(CONFIG_HAS_IOPORT) || bochs->mmio; 101 + } 102 + 99 103 static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val) 100 104 { 101 105 if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df)) 102 106 return; 103 107 104 - if (bochs->mmio) { 108 + if (bochs_uses_mmio(bochs)) { 105 109 int offset = ioport - 0x3c0 + 0x400; 106 110 107 111 writeb(val, bochs->mmio + offset); ··· 120 114 if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df)) 121 115 return 0xff; 122 116 123 - if (bochs->mmio) { 117 + if (bochs_uses_mmio(bochs)) { 124 118 int offset = ioport - 0x3c0 + 0x400; 125 119 126 120 return readb(bochs->mmio + offset); ··· 133 127 { 134 128 u16 ret = 0; 135 129 136 - if (bochs->mmio) { 130 + if (bochs_uses_mmio(bochs)) { 137 131 int offset = 0x500 + (reg << 1); 138 132 139 133 ret = readw(bochs->mmio + offset); ··· 146 140 147 141 static void bochs_dispi_write(struct bochs_device *bochs, u16 reg, u16 val) 148 142 { 149 - if (bochs->mmio) { 143 + if (bochs_uses_mmio(bochs)) { 150 144 int offset = 0x500 + (reg << 1); 151 145 152 146 writew(val, bochs->mmio + offset); ··· 234 228 DRM_ERROR("Cannot map mmio region\n"); 235 229 return -ENOMEM; 236 230 } 237 - } else { 231 + } else if (IS_ENABLED(CONFIG_HAS_IOPORT)) { 238 232 ioaddr = VBE_DISPI_IOPORT_INDEX; 239 233 iosize = 2; 240 234 if (!request_region(ioaddr, iosize, "bochs-drm")) { ··· 242 236 return -EBUSY; 243 237 } 244 238 bochs->ioports = 1; 239 + } else { 240 + dev_err(dev->dev, "I/O ports are not supported\n"); 241 + return -EIO; 245 242 } 246 243 247 244 id = bochs_dispi_read(bochs, VBE_DISPI_INDEX_ID);
+2
drivers/gpu/drm/tiny/cirrus.c
··· 509 509 510 510 cirrus_mode_set(cirrus, &crtc_state->mode); 511 511 512 + #ifdef CONFIG_HAS_IOPORT 512 513 /* Unblank (needed on S3 resume, vgabios doesn't do it then) */ 513 514 outb(VGA_AR_ENABLE_DISPLAY, VGA_ATT_W); 515 + #endif 514 516 515 517 drm_dev_exit(idx); 516 518 }
+1 -1
drivers/gpu/drm/xe/Kconfig
··· 49 49 50 50 config DRM_XE_DISPLAY 51 51 bool "Enable display support" 52 - depends on DRM_XE && DRM_XE=m 52 + depends on DRM_XE && DRM_XE=m && HAS_IOPORT 53 53 select FB_IOMEM_HELPERS 54 54 select I2C 55 55 select I2C_ALGOBIT