From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: "Sunil Khatri" <sunil.khatri@amd.com>,
"Alex Deucher" <alexander.deucher@amd.com>,
"Christian König" <christian.koenig@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH v4 05/15] drm/amdgpu: validate hw_fini before function call
Date: Thu, 17 Oct 2024 13:52:38 +0200 [thread overview]
Message-ID: <b44b172b-675c-465a-8329-1d93f2abc04e@gmail.com> (raw)
In-Reply-To: <20241017100615.1492144-6-sunil.khatri@amd.com>
Am 17.10.24 um 12:06 schrieb Sunil Khatri:
> Before making a function call to hw_fini, validate
> the function pointer like we do in sw_init.
>
> Signed-off-by: Sunil Khatri <sunil.khatri@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 33 ++++++++++++++--------
> 1 file changed, 22 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index cf84b50f2355..96cecd4a636b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -3287,11 +3287,17 @@ static void amdgpu_device_smu_fini_early(struct amdgpu_device *adev)
> if (!adev->ip_blocks[i].status.hw)
> continue;
> if (adev->ip_blocks[i].version->type == AMD_IP_BLOCK_TYPE_SMC) {
> - r = adev->ip_blocks[i].version->funcs->hw_fini(&adev->ip_blocks[i]);
> - /* XXX handle errors */
> - if (r) {
> - DRM_DEBUG("hw_fini of IP block <%s> failed %d\n",
> - adev->ip_blocks[i].version->funcs->name, r);
> + if (!adev->ip_blocks[i].version->funcs->hw_fini) {
> + DRM_ERROR("hw_fini of IP block <%s> not defined\n",
> + adev->ip_blocks[i].version->funcs->name);
> + } else {
> + r = adev->ip_blocks[i].version->funcs->hw_fini(
> + &adev->ip_blocks[i]);
> + /* XXX handle errors */
> + if (r) {
> + DRM_DEBUG("hw_fini of IP block <%s> failed %d\n",
> + adev->ip_blocks[i].version->funcs->name, r);
> + }
> }
> adev->ip_blocks[i].status.hw = false;
> break;
> @@ -3325,12 +3331,17 @@ static int amdgpu_device_ip_fini_early(struct amdgpu_device *adev)
> for (i = adev->num_ip_blocks - 1; i >= 0; i--) {
> if (!adev->ip_blocks[i].status.hw)
> continue;
> -
> - r = adev->ip_blocks[i].version->funcs->hw_fini(&adev->ip_blocks[i]);
> - /* XXX handle errors */
> - if (r) {
> - DRM_DEBUG("hw_fini of IP block <%s> failed %d\n",
> - adev->ip_blocks[i].version->funcs->name, r);
> + if (!adev->ip_blocks[i].version->funcs->hw_fini) {
> + DRM_ERROR("hw_fini of IP block <%s> not defined\n",
> + adev->ip_blocks[i].version->funcs->name);
> + } else {
> + r = adev->ip_blocks[i].version->funcs->hw_fini(
> + &adev->ip_blocks[i]);
> + /* XXX handle errors */
> + if (r) {
> + DRM_DEBUG("hw_fini of IP block <%s> failed %d\n",
> + adev->ip_blocks[i].version->funcs->name, r);
> + }
I strongly suggest to make this a separate function, e.g. something like
amdgpu_ip_block_hw_fini() and then call it twice.
Regards,
Christian.
> }
>
> adev->ip_blocks[i].status.hw = false;
next prev parent reply other threads:[~2024-10-17 11:52 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 10:06 [PATCH v4 00/15] validate/clean the functions of ip funcs Sunil Khatri
2024-10-17 10:06 ` [PATCH v4 01/15] drm/amdgpu: validate sw_init before function call Sunil Khatri
2024-10-17 10:06 ` [PATCH v4 02/15] drm/amdgpu: clean the dummy sw_init functions Sunil Khatri
2024-10-17 10:06 ` [PATCH v4 03/15] drm/amdgpu: validate sw_fini before function call Sunil Khatri
2024-10-17 10:06 ` [PATCH v4 04/15] drm/amdgpu: clean the dummy sw_fini functions Sunil Khatri
2024-10-17 10:06 ` [PATCH v4 05/15] drm/amdgpu: validate hw_fini before function call Sunil Khatri
2024-10-17 11:52 ` Christian König [this message]
2024-10-17 12:44 ` Khatri, Sunil
2024-10-17 10:06 ` [PATCH v4 06/15] drm/amdgpu: validate suspend " Sunil Khatri
2024-10-17 11:54 ` Christian König
2024-10-17 12:45 ` Khatri, Sunil
2024-10-17 10:06 ` [PATCH v4 07/15] drm/amdgpu: validate resume " Sunil Khatri
2024-10-17 11:55 ` Christian König
2024-10-17 12:46 ` Khatri, Sunil
2024-10-17 10:06 ` [PATCH v4 08/15] drm/amdgpu: validate wait_for_idle " Sunil Khatri
2024-10-17 10:06 ` [PATCH v4 09/15] drm/amdgpu: clean the dummy resume functions Sunil Khatri
2024-10-17 10:06 ` [PATCH v4 10/15] drm/amdgpu: clean the dummy suspend functions Sunil Khatri
2024-10-17 10:06 ` [PATCH v4 11/15] drm/amdgpu: clean the dummy hw_fini functions Sunil Khatri
2024-10-17 11:58 ` Christian König
2024-10-17 12:47 ` Khatri, Sunil
2024-10-17 10:06 ` [PATCH v4 12/15] drm/amdgpu: clean the dummy wait_for_idle functions Sunil Khatri
2024-10-17 10:06 ` [PATCH v4 13/15] drm/amdgpu: clean the dummy soft_reset functions Sunil Khatri
2024-10-17 10:06 ` [PATCH v4 14/15] drm/amdgpu: clean unused functions of amd_ip_funcs Sunil Khatri
2024-10-17 12:18 ` Christian König
2024-10-17 12:49 ` Khatri, Sunil
2024-10-17 10:06 ` [PATCH v4 15/15] drm/amdgpu: validate get_clockgating_state before use Sunil Khatri
2024-10-17 12:20 ` Christian König
2024-10-17 12:55 ` Khatri, Sunil
2024-10-17 13:15 ` Christian König
2024-10-17 12:23 ` [PATCH v4 00/15] validate/clean the functions of ip funcs Christian König
2024-10-17 12:57 ` Khatri, Sunil
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=b44b172b-675c-465a-8329-1d93f2abc04e@gmail.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=sunil.khatri@amd.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