Skip to contentSkip to conversation

drm/vkms: convert to use faux_device

PATCH In review Greg Kroah-Hartman 2 participants 2 messages Jul 1, 2025 – Jul 2, 2025

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

PATCH v5 1/1 drm/vkms: convert to use faux_device

The vkms driver does not need to create a platform device, as there is no real platform resources associated it, it only did so because it was simple to do that in order to get a device to use for resource management of drm resources. Change the driver to use the faux device instead as this is NOT a real platform device.

---
v5: - rebased against 6.16-rc4
- added reviewed-by and tested-by lines
- was somehow dropped from drm trees, resending to make sure it isn't lost

v4: - first version of the patch, was part of a larger patch series that
has been mostly all applied to the tree.

 drivers/gpu/drm/vkms/vkms_drv.c | 28 ++++++++++++++--------------
 drivers/gpu/drm/vkms/vkms_drv.h |  4 ++--
 2 files changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/vkms/vkms_drv.c +14 -14
index a24d1655f7b8..e8472d9b6e3b 100644
@@ -10,7 +10,7 @@
  */
 
 #include <linux/module.h>
-#include <linux/platform_device.h>
+#include <linux/device/faux.h>
 #include <linux/dma-mapping.h>
 
 #include <drm/clients/drm_client_setup.h>
