linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/bochs: add drm_driver.release callback.
@ 2020-02-07 12:13 Gerd Hoffmann
  2020-02-07 13:15 ` Thomas Zimmermann
  2020-02-07 13:42 ` Daniel Vetter
  0 siblings, 2 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2020-02-07 12:13 UTC (permalink / raw)
  To: dri-devel
  Cc: Gurchetan Singh, Gerd Hoffmann, David Airlie, Daniel Vetter,
	open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, open list

From: Gurchetan Singh <gurchetansingh@chromium.org>

Move bochs_unload call from bochs_remove() to the new bochs_release()
callback.  Also call drm_dev_unregister() first in bochs_remove().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 drivers/gpu/drm/bochs/bochs_drv.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c
index 10460878414e..87ee1eb21a4d 100644
--- a/drivers/gpu/drm/bochs/bochs_drv.c
+++ b/drivers/gpu/drm/bochs/bochs_drv.c
@@ -60,6 +60,11 @@ static int bochs_load(struct drm_device *dev)
 
 DEFINE_DRM_GEM_FOPS(bochs_fops);
 
+static void bochs_release(struct drm_device *dev)
+{
+	bochs_unload(dev);
+}
+
 static struct drm_driver bochs_driver = {
 	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
 	.fops			= &bochs_fops,
@@ -69,6 +74,7 @@ static struct drm_driver bochs_driver = {
 	.major			= 1,
 	.minor			= 0,
 	DRM_GEM_VRAM_DRIVER,
+	.release                = bochs_release,
 };
 
 /* ---------------------------------------------------------------------- */
@@ -148,9 +154,8 @@ static void bochs_pci_remove(struct pci_dev *pdev)
 {
 	struct drm_device *dev = pci_get_drvdata(pdev);
 
-	drm_atomic_helper_shutdown(dev);
 	drm_dev_unregister(dev);
-	bochs_unload(dev);
+	drm_atomic_helper_shutdown(dev);
 	drm_dev_put(dev);
 }
 
-- 
2.18.1


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

* Re: [PATCH] drm/bochs: add drm_driver.release callback.
  2020-02-07 12:13 [PATCH] drm/bochs: add drm_driver.release callback Gerd Hoffmann
@ 2020-02-07 13:15 ` Thomas Zimmermann
  2020-02-07 13:42 ` Daniel Vetter
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2020-02-07 13:15 UTC (permalink / raw)
  To: Gerd Hoffmann, dri-devel
  Cc: David Airlie, open list,
	open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, Gurchetan Singh


[-- Attachment #1.1: Type: text/plain, Size: 1817 bytes --]



Am 07.02.20 um 13:13 schrieb Gerd Hoffmann:
> From: Gurchetan Singh <gurchetansingh@chromium.org>
> 
> Move bochs_unload call from bochs_remove() to the new bochs_release()
> callback.  Also call drm_dev_unregister() first in bochs_remove().
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>

Acked-by: Thomas Zimmermann <tzimmermann@suse.de>

> ---
>  drivers/gpu/drm/bochs/bochs_drv.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c
> index 10460878414e..87ee1eb21a4d 100644
> --- a/drivers/gpu/drm/bochs/bochs_drv.c
> +++ b/drivers/gpu/drm/bochs/bochs_drv.c
> @@ -60,6 +60,11 @@ static int bochs_load(struct drm_device *dev)
>  
>  DEFINE_DRM_GEM_FOPS(bochs_fops);
>  
> +static void bochs_release(struct drm_device *dev)
> +{
> +	bochs_unload(dev);
> +}
> +
>  static struct drm_driver bochs_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
>  	.fops			= &bochs_fops,
> @@ -69,6 +74,7 @@ static struct drm_driver bochs_driver = {
>  	.major			= 1,
>  	.minor			= 0,
>  	DRM_GEM_VRAM_DRIVER,
> +	.release                = bochs_release,
>  };
>  
>  /* ---------------------------------------------------------------------- */
> @@ -148,9 +154,8 @@ static void bochs_pci_remove(struct pci_dev *pdev)
>  {
>  	struct drm_device *dev = pci_get_drvdata(pdev);
>  
> -	drm_atomic_helper_shutdown(dev);
>  	drm_dev_unregister(dev);
> -	bochs_unload(dev);
> +	drm_atomic_helper_shutdown(dev);
>  	drm_dev_put(dev);
>  }
>  
> 

-- 
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH] drm/bochs: add drm_driver.release callback.
  2020-02-07 12:13 [PATCH] drm/bochs: add drm_driver.release callback Gerd Hoffmann
  2020-02-07 13:15 ` Thomas Zimmermann
@ 2020-02-07 13:42 ` Daniel Vetter
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2020-02-07 13:42 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: dri-devel, Gurchetan Singh, David Airlie, Daniel Vetter,
	open list:DRM DRIVER FOR BOCHS VIRTUAL GPU, open list

On Fri, Feb 07, 2020 at 01:13:12PM +0100, Gerd Hoffmann wrote:
> From: Gurchetan Singh <gurchetansingh@chromium.org>
> 
> Move bochs_unload call from bochs_remove() to the new bochs_release()
> callback.  Also call drm_dev_unregister() first in bochs_remove().
> 
> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
> ---
>  drivers/gpu/drm/bochs/bochs_drv.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c
> index 10460878414e..87ee1eb21a4d 100644
> --- a/drivers/gpu/drm/bochs/bochs_drv.c
> +++ b/drivers/gpu/drm/bochs/bochs_drv.c
> @@ -60,6 +60,11 @@ static int bochs_load(struct drm_device *dev)
>  
>  DEFINE_DRM_GEM_FOPS(bochs_fops);
>  
> +static void bochs_release(struct drm_device *dev)
> +{
> +	bochs_unload(dev);

Hm I think this needs to be split, and bochs_hw_fini needs to stay in
bochs_pci_remove. Otherwise we again release the iommu mappings too late
(there was just a discussion about that on the fbdev side of things
getting this wrong). Good to fix the lifetime fun here, but let's not move
too far :-)

Ideally we'd move the iomapping to devm_, that would remove it at the
right time I think.

Slight annoyance might be that we then need to shoot down the varios
mmaps, which I frankly don't know how to do. But keeping them pointing at
wrong stuff also isn't that great :-/

Cheers, Daniel

> +}
> +
>  static struct drm_driver bochs_driver = {
>  	.driver_features	= DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC,
>  	.fops			= &bochs_fops,
> @@ -69,6 +74,7 @@ static struct drm_driver bochs_driver = {
>  	.major			= 1,
>  	.minor			= 0,
>  	DRM_GEM_VRAM_DRIVER,
> +	.release                = bochs_release,
>  };
>  
>  /* ---------------------------------------------------------------------- */
> @@ -148,9 +154,8 @@ static void bochs_pci_remove(struct pci_dev *pdev)
>  {
>  	struct drm_device *dev = pci_get_drvdata(pdev);
>  
> -	drm_atomic_helper_shutdown(dev);
>  	drm_dev_unregister(dev);
> -	bochs_unload(dev);
> +	drm_atomic_helper_shutdown(dev);
>  	drm_dev_put(dev);
>  }
>  
> -- 
> 2.18.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

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

end of thread, other threads:[~2020-02-07 13:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-07 12:13 [PATCH] drm/bochs: add drm_driver.release callback Gerd Hoffmann
2020-02-07 13:15 ` Thomas Zimmermann
2020-02-07 13:42 ` Daniel Vetter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).