dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Maxime Ripard <maxime@cerno.tech>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Maxime Ripard <maxime@cerno.tech>,
	Daniel Vetter <daniel.vetter@intel.com>,
	David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Subject: [PATCH v2 64/68] drm/vc4: Switch to drmm_mutex_init
Date: Wed, 22 Jun 2022 16:32:05 +0200	[thread overview]
Message-ID: <20220622143209.600298-65-maxime@cerno.tech> (raw)
In-Reply-To: <20220622143209.600298-1-maxime@cerno.tech>

mutex_init is supposed to be balanced by a call to mutex_destroy that we
were never doing in the vc4 driver.

Since a DRM-managed mutex_init variant has been introduced, let's just
switch to it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
---
 drivers/gpu/drm/vc4/vc4_bo.c   | 15 +++++++++++++--
 drivers/gpu/drm/vc4/vc4_drv.c  |  4 +++-
 drivers/gpu/drm/vc4/vc4_gem.c  | 10 ++++++++--
 drivers/gpu/drm/vc4/vc4_hdmi.c |  5 ++++-
 4 files changed, 28 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c
index 19807e4e0c55..312a1a936caf 100644
--- a/drivers/gpu/drm/vc4/vc4_bo.c
+++ b/drivers/gpu/drm/vc4/vc4_bo.c
@@ -392,6 +392,7 @@ struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size)
 {
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
 	struct vc4_bo *bo;
+	int ret;
 
 	if (WARN_ON_ONCE(vc4->is_vc5))
 		return ERR_PTR(-ENODEV);
@@ -402,7 +403,11 @@ struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size)
 
 	bo->madv = VC4_MADV_WILLNEED;
 	refcount_set(&bo->usecnt, 0);
-	mutex_init(&bo->madv_lock);
+
+	ret = drmm_mutex_init(dev, &bo->madv_lock);
+	if (ret)
+		return ERR_PTR(ret);
+
 	mutex_lock(&vc4->bo_lock);
 	bo->label = VC4_BO_TYPE_KERNEL;
 	vc4->bo_labels[VC4_BO_TYPE_KERNEL].num_allocated++;
