Skip to contentSkip to conversation

drm: Make it compilable without CONFIG_HDMI and CONFIG_I2C

PATCH In review Thomas Huth 3 participants 7 messages Apr 13, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover drm: Make it compilable without CONFIG_HDMI and CONFIG_I2C

By enabling the DRM code for virtio-gpu on S390, you currently also get all the code that is enabled by CONFIG_HDMI and CONFIG_I2C automatically. This is quite ugly, since on S390, there is no HDMI and no I2C. Thus it would be great if the DRM code could also be compiled without CONFIG_HDMI and CONFIG_I2C. These two patches now refactor the DRM code a little bit so that we can compile it also without CONFIG_HDMI and CONFIG_I2C.

Thomas Huth (2):
drivers/gpu/drm: Move CONFIG_HDMI-dependent code to a separate file drivers/gpu/drm: Make the DRM code compilable without CONFIG_I2C

 drivers/gpu/drm/Kconfig             |   6 +-
 drivers/gpu/drm/Makefile            |  17 ++--
 drivers/gpu/drm/drm_crtc_internal.h |   2 +
 drivers/gpu/drm/drm_edid.c          | 173 ++--------------------------------
 drivers/gpu/drm/drm_hdmi.c          | 182 ++++++++++++++++++++++++++++++++++++
 5 files changed, 206 insertions(+), 174 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_hdmi.c
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/2 drm: Move CONFIG_HDMI-dependent code to a separate file

Selecting CONFIG_HDMI for S390 is inappropriate - there is no real graphic hardware on this architecture. The drm subsystem is only enabled here for using the virtual graphics card "virtio-gpu". So it should be possible to compile the drm subsystem also without CONFIG_DRM. Let's move the related code to a separate file for this.

---
 drivers/gpu/drm/Kconfig             |   2 +-
 drivers/gpu/drm/Makefile            |   1 +
 drivers/gpu/drm/drm_crtc_internal.h |   2 +
 drivers/gpu/drm/drm_edid.c          | 163 +-------------------------------
 drivers/gpu/drm/drm_hdmi.c          | 182 ++++++++++++++++++++++++++++++++++++
 5 files changed, 188 insertions(+), 162 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_hdmi.c
drivers/gpu/drm/Kconfig +1 -1
index deeefa7..298a518 100644
@@ -8,7 +8,7 @@ menuconfig DRM
 	tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
 	depends on (AGP || AGP=n) && !EMULATED_CMPXCHG && HAS_DMA
 	select DRM_PANEL_ORIENTATION_QUIRKS
-	select HDMI
+	select HDMI if !S390
 	select FB_CMDLINE
 	select I2C
 	select I2C_ALGOBIT
drivers/gpu/drm/Makefile +1 -0
index 50093ff..16fd8e3 100644
@@ -20,6 +20,7 @@ drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
 		drm_dumb_buffers.o drm_mode_config.o drm_vblank.o \
 		drm_syncobj.o drm_lease.o
 
+drm-$(CONFIG_HDMI) += drm_hdmi.o
 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
 drm-$(CONFIG_DRM_VM) += drm_vm.o
 drm-$(CONFIG_COMPAT) += drm_ioc32.o
