public inbox for drm-ai-reviews@public-inbox.freedesktop.org
 help / color / mirror / Atom feed
From: Christian König <christian.koenig@amd.com>
To: Andre Hirata <andrejhirata@usp.br>,
	kenneth.feng@amd.com, alexander.deucher@amd.com,
	airlied@gmail.com, simona@ffwll.ch
Cc: Gabriel Dimant <gabriel.dimant@usp.br>,
	Guilherme Gabriel <guilhermesangabriel@usp.br>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH RESEND] drm/amd/pm: Use guard(mutex) instead of manual lock+unlock
Date: Fri, 8 May 2026 10:43:48 +0200	[thread overview]
Message-ID: <dcc966e0-da1d-4589-ad04-02aeb1a8e06f@amd.com> (raw)
In-Reply-To: <20260508024744.6523-1-andrejhirata@usp.br>

Just two notes, apart from that looks like a nice cleanup to me.

On 5/8/26 04:47, Andre Hirata wrote:
> @@ -46,10 +47,9 @@ int amdgpu_dpm_get_sclk(struct amdgpu_device *adev, bool low)
>         if (!pp_funcs->get_sclk)
>                 return 0;
> 
> -       mutex_lock(&adev->pm.mutex);
> +       guard(mutex)(&adev->pm.mutex);
>         ret = pp_funcs->get_sclk((adev)->powerplay.pp_handle,
>                                  low);
> -       mutex_unlock(&adev->pm.mutex);
> 
>         return ret;

In a lot of cases you can now turn the patter "ret = f(...); return ret;" into just return f(..); and potentially drop the ret variable.

>  }
> 
> @@ -291,9 +265,8 @@ bool amdgpu_dpm_is_mode1_reset_supported(struct amdgpu_device *adev)
>         bool support_mode1_reset = false;
> 
>         if (is_support_sw_smu(adev)) {
> -               mutex_lock(&adev->pm.mutex);
> +               guard(mutex)(&adev->pm.mutex);
>                 support_mode1_reset = smu_mode1_reset_is_support(smu);
> -               mutex_unlock(&adev->pm.mutex);
>         }
> 
>         return support_mode1_reset;

For cases like this here the coding pattern to check the pre-requisites and abort early is usually better.

So this example here would become:

if (!is_support_sw_smu(adev))
	return false;

guard(mutex)(&adev->pm.mutex);
return smu_mode1_reset_is_support(smu);

Which as far as I can see is less code and much easier to read/understand.

But both suggestions could be a separate patch if you want to keep this one as it is.

Regards,
Christian.

  reply	other threads:[~2026-05-08  8:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08  2:47 [PATCH RESEND] drm/amd/pm: Use guard(mutex) instead of manual lock+unlock Andre Hirata
2026-05-08  8:43 ` Christian König [this message]
2026-05-08 10:36   ` Andre Jun Hirata
2026-05-08 11:12 ` [PATCH v2] " Andre Jun Hirata
2026-05-08 12:44   ` Christian König
2026-05-08 14:21   ` [PATCH v3] " Andre Jun Hirata
2026-05-08 17:23     ` [PATCH v4] " Andre Jun Hirata
2026-05-08 23:03       ` [PATCH v5] " Andre Jun Hirata
2026-05-11  4:58         ` Wang, Yang(Kevin)
2026-05-11 12:42           ` [PATCH v6] " Andre Jun Hirata
2026-05-11 13:50             ` Lazar, Lijo
2026-05-12 23:04               ` [PATCH v7] " Andre Jun Hirata
2026-05-13  5:38                 ` [PATCH v8] " Andre Jun Hirata
2026-05-13  4:39         ` [PATCH v5] " kernel test robot
2026-05-13  6:12         ` kernel test robot
2026-05-13  5:11       ` [PATCH v4] " kernel test robot
2026-05-16  2:18 ` Claude review: " Claude Code Review Bot
2026-05-16  2:18 ` Claude Code Review Bot

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=dcc966e0-da1d-4589-ad04-02aeb1a8e06f@amd.com \
    --to=christian.koenig@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=andrejhirata@usp.br \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gabriel.dimant@usp.br \
    --cc=guilhermesangabriel@usp.br \
    --cc=kenneth.feng@amd.com \
    --cc=simona@ffwll.ch \
    /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