@@ -1003,6 +1008,7 @@ static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused);
 int vc4_bo_cache_init(struct drm_device *dev)
 {
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
+	int ret;
 	int i;
 
 	if (WARN_ON_ONCE(vc4->is_vc5))
@@ -1022,7 +1028,12 @@ int vc4_bo_cache_init(struct drm_device *dev)
 	for (i = 0; i < VC4_BO_TYPE_COUNT; i++)
 		vc4->bo_labels[i].name = bo_type_names[i];
 
-	mutex_init(&vc4->bo_lock);
+	ret = drmm_mutex_init(dev, &vc4->bo_lock);
+	if (ret) {
+		kfree(vc4->bo_labels);
+		return ret;
+	}
+
 	INIT_LIST_HEAD(&vc4->bo_cache.time_list);
 
 	INIT_WORK(&vc4->bo_cache.time_work, vc4_bo_cache_time_work);
diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c
index 06d605a12633..c85f86a87bda 100644
--- a/drivers/gpu/drm/vc4/vc4_drv.c
+++ b/drivers/gpu/drm/vc4/vc4_drv.c
@@ -305,7 +305,9 @@ static int vc4_drm_bind(struct device *dev)
 	INIT_LIST_HEAD(&vc4->debugfs_list);
 
 	if (!is_vc5) {
-		mutex_init(&vc4->bin_bo_lock);
+		ret = drmm_mutex_init(drm, &vc4->bin_bo_lock);
+		if (ret)
+			return ret;
 
 		ret = vc4_bo_cache_init(drm);
 		if (ret)
diff --git a/drivers/gpu/drm/vc4/vc4_gem.c b/drivers/gpu/drm/vc4/vc4_gem.c
index fe10d9c3fff8..7acb43972e69 100644
--- a/drivers/gpu/drm/vc4/vc4_gem.c
+++ b/drivers/gpu/drm/vc4/vc4_gem.c
@@ -1308,6 +1308,7 @@ static void vc4_gem_destroy(struct drm_device *dev, void *unused);
 int vc4_gem_init(struct drm_device *dev)
 {
 	struct vc4_dev *vc4 = to_vc4_dev(dev);
+	int ret;
 
 	if (WARN_ON_ONCE(vc4->is_vc5))
 		return -ENODEV;
@@ -1325,10 +1326,15 @@ int vc4_gem_init(struct drm_device *dev)
 
 	INIT_WORK(&vc4->job_done_work, vc4_job_done_work);
 
-	mutex_init(&vc4->power_lock);
+	ret = drmm_mutex_init(dev, &vc4->power_lock);
+	if (ret)
+		return ret;
 
 	INIT_LIST_HEAD(&vc4->purgeable.list);
-	mutex_init(&vc4->purgeable.lock);
+
+	ret = drmm_mutex_init(dev, &vc4->purgeable.lock);
+	if (ret)
+		return ret;
 
 	return drmm_add_action_or_reset(dev, vc4_gem_destroy, NULL);
 }
diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index ef46dc34316a..8f6531e2a500 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -3196,7 +3196,10 @@ static int vc4_hdmi_bind(struct device *dev, struct device *master, void *data)
 	if (!vc4_hdmi)
 		return -ENOMEM;
 
-	mutex_init(&vc4_hdmi->mutex);
+	ret = drmm_mutex_init(drm, &vc4_hdmi->mutex);
+	if (ret)
+		return ret;
+
 	spin_lock_init(&vc4_hdmi->hw_lock);
 	INIT_DELAYED_WORK(&vc4_hdmi->scrambling_work, vc4_hdmi_scrambling_wq);
 
-- 
2.36.1


  parent reply	other threads:[~2022-06-22 14:35 UTC|newest]

Thread overview: 82+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-22 14:31 [PATCH v2 00/68] drm/vc4: Fix hotplug for vc4 Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 01/68] drm/mipi-dsi: Detach devices when removing the host Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 02/68] drm/crtc: Introduce drmm_crtc_init_with_planes Maxime Ripard
2022-06-22 18:37   ` kernel test robot
2022-06-28  8:54   ` Thomas Zimmermann
2022-06-22 14:31 ` [PATCH v2 03/68] drm/encoder: Introduce drmm_encoder_init Maxime Ripard
2022-06-22 19:38   ` kernel test robot
2022-06-28  8:55   ` Thomas Zimmermann
2022-06-22 14:31 ` [PATCH v2 04/68] drm/connector: Reorder headers Maxime Ripard
2022-06-24 19:21   ` Sam Ravnborg
2022-06-22 14:31 ` [PATCH v2 05/68] drm/connector: Mention the cleanup after drm_connector_init Maxime Ripard
2022-06-24 19:25   ` Sam Ravnborg
2022-06-22 14:31 ` [PATCH v2 06/68] drm/connector: Clarify when drm_connector_unregister is needed Maxime Ripard
2022-06-24 19:25   ` Sam Ravnborg
2022-06-22 14:31 ` [PATCH v2 07/68] drm/connector: Introduce drmm_connector_init Maxime Ripard
2022-06-24 19:26   ` Sam Ravnborg
2022-06-22 14:31 ` [PATCH v2 08/68] drm/connector: Introduce drmm_connector_init_with_ddc Maxime Ripard
2022-06-24 19:26   ` Sam Ravnborg
2022-06-28  9:00   ` Thomas Zimmermann
2022-06-28 14:05     ` Jani Nikula
2022-06-22 14:31 ` [PATCH v2 09/68] drm/bridge: panel: Introduce drmm_panel_bridge_add Maxime Ripard
2022-06-24 19:27   ` Sam Ravnborg
2022-06-22 14:31 ` [PATCH v2 10/68] drm/bridge: panel: Introduce drmm_of_get_bridge Maxime Ripard
2022-06-24 19:31   ` Sam Ravnborg
2022-06-22 14:31 ` [PATCH v2 11/68] drm/vc4: drv: Call component_unbind_all() Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 12/68] drm/vc4: drv: Use drm_dev_unplug Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 13/68] drm/vc4: crtc: Create vblank reporting function Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 14/68] drm/vc4: hvs: Protect device resources after removal Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 15/68] drm/vc4: hvs: Remove planes currently allocated before taking down Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 16/68] drm/vc4: plane: Take possible_crtcs as an argument Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 17/68] drm/vc4: crtc: Remove manual plane removal on error Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 18/68] drm/vc4: plane: Switch to drmm_universal_plane_alloc() Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 19/68] drm/vc4: crtc: Move debugfs_name to crtc_data Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 20/68] drm/vc4: crtc: Switch to drmm_kzalloc Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 21/68] drm/vc4: crtc: Switch to DRM-managed CRTC initialization Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 22/68] drm/vc4: dpi: Remove vc4_dev dpi pointer Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 23/68] drm/vc4: dpi: Embed DRM structures into the private structure Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 24/68] drm/vc4: dpi: Switch to drmm_kzalloc Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 25/68] drm/vc4: dpi: Return an error if we can't enable our clock Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 26/68] drm/vc4: dpi: Remove unnecessary drm_of_panel_bridge_remove call Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 27/68] drm/vc4: dpi: Add action to disable the clock Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 28/68] drm/vc4: dpi: Switch to DRM-managed encoder initialization Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 29/68] drm/vc4: dpi: Switch to drmm_of_get_bridge Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 30/68] drm/vc4: dpi: Protect device resources Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 31/68] drm/vc4: dsi: Embed DRM structures into the private structure Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 32/68] drm/vc4: dsi: Switch to DRM-managed encoder initialization Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 33/68] drm/vc4: dsi: Switch to drmm_of_get_bridge Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 34/68] drm/vc4: dsi: Fix the driver structure lifetime Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 35/68] drm/vc4: dsi: Switch to devm_pm_runtime_enable Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 36/68] drm/vc4: hdmi: Switch to drmm_kzalloc Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 37/68] drm/vc4: hdmi: Remove call to drm_connector_unregister() Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 38/68] drm/vc4: hdmi: Switch to DRM-managed encoder initialization Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 39/68] drm/vc4: hdmi: Switch to DRM-managed connector initialization Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 40/68] drm/vc4: hdmi: Switch to device-managed ALSA initialization Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 41/68] drm/vc4: hdmi: Switch to device-managed CEC initialization Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 42/68] drm/vc4: hdmi: Use a device-managed action for DDC Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 43/68] drm/vc4: hdmi: Switch to DRM-managed kfree to build regsets Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 44/68] drm/vc4: hdmi: Use devm to register hotplug interrupts Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 45/68] drm/vc4: hdmi: Move audio structure offset checks Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 46/68] drm/vc4: hdmi: Protect device resources after removal Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 47/68] drm/vc4: hdmi: Switch to devm_pm_runtime_enable Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 48/68] drm/vc4: txp: Remove vc4_dev txp pointer Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 49/68] drm/vc4: txp: Remove duplicate regset Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 50/68] drm/vc4: txp: Switch to drmm_kzalloc Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 51/68] drm/vc4: txp: Remove call to drm_connector_unregister() Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 52/68] drm/vc4: txp: Protect device resources Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 53/68] drm/vc4: vec: Remove vc4_dev vec pointer Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 54/68] drm/vc4: vec: Embed DRM structures into the private structure Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 55/68] drm/vc4: vec: Switch to drmm_kzalloc Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 56/68] drm/vc4: vec: Remove call to drm_connector_unregister() Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 57/68] drm/vc4: vec: Switch to DRM-managed encoder initialization Maxime Ripard
2022-06-22 14:31 ` [PATCH v2 58/68] drm/vc4: vec: Switch to DRM-managed connector initialization Maxime Ripard
2022-06-22 14:32 ` [PATCH v2 59/68] drm/vc4: vec: Protect device resources after removal Maxime Ripard
2022-06-22 14:32 ` [PATCH v2 60/68] drm/vc4: vec: Switch to devm_pm_runtime_enable Maxime Ripard
2022-06-22 14:32 ` [PATCH v2 61/68] drm/vc4: debugfs: Protect device resources Maxime Ripard
2022-06-22 14:32 ` [PATCH v2 62/68] drm/vc4: debugfs: Return an error on failure Maxime Ripard
2022-06-22 14:32 ` [PATCH v2 63/68] drm/vc4: debugfs: Simplify debugfs registration Maxime Ripard
2022-06-22 14:32 ` Maxime Ripard [this message]
2022-06-22 14:32 ` [PATCH v2 65/68] drm/vc4: perfmon: Add missing mutex_destroy Maxime Ripard
2022-06-22 14:32 ` [PATCH v2 66/68] drm/vc4: v3d: Stop disabling interrupts Maxime Ripard
2022-06-22 14:32 ` [PATCH v2 67/68] drm/vc4: v3d: Rework the runtime_pm setup Maxime Ripard
2022-06-22 14:32 ` [PATCH v2 68/68] drm/vc4: v3d: Switch to devm_pm_runtime_enable Maxime Ripard

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=20220622143209.600298-65-maxime@cerno.tech \
    --to=maxime@cerno.tech \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=tzimmermann@suse.de \
    /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