drivers/gpu/drm/drm_crtc_internal.h +2 -0
index 3c2b828..0804348 100644
@@ -220,3 +220,5 @@ int drm_mode_page_flip_ioctl(struct drm_device *dev,
 
 /* drm_edid.c */
 void drm_mode_fixup_1366x768(struct drm_display_mode *mode);
+u8 drm_match_hdmi_mode(const struct drm_display_mode *to_match);
+bool drm_valid_hdmi_vic(u8 vic);
drivers/gpu/drm/drm_edid.c +2 -161

193 lines not on this page · raw message

drivers/gpu/drm/drm_hdmi.c new file +182 -0

182 lines not on this page · raw message

Signature · 1 line
1.8.3.1
#2 lore raw

PATCH 2/2 drm: Make the DRM code compilable without CONFIG_I2C

In reply to Thomas Huth

Selecting CONFIG_HDMI for S390 is inappropriate - there is no real graphic hardware on this architecture. The drm subsystem is only enabled here for using the virtual graphics card "virtio-gpu". So it should be possible to compile the drm subsystem also without CONFIG_I2C. Tweak the Makefile to only compile the affected files with CONFIG_I2C=y and disable some I2C-related code in drm_edid.c.

---
 drivers/gpu/drm/Kconfig    |  4 ++--
 drivers/gpu/drm/Makefile   | 16 +++++++++-------
 drivers/gpu/drm/drm_edid.c | 10 +++++++---
 3 files changed, 18 insertions(+), 12 deletions(-)
drivers/gpu/drm/Kconfig +2 -2
index 298a518..c9df67f 100644
@@ -10,8 +10,8 @@ menuconfig DRM
 	select DRM_PANEL_ORIENTATION_QUIRKS
 	select HDMI if !S390
 	select FB_CMDLINE
-	select I2C
-	select I2C_ALGOBIT
+	select I2C if !S390
+	select I2C_ALGOBIT if !S390
 	select DMA_SHARED_BUFFER
 	select SYNC_FILE
 	help
drivers/gpu/drm/Makefile +9 -7
index 16fd8e3..4cf53ba 100644
@@ -7,10 +7,9 @@ drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
 		drm_context.o drm_dma.o \
 		drm_file.o drm_gem.o drm_ioctl.o drm_irq.o \
 		drm_lock.o drm_memory.o drm_drv.o \
-		drm_scatter.o drm_pci.o \
+		drm_scatter.o drm_pci.o drm_info.o \
 		drm_sysfs.o drm_hashtab.o drm_mm.o \
 		drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \
-		drm_info.o drm_encoder_slave.o \
 		drm_trace_points.o drm_global.o drm_prime.o \
 		drm_rect.o drm_vma_manager.o drm_flip_work.o \
 		drm_modeset_lock.o drm_atomic.o drm_bridge.o \
@@ -20,6 +19,7 @@ drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
 		drm_dumb_buffers.o drm_mode_config.o drm_vblank.o \
 		drm_syncobj.o drm_lease.o
 
+drm-$(CONFIG_I2C) += drm_encoder_slave.o
 drm-$(CONFIG_HDMI) += drm_hdmi.o
 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
 drm-$(CONFIG_DRM_VM) += drm_vm.o
@@ -32,11 +32,13 @@ drm-$(CONFIG_AGP) += drm_agpsupport.o
 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
 drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
 
-drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
-		drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
-		drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
-		drm_simple_kms_helper.o drm_modeset_helper.o \
-		drm_scdc_helper.o drm_gem_framebuffer_helper.o
+drm_kms_helper-y := drm_crtc_helper.o drm_probe_helper.o \
+		drm_plane_helper.o drm_atomic_helper.o \
+		drm_gem_framebuffer_helper.o drm_kms_helper_common.o \
+		drm_simple_kms_helper.o drm_modeset_helper.o
+
+drm_kms_helper-$(CONFIG_I2C) += drm_dp_helper.o drm_dp_mst_topology.o \
+		drm_dp_dual_mode_helper.o drm_scdc_helper.o
 
 drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
drivers/gpu/drm/drm_edid.c +7 -3
index 3820763..0d0d5af 100644
@@ -1467,11 +1467,14 @@ bool drm_edid_is_valid(struct edid *edid)
 static int
 drm_do_probe_ddc_edid(void *data, u8 *buf, unsigned int block, size_t len)
 {
-	struct i2c_adapter *adapter = data;
-	unsigned char start = block * EDID_LENGTH;
 	unsigned char segment = block >> 1;
 	unsigned char xfers = segment ? 3 : 2;
-	int ret, retries = 5;
+	int ret = -1;
+
+#if IS_ENABLED(CONFIG_I2C)
+	struct i2c_adapter *adapter = data;
+	unsigned char start = block * EDID_LENGTH;
+	int retries = 5;
 
 	/*
 	 * The core I2C driver will automatically retry the transfer if the
@@ -1512,6 +1515,7 @@ bool drm_edid_is_valid(struct edid *edid)
 			break;
 		}
 	} while (ret != xfers && --retries);
+#endif	/* CONFIG_I2C */
 
 	return ret == xfers ? 0 : -1;
 }
Signature · 6 lines
1.8.3.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#3 lore raw

Re: [PATCH 2/2] drm: Make the DRM code compilable without CONFIG_I2C

Quoted 78 lines · Thomas Huth

Selecting CONFIG_HDMI for S390 is inappropriate - there is no real graphic hardware on this architecture. The drm subsystem is only enabled here for using the virtual graphics card "virtio-gpu". So it should be possible to compile the drm subsystem also without CONFIG_I2C. Tweak the Makefile to only compile the affected files with CONFIG_I2C=y and disable some I2C-related code in drm_edid.c.

---
 drivers/gpu/drm/Kconfig    |  4 ++--
 drivers/gpu/drm/Makefile   | 16 +++++++++-------
 drivers/gpu/drm/drm_edid.c | 10 +++++++---
 3 files changed, 18 insertions(+), 12 deletions(-)
drivers/gpu/drm/Kconfig +2 -2
index 298a518..c9df67f 100644
@@ -10,8 +10,8 @@ menuconfig DRM
 	select DRM_PANEL_ORIENTATION_QUIRKS
 	select HDMI if !S390
 	select FB_CMDLINE
-	select I2C
-	select I2C_ALGOBIT
+	select I2C if !S390
+	select I2C_ALGOBIT if !S390
 	select DMA_SHARED_BUFFER
 	select SYNC_FILE
 	help
drivers/gpu/drm/Makefile +9 -7
index 16fd8e3..4cf53ba 100644
@@ -7,10 +7,9 @@ drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
 		drm_context.o drm_dma.o \
 		drm_file.o drm_gem.o drm_ioctl.o drm_irq.o \
 		drm_lock.o drm_memory.o drm_drv.o \
-		drm_scatter.o drm_pci.o \
+		drm_scatter.o drm_pci.o drm_info.o \
 		drm_sysfs.o drm_hashtab.o drm_mm.o \
 		drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o \
-		drm_info.o drm_encoder_slave.o \
 		drm_trace_points.o drm_global.o drm_prime.o \
 		drm_rect.o drm_vma_manager.o drm_flip_work.o \
 		drm_modeset_lock.o drm_atomic.o drm_bridge.o \
@@ -20,6 +19,7 @@ drm-y       :=	drm_auth.o drm_bufs.o drm_cache.o \
 		drm_dumb_buffers.o drm_mode_config.o drm_vblank.o \
 		drm_syncobj.o drm_lease.o
 
+drm-$(CONFIG_I2C) += drm_encoder_slave.o
 drm-$(CONFIG_HDMI) += drm_hdmi.o
 drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o
 drm-$(CONFIG_DRM_VM) += drm_vm.o
@@ -32,11 +32,13 @@ drm-$(CONFIG_AGP) += drm_agpsupport.o
 drm-$(CONFIG_DEBUG_FS) += drm_debugfs.o drm_debugfs_crc.o
 drm-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o
 
-drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o \
-		drm_plane_helper.o drm_dp_mst_topology.o drm_atomic_helper.o \
-		drm_kms_helper_common.o drm_dp_dual_mode_helper.o \
-		drm_simple_kms_helper.o drm_modeset_helper.o \
-		drm_scdc_helper.o drm_gem_framebuffer_helper.o
+drm_kms_helper-y := drm_crtc_helper.o drm_probe_helper.o \
+		drm_plane_helper.o drm_atomic_helper.o \
+		drm_gem_framebuffer_helper.o drm_kms_helper_common.o \
+		drm_simple_kms_helper.o drm_modeset_helper.o
+
+drm_kms_helper-$(CONFIG_I2C) += drm_dp_helper.o drm_dp_mst_topology.o \
+		drm_dp_dual_mode_helper.o drm_scdc_helper.o
 
 drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o
 drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
drivers/gpu/drm/drm_edid.c +0 -0
index 3820763..0d0d5af 100644
@@ -1467,11 +1467,14 @@ bool drm_edid_is_valid(struct edid *edid)
 static int

drivers/gpu/drm/drm_edid.c bool drm_edid_is_valid(struct edid *edid) · line 1474

Quoted 10 lines
drivers/gpu/drm/drm_edid.c +3 -3
 drm_do_probe_ddc_edid(void *data, u8 *buf, unsigned int block, size_t len)
 {
-	struct i2c_adapter *adapter = data;
-	unsigned char start = block * EDID_LENGTH;
 	unsigned char segment = block >> 1;
 	unsigned char xfers = segment ? 3 : 2;
-	int ret, retries = 5;
+	int ret = -1;
+
+#if IS_ENABLED(CONFIG_I2C)

So I don't know if the patches are worth it, I'll let others decide, but no matter what the conditional build needs to be *outside* of function bodies. The #else branch would then contain just:

#else
static inline int
drm_do_probe_ddc_edid(void *data, u8 *buf, unsigned int block, size_t len)

{
        return -1;
}

#endif /* CONFIG_I2C */

BR,
Jani.

Quoted 14 lines
drivers/gpu/drm/drm_edid.c +4 -0
+	struct i2c_adapter *adapter = data;
+	unsigned char start = block * EDID_LENGTH;
+	int retries = 5;
 
 	/*
 	 * The core I2C driver will automatically retry the transfer if the
@@ -1512,6 +1515,7 @@ bool drm_edid_is_valid(struct edid *edid)
 			break;
 		}
 	} while (ret != xfers && --retries);
+#endif	/* CONFIG_I2C */
 
 	return ret == xfers ? 0 : -1;
 }
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
#4 lore raw
In reply to Thomas Huth
Quoted 10 lines · Thomas Huth

By enabling the DRM code for virtio-gpu on S390, you currently also get all the code that is enabled by CONFIG_HDMI and CONFIG_I2C automatically. This is quite ugly, since on S390, there is no HDMI and no I2C. Thus it would be great if the DRM code could also be compiled without CONFIG_HDMI and CONFIG_I2C. These two patches now refactor the DRM code a little bit so that we can compile it also without CONFIG_HDMI and CONFIG_I2C.

Thomas Huth (2):
drivers/gpu/drm: Move CONFIG_HDMI-dependent code to a separate file drivers/gpu/drm: Make the DRM code compilable without CONFIG_I2C

What's the benefit? Why does I2C/HDMI hurt you?

Note that you still can't compile out DP code, and the DRM legacy code, and that's much bigger ...
-Daniel

Quoted 16 lines
 drivers/gpu/drm/Kconfig             |   6 +-
 drivers/gpu/drm/Makefile            |  17 ++--
 drivers/gpu/drm/drm_crtc_internal.h |   2 +
 drivers/gpu/drm/drm_edid.c          | 173 ++--------------------------------
 drivers/gpu/drm/drm_hdmi.c          | 182 ++++++++++++++++++++++++++++++++++++
 5 files changed, 206 insertions(+), 174 deletions(-)
 create mode 100644 drivers/gpu/drm/drm_hdmi.c

--
1.8.3.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#5 lore raw
Quoted 8 lines · Daniel Vetter
Quoted 7 lines · Thomas Huth

By enabling the DRM code for virtio-gpu on S390, you currently also get all the code that is enabled by CONFIG_HDMI and CONFIG_I2C automatically. This is quite ugly, since on S390, there is no HDMI and no I2C. Thus it would be great if the DRM code could also be compiled without CONFIG_HDMI and CONFIG_I2C. These two patches now refactor the DRM code a little bit so that we can compile it also without CONFIG_HDMI and CONFIG_I2C.

Quoted 5 lines
Quoted 3 lines

Thomas Huth (2):
drivers/gpu/drm: Move CONFIG_HDMI-dependent code to a separate file drivers/gpu/drm: Make the DRM code compilable without CONFIG_I2C

What's the benefit? Why does I2C/HDMI hurt you?

Why should I be forced to compile-in subsystems that do not make any sense on this architecture? It's just completely weird to see CONFIG_I2C enabled on s390x.

Thomas
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#6 lore raw
Quoted 13 lines · Thomas Huth
Quoted 12 lines · Daniel Vetter
Quoted 10 lines · Thomas Huth

By enabling the DRM code for virtio-gpu on S390, you currently also get all the code that is enabled by CONFIG_HDMI and CONFIG_I2C automatically. This is quite ugly, since on S390, there is no HDMI and no I2C. Thus it would be great if the DRM code could also be compiled without CONFIG_HDMI and CONFIG_I2C. These two patches now refactor the DRM code a little bit so that we can compile it also without CONFIG_HDMI and CONFIG_I2C.

Thomas Huth (2):
drivers/gpu/drm: Move CONFIG_HDMI-dependent code to a separate file drivers/gpu/drm: Make the DRM code compilable without CONFIG_I2C

Quoted 5 lines
Quoted 1 line

What's the benefit? Why does I2C/HDMI hurt you?

Why should I be forced to compile-in subsystems that do not make any sense on this architecture? It's just completely weird to see CONFIG_I2C enabled on s390x.

"Looks wierd" is not really a good engineering criteria, especially in graphics :-)

For context: In DRM almost nothing is optional, and it greatly simplifies life and coding. We don't have epic amounts of #ifdef battles to make trivial code changes compile, except in all the places where external stuff is optional (like backlight).

So making something optional will have a pretty clear cost on the drm subsystem, and it doesn't make sense to pay that cost to "look less wierd". To get this merged we need some clear benefits, which will balance out the inevitable cost of having to maintain this forever (and most likely getting yelled at by Linus for making some rando compile config no longer work).
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel