From: "Christian König" <christian.koenig@amd.com>
To: Qing Wang <wangqing@vivo.com>,
Alex Deucher <alexander.deucher@amd.com>,
"Pan, Xinhui" <Xinhui.Pan@amd.com>,
David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] amdgpu: assign adev after null check
Date: Tue, 15 Feb 2022 09:58:16 +0100 [thread overview]
Message-ID: <85da792e-d3c7-689f-e56a-9ec2cd7d9464@amd.com> (raw)
In-Reply-To: <1644890361-65071-1-git-send-email-wangqing@vivo.com>
Am 15.02.22 um 02:59 schrieb Qing Wang:
> From: Wang Qing <wangqing@vivo.com>
>
> adev should be assigned after a null check
I would rather remove the NULL check altogether.
The caller is supposed to make sure that the context is valid and even
if it isn't that's not a recoverable error here.
Regards,
Christian.
>
> Signed-off-by: Wang Qing <wangqing@vivo.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> index 2c929fa..da114f7
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
> @@ -259,12 +259,13 @@ static void amdgpu_ctx_fini_entity(struct amdgpu_ctx_entity *entity)
> static int amdgpu_ctx_get_stable_pstate(struct amdgpu_ctx *ctx,
> u32 *stable_pstate)
> {
> - struct amdgpu_device *adev = ctx->adev;
> + struct amdgpu_device *adev;
> enum amd_dpm_forced_level current_level;
>
> if (!ctx)
> return -EINVAL;
>
> + adev = ctx->adev;
> current_level = amdgpu_dpm_get_performance_level(adev);
>
> switch (current_level) {
> @@ -290,13 +291,14 @@ static int amdgpu_ctx_get_stable_pstate(struct amdgpu_ctx *ctx,
> static int amdgpu_ctx_set_stable_pstate(struct amdgpu_ctx *ctx,
> u32 stable_pstate)
> {
> - struct amdgpu_device *adev = ctx->adev;
> + struct amdgpu_device *adev;
> enum amd_dpm_forced_level level;
> int r;
>
> if (!ctx)
> return -EINVAL;
>
> + adev = ctx->adev;
> mutex_lock(&adev->pm.stable_pstate_ctx_lock);
> if (adev->pm.stable_pstate_ctx && adev->pm.stable_pstate_ctx != ctx) {
> r = -EBUSY;
prev parent reply other threads:[~2022-02-15 8:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-15 1:59 [PATCH] amdgpu: assign adev after null check Qing Wang
2022-02-15 8:58 ` Christian König [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=85da792e-d3c7-689f-e56a-9ec2cd7d9464@amd.com \
--to=christian.koenig@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@linux.ie \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wangqing@vivo.com \
/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