All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Luiz Otavio Mello <luiz.mello@estudante.ufscar.br>,
	rodrigo.vivi@intel.com, joonas.lahtinen@linux.intel.com,
	tursulin@ursulin.net, airlied@gmail.com, simona@ffwll.ch
Cc: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	mairacanal@riseup.net,
	Luiz Otavio Mello <luiz.mello@estudante.ufscar.br>
Subject: Re: [PATCH 3/9] drm/i915: Change mutex initialization in intel_guc_log
Date: Wed, 06 Aug 2025 12:06:36 +0300	[thread overview]
Message-ID: <b56a660a9b54de4895107b68104b79a747896109@intel.com> (raw)
In-Reply-To: <20250805143908.32343-4-luiz.mello@estudante.ufscar.br>

On Tue, 05 Aug 2025, Luiz Otavio Mello <luiz.mello@estudante.ufscar.br> wrote:
> The intel_guc_log->relay.lock is currently initialized in
> intel_guc_log_init_early(), but it lacks a corresponding destructor,
> which can lead to a memory leak.

That's not quite accurate. The destructor is only relevant for
CONFIG_DEBUG_MUTEXES=y, which ensures the lock is not used after it's
been destroyed. Otherwise it's a nop.

The patch itself makes sense.

BR,
Jani.

>
> This patch replaces the use of mutex_init() with drmm_mutex_init(),
> which ensures the lock is properly destroyed when the driver is
> unloaded.
>
> Signed-off-by: Luiz Otavio Mello <luiz.mello@estudante.ufscar.br>
> ---
>  drivers/gpu/drm/i915/gt/uc/intel_guc_log.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
> index 7135fdb0ebb4..469173791394 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_log.c
> @@ -6,6 +6,8 @@
>  #include <linux/debugfs.h>
>  #include <linux/string_helpers.h>
>  
> +#include <drm/drm_managed.h>
> +
>  #include "gt/intel_gt.h"
>  #include "i915_drv.h"
>  #include "i915_irq.h"
> @@ -512,7 +514,10 @@ static void guc_log_relay_unmap(struct intel_guc_log *log)
>  
>  void intel_guc_log_init_early(struct intel_guc_log *log)
>  {
> -	mutex_init(&log->relay.lock);
> +	struct intel_guc *guc = log_to_guc(log);
> +	struct drm_i915_private *i915 = guc_to_i915(guc);
> +
> +	drmm_mutex_init(&i915->drm, &log->relay.lock);
>  	INIT_WORK(&log->relay.flush_work, copy_debug_logs_work);
>  	log->relay.started = false;
>  }

-- 
Jani Nikula, Intel

  reply	other threads:[~2025-08-06  9:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-05 14:38 [PATCH 0/9] drm/i915: Remove legacy struct_mutex usage Luiz Otavio Mello
2025-08-05 14:38 ` [PATCH 1/9] drm/i915: Move struct_mutex to drm_i915_private Luiz Otavio Mello
2025-08-05 14:38 ` [PATCH 2/9] drm/i915: Remove struct_mutex in i915_irq.c Luiz Otavio Mello
2025-08-05 14:38 ` [PATCH 3/9] drm/i915: Change mutex initialization in intel_guc_log Luiz Otavio Mello
2025-08-06  9:06   ` Jani Nikula [this message]
2025-08-05 14:38 ` [PATCH 4/9] drm/i915: Replace struct_mutex in intel_guc_log.c Luiz Otavio Mello
2025-08-05 14:39 ` [PATCH 5/9] drm/i915/gem: Clean-up outdated struct_mutex comments Luiz Otavio Mello
2025-08-05 14:39 ` [PATCH 6/9] drm/i915/display: Remove " Luiz Otavio Mello
2025-08-05 14:39 ` [PATCH 7/9] drm/i915: Clean-up " Luiz Otavio Mello
2025-08-05 14:39 ` [PATCH 8/9] drm/i915: Remove unused struct_mutex from drm_i915_private Luiz Otavio Mello
2025-08-05 14:39 ` [PATCH 9/9] drm/i915: Remove todo and comments about struct_mutex Luiz Otavio Mello
2025-08-06 14:51 ` ✗ LGCI.VerificationFailed: failure for drm/i915: Remove legacy struct_mutex usage Patchwork
2025-08-06 22:02   ` Rodrigo Vivi

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=b56a660a9b54de4895107b68104b79a747896109@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=luiz.mello@estudante.ufscar.br \
    --cc=mairacanal@riseup.net \
    --cc=rodrigo.vivi@intel.com \
    --cc=simona@ffwll.ch \
    --cc=tursulin@ursulin.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.