mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Maíra Canal" <mcanal@igalia.com>
To: Erick Karanja <karanja99erick@gmail.com>,
	mripard@kernel.org, dave.stevenson@raspberrypi.com
Cc: kernel-list@raspberrypi.com, maarten.lankhorst@linux.intel.com,
	tzimmermann@suse.de, airlied@gmail.com, simona@ffwll.ch,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/vc4: Replace lock/unlock pattern to use guard
Date: Wed, 12 Nov 2025 09:28:30 -0300	[thread overview]
Message-ID: <7d1df5ed-7119-4e59-b1e0-e54aa572282b@igalia.com> (raw)
In-Reply-To: <20251112080220.223318-1-karanja99erick@gmail.com>

Hi Erick,

On 12/11/25 05:02, Erick Karanja wrote:
> Replace manual lock/unlock patterns with guard.
> This simplifies the code.
> 
> Generated-by: Coccinelle SmPL
> Signed-off-by: Erick Karanja <karanja99erick@gmail.com>
> ---
>   drivers/gpu/drm/vc4/vc4_v3d.c | 45 ++++++++++++++---------------------
>   1 file changed, 18 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_v3d.c b/drivers/gpu/drm/vc4/vc4_v3d.c
> index bb09df5000bd..8271a6610d6e 100644
> --- a/drivers/gpu/drm/vc4/vc4_v3d.c
> +++ b/drivers/gpu/drm/vc4/vc4_v3d.c
> @@ -130,17 +130,15 @@ vc4_v3d_pm_get(struct vc4_dev *vc4)
>   	if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
>   		return -ENODEV;
>   
> -	mutex_lock(&vc4->power_lock);
> +	guard(mutex)(&vc4->power_lock);
>   	if (vc4->power_refcount++ == 0) {
>   		int ret = pm_runtime_get_sync(&vc4->v3d->pdev->dev);
>   
>   		if (ret < 0) {
>   			vc4->power_refcount--;
> -			mutex_unlock(&vc4->power_lock);
>   			return ret;
>   		}
>   	}
> -	mutex_unlock(&vc4->power_lock);
>   
>   	return 0;
>   }
> @@ -151,12 +149,11 @@ vc4_v3d_pm_put(struct vc4_dev *vc4)
>   	if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
>   		return;
>   
> -	mutex_lock(&vc4->power_lock);
> +	guard(mutex)(&vc4->power_lock);
>   	if (--vc4->power_refcount == 0) {
>   		pm_runtime_mark_last_busy(&vc4->v3d->pdev->dev);
>   		pm_runtime_put_autosuspend(&vc4->v3d->pdev->dev);
>   	}
> -	mutex_unlock(&vc4->power_lock);
>   }
>   
>   static void vc4_v3d_init_hw(struct drm_device *dev)
> @@ -173,7 +170,6 @@ static void vc4_v3d_init_hw(struct drm_device *dev)
>   int vc4_v3d_get_bin_slot(struct vc4_dev *vc4)
>   {
>   	struct drm_device *dev = &vc4->base;
> -	unsigned long irqflags;
>   	int slot;
>   	uint64_t seqno = 0;
>   	struct vc4_exec_info *exec;
> @@ -182,23 +178,22 @@ int vc4_v3d_get_bin_slot(struct vc4_dev *vc4)
>   		return -ENODEV;
>   
>   try_again:
> -	spin_lock_irqsave(&vc4->job_lock, irqflags);
> -	slot = ffs(~vc4->bin_alloc_used);
> -	if (slot != 0) {
> -		/* Switch from ffs() bit index to a 0-based index. */
> -		slot--;
> -		vc4->bin_alloc_used |= BIT(slot);
> -		spin_unlock_irqrestore(&vc4->job_lock, irqflags);
> -		return slot;
> -	}
> +	scoped_guard (spinlock_irqsave, &vc4->job_lock) {
> +		slot = ffs(~vc4->bin_alloc_used);
> +		if (slot != 0) {
> +			/* Switch from ffs() bit index to a 0-based index. */
> +			slot--;
> +			vc4->bin_alloc_used |= BIT(slot);
> +			return slot;
> +		}
>   
> -	/* Couldn't find an open slot.  Wait for render to complete
> +		/* Couldn't find an open slot.  Wait for render to complete
>   	 * and try again.
>   	 */

Could you please align the rest of the comment?

Best Regards,
- Maíra

      reply	other threads:[~2025-11-12 12:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12  8:02 Erick Karanja
2025-11-12 12:28 ` Maíra Canal [this message]

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=7d1df5ed-7119-4e59-b1e0-e54aa572282b@igalia.com \
    --to=mcanal@igalia.com \
    --cc=airlied@gmail.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=karanja99erick@gmail.com \
    --cc=kernel-list@raspberrypi.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --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

all inboxes | Powered by JetHome®