dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: DRI Development <dri-devel@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: [PATCH 23/51] drm: Manage drm_gem_init with drmm_
Date: Mon,  2 Mar 2020 23:26:03 +0100	[thread overview]
Message-ID: <20200302222631.3861340-24-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <20200302222631.3861340-1-daniel.vetter@ffwll.ch>

We might want to look into pushing this down into drm_mm_init, but
that would mean rolling out return codes to a pile of functions
unfortunately. So let's leave that for now.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_drv.c      |  8 +-------
 drivers/gpu/drm/drm_gem.c      | 21 ++++++++++-----------
 drivers/gpu/drm/drm_internal.h |  1 -
 3 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 29d106195ab3..9a646155dfc6 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -688,13 +688,10 @@ int drm_dev_init(struct drm_device *dev,
 
 	ret = drm_dev_set_unique(dev, dev_name(parent));
 	if (ret)
-		goto err_setunique;
+		goto err;
 
 	return 0;
 
-err_setunique:
-	if (drm_core_check_feature(dev, DRIVER_GEM))
-		drm_gem_destroy(dev);
 err:
 	drm_managed_release(dev);
 
@@ -756,9 +753,6 @@ EXPORT_SYMBOL(devm_drm_dev_init);
 void drm_dev_fini(struct drm_device *dev)
 {
 	drm_vblank_cleanup(dev);
-
-	if (drm_core_check_feature(dev, DRIVER_GEM))
-		drm_gem_destroy(dev);
 }
 EXPORT_SYMBOL(drm_dev_fini);
 
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 0b6e6623735e..31095e0f6b9f 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -44,6 +44,7 @@
 #include <drm/drm_drv.h>
 #include <drm/drm_file.h>
 #include <drm/drm_gem.h>
+#include <drm/drm_managed.h>
 #include <drm/drm_print.h>
 #include <drm/drm_vma_manager.h>
 
@@ -77,6 +78,12 @@
  * up at a later date, and as our interface with shmfs for memory allocation.
  */
 
+static void
+drm_gem_init_release(struct drm_device *dev, void *ptr)
+{
+	drm_vma_offset_manager_destroy(dev->vma_offset_manager);
+}
+
 /**
  * drm_gem_init - Initialize the GEM device fields
  * @dev: drm_devic structure to initialize
@@ -89,7 +96,8 @@ drm_gem_init(struct drm_device *dev)
 	mutex_init(&dev->object_name_lock);
 	idr_init_base(&dev->object_name_idr, 1);
 
-	vma_offset_manager = kzalloc(sizeof(*vma_offset_manager), GFP_KERNEL);
+	vma_offset_manager = drmm_kzalloc(dev, sizeof(*vma_offset_manager),
+					  GFP_KERNEL);
 	if (!vma_offset_manager) {
 		DRM_ERROR("out of memory\n");
 		return -ENOMEM;
@@ -100,16 +108,7 @@ drm_gem_init(struct drm_device *dev)
 				    DRM_FILE_PAGE_OFFSET_START,
 				    DRM_FILE_PAGE_OFFSET_SIZE);
 
-	return 0;
-}
-
-void
-drm_gem_destroy(struct drm_device *dev)
-{
-
-	drm_vma_offset_manager_destroy(dev->vma_offset_manager);
-	kfree(dev->vma_offset_manager);
-	dev->vma_offset_manager = NULL;
+	return drmm_add_action(dev, drm_gem_init_release, NULL);
 }
 
 /**
diff --git a/drivers/gpu/drm/drm_internal.h b/drivers/gpu/drm/drm_internal.h
index 8c2628dfc6c7..cb09e95a795e 100644
--- a/drivers/gpu/drm/drm_internal.h
+++ b/drivers/gpu/drm/drm_internal.h
@@ -144,7 +144,6 @@ void drm_sysfs_lease_event(struct drm_device *dev);
 /* drm_gem.c */
 struct drm_gem_object;
 int drm_gem_init(struct drm_device *dev);
-void drm_gem_destroy(struct drm_device *dev);
 int drm_gem_handle_create_tail(struct drm_file *file_priv,
 			       struct drm_gem_object *obj,
 			       u32 *handlep);
-- 
2.24.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2020-03-02 22:27 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-02 22:25 [PATCH 00/51] drm_device managed resources, v4 Daniel Vetter
2020-03-02 22:25 ` [PATCH 01/51] mm/sl[uo]b: export __kmalloc_track(_node)_caller Daniel Vetter
2020-03-02 22:25 ` [PATCH 02/51] drm/i915: Don't clear drvdata in ->release Daniel Vetter
2020-03-02 22:25 ` [PATCH 03/51] drm: add managed resources tied to drm_device Daniel Vetter
2020-03-03  8:04   ` Dan Carpenter
2020-03-03  8:25     ` Daniel Vetter
2020-03-03  8:44   ` [PATCH] " Daniel Vetter
2020-03-06 19:38     ` Sam Ravnborg
2020-03-11  9:07   ` [PATCH 03/51] " Thomas Zimmermann
2020-03-11  9:47     ` Thomas Zimmermann
2020-03-16  8:45     ` Daniel Vetter
2020-03-11  9:14   ` Thomas Zimmermann
2020-03-16  8:50     ` Daniel Vetter
2020-03-02 22:25 ` [PATCH 04/51] drm: Set final_kfree in drm_dev_alloc Daniel Vetter
2020-03-03  7:44   ` Gerd Hoffmann
2020-03-07  8:06   ` Sam Ravnborg
2020-03-23 11:02     ` Daniel Vetter
2020-03-11  9:09   ` Thomas Zimmermann
2020-03-02 22:25 ` [PATCH 05/51] drm/mipi_dbi: Use drmm_add_final_kfree in all drivers Daniel Vetter
2020-03-02 22:25 ` [PATCH 06/51] drm/udl: Use drmm_add_final_kfree Daniel Vetter
2020-03-11  9:10   ` Thomas Zimmermann
2020-03-02 22:25 ` [PATCH 07/51] drm/qxl: " Daniel Vetter
2020-03-03  7:44   ` Gerd Hoffmann
2020-03-02 22:25 ` [PATCH 08/51] drm/i915: " Daniel Vetter
2020-03-02 22:25 ` [PATCH 09/51] drm/cirrus: " Daniel Vetter
2020-03-03  7:49   ` Gerd Hoffmann
2020-03-03  8:27     ` Daniel Vetter
2020-03-02 22:25 ` [PATCH 10/51] drm/v3d: " Daniel Vetter
2020-03-02 22:25 ` [PATCH 11/51] drm/tidss: " Daniel Vetter
2020-03-02 22:25 ` [PATCH 12/51] drm/mcde: " Daniel Vetter
2020-03-02 22:25 ` [PATCH 13/51] drm/vgem: " Daniel Vetter
2020-03-02 22:25 ` [PATCH 14/51] drm/vkms: " Daniel Vetter
2020-03-02 22:25 ` [PATCH 15/51] drm/repaper: " Daniel Vetter
2020-03-06 20:27   ` Sam Ravnborg
2020-03-02 22:25 ` [PATCH 16/51] drm/ingenic: " Daniel Vetter
2020-03-06 20:27   ` Sam Ravnborg
2020-03-02 22:25 ` [PATCH 17/51] drm/gm12u320: " Daniel Vetter
2020-03-06 20:27   ` Sam Ravnborg
2020-03-02 22:25 ` [PATCH 18/51] drm/<drivers>: " Daniel Vetter
2020-03-06 20:28   ` Sam Ravnborg
2020-03-02 22:25 ` [PATCH 19/51] drm: Cleanups after drmm_add_final_kfree rollout Daniel Vetter
2020-03-03  8:45   ` [PATCH] " Daniel Vetter
2020-03-06 20:31     ` Sam Ravnborg
2020-03-06 20:29   ` [PATCH 19/51] " Sam Ravnborg
2020-03-11  9:15   ` Thomas Zimmermann
2020-03-02 22:26 ` [PATCH 20/51] drm: Handle dev->unique with drmm_ Daniel Vetter
2020-03-06 20:37   ` Sam Ravnborg
2020-03-23 10:54     ` Daniel Vetter
2020-03-11  9:19   ` Thomas Zimmermann
2020-03-02 22:26 ` [PATCH 21/51] drm: Use drmm_ for drm_dev_init cleanup Daniel Vetter
2020-03-11  9:39   ` Thomas Zimmermann
2020-03-16  9:02     ` Daniel Vetter
2020-03-02 22:26 ` [PATCH 22/51] drm: manage drm_minor cleanup with drmm_ Daniel Vetter
2020-03-11  9:59   ` Thomas Zimmermann
2020-03-16  9:07     ` Daniel Vetter
2020-03-02 22:26 ` Daniel Vetter [this message]
2020-03-07  8:20   ` [PATCH 23/51] drm: Manage drm_gem_init " Sam Ravnborg
2020-03-02 22:26 ` [PATCH 24/51] drm: Manage drm_vblank_cleanup " Daniel Vetter
2020-03-07  8:28   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 25/51] drm: Garbage collect drm_dev_fini Daniel Vetter
2020-03-07  8:30   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 26/51] drm: Manage drm_mode_config_init with drmm_ Daniel Vetter
2020-03-06 20:04   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 27/51] drm/bochs: Remove leftover drm_atomic_helper_shutdown Daniel Vetter
2020-03-03  7:49   ` Gerd Hoffmann
2020-03-02 22:26 ` [PATCH 28/51] drm/bochs: Drop explicit drm_mode_config_cleanup Daniel Vetter
2020-03-03  7:50   ` Gerd Hoffmann
2020-03-06 20:14   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 29/51] drm/cirrus: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-03-03  7:51   ` Gerd Hoffmann
2020-03-02 22:26 ` [PATCH 30/51] drm/cirrus: Fully embrace devm_ Daniel Vetter
2020-03-03  7:51   ` Gerd Hoffmann
2020-03-02 22:26 ` [PATCH 31/51] drm/ingenic: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-03-06 20:17   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 32/51] drm/mcde: " Daniel Vetter
2020-03-06 20:18   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 33/51] drm/mcde: More devm_drm_dev_init Daniel Vetter
2020-03-02 22:26 ` [PATCH 34/51] drm/meson: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-03-02 22:26 ` [PATCH 35/51] drm/pl111: " Daniel Vetter
2020-03-07  8:37   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 36/51] drm/rcar-du: " Daniel Vetter
2020-03-02 22:26 ` [PATCH 37/51] drm/rockchip: " Daniel Vetter
2020-03-07  8:38   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 38/51] drm/stm: " Daniel Vetter
2020-03-07  9:25   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 39/51] drm/shmob: " Daniel Vetter
2020-03-02 22:26 ` [PATCH 40/51] drm/mtk: " Daniel Vetter
2020-03-07  9:26   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 41/51] drm/tidss: " Daniel Vetter
2020-03-02 22:26 ` [PATCH 42/51] drm/gm12u320: More drmm_ Daniel Vetter
2020-03-02 22:26 ` [PATCH 43/51] drm/gm12u320: Use devm_drm_dev_init Daniel Vetter
2020-03-02 22:26 ` [PATCH 44/51] drm/gm12u320: Use helpers for shutdown/suspend/resume Daniel Vetter
2020-03-02 22:26 ` [PATCH 45/51] drm/gm12u320: Simplify upload work Daniel Vetter
2020-03-02 22:26 ` [PATCH 46/51] drm/repaper: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-03-07  9:31   ` Sam Ravnborg
2020-03-02 22:26 ` [PATCH 47/51] drm/mipi-dbi: Move drm_mode_config_init into mipi library Daniel Vetter
2020-03-02 22:26 ` [PATCH 48/51] drm/mipi-dbi: Drop explicit drm_mode_config_cleanup call Daniel Vetter
2020-03-02 22:26 ` [PATCH 49/51] drm/udl: " Daniel Vetter
2020-03-02 22:26 ` [PATCH 50/51] drm/udl: drop drm_driver.release hook Daniel Vetter
2020-03-03  7:57   ` Thomas Zimmermann
2020-03-02 22:26 ` [PATCH 51/51] drm: Add docs for managed resources Daniel Vetter
2020-03-07 10:07   ` Sam Ravnborg
  -- strict thread matches above, loose matches on Subject: below --
2020-03-23 14:48 [PATCH 00/51] drm_device managed resources, v5 Daniel Vetter
2020-03-23 14:49 ` [PATCH 23/51] drm: Manage drm_gem_init with drmm_ Daniel Vetter
2020-02-27 18:14 [PATCH 00/51] drm managed resources, v3 Daniel Vetter
2020-02-27 18:14 ` [PATCH 23/51] drm: Manage drm_gem_init with drmm_ Daniel Vetter
2020-02-21 21:02 [PATCH 00/51] drm managed resources, v2 Daniel Vetter
2020-02-21 21:02 ` [PATCH 23/51] drm: Manage drm_gem_init with drmm_ Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200302222631.3861340-24-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).