drm: Handle HAS_IOPORT dependencies
Subsystems (5)
cover drm: Handle HAS_IOPORT dependencies
Hi DRM Maintainers,
This is a follow up in my ongoing effort of making inb()/outb() and similar I/O port accessors compile-time optional. Previously I sent this as a treewide series titled "treewide: Remove I/O port accessors for HAS_IOPORT=n" with the latest being its 5th version[0]. With a significant subset of patches merged I've changed over to per-subsystem series. These series are stand alone and should be merged via the relevant tree such that with all subsystems complete we can follow this up with the final patch that will make the I/O port accessors compile-time optional.
The current state of the full series with changes to the remaining subsystems and the aforementioned final patch can be found for your convenience on my git.kernel.org tree in the has_ioport_v6 branch[1] with signed tags. As for compile-time vs runtime see Linus' reply to my first attempt[2].
Thanks,
Niklas
[0] https://lore.kernel.org/all/[email protected]/
[1] https://git.kernel.org/pub/scm/linux/kernel/git/niks/linux.git/log/?h=has_ioport_v6
[2] https://lore.kernel.org/lkml/CAHk-=wg80je=K7madF4e7WrRNp37e3qh6y10Svhdc7O8SZ_-8g@mail.gmail.com/
Niklas Schnelle (1):
drm: handle HAS_IOPORT dependencies
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 +- 4 files changed, 21 insertions(+), 1 deletion(-)
Signature · 1 line
2.40.1
PATCH 1/1 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.
---
Note: This patch does not depend any not-yet-mainline HAS_IOPORT changes and may be merged via subsystem specific trees at your earliest convenience.
v5->v6: Added HAS_IOPORT for xe driver which copied some I/O port use from existing intel drivers.
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 +- 4 files changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/qxl/Kconfig +1 -0
@@ -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
drivers/gpu/drm/tiny/bochs.c +17 -0
@@ -2,6 +2,7 @@#include <linux/module.h> #include <linux/pci.h> +#include <asm/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" )) {
drivers/gpu/drm/tiny/cirrus.c +2 -0
@@ -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); }
drivers/gpu/drm/xe/Kconfig +1 -1
@@ -48,7 +48,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
Signature · 1 line
2.40.1