Re: [PATCH] drm/virtgpu: fix double unregistration

2019-11-12 Thread Chuhong Yuan
On Tue, Nov 12, 2019 at 5:40 PM Daniel Vetter  wrote:
>
> On Sat, Nov 09, 2019 at 03:54:17PM +0800, Chuhong Yuan wrote:
> > drm_put_dev also calls drm_dev_unregister, so dev will be unregistered
> > twice.
> > Replace it with drm_dev_put to fix it.
> >
> > Signed-off-by: Chuhong Yuan 
>
> Nice catch, I'll apply.
>
> Since this is so confusing, we actually have a todo to remove drm_put_dev
> completely from the codebase (and open-code it with explicit
> unregister+put). Want to do that little patch series to update the
> remaining few drivers and then remove drm_put_dev from core code?
>
> Thanks, Daniel
>

I am sorry that I have to focus on my current project in recent days.
But since this is a problem, I have written a Coccinelle script just now
to find drm_put_dev and open-code it.
I hope this helps.
The script is:

virtual patch

@ drm_put_dev depends on patch exists @
expression dev;
@@

- drm_put_dev(dev);
+ drm_dev_unregister(dev);
+ drm_dev_put(dev);

Regards,
Chuhong
> > ---
> >  drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c 
> > b/drivers/gpu/drm/virtio/virtgpu_drv.c
> > index 0fc32fa0b3c0..fccc24e21af8 100644
> > --- a/drivers/gpu/drm/virtio/virtgpu_drv.c
> > +++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
> > @@ -138,7 +138,7 @@ static void virtio_gpu_remove(struct virtio_device 
> > *vdev)
> >
> >   drm_dev_unregister(dev);
> >   virtio_gpu_deinit(dev);
> > - drm_put_dev(dev);
> > + drm_dev_put(dev);
> >  }
> >
> >  static void virtio_gpu_config_changed(struct virtio_device *vdev)
> > --
> > 2.23.0
> >
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> http://blog.ffwll.ch
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] drm/virtgpu: fix double unregistration

2019-11-08 Thread Chuhong Yuan
drm_put_dev also calls drm_dev_unregister, so dev will be unregistered
twice.
Replace it with drm_dev_put to fix it.

Signed-off-by: Chuhong Yuan 
---
 drivers/gpu/drm/virtio/virtgpu_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_drv.c 
b/drivers/gpu/drm/virtio/virtgpu_drv.c
index 0fc32fa0b3c0..fccc24e21af8 100644
--- a/drivers/gpu/drm/virtio/virtgpu_drv.c
+++ b/drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -138,7 +138,7 @@ static void virtio_gpu_remove(struct virtio_device *vdev)
 
drm_dev_unregister(dev);
virtio_gpu_deinit(dev);
-   drm_put_dev(dev);
+   drm_dev_put(dev);
 }
 
 static void virtio_gpu_config_changed(struct virtio_device *vdev)
-- 
2.23.0

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] drm/qxl: Use dev_get_drvdata where possible

2019-07-24 Thread Chuhong Yuan
Instead of using to_pci_dev + pci_get_drvdata,
use dev_get_drvdata to make code simpler.

Signed-off-by: Chuhong Yuan 
---
 drivers/gpu/drm/qxl/qxl_drv.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/qxl/qxl_drv.c b/drivers/gpu/drm/qxl/qxl_drv.c
index f33e349c4ec5..af1e2b377945 100644
--- a/drivers/gpu/drm/qxl/qxl_drv.c
+++ b/drivers/gpu/drm/qxl/qxl_drv.c
@@ -206,16 +206,14 @@ static int qxl_pm_resume(struct device *dev)
 
 static int qxl_pm_thaw(struct device *dev)
 {
-   struct pci_dev *pdev = to_pci_dev(dev);
-   struct drm_device *drm_dev = pci_get_drvdata(pdev);
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
 
return qxl_drm_resume(drm_dev, true);
 }
 
 static int qxl_pm_freeze(struct device *dev)
 {
-   struct pci_dev *pdev = to_pci_dev(dev);
-   struct drm_device *drm_dev = pci_get_drvdata(pdev);
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
 
return qxl_drm_freeze(drm_dev);
 }
-- 
2.20.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] drm/bochs: Use dev_get_drvdata

2019-07-24 Thread Chuhong Yuan
Instead of using to_pci_dev + pci_get_drvdata,
use dev_get_drvdata to make code simpler.

Signed-off-by: Chuhong Yuan 
---
 drivers/gpu/drm/bochs/bochs_drv.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_drv.c 
b/drivers/gpu/drm/bochs/bochs_drv.c
index 8f3a5bda9d03..d8a50200408c 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -83,16 +83,14 @@ static struct drm_driver bochs_driver = {
 #ifdef CONFIG_PM_SLEEP
 static int bochs_pm_suspend(struct device *dev)
 {
-   struct pci_dev *pdev = to_pci_dev(dev);
-   struct drm_device *drm_dev = pci_get_drvdata(pdev);
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
 
return drm_mode_config_helper_suspend(drm_dev);
 }
 
 static int bochs_pm_resume(struct device *dev)
 {
-   struct pci_dev *pdev = to_pci_dev(dev);
-   struct drm_device *drm_dev = pci_get_drvdata(pdev);
+   struct drm_device *drm_dev = dev_get_drvdata(dev);
 
return drm_mode_config_helper_resume(drm_dev);
 }
-- 
2.20.1

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization