drm: Make drivers to honour the nomodeset parameter
Subsystems (12)
v3 cover drm: Make drivers to honour the nomodeset parameter
The nomodeset kernel command line parameter is used to prevent the KMS/DRM drivers to be registered/probed. But only a few drivers implement support for this and most DRM drivers just ignore it.
This patch series is a v3 to make DRM drivers to honour nomodeset. It is posted as separate patches to make easier for drivers maintainers to ack or pick them independently at their own pace.
The drm_module_{pci,platform}_driver() helper macros are added, which are just wrappers around module_{pci,platform}_driver() but adding a check for drm_firmware_drivers_only() and returning -ENODEV if that is true.
PCI and platform DRM drivers are then modified in the following patches to make use of those macros.
Only KMS drivers will be ported to use these new macros, and only for PCI and platform DRM drivers. A follow-up series might do the same for drivers that are rendering-only and for USB/SPI/I2C devices, but it will need more discussion to agree whether that's desirable or not.
Not all drivers were posted in v3 to avoid flooding the list with too many patches. I'm only including the patches adding the macros and some patches as an example of their usage.
I've built tested with 'make allmodconfig && make M=drivers/gpu/drm' but I don't have hardware to test the drivers, so review/testing is appreciated.
Best regards,
Javier
Changes in v3:
- Include Thomas Zimmermann's patches in the series and rebase on top.
- Add collected Acked-by tags from v2.
Changes in v2:
- Add drm_module_{pci,platform}_driver() macros and put the check there (Thomas Zimmermann).
- Use the drm_module_*_driver() macros if possible (Thomas Zimmermann).
- Leave the DRM drivers that don't set the DRIVER_MODESET driver feature (Lucas Stach).
- Leave USB/SPI/I2C drivers and only include PCI and platform ones (Noralf Trønnes).
- Add collected Reviewed-by tags
Javier Martinez Canillas (5):
drm: Provide platform module-init macro drm/imx/dcss: Replace module initialization with DRM helpers drm/komeda: Replace module initialization with DRM helpers drm/arm/hdlcd: Replace module initialization with DRM helpers drm/malidp: Replace module initialization with DRM helpers
Thomas Zimmermann (5):
drm: Provide PCI module-init macros
drm/ast: Replace module-init boiler-plate code with DRM helpers drm/bochs: Replace module-init boiler-plate code with DRM helpers drm/cirrus: Replace module-init boiler-plate code with DRM helpers drm/hisilicon/hibmc: Replace module initialization with DRM helpers
Documentation/gpu/drm-internals.rst | 6 + .../gpu/drm/arm/display/komeda/komeda_drv.c | 3 +- drivers/gpu/drm/arm/hdlcd_drv.c | 3 +- drivers/gpu/drm/arm/malidp_drv.c | 3 +- drivers/gpu/drm/ast/ast_drv.c | 18 +-- .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 3 +- drivers/gpu/drm/imx/dcss/dcss-drv.c | 3 +- drivers/gpu/drm/tiny/bochs.c | 20 +-- drivers/gpu/drm/tiny/cirrus.c | 17 +-- include/drm/drm_module.h | 125 ++++++++++++++++++ 10 files changed, 147 insertions(+), 54 deletions(-) create mode 100644 include/drm/drm_module.h
Signature · 1 line
2.33.1
PATCH v3 1/10 drm: Provide PCI module-init macros
From: Thomas Zimmermann <[email protected]>
Provide helper macros to register PCI-based DRM drivers. The new macros behave like module_pci_driver() with an additional test if DRM modesetting has been enabled.
---
(no changes since v1)
Documentation/gpu/drm-internals.rst | 6 ++ include/drm/drm_module.h | 95 +++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 include/drm/drm_module.h
Documentation/gpu/drm-internals.rst +6 -0
@@ -75,6 +75,12 @@ update it, its value is mostly useless. The DRM core prints it to the kernel log at initialization time and passes it to userspace through the DRM_IOCTL_VERSION ioctl. +Module Initialization +--------------------- + +.. kernel-doc:: include/drm/drm_module.h + :doc: overview + Managing Ownership of the Framebuffer Aperture ----------------------------------------------
include/drm/drm_module.h new file +95 -0
95 lines not on this page · raw message
Signature · 1 line
2.33.1
PATCH v3 2/10 drm/ast: Replace module-init boiler-plate code with DRM helpers
In reply to Javier Martinez CanillasFrom: Thomas Zimmermann <[email protected]>
Remove custom ast_init() and ast_exit() functions and initialize the module with DRM module helpers.
---
(no changes since v1)
drivers/gpu/drm/ast/ast_drv.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
drivers/gpu/drm/ast/ast_drv.c +2 -16
@@ -34,6 +34,7 @@#include <drm/drm_crtc_helper.h> #include <drm/drm_drv.h> #include <drm/drm_gem_vram_helper.h> +#include <drm/drm_module.h> #include <drm/drm_probe_helper.h> #include "ast_drv.h"
@@ -230,22 +231,7 @@ static struct pci_driver ast_pci_driver = { .driver.pm = &ast_pm_ops, }; -static int __init ast_init (void ) -{ -if (drm_firmware_drivers_only () && ast_modeset ==-1 ) -return -EINVAL ; - -if (ast_modeset ==0 ) -return -EINVAL ; -return pci_register_driver (&ast_pci_driver); -} -static void __exit ast_exit(void) -{ -pci_unregister_driver (&ast_pci_driver); -} - -module_init (ast_init); -module_exit (ast_exit); +drm_module_pci_driver_if_modeset (ast_pci_driver, ast_modeset);MODULE_AUTHOR (DRIVER_AUTHOR );MODULE_DESCRIPTION (DRIVER_DESC );
Signature · 1 line
2.33.1
PATCH v3 3/10 drm/bochs: Replace module-init boiler-plate code with DRM helpers
In reply to Javier Martinez CanillasFrom: Thomas Zimmermann <[email protected]>
Remove custom bochs_init() and bochs_exit() functions and initialize the module with DRM module helpers.
---
(no changes since v1)
drivers/gpu/drm/tiny/bochs.c | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-)
drivers/gpu/drm/tiny/bochs.c +2 -18
@@ -10,6 +10,7 @@#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_gem_vram_helper.h> #include <drm/drm_managed.h> +#include <drm/drm_module.h> #include <drm/drm_probe_helper.h> #include <drm/drm_simple_kms_helper.h>
@@ -716,24 +717,7 @@ static struct pci_driver bochs_pci_driver = {/* ---------------------------------------------------------------------- */ /* module init/exit */ -static int __init bochs_init (void ) -{ -if (drm_firmware_drivers_only () && bochs_modeset ==-1 ) -return -EINVAL ; - -if (bochs_modeset ==0 ) -return -EINVAL ; - -return pci_register_driver (&bochs_pci_driver); -} - -static void __exit bochs_exit(void) -{ -pci_unregister_driver (&bochs_pci_driver); -} - -module_init (bochs_init); -module_exit (bochs_exit); +drm_module_pci_driver_if_modeset (bochs_pci_driver, bochs_modeset);MODULE_DEVICE_TABLE (pci, bochs_pci_tbl);MODULE_AUTHOR ("Gerd Hoffmann <[email protected]>" );
Signature · 1 line
2.33.1
Gerd Hoffmann
maintainerRe: [PATCH v3 03/10] drm/bochs: Replace module-init boiler-plate code with DRM helpers
drivers/gpu/drm/tiny/bochs.c static struct pci_driver bochs_pci_driver = { · line 722
Quoted 4 lines · Javier Martinez Canillas
drivers/gpu/drm/tiny/bochs.c +0
-4-static int __init bochs_init (void ) -{ -if (drm_firmware_drivers_only () && bochs_modeset ==-1 ) -return -EINVAL ;
Also cleanup bochs_modeset? I guess its not used any more after this patch ...
take care,
Gerd
Re: [PATCH v3 03/10] drm/bochs: Replace module-init boiler-plate code with DRM helpers
Hello Gerd,
Quoted 9 lines · Gerd Hoffmann
drivers/gpu/drm/tiny/bochs.c static struct pci_driver bochs_pci_driver = { · line 722
Quoted 4 lines · Javier Martinez Canillas
drivers/gpu/drm/tiny/bochs.c +0
-4-static int __init bochs_init (void ) -{ -if (drm_firmware_drivers_only () && bochs_modeset ==-1 ) -return -EINVAL ;Also cleanup
bochs_modeset? I guess its not used any more after this patch ...
That's still used. It is passed as an argument to the macro:
drm_module_pci_driver_if_modeset(bochs_pci_driver, bochs_modeset);
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
PATCH v3 4/10 drm/cirrus: Replace module-init boiler-plate code with DRM helpers
In reply to Javier Martinez CanillasFrom: Thomas Zimmermann <[email protected]>
Remove custom cirrus_init() and cirrus_exit() functions and initialize the module with DRM module helpers.
---
(no changes since v1)
drivers/gpu/drm/tiny/cirrus.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-)
drivers/gpu/drm/tiny/cirrus.c +2 -15
@@ -39,6 +39,7 @@#include <drm/drm_ioctl.h> #include <drm/drm_managed.h> #include <drm/drm_modeset_helper_vtables.h> +#include <drm/drm_module.h> #include <drm/drm_probe_helper.h> #include <drm/drm_simple_kms_helper.h>
@@ -633,21 +634,7 @@ static struct pci_driver cirrus_pci_driver = { .remove = cirrus_pci_remove, }; -static int __init cirrus_init (void ) -{ -if (drm_firmware_drivers_only ()) -return -EINVAL ; - -return pci_register_driver (&cirrus_pci_driver); -} - -static void __exit cirrus_exit(void) -{ -pci_unregister_driver (&cirrus_pci_driver); -} - -module_init (cirrus_init); -module_exit (cirrus_exit); +drm_module_pci_driver (cirrus_pci_driver)MODULE_DEVICE_TABLE (pci, pciidlist);MODULE_LICENSE ("GPL" );
Signature · 1 line
2.33.1
PATCH v3 5/10 drm/hisilicon/hibmc: Replace module initialization with DRM helpers
In reply to Javier Martinez CanillasFrom: Thomas Zimmermann <[email protected]>
Replace module_pci_driver() with drm_module_pci_driver(). The DRM macro respects drm_firmware_drivers_only() and fails if the flag has been set.
---
(no changes since v1)
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c +2 -1
@@ -20,6 +20,7 @@#include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_gem_vram_helper.h> #include <drm/drm_managed.h> +#include <drm/drm_module.h> #include <drm/drm_vblank.h> #include "hibmc_drm_drv.h"
@@ -379,7 +380,7 @@ static struct pci_driver hibmc_pci_driver = { .driver.pm = &hibmc_pm_ops, }; -module_pci_driver (hibmc_pci_driver); +drm_module_pci_driver (hibmc_pci_driver);MODULE_DEVICE_TABLE (pci, hibmc_pci_table);MODULE_AUTHOR ("RongrongZou <[email protected]>" );
Signature · 1 line
2.33.1
PATCH v3 6/10 drm: Provide platform module-init macro
In reply to Javier Martinez CanillasProvide a helper macro to register platform DRM drivers. The new macro behaves like module_platform_driver() with an additional test if DRM modesetting has been enabled.
---
(no changes since v1)
include/drm/drm_module.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
include/drm/drm_module.h +30 -0
@@ -4,6 +4,7 @@#define DRM_MODULE_H #include <linux/pci.h> +#include <linux/platform_device.h> #include <drm/drm_drv.h>
@@ -92,4 +93,33 @@ drm_pci_unregister_driver_if_modeset(struct pci_driver *pci_drv, int modeset)module_driver (__pci_drv, drm_pci_register_driver_if_modeset, \ drm_pci_unregister_driver_if_modeset, __modeset) +/* +* Platform drivers + */ + +static inline int __init +drm_platform_driver_register (struct platform_driver *platform_drv) +{ +if (drm_firmware_drivers_only ()) +return -ENODEV ; + +return platform_driver_register (platform_drv); +} + +/** +* drm_module_platform_driver - Register a DRM driver for platform devices +* @__platform_drv: the platform driver structure +* +* Registers a DRM driver for devices on the platform bus. The helper +* macro behaves like module_platform_driver() but tests the state of +* drm_firmware_drivers_only(). For more complex module initialization, +* use module_init() and module_exit() directly. +* +* Each module may only use this macro once. Calling it replaces +* module_init() and module_exit(). +*/ +#define drm_module_platform_driver (__platform_drv) \ + module_driver(__platform_drv, drm_platform_driver_register, \ + platform_driver_unregister) +#endif
Signature · 1 line
2.33.1
PATCH v3 7/10 drm/imx/dcss: Replace module initialization with DRM helpers
In reply to Javier Martinez CanillasReplace module_platform_driver() with drm_module_platform_driver(). The DRM macro respects drm_firmware_drivers_only() and fails if the flag has been set.
---
(no changes since v1)
drivers/gpu/drm/imx/dcss/dcss-drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/imx/dcss/dcss-drv.c +2 -1
@@ -6,6 +6,7 @@#include <linux/module.h> #include <linux/kernel.h> #include <linux/platform_device.h> +#include <drm/drm_module.h> #include <drm/drm_of.h> #include "dcss-dev.h"
@@ -131,7 +132,7 @@ static struct platform_driver dcss_platform_driver = { }, }; -module_platform_driver (dcss_platform_driver); +drm_module_platform_driver (dcss_platform_driver);MODULE_AUTHOR ("Laurentiu Palcu <[email protected]>" );MODULE_DESCRIPTION ("DCSS driver for i.MX8MQ" );
Signature · 1 line
2.33.1
PATCH v3 8/10 drm/komeda: Replace module initialization with DRM helpers
In reply to Javier Martinez CanillasReplace module_platform_driver() with drm_module_platform_driver(). The DRM macro respects drm_firmware_drivers_only() and fails if the flag has been set.
---
(no changes since v1)
drivers/gpu/drm/arm/display/komeda/komeda_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/arm/display/komeda/komeda_drv.c +2 -1
@@ -9,6 +9,7 @@#include <linux/platform_device.h> #include <linux/component.h> #include <linux/pm_runtime.h> +#include <drm/drm_module.h> #include <drm/drm_of.h> #include "komeda_dev.h" #include "komeda_kms.h"
@@ -198,7 +199,7 @@ static struct platform_driver komeda_platform_driver = { }, }; -module_platform_driver (komeda_platform_driver); +drm_module_platform_driver (komeda_platform_driver);MODULE_AUTHOR ("James.Qian.Wang <[email protected]>" );MODULE_DESCRIPTION ("Komeda KMS driver" );
Signature · 1 line
2.33.1
PATCH v3 9/10 drm/arm/hdlcd: Replace module initialization with DRM helpers
In reply to Javier Martinez CanillasReplace module_platform_driver() with drm_module_platform_driver(). The DRM macro respects drm_firmware_drivers_only() and fails if the flag has been set.
---
(no changes since v1)
drivers/gpu/drm/arm/hdlcd_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/arm/hdlcd_drv.c +2 -1
@@ -30,6 +30,7 @@#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h> +#include <drm/drm_module.h> #include <drm/drm_of.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h>
@@ -434,7 +435,7 @@ static struct platform_driver hdlcd_platform_driver = { }, }; -module_platform_driver (hdlcd_platform_driver); +drm_module_platform_driver (hdlcd_platform_driver);MODULE_AUTHOR ("Liviu Dudau" );MODULE_DESCRIPTION ("ARM HDLCD DRM driver" );
Signature · 1 line
2.33.1
PATCH v3 10/10 drm/malidp: Replace module initialization with DRM helpers
In reply to Javier Martinez CanillasReplace module_platform_driver() with drm_module_platform_driver(). The DRM macro respects drm_firmware_drivers_only() and fails if the flag has been set.
---
(no changes since v1)
drivers/gpu/drm/arm/malidp_drv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/arm/malidp_drv.c +2 -1
@@ -25,6 +25,7 @@#include <drm/drm_gem_cma_helper.h> #include <drm/drm_gem_framebuffer_helper.h> #include <drm/drm_modeset_helper.h> +#include <drm/drm_module.h> #include <drm/drm_of.h> #include <drm/drm_probe_helper.h> #include <drm/drm_vblank.h>
@@ -1008,7 +1009,7 @@ static struct platform_driver malidp_platform_driver = { }, }; -module_platform_driver (malidp_platform_driver); +drm_module_platform_driver (malidp_platform_driver);MODULE_AUTHOR ("Liviu Dudau <[email protected]>" );MODULE_DESCRIPTION ("ARM Mali DP DRM driver" );
Signature · 1 line
2.33.1
Hi
patches 6 to 10 are
Best regards
Thomas
Am 22.12.21 um 09:28 schrieb Javier Martinez Canillas:
Quoted 71 lines
The nomodeset kernel command line parameter is used to prevent the KMS/DRM drivers to be registered/probed. But only a few drivers implement support for this and most DRM drivers just ignore it.
This patch series is a v3 to make DRM drivers to honour nomodeset. It is posted as separate patches to make easier for drivers maintainers to ack or pick them independently at their own pace.
The drm_module_{pci,platform}_driver() helper macros are added, which are just wrappers around module_{pci,platform}_driver() but adding a check for
drm_firmware_drivers_only()and returning-ENODEVif that is true.PCI and platform DRM drivers are then modified in the following patches to make use of those macros.
Only KMS drivers will be ported to use these new macros, and only for PCI and platform DRM drivers. A follow-up series might do the same for drivers that are rendering-only and for USB/SPI/I2C devices, but it will need more discussion to agree whether that's desirable or not.
Not all drivers were posted in v3 to avoid flooding the list with too many patches. I'm only including the patches adding the macros and some patches as an example of their usage.
I've built tested with 'make allmodconfig && make M=drivers/gpu/drm' but I don't have hardware to test the drivers, so review/testing is appreciated.
Best regards,
JavierChanges in v3:
- Include Thomas Zimmermann's patches in the series and rebase on top.
- Add collected Acked-by tags from v2.Changes in v2:
- Add drm_module_{pci,platform}_driver() macros and put the check there (Thomas Zimmermann).
- Use the drm_module_*_driver() macros if possible (Thomas Zimmermann).
- Leave the DRM drivers that don't set theDRIVER_MODESETdriver feature (Lucas Stach).
- Leave USB/SPI/I2C drivers and only include PCI and platform ones (Noralf Trønnes).
- Add collected Reviewed-by tagsJavier Martinez Canillas (5):
drm: Provide platform module-init macro drm/imx/dcss: Replace module initialization with DRM helpers drm/komeda: Replace module initialization with DRM helpers drm/arm/hdlcd: Replace module initialization with DRM helpers drm/malidp: Replace module initialization with DRM helpersThomas Zimmermann (5):
drm: Provide PCI module-init macros
drm/ast: Replace module-init boiler-plate code with DRM helpers drm/bochs: Replace module-init boiler-plate code with DRM helpers drm/cirrus: Replace module-init boiler-plate code with DRM helpers drm/hisilicon/hibmc: Replace module initialization with DRM helpersDocumentation/gpu/drm-internals.rst | 6 + .../gpu/drm/arm/display/komeda/komeda_drv.c | 3 +- drivers/gpu/drm/arm/hdlcd_drv.c | 3 +- drivers/gpu/drm/arm/malidp_drv.c | 3 +- drivers/gpu/drm/ast/ast_drv.c | 18 +-- .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 3 +- drivers/gpu/drm/imx/dcss/dcss-drv.c | 3 +- drivers/gpu/drm/tiny/bochs.c | 20 +-- drivers/gpu/drm/tiny/cirrus.c | 17 +-- include/drm/drm_module.h | 125 ++++++++++++++++++ 10 files changed, 147 insertions(+), 54 deletions(-)create mode 100644
include/drm/drm_module.h
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: Ivo Totev
Quoted 8 lines · Javier Martinez Canillas
The nomodeset kernel command line parameter is used to prevent the KMS/DRM drivers to be registered/probed. But only a few drivers implement support for this and most DRM drivers just ignore it.
This patch series is a v3 to make DRM drivers to honour nomodeset. It is posted as separate patches to make easier for drivers maintainers to ack or pick them independently at their own pace.
[snip]
Quoted 8 lines
Thomas Zimmermann (5):
drm: Provide PCI module-init macros
drm/ast: Replace module-init boiler-plate code with DRM helpers drm/bochs: Replace module-init boiler-plate code with DRM helpers drm/cirrus: Replace module-init boiler-plate code with DRM helpers drm/hisilicon/hibmc: Replace module initialization with DRM helpers
For Thomas' patches (1-5)
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat
Quoted 8 lines · Javier Martinez Canillas
The nomodeset kernel command line parameter is used to prevent the KMS/DRM drivers to be registered/probed. But only a few drivers implement support for this and most DRM drivers just ignore it.
This patch series is a v3 to make DRM drivers to honour nomodeset. It is posted as separate patches to make easier for drivers maintainers to ack or pick them independently at their own pace.
I've pushed this series to drm-misc-next.
Best regards,
Signature · 3 lines
Javier Martinez Canillas Linux Engineering Red Hat