@@ -149,27 +149,27 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev)
 static int vkms_create(struct vkms_config *config)
 {
 	int ret;
-	struct platform_device *pdev;
+	struct faux_device *fdev;
 	struct vkms_device *vkms_device;
 	const char *dev_name;
 
 	dev_name = vkms_config_get_device_name(config);
-	pdev = platform_device_register_simple(dev_name, -1, NULL, 0);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
+	fdev = faux_device_create(dev_name, NULL, NULL);
+	if (!fdev)
+		return -ENODEV;
 
-	if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) {
+	if (!devres_open_group(&fdev->dev, NULL, GFP_KERNEL)) {
 		ret = -ENOMEM;
 		goto out_unregister;
 	}
 
-	vkms_device = devm_drm_dev_alloc(&pdev->dev, &vkms_driver,
+	vkms_device = devm_drm_dev_alloc(&fdev->dev, &vkms_driver,
 					 struct vkms_device, drm);
 	if (IS_ERR(vkms_device)) {
 		ret = PTR_ERR(vkms_device);
 		goto out_devres;
 	}
-	vkms_device->platform = pdev;
+	vkms_device->faux_dev = fdev;
 	vkms_device->config = config;
 	config->dev = vkms_device;
 
@@ -203,9 +203,9 @@ static int vkms_create(struct vkms_config *config)
 	return 0;
 
 out_devres:
-	devres_release_group(&pdev->dev, NULL);
+	devres_release_group(&fdev->dev, NULL);
 out_unregister:
-	platform_device_unregister(pdev);
+	faux_device_destroy(fdev);
 	return ret;
 }
 
@@ -231,19 +231,19 @@ static int __init vkms_init(void)
 
 static void vkms_destroy(struct vkms_config *config)
 {
-	struct platform_device *pdev;
+	struct faux_device *fdev;
 
 	if (!config->dev) {
 		DRM_INFO("vkms_device is NULL.\n");
 		return;
 	}
 
-	pdev = config->dev->platform;
+	fdev = config->dev->faux_dev;
 
 	drm_dev_unregister(&config->dev->drm);
 	drm_atomic_helper_shutdown(&config->dev->drm);
-	devres_release_group(&pdev->dev, NULL);
-	platform_device_unregister(pdev);
+	devres_release_group(&fdev->dev, NULL);
+	faux_device_destroy(fdev);
 
 	config->dev = NULL;
 }
drivers/gpu/drm/vkms/vkms_drv.h +2 -2
index a74a7fc3a056..5a46016e1890 100644
@@ -197,13 +197,13 @@ struct vkms_config;
  * struct vkms_device - Description of a VKMS device
  *
  * @drm - Base device in DRM
- * @platform - Associated platform device
+ * @faux_dev - Associated faux device
  * @output - Configuration and sub-components of the VKMS device
  * @config: Configuration used in this VKMS device
  */
 struct vkms_device {
 	struct drm_device drm;
-	struct platform_device *platform;
+	struct faux_device *faux_dev;
 	const struct vkms_config *config;
 };
 
Signature · 1 line
2.50.0
#1 lore raw

Hi

Am 01.07.25 um 12:49 schrieb Greg Kroah-Hartman:

Quoted 18 lines

The vkms driver does not need to create a platform device, as there is no real platform resources associated it, it only did so because it was simple to do that in order to get a device to use for resource management of drm resources. Change the driver to use the faux device instead as this is NOT a real platform device.

Quoted 5 lines

---
v5: - rebased against 6.16-rc4
- added reviewed-by and tested-by lines
- was somehow dropped from drm trees, resending to make sure it isn't lost

Also see my comment in the vgem change. The patches will go in soon after "drm/gem-shmem: Do not map s/g table by default". [1] Thanks for the update.

Best regards
Thomas

[1] https://patchwork.freedesktop.org/series/150968/

Quoted 112 lines

v4: - first version of the patch, was part of a larger patch series that
has been mostly all applied to the tree.

  drivers/gpu/drm/vkms/vkms_drv.c | 28 ++++++++++++++--------------
  drivers/gpu/drm/vkms/vkms_drv.h |  4 ++--
  2 files changed, 16 insertions(+), 16 deletions(-)
drivers/gpu/drm/vkms/vkms_drv.c +14 -14
index a24d1655f7b8..e8472d9b6e3b 100644
@@ -10,7 +10,7 @@
   */
 
  #include <linux/module.h>
-#include <linux/platform_device.h>
+#include <linux/device/faux.h>
  #include <linux/dma-mapping.h>
 
  #include <drm/clients/drm_client_setup.h>
@@ -149,27 +149,27 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev)
  static int vkms_create(struct vkms_config *config)
  {
  	int ret;
-	struct platform_device *pdev;
+	struct faux_device *fdev;
  	struct vkms_device *vkms_device;
  	const char *dev_name;
 
  	dev_name = vkms_config_get_device_name(config);
-	pdev = platform_device_register_simple(dev_name, -1, NULL, 0);
-	if (IS_ERR(pdev))
-		return PTR_ERR(pdev);
+	fdev = faux_device_create(dev_name, NULL, NULL);
+	if (!fdev)
+		return -ENODEV;
 
-	if (!devres_open_group(&pdev->dev, NULL, GFP_KERNEL)) {
+	if (!devres_open_group(&fdev->dev, NULL, GFP_KERNEL)) {
  		ret = -ENOMEM;
  		goto out_unregister;
  	}
 
-	vkms_device = devm_drm_dev_alloc(&pdev->dev, &vkms_driver,
+	vkms_device = devm_drm_dev_alloc(&fdev->dev, &vkms_driver,
  					 struct vkms_device, drm);
  	if (IS_ERR(vkms_device)) {
  		ret = PTR_ERR(vkms_device);
  		goto out_devres;
  	}
-	vkms_device->platform = pdev;
+	vkms_device->faux_dev = fdev;
  	vkms_device->config = config;
  	config->dev = vkms_device;
 
@@ -203,9 +203,9 @@ static int vkms_create(struct vkms_config *config)
  	return 0;
 
  out_devres:
-	devres_release_group(&pdev->dev, NULL);
+	devres_release_group(&fdev->dev, NULL);
  out_unregister:
-	platform_device_unregister(pdev);
+	faux_device_destroy(fdev);
  	return ret;
  }
 
@@ -231,19 +231,19 @@ static int __init vkms_init(void)
 
  static void vkms_destroy(struct vkms_config *config)
  {
-	struct platform_device *pdev;
+	struct faux_device *fdev;
 
  	if (!config->dev) {
  		DRM_INFO("vkms_device is NULL.\n");
  		return;
  	}
 
-	pdev = config->dev->platform;
+	fdev = config->dev->faux_dev;
 
  	drm_dev_unregister(&config->dev->drm);
  	drm_atomic_helper_shutdown(&config->dev->drm);
-	devres_release_group(&pdev->dev, NULL);
-	platform_device_unregister(pdev);
+	devres_release_group(&fdev->dev, NULL);
+	faux_device_destroy(fdev);
 
  	config->dev = NULL;
  }
drivers/gpu/drm/vkms/vkms_drv.h +2 -2
index a74a7fc3a056..5a46016e1890 100644
@@ -197,13 +197,13 @@ struct vkms_config;
   * struct vkms_device - Description of a VKMS device
   *
   * @drm - Base device in DRM
- * @platform - Associated platform device
+ * @faux_dev - Associated faux device
   * @output - Configuration and sub-components of the VKMS device
   * @config: Configuration used in this VKMS device
   */
  struct vkms_device {
  	struct drm_device drm;
-	struct platform_device *platform;
+	struct faux_device *faux_dev;
  	const struct vkms_config *config;
  };
 
Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)