drm: Move several files from DRM core into modules
Subsystems (2)
Thomas Zimmermann
maintainercover drm: Move several files from DRM core into modules
Move a number of files into modules and behind config options.
So far, early boot graphics was provided by fbdev. With simpledrm, and possibly other generic DRM drivers, it's now possible to have general early-boot output with DRM. This requires the DRM core to be linked into the kernel binary image.
The reduction in size here is only ~1%, but the patchset is part of a larger effort to reduce the size of the DRM core module.
Thomas Zimmermann (3):
drm: Build drm_irq.o only if CONFIG_DRM_LEGACY has been set
drm: Link several object files into drm_kms_helper.ko
drm: Move GEM memory managers into modules
drivers/gpu/drm/Kconfig | 4 ++-- drivers/gpu/drm/Makefile | 26 +++++++++++++++----------- drivers/gpu/drm/drm_gem_cma_helper.c | 4 ++++ drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++++ drivers/gpu/drm/drm_irq.c | 2 -- 5 files changed, 25 insertions(+), 15 deletions(-)
--
2.33.0
Thomas Zimmermann
maintainerPATCH 1/3 drm: Build drm_irq.o only if CONFIG_DRM_LEGACY has been set
All code in drm_irq.o is for legacy UMs drivers. Only build and link the file if CONFIG_DRM_LEGACY has been enabled.
--- drivers/gpu/drm/Makefile | 6 +++--- drivers/gpu/drm/drm_irq.c | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-)
drivers/gpu/drm/Makefile +3 -3
@@ -4,7 +4,7 @@ # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. drm-y := drm_aperture.o drm_auth.o drm_cache.o \ - drm_file.o drm_gem.o drm_ioctl.o drm_irq.o \ + drm_file.o drm_gem.o drm_ioctl.o \ drm_drv.o \ drm_sysfs.o drm_hashtab.o drm_mm.o \ drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o drm_displayid.o \
@@ -21,8 +21,8 @@ drm-y := drm_aperture.o drm_auth.o drm_cache.o \ drm_managed.o drm_vblank_work.o drm-$(CONFIG_DRM_LEGACY) += drm_agpsupport.o drm_bufs.o drm_context.o drm_dma.o \ - drm_legacy_misc.o drm_lock.o drm_memory.o drm_scatter.o \ - drm_vm.o + drm_irq.o drm_legacy_misc.o drm_lock.o drm_memory.o \ + drm_scatter.o drm_vm.o drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o drm-$(CONFIG_COMPAT) += drm_ioc32.o drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o
drivers/gpu/drm/drm_irq.c +0 -2
@@ -66,7 +66,6 @@#include "drm_internal.h" -#if IS_ENABLED (CONFIG_DRM_LEGACY )static int drm_legacy_irq_install (struct drm_device *dev,int irq) {int ret;
@@ -203,4 +202,3 @@ int drm_legacy_irq_control(struct drm_device *dev, void *data,return -EINVAL ; } } -#endif
Signature · 1 line
2.33.0
Thomas Zimmermann
maintainerPATCH 2/3 drm: Link several object files into drm_kms_helper.ko
In reply to Thomas ZimmermannSeveral core DRM functions are not used by the DRM core. Link the object files into the KMS helper library.
--- drivers/gpu/drm/Makefile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/drm/Makefile +5 -5
@@ -8,16 +8,15 @@ drm-y := drm_aperture.o drm_auth.o drm_cache.o \ drm_drv.o \ drm_sysfs.o drm_hashtab.o drm_mm.o \ drm_crtc.o drm_fourcc.o drm_modes.o drm_edid.o drm_displayid.o \ - drm_encoder_slave.o \ drm_trace_points.o drm_prime.o \ - drm_rect.o drm_vma_manager.o drm_flip_work.o \ + drm_vma_manager.o \ drm_modeset_lock.o drm_atomic.o drm_bridge.o \ drm_framebuffer.o drm_connector.o drm_blend.o \ drm_encoder.o drm_mode_object.o drm_property.o \ drm_plane.o drm_color_mgmt.o drm_print.o \ drm_dumb_buffers.o drm_mode_config.o drm_vblank.o \ drm_syncobj.o drm_lease.o drm_writeback.o drm_client.o \ - drm_client_modeset.o drm_atomic_uapi.o drm_hdcp.o \ + drm_client_modeset.o drm_atomic_uapi.o \ drm_managed.o drm_vblank_work.o drm-$(CONFIG_DRM_LEGACY) += drm_agpsupport.o drm_bufs.o drm_context.o drm_dma.o \
@@ -43,14 +42,15 @@ drm_ttm_helper-y := drm_gem_ttm_helper.o obj-$(CONFIG_DRM_TTM_HELPER) += drm_ttm_helper.o drm_kms_helper-y := drm_bridge_connector.o drm_crtc_helper.o drm_dp_helper.o \ - drm_dsc.o drm_probe_helper.o \ + drm_dsc.o drm_encoder_slave.o drm_flip_work.o drm_hdcp.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_atomic_helper.o \ drm_gem_framebuffer_helper.o \ drm_atomic_state_helper.o drm_damage_helper.o \ - drm_format_helper.o drm_self_refresh_helper.o + drm_format_helper.o drm_self_refresh_helper.o drm_rect.o drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o
Signature · 1 line
2.33.0
Thomas Zimmermann
maintainerPATCH 3/3 drm: Move GEM memory managers into modules
In reply to Thomas ZimmermannDRM core uses the GEM base object to access GEM functionality. It does not depend on individual implementations. Move the code into modules.
Also move the CMA framebuffer helpers into the CMA's module, as they're not usable without CMA.
--- drivers/gpu/drm/Kconfig | 4 ++-- drivers/gpu/drm/Makefile | 10 +++++++--- drivers/gpu/drm/drm_gem_cma_helper.c | 4 ++++ drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++++ 4 files changed, 17 insertions(+), 5 deletions(-)
drivers/gpu/drm/Kconfig +2 -2
@@ -212,7 +212,7 @@ config DRM_TTM_HELPER Helpers for ttm-based gem objects config DRM_GEM_CMA_HELPER - bool + tristate depends on DRM help Choose this if you need the GEM CMA helper functions
@@ -225,7 +225,7 @@ config DRM_KMS_CMA_HELPER Choose this if you need the KMS CMA helper functions config DRM_GEM_SHMEM_HELPER - bool + tristate depends on DRM && MMU help Choose this if you need the GEM shmem helper functions
drivers/gpu/drm/Makefile +7 -3
@@ -24,8 +24,6 @@ drm-$(CONFIG_DRM_LEGACY) += drm_agpsupport.o drm_bufs.o drm_context.o drm_dma.o drm_scatter.o drm_vm.o drm-$(CONFIG_DRM_LIB_RANDOM) += lib/drm_random.o drm-$(CONFIG_COMPAT) += drm_ioc32.o -drm-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_gem_cma_helper.o -drm-$(CONFIG_DRM_GEM_SHMEM_HELPER) += drm_gem_shmem_helper.o drm-$(CONFIG_DRM_PANEL) += drm_panel.o drm-$(CONFIG_OF) += drm_of.o drm-$(CONFIG_PCI) += drm_pci.o
@@ -35,6 +33,13 @@ drm-$(CONFIG_DRM_PRIVACY_SCREEN) += drm_privacy_screen.o drm_privacy_screen_x86. obj-$(CONFIG_DRM_DP_AUX_BUS) += drm_dp_aux_bus.o +drm_cma_helper-y := drm_gem_cma_helper.o +drm_cma_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o +obj-$(CONFIG_DRM_GEM_CMA_HELPER) += drm_cma_helper.o + +drm_shmem_helper-y := drm_gem_shmem_helper.o +obj-$(CONFIG_DRM_GEM_SHMEM_HELPER) += drm_shmem_helper.o + drm_vram_helper-y := drm_gem_vram_helper.o obj-$(CONFIG_DRM_VRAM_HELPER) += drm_vram_helper.o
@@ -54,7 +59,6 @@ drm_kms_helper-y := drm_bridge_connector.o drm_crtc_helper.o drm_dp_helper.o \ drm_kms_helper-$(CONFIG_DRM_PANEL_BRIDGE) += bridge/panel.o drm_kms_helper-$(CONFIG_DRM_FBDEV_EMULATION) += drm_fb_helper.o -drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o drm_kms_helper-$(CONFIG_DRM_DP_AUX_CHARDEV) += drm_dp_aux_dev.o drm_kms_helper-$(CONFIG_DRM_DP_CEC) += drm_dp_cec.o
drivers/gpu/drm/drm_gem_cma_helper.c +4 -0
@@ -13,6 +13,7 @@#include <linux/dma-mapping.h> #include <linux/export.h> #include <linux/mm.h> +#include <linux/module.h> #include <linux/mutex.h> #include <linux/slab.h>
@@ -578,3 +579,6 @@ drm_gem_cma_prime_import_sg_table_vmap(struct drm_device *dev,return obj; }EXPORT_SYMBOL (drm_gem_cma_prime_import_sg_table_vmap); + +MODULE_DESCRIPTION ("DRM CMA memory-management helpers" ); +MODULE_LICENSE ("GPL" );
drivers/gpu/drm/drm_gem_shmem_helper.c +4 -0
@@ -5,6 +5,7 @@#include <linux/dma-buf.h> #include <linux/export.h> +#include <linux/module.h> #include <linux/mutex.h> #include <linux/shmem_fs.h> #include <linux/slab.h>
@@ -774,3 +775,6 @@ drm_gem_shmem_prime_import_sg_table(struct drm_device *dev,return &shmem->base; }EXPORT_SYMBOL_GPL (drm_gem_shmem_prime_import_sg_table); + +MODULE_DESCRIPTION ("DRM SHMEM memory-management helpers" ); +MODULE_LICENSE ("GPL v2" );
Signature · 1 line
2.33.0
Quoted 7 lines · Thomas Zimmermann
Move a number of files into modules and behind config options.
So far, early boot graphics was provided by fbdev. With simpledrm, and possibly other generic DRM drivers, it's now possible to have general early-boot output with DRM. This requires the DRM core to be linked into the kernel binary image.
Quoted 7 lines
The reduction in size here is only ~1%, but the patchset is part of a larger effort to reduce the size of the DRM core module.
Thomas Zimmermann (3):
drm: Build drm_irq.o only ifCONFIG_DRM_LEGACYhas been set
drm: Link several object files into drm_kms_helper.ko
drm: Move GEM memory managers into modules
Assuming it all compiles still in all combos, on the series:
Quoted 11 lines
drivers/gpu/drm/Kconfig | 4 ++-- drivers/gpu/drm/Makefile | 26 +++++++++++++++----------- drivers/gpu/drm/drm_gem_cma_helper.c | 4 ++++ drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++++ drivers/gpu/drm/drm_irq.c | 2 -- 5 files changed, 25 insertions(+), 15 deletions(-)--
2.33.0
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Thomas Zimmermann
maintainerHi
Am 21.10.21 um 13:52 schrieb Daniel Vetter:
Quoted 11 lines · Thomas Zimmermann
Quoted 10 lines
Move a number of files into modules and behind config options.
So far, early boot graphics was provided by fbdev. With simpledrm, and possibly other generic DRM drivers, it's now possible to have general early-boot output with DRM. This requires the DRM core to be linked into the kernel binary image.
The reduction in size here is only ~1%, but the patchset is part of a larger effort to reduce the size of the DRM core module.
Quoted 8 lines
Quoted 4 lines
Thomas Zimmermann (3):
drm: Build drm_irq.o only ifCONFIG_DRM_LEGACYhas been set
drm: Link several object files into drm_kms_helper.ko
drm: Move GEM memory managers into modulesAssuming it all compiles still in all combos, on the series:
Acked-by Daniel Vetter <[email protected]>
Thanks for the A-b. I built with DRM_LEGACY set and unset.
The GEM changes shouldn't be affected by the config. With the CMA helpers in a separate module, we could maybe remove CONFIG_DRM_KMS_CMA_HELPER and link drm_fb_cma_helper.o if CONFIG_DRM_KMS_HELPER has been selected.
Best regards
Thomas
Quoted 12 lines
Quoted 11 lines
drivers/gpu/drm/Kconfig | 4 ++-- drivers/gpu/drm/Makefile | 26 +++++++++++++++----------- drivers/gpu/drm/drm_gem_cma_helper.c | 4 ++++ drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++++ drivers/gpu/drm/drm_irq.c | 2 -- 5 files changed, 25 insertions(+), 15 deletions(-)--
2.33.0
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
Quoted 9 lines · Thomas Zimmermann
Move a number of files into modules and behind config options.
So far, early boot graphics was provided by fbdev. With simpledrm, and possibly other generic DRM drivers, it's now possible to have general early-boot output with DRM. This requires the DRM core to be linked into the kernel binary image.
The reduction in size here is only ~1%, but the patchset is part of a larger effort to reduce the size of the DRM core module.
I think the main problem is really that of organization. You have all of the files under drivers/gpu/drm/ and the only way to know which module the files belong to is to look at the Makefile and the Kconfig. It's not obvious based on the file names or directory, at all. And there are nearly a hundred drm_*.c files there!
We also seem to have stuff depend on DRM alone, while functionally they should really depend on DRM_KMS_HELPER too.
The subdirectories under drm/ also don't have any distinction between being part of drm core and helpers or drivers. We have lib, scheduler, selftests, and ttm next to the drivers.
We should start adding drm_* subdirectories, and moving the modules separate from drm core there. We should rename the current non-driver directories drm_*. We need better structure.
BR,
Jani.
Quoted 16 lines
Thomas Zimmermann (3):
drm: Build drm_irq.o only ifCONFIG_DRM_LEGACYhas been set
drm: Link several object files into drm_kms_helper.ko
drm: Move GEM memory managers into modulesdrivers/gpu/drm/Kconfig | 4 ++-- drivers/gpu/drm/Makefile | 26 +++++++++++++++----------- drivers/gpu/drm/drm_gem_cma_helper.c | 4 ++++ drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++++ drivers/gpu/drm/drm_irq.c | 2 -- 5 files changed, 25 insertions(+), 15 deletions(-)--
2.33.0
Signature · 1 line
Jani Nikula, Intel Open Source Graphics Center
Thomas Zimmermann
maintainerHi
Am 21.10.21 um 14:38 schrieb Jani Nikula:
Quoted 11 lines · Thomas Zimmermann
Quoted 9 lines
Move a number of files into modules and behind config options.
So far, early boot graphics was provided by fbdev. With simpledrm, and possibly other generic DRM drivers, it's now possible to have general early-boot output with DRM. This requires the DRM core to be linked into the kernel binary image.
The reduction in size here is only ~1%, but the patchset is part of a larger effort to reduce the size of the DRM core module.
Quoted 8 lines
I think the main problem is really that of organization. You have all of the files under
drivers/gpu/drm/and the only way to know which module the files belong to is to look at theMakefileand theKconfig. It's not obvious based on the file names or directory, at all. And there are nearly a hundred drm_*.c files there!We also seem to have stuff depend on DRM alone, while functionally they should really depend on
DRM_KMS_HELPERtoo.
The point of my effort is to have a built-in simpledrm for early-boot graphics that requires only a minimal set of built-in dependency. Most of the 'advanced' features that native drivers use should go into modules. It's a bit unrealistic, but any progress is good.
Quoted 8 lines
The subdirectories under drm/ also don't have any distinction between being part of drm core and helpers or drivers. We have lib, scheduler, selftests, and ttm next to the drivers.
We should start adding drm_* subdirectories, and moving the modules separate from drm core there. We should rename the current non-driver directories drm_*. We need better structure.
Well, there are core functions and helpers. Often, both are in the same file and the core 'accidentally' pulls in helpers. For example, I found that the core connector automatically creates an EDID property and tries to fill in some values, which in turn pulls all the EDID parsing helpers. It would be nice to move the parsing code into a module, but it's not possible ATM.
For a start we could try to split files into core and helper code and link them into different modules.
Best regards
Thomas
Quoted 25 lines
BR,
Jani.Quoted 16 lines
Thomas Zimmermann (3):
drm: Build drm_irq.o only ifCONFIG_DRM_LEGACYhas been set
drm: Link several object files into drm_kms_helper.ko
drm: Move GEM memory managers into modulesdrivers/gpu/drm/Kconfig | 4 ++-- drivers/gpu/drm/Makefile | 26 +++++++++++++++----------- drivers/gpu/drm/drm_gem_cma_helper.c | 4 ++++ drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++++ drivers/gpu/drm/drm_irq.c | 2 -- 5 files changed, 25 insertions(+), 15 deletions(-)--
2.33.0
Signature · 6 lines
Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 Nürnberg, Germany (HRB 36809, AG Nürnberg) Geschäftsführer: Felix Imendörffer
Quoted 21 lines · Jani Nikula
Quoted 9 lines · Thomas Zimmermann
Move a number of files into modules and behind config options.
So far, early boot graphics was provided by fbdev. With simpledrm, and possibly other generic DRM drivers, it's now possible to have general early-boot output with DRM. This requires the DRM core to be linked into the kernel binary image.
The reduction in size here is only ~1%, but the patchset is part of a larger effort to reduce the size of the DRM core module.
I think the main problem is really that of organization. You have all of the files under
drivers/gpu/drm/and the only way to know which module the files belong to is to look at theMakefileand theKconfig. It's not obvious based on the file names or directory, at all. And there are nearly a hundred drm_*.c files there!We also seem to have stuff depend on DRM alone, while functionally they should really depend on
DRM_KMS_HELPERtoo.
Quoted 7 lines
The subdirectories under drm/ also don't have any distinction between being part of drm core and helpers or drivers. We have lib, scheduler, selftests, and ttm next to the drivers.
We should start adding drm_* subdirectories, and moving the modules separate from drm core there. We should rename the current non-driver directories drm_*. We need better structure.
Yeah it might be time for drm/core and drm/helpers or maybe even split-up helpers, dunno. drm/core probably needs to contain also all the legacy cruft since Kbuild doesn't support source files for the same module spread across directories (I think at least, or was that only meson?). Selftests might need to go with respective modules, not sure.
-Daniel
Quoted 27 lines
BR,
Jani.Quoted 13 lines
Thomas Zimmermann (3):
drm: Build drm_irq.o only ifCONFIG_DRM_LEGACYhas been set
drm: Link several object files into drm_kms_helper.ko
drm: Move GEM memory managers into modulesdrivers/gpu/drm/Kconfig | 4 ++-- drivers/gpu/drm/Makefile | 26 +++++++++++++++----------- drivers/gpu/drm/drm_gem_cma_helper.c | 4 ++++ drivers/gpu/drm/drm_gem_shmem_helper.c | 4 ++++ drivers/gpu/drm/drm_irq.c | 2 -- 5 files changed, 25 insertions(+), 15 deletions(-)Quoted 3 lines
--
2.33.0--
Jani Nikula, Intel Open Source Graphics Center
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch