Skip to contentSkip to conversation

drm/vgem: Fix vgem_init to get drm device avaliable.

PATCH In review Deepak Sharma 3 participants 8 messages Oct 25, 2017 – Nov 20, 2017

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

PATCH 1/1 drm/vgem: Fix vgem_init to get drm device avaliable.

From: Deepak Sharma <[email protected]>

Modify vgem_init to take platform dev as parent in drm_dev_init. This will make drm device available at "/sys/devices/platform/vgem" in x86 chromebook.

---
 drivers/gpu/drm/vgem/vgem_drv.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/vgem/vgem_drv.c +7 -8
index c938af8c40cf..17e2eafc62b8 100644
@@ -471,31 +471,30 @@ static int __init vgem_init(void)
 	if (!vgem_device)
 		return -ENOMEM;
 
-	ret = drm_dev_init(&vgem_device->drm, &vgem_driver, NULL);
-	if (ret)
-		goto out_free;
-
 	vgem_device->platform =
 		platform_device_register_simple("vgem", -1, NULL, 0);
 	if (IS_ERR(vgem_device->platform)) {
 		ret = PTR_ERR(vgem_device->platform);
-		goto out_fini;
+		goto out_free;
 	}
 
 	dma_coerce_mask_and_coherent(&vgem_device->platform->dev,
 				     DMA_BIT_MASK(64));
+	ret = drm_dev_init(&vgem_device->drm, &vgem_driver, &vgem_device->platform->dev);
+	if (ret)
+		goto out_unregister;
 
 	/* Final step: expose the device/driver to userspace */
 	ret  = drm_dev_register(&vgem_device->drm, 0);
 	if (ret)
-		goto out_unregister;
+		goto out_fini;
 
 	return 0;
 
-out_unregister:
-	platform_device_unregister(vgem_device->platform);
 out_fini:
 	drm_dev_fini(&vgem_device->drm);
+out_unregister:
+	platform_device_unregister(vgem_device->platform);
 out_free:
 	kfree(vgem_device);
 	return ret;
Signature · 6 lines
2.14.2

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

From: Deepak Sharma <[email protected]>

Modify vgem_init to take platform dev as parent in drm_dev_init. This will make drm device available at "/sys/devices/platform/vgem" in x86 chromebook.

Quoted 54 lines
---
 drivers/gpu/drm/vgem/vgem_drv.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/gpu/drm/vgem/vgem_drv.c +7 -8
index c938af8c40cf..17e2eafc62b8 100644
@@ -471,31 +471,30 @@ static int __init vgem_init(void)
 	if (!vgem_device)
 		return -ENOMEM;
 
-	ret = drm_dev_init(&vgem_device->drm, &vgem_driver, NULL);
-	if (ret)
-		goto out_free;
-
 	vgem_device->platform =
 		platform_device_register_simple("vgem", -1, NULL, 0);
 	if (IS_ERR(vgem_device->platform)) {
 		ret = PTR_ERR(vgem_device->platform);
-		goto out_fini;
+		goto out_free;
 	}
 
 	dma_coerce_mask_and_coherent(&vgem_device->platform->dev,
 				     DMA_BIT_MASK(64));
+	ret = drm_dev_init(&vgem_device->drm, &vgem_driver, &vgem_device->platform->dev);
+	if (ret)
+		goto out_unregister;
 
 	/* Final step: expose the device/driver to userspace */
 	ret  = drm_dev_register(&vgem_device->drm, 0);
 	if (ret)
-		goto out_unregister;
+		goto out_fini;
 
 	return 0;
 
-out_unregister:
-	platform_device_unregister(vgem_device->platform);
 out_fini:
 	drm_dev_fini(&vgem_device->drm);
+out_unregister:
+	platform_device_unregister(vgem_device->platform);
 out_free:
 	kfree(vgem_device);
 	return ret;
Signature · 6 lines
2.14.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 5 lines
Sean Paul, Software Engineer, Google / Chromium OS
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
#2 lore raw
In reply to Deepak Sharma
Quoted 6 lines · Deepak Sharma

From: Deepak Sharma <[email protected]>

Modify vgem_init to take platform dev as parent in drm_dev_init. This will make drm device available at "/sys/devices/platform/vgem" in x86 chromebook.

Shouldn't one update the drm_dev_init/drm_dev_alloc documentation while doing this?
But more importantly, this will change the "unique" string (see drm_dev_set_unique).

The topic around it rather convoluted and messy, so please check this change doesn't cause subtle regressions.
There's a doc hunk in drm_ioctl.c to begin with, plus userspace such as IGT [1] might rely on the current behaviour.

HTH
Emil

[1] https://cgit.freedesktop.org/drm/igt-gpu-tools/
_______________________________________________
dri-devel mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

#3 lore raw

-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Monday, October 30, 2017 6:23 AM
To: Sharma, Deepak <[email protected]>
Cc: ML dri-devel <[email protected]>; Deucher, Alexander <[email protected]>; Stéphane Marchesin <[email protected]>
Subject: Re: [PATCH] drm/vgem: Fix vgem_init to get drm device avaliable.

Quoted 6 lines · Deepak Sharma

From: Deepak Sharma <[email protected]>

Modify vgem_init to take platform dev as parent in drm_dev_init. This will make drm device available at "/sys/devices/platform/vgem" in x86 chromebook.

Shouldn't one update the drm_dev_init/drm_dev_alloc documentation while doing this? But more importantly, this will change the "unique" string (see drm_dev_set_unique).

Sorry I did not get your comment about updating drm_dev_init/drm_dev_alloc documentation for this change. Do you see any issue if this "unique string " is changed

The topic around it rather convoluted and messy, so please check this change doesn't cause subtle regressions. There's a doc hunk in drm_ioctl.c to begin with, plus userspace such as IGT [1] might rely on the current behaviour.

HTH
Emil

[1] https://cgit.freedesktop.org/drm/igt-gpu-tools/

I did run vgem test from IGT to check for regression , do you suspect regression in other tests ?

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

#4 lore raw
Quoted 11 lines · Deepak
Quoted 7 lines
Quoted 5 lines

Modify vgem_init to take platform dev as parent in drm_dev_init. This will make drm device available at "/sys/devices/platform/vgem" in x86 chromebook.

Shouldn't one update the drm_dev_init/drm_dev_alloc documentation while doing this? But more importantly, this will change the "unique" string (see drm_dev_set_unique).

Sorry I did not get your comment about updating drm_dev_init/drm_dev_alloc documentation for this change. Do you see any issue if this "unique string " is changed

VGEM is unlike other DRM drivers and I'm not sure if there is any userspace that depends on the exact value.
If there's none - great.

I'd still recommend updating the two functions' documentation, ideally coupled with enforcing for *parent to be non NULL.
Could be code as follow-up though.

Quoted 10 lines
Quoted 5 lines

The topic around it rather convoluted and messy, so please check this change doesn't cause subtle regressions. There's a doc hunk in drm_ioctl.c to begin with, plus userspace such as IGT [1] might rely on the current behaviour.

HTH
Emil

[1] https://cgit.freedesktop.org/drm/igt-gpu-tools/

I did run vgem test from IGT to check for regression , do you suspect regression in other tests ?

There are two vgem only and a handful of others. Quick grep shows:

tests/amdgpu/amd_prime.c
tests/gem_concurrent_all.c
tests/gem_exec_await.c
tests/gem_exec_fence.c
tests/gem_exec_latency.c
tests/gem_exec_schedule.c
tests/gem_ringfill.c
tests/gem_wait.c
tests/prime_vgem.c
tests/vgem_basic.c
tests/vgem_slow.c

Most of which use i915 <> vgem. If you don't have the HW to test, one can use the Intel GFX trybot.
Just keep [1] in the To/CC list and you'll get a report with the results.

HTH
Emil

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

#5 lore raw

-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Friday, November 10, 2017 5:11 AM
To: Sharma, Deepak <[email protected]>
Cc: ML dri-devel <[email protected]>; Deucher, Alexander <[email protected]>; Stéphane Marchesin <[email protected]>
Subject: Re: [PATCH] drm/vgem: Fix vgem_init to get drm device avaliable.

Quoted 5 lines · Deepak
Quoted 5 lines
Quoted 5 lines

Modify vgem_init to take platform dev as parent in drm_dev_init. This will make drm device available at "/sys/devices/platform/vgem" in x86 chromebook.

Quoted 7 lines
Quoted 2 lines

Shouldn't one update the drm_dev_init/drm_dev_alloc documentation while doing this? But more importantly, this will change the "unique" string (see drm_dev_set_unique).

Sorry I did not get your comment about updating drm_dev_init/drm_dev_alloc documentation for this change. Do you see any issue if this "unique string " is changed

VGEM is unlike other DRM drivers and I'm not sure if there is any userspace that depends on the exact value. If there's none - great.

I'd still recommend updating the two functions' documentation, ideally coupled with enforcing for *parent to be non NULL. Could be code as follow-up though.

If I got it correctly you are referring "Note that for purely virtual devices @parent can be NULL" for said two functions.
I think changes might be required if it was "should/must be NULL"?

Quoted 10 lines
Quoted 5 lines

The topic around it rather convoluted and messy, so please check this change doesn't cause subtle regressions. There's a doc hunk in drm_ioctl.c to begin with, plus userspace such as IGT [1] might rely on the current behaviour.

HTH
Emil

[1] https://cgit.freedesktop.org/drm/igt-gpu-tools/

I did run vgem test from IGT to check for regression , do you suspect regression in other tests ?

There are two vgem only and a handful of others. Quick grep shows:

tests/amdgpu/amd_prime.c
tests/gem_concurrent_all.c
tests/gem_exec_await.c
tests/gem_exec_fence.c
tests/gem_exec_latency.c
tests/gem_exec_schedule.c
tests/gem_ringfill.c
tests/gem_wait.c
tests/prime_vgem.c
tests/vgem_basic.c
tests/vgem_slow.c

Most of which use i915 <> vgem. If you don't have the HW to test, one can use the Intel GFX trybot. Just keep [1] in the To/CC list and you'll get a report with the results.

Thanks. I have added Intel GFX trybot in CC, that should be sufficient or I need to send patch again using git send-mail?

HTH
Emil

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

#6 lore raw
Quoted 6 lines · Deepak
Quoted 4 lines

I'd still recommend updating the two functions' documentation, ideally coupled with enforcing for *parent to be non NULL. Could be code as follow-up though.

If I got it correctly you are referring "Note that for purely virtual devices @parent can be NULL" for said two functions.
I think changes might be required if it was "should/must be NULL"?

Since you're changing the behaviour:
The statement "Note that for purely virtual devices @parent can be NULL" is never true and should be dropped.

Additionally, you want to update the functions to error out when parent is NULL since it indicates a driver bug.
For the drm_dev_set_unique hunk one can drop the comment (it's NA) and simplify to:

ret = drm_dev_set_unique(dev, dev_name(parent));

As mentioned before - it can be code as follow-up.

Quoted 7 lines
Quoted 4 lines

Most of which use i915 <> vgem. If you don't have the HW to test, one can use the Intel GFX trybot. Just keep [1] in the To/CC list and you'll get a report with the results.

Thanks. I have added Intel GFX trybot in CC, that should be sufficient or I need to send patch again using git send-mail?

Right, should have been clearer - the actual patches should be send/cc'd. Otherwise one has know way of retrieving (and thus testing) the patch ;-)

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

#7 lore raw

I got your point . I can push follow up patch with document change and code update as discussed here. Keeping that I think this patch should be ok to land?

Thanks,
Deepak

-----Original Message-----
From: Emil Velikov [mailto:[email protected]]
Sent: Thursday, November 16, 2017 7:40 AM
To: Sharma, Deepak <[email protected]>
Cc: ML dri-devel <[email protected]>; Deucher, Alexander <[email protected]>; Stéphane Marchesin <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/vgem: Fix vgem_init to get drm device avaliable.

Quoted 6 lines · Deepak
Quoted 4 lines

I'd still recommend updating the two functions' documentation, ideally coupled with enforcing for *parent to be non NULL. Could be code as follow-up though.

If I got it correctly you are referring "Note that for purely virtual devices @parent can be NULL" for said two functions.
I think changes might be required if it was "should/must be NULL"?

Since you're changing the behaviour:
The statement "Note that for purely virtual devices @parent can be NULL" is never true and should be dropped.

Additionally, you want to update the functions to error out when parent is NULL since it indicates a driver bug. For the drm_dev_set_unique hunk one can drop the comment (it's NA) and simplify to:

ret = drm_dev_set_unique(dev, dev_name(parent));

As mentioned before - it can be code as follow-up.

Quoted 7 lines
Quoted 4 lines

Most of which use i915 <> vgem. If you don't have the HW to test, one can use the Intel GFX trybot. Just keep [1] in the To/CC list and you'll get a report with the results.

Thanks. I have added Intel GFX trybot in CC, that should be sufficient or I need to send patch again using git send-mail?

Right, should have been clearer - the actual patches should be send/cc'd. Otherwise one has know way of retrieving (and thus testing) the patch ;-)

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