LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] drm/virtgpu: fix double unregistration
@ 2019-11-09  7:54 Chuhong Yuan
  2019-11-12  9:40 ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Chuhong Yuan @ 2019-11-09  7:54 UTC (permalink / raw)
  To: unlisted-recipients:; (no To-header on input)
  Cc: David Airlie, Gerd Hoffmann, Daniel Vetter, dri-devel,
	virtualization, linux-kernel, 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 <hslester96@gmail.com>
---
 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/virtgpu: fix double unregistration
  2019-11-09  7:54 [PATCH] drm/virtgpu: fix double unregistration Chuhong Yuan
@ 2019-11-12  9:40 ` Daniel Vetter
  2019-11-12 11:03   ` Chuhong Yuan
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Vetter @ 2019-11-12  9:40 UTC (permalink / raw)
  To: Chuhong Yuan
  Cc: David Airlie, Gerd Hoffmann, Daniel Vetter, dri-devel,
	virtualization, linux-kernel

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 <hslester96@gmail.com>

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

> ---
>  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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/virtgpu: fix double unregistration
  2019-11-12  9:40 ` Daniel Vetter
@ 2019-11-12 11:03   ` Chuhong Yuan
  0 siblings, 0 replies; 3+ messages in thread
From: Chuhong Yuan @ 2019-11-12 11:03 UTC (permalink / raw)
  To: Chuhong Yuan, David Airlie, Gerd Hoffmann, dri-devel,
	virtualization, LKML
  Cc: Daniel Vetter

On Tue, Nov 12, 2019 at 5:40 PM Daniel Vetter <daniel@ffwll.ch> 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 <hslester96@gmail.com>
>
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-09  7:54 [PATCH] drm/virtgpu: fix double unregistration Chuhong Yuan
2019-11-12  9:40 ` Daniel Vetter
2019-11-12 11:03   ` Chuhong Yuan

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git