Skip to contentSkip to conversation

drm/vkms: provide a parent device to drm_dev_init()

PATCH In review Emil Velikov 2 participants 3 messages Oct 26, 2018 – Oct 29, 2018

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

PATCH 1/1 drm/vkms: provide a parent device to drm_dev_init()

From: Emil Velikov <[email protected]>

Earlier commit updated the vgem driver to improve the topology, by passing a platform device as parent to drm_dev_init(). Shortly afterwords we updated the core function to BUG() in order to catch any buggy drivers passing NULL as parent.

While I missed the vkms driver (as the patch predates vkms by a few months), the BUG caught the issue within couple of hours.

Swap the drm_dev_init <> platform_device_register_simple order, to the driver back to life.

Fixes f08877e79485 ("drm: BUG_ON if passing NULL parent to drm_dev_init")
Cc Daniel Vetter <[email protected]>
Cc Deepak Sharma <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Sean Paul <[email protected]>
Cc Haneen Mohammed <[email protected]>
Cc Rodrigo Siqueira <[email protected]>

---
Rodrigo, Haneen, my plan is to push the patch to the drm-misc tree. An Ack/Rb will be appreciated.

Thanks
Emil

---
 drivers/gpu/drm/vkms/vkms_drv.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/vkms/vkms_drv.c +11 -10
index 07cfde1b4132..a3d57e0f5ee5 100644
@@ -108,17 +108,18 @@ static int __init vkms_init(void)
 	if (!vkms_device)
 		return -ENOMEM;
 
-	ret = drm_dev_init(&vkms_device->drm, &vkms_driver, NULL);
-	if (ret)
-		goto out_free;
-
 	vkms_device->platform =
 		platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
 	if (IS_ERR(vkms_device->platform)) {
 		ret = PTR_ERR(vkms_device->platform);
-		goto out_fini;
+		goto out_free;
 	}
 
+	ret = drm_dev_init(&vkms_device->drm, &vkms_driver,
+			   &vkms_device->platform->dev);
+	if (ret)
+		goto out_unregister;
+
 	vkms_device->drm.irq_enabled = true;
 
 	ret = drm_vblank_init(&vkms_device->drm, 1);
@@ -129,20 +130,20 @@ static int __init vkms_init(void)
 
 	ret = vkms_modeset_init(vkms_device);
 	if (ret)
-		goto out_unregister;
+		goto out_fini;
 
 	ret = drm_dev_register(&vkms_device->drm, 0);
 	if (ret)
-		goto out_unregister;
+		goto out_fini;
 
 	return 0;
 
-out_unregister:
-	platform_device_unregister(vkms_device->platform);
-
 out_fini:
 	drm_dev_fini(&vkms_device->drm);
 
+out_unregister:
+	platform_device_unregister(vkms_device->platform);
+
 out_free:
 	kfree(vkms_device);
 	return ret;
Signature · 6 lines
2.19.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines · Emil Velikov

From: Emil Velikov <[email protected]>

Earlier commit updated the vgem driver to improve the topology, by passing a platform device as parent to drm_dev_init(). Shortly afterwords we updated the core function to BUG() in order to catch any buggy drivers passing NULL as parent.

While I missed the vkms driver (as the patch predates vkms by a few months), the BUG caught the issue within couple of hours.

Swap the drm_dev_init <> platform_device_register_simple order, to the driver back to life.

Fixes f08877e79485 ("drm: BUG_ON if passing NULL parent to drm_dev_init")
Cc Daniel Vetter <[email protected]>
Cc Deepak Sharma <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Sean Paul <[email protected]>
Cc Haneen Mohammed <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Quoted 3 lines

---
Rodrigo, Haneen, my plan is to push the patch to the drm-misc tree. An Ack/Rb will be appreciated.

btw just read through this stuff again, and noticed how vgem is using drm_gem_prime_import_dev(). I think now that your patches have landed we could get rid of that?
-Daniel

Quoted 64 lines

Thanks
Emil

---
 drivers/gpu/drm/vkms/vkms_drv.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)
drivers/gpu/drm/vkms/vkms_drv.c +11 -10
index 07cfde1b4132..a3d57e0f5ee5 100644
@@ -108,17 +108,18 @@ static int __init vkms_init(void)
 	if (!vkms_device)
 		return -ENOMEM;
 
-	ret = drm_dev_init(&vkms_device->drm, &vkms_driver, NULL);
-	if (ret)
-		goto out_free;
-
 	vkms_device->platform =
 		platform_device_register_simple(DRIVER_NAME, -1, NULL, 0);
 	if (IS_ERR(vkms_device->platform)) {
 		ret = PTR_ERR(vkms_device->platform);
-		goto out_fini;
+		goto out_free;
 	}
 
+	ret = drm_dev_init(&vkms_device->drm, &vkms_driver,
+			   &vkms_device->platform->dev);
+	if (ret)
+		goto out_unregister;
+
 	vkms_device->drm.irq_enabled = true;
 
 	ret = drm_vblank_init(&vkms_device->drm, 1);
@@ -129,20 +130,20 @@ static int __init vkms_init(void)
 
 	ret = vkms_modeset_init(vkms_device);
 	if (ret)
-		goto out_unregister;
+		goto out_fini;
 
 	ret = drm_dev_register(&vkms_device->drm, 0);
 	if (ret)
-		goto out_unregister;
+		goto out_fini;
 
 	return 0;
 
-out_unregister:
-	platform_device_unregister(vkms_device->platform);
-
 out_fini:
 	drm_dev_fini(&vkms_device->drm);
 
+out_unregister:
+	platform_device_unregister(vkms_device->platform);
+
 out_free:
 	kfree(vkms_device);
 	return ret;
Signature · 1 line
2.19.1
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
Quoted 29 lines · Daniel Vetter
Quoted 23 lines · Emil Velikov

From: Emil Velikov <[email protected]>

Earlier commit updated the vgem driver to improve the topology, by passing a platform device as parent to drm_dev_init(). Shortly afterwords we updated the core function to BUG() in order to catch any buggy drivers passing NULL as parent.

While I missed the vkms driver (as the patch predates vkms by a few months), the BUG caught the issue within couple of hours.

Swap the drm_dev_init <> platform_device_register_simple order, to the driver back to life.

Fixes f08877e79485 ("drm: BUG_ON if passing NULL parent to drm_dev_init")
Cc Daniel Vetter <[email protected]>
Cc Deepak Sharma <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Sean Paul <[email protected]>
Cc Haneen Mohammed <[email protected]>
Cc Rodrigo Siqueira <[email protected]>
Quoted 3 lines

---
Rodrigo, Haneen, my plan is to push the patch to the drm-misc tree. An Ack/Rb will be appreciated.

Quoted 2 lines

Thanks, pushed via dim. Since this way breaking the 0day buildbot, I've decided to not wait too long.

Quoted 3 lines

btw just read through this stuff again, and noticed how vgem is using drm_gem_prime_import_dev(). I think now that your patches have landed we could get rid of that?

AFAICT the exynos is also using drm_gem_prime_import_dev. Having a slightly closer look, it uses a distinct component driver for DMA. One that varies across HW generation.

It should be doable to rework/remove that, since my knowledge in exynos is limited, I'd refrain for now.

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