Skip to content

Commit f663c6a

Browse files
niklas88arndb
authored andcommitted
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>
1 parent f062b6e commit f663c6a

5 files changed

Lines changed: 19 additions & 8 deletions

File tree

drivers/gpu/drm/gma500/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
config DRM_GMA500
33
tristate "Intel GMA500/600/3600/3650 KMS Framebuffer"
4-
depends on DRM && PCI && X86 && MMU
4+
depends on DRM && PCI && X86 && MMU && HAS_IOPORT
55
select DRM_KMS_HELPER
66
select FB_IOMEM_HELPERS if DRM_FBDEV_EMULATION
77
select I2C

drivers/gpu/drm/qxl/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
config DRM_QXL
33
tristate "QXL virtual GPU"
4-
depends on DRM && PCI && MMU
4+
depends on DRM && PCI && MMU && HAS_IOPORT
55
select DRM_KMS_HELPER
66
select DRM_TTM
77
select DRM_TTM_HELPER

drivers/gpu/drm/tiny/bochs.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-or-later
22

3+
#include <linux/bug.h>
34
#include <linux/module.h>
45
#include <linux/pci.h>
56

@@ -95,12 +96,17 @@ struct bochs_device {
9596

9697
/* ---------------------------------------------------------------------- */
9798

99+
static __always_inline bool bochs_uses_mmio(struct bochs_device *bochs)
100+
{
101+
return !IS_ENABLED(CONFIG_HAS_IOPORT) || bochs->mmio;
102+
}
103+
98104
static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val)
99105
{
100106
if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df))
101107
return;
102108

103-
if (bochs->mmio) {
109+
if (bochs_uses_mmio(bochs)) {
104110
int offset = ioport - 0x3c0 + 0x400;
105111

106112
writeb(val, bochs->mmio + offset);
@@ -114,7 +120,7 @@ static u8 bochs_vga_readb(struct bochs_device *bochs, u16 ioport)
114120
if (WARN_ON(ioport < 0x3c0 || ioport > 0x3df))
115121
return 0xff;
116122

117-
if (bochs->mmio) {
123+
if (bochs_uses_mmio(bochs)) {
118124
int offset = ioport - 0x3c0 + 0x400;
119125

120126
return readb(bochs->mmio + offset);
@@ -127,7 +133,7 @@ static u16 bochs_dispi_read(struct bochs_device *bochs, u16 reg)
127133
{
128134
u16 ret = 0;
129135

130-
if (bochs->mmio) {
136+
if (bochs_uses_mmio(bochs)) {
131137
int offset = 0x500 + (reg << 1);
132138

133139
ret = readw(bochs->mmio + offset);
@@ -140,7 +146,7 @@ static u16 bochs_dispi_read(struct bochs_device *bochs, u16 reg)
140146

141147
static void bochs_dispi_write(struct bochs_device *bochs, u16 reg, u16 val)
142148
{
143-
if (bochs->mmio) {
149+
if (bochs_uses_mmio(bochs)) {
144150
int offset = 0x500 + (reg << 1);
145151

146152
writew(val, bochs->mmio + offset);
@@ -228,14 +234,17 @@ static int bochs_hw_init(struct drm_device *dev)
228234
DRM_ERROR("Cannot map mmio region\n");
229235
return -ENOMEM;
230236
}
231-
} else {
237+
} else if (IS_ENABLED(CONFIG_HAS_IOPORT)) {
232238
ioaddr = VBE_DISPI_IOPORT_INDEX;
233239
iosize = 2;
234240
if (!request_region(ioaddr, iosize, "bochs-drm")) {
235241
DRM_ERROR("Cannot request ioports\n");
236242
return -EBUSY;
237243
}
238244
bochs->ioports = 1;
245+
} else {
246+
dev_err(dev->dev, "I/O ports are not supported\n");
247+
return -EIO;
239248
}
240249

241250
id = bochs_dispi_read(bochs, VBE_DISPI_INDEX_ID);

drivers/gpu/drm/tiny/cirrus.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,10 @@ static void cirrus_crtc_helper_atomic_enable(struct drm_crtc *crtc,
509509

510510
cirrus_mode_set(cirrus, &crtc_state->mode);
511511

512+
#ifdef CONFIG_HAS_IOPORT
512513
/* Unblank (needed on S3 resume, vgabios doesn't do it then) */
513514
outb(VGA_AR_ENABLE_DISPLAY, VGA_ATT_W);
515+
#endif
514516

515517
drm_dev_exit(idx);
516518
}

drivers/gpu/drm/xe/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ config DRM_XE
4949

5050
config DRM_XE_DISPLAY
5151
bool "Enable display support"
52-
depends on DRM_XE && DRM_XE=m
52+
depends on DRM_XE && DRM_XE=m && HAS_IOPORT
5353
select FB_IOMEM_HELPERS
5454
select I2C
5555
select I2C_ALGOBIT

0 commit comments

Comments
 (0)