From: Mario Limonciello <mario.limonciello@amd.com>
To: Jiang Liu <gerry@linux.alibaba.com>,
alexander.deucher@amd.com, christian.koenig@amd.com,
Xinhui.Pan@amd.com, airlied@gmail.com, simona@ffwll.ch,
sunil.khatri@amd.com, lijo.lazar@amd.com, Hawking.Zhang@amd.com,
xiaogang.chen@amd.com, Kent.Russell@amd.com,
shuox.liu@linux.alibaba.com, amd-gfx@lists.freedesktop.org
Subject: Re: [RFC v2 03/15] drm/amdgpu: free all resources on error recovery path of amdgpu_ras_init()
Date: Thu, 16 Jan 2025 15:02:39 -0600 [thread overview]
Message-ID: <f2bfd02c-dc41-4e18-a59e-465b113e6288@amd.com> (raw)
In-Reply-To: <fe7c662f67cb5f079cef7688d033bf93539db277.1736732062.git.gerry@linux.alibaba.com>
On 1/12/2025 19:42, Jiang Liu wrote:
> Free all allocated resources on error recovery path in function
> amdgpu_ras_init().
>
> Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 19 ++++++++++++++-----
> 1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> index c10ea3fd3e16..6b508a9b1abe 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> @@ -3864,6 +3864,7 @@ static void amdgpu_ras_init_reserved_vram_size(struct amdgpu_device *adev)
> int amdgpu_ras_init(struct amdgpu_device *adev)
> {
> struct amdgpu_ras *con = amdgpu_ras_get_context(adev);
> + struct amdgpu_ras_block_list *ras_node, *tmp;
> int r;
>
> if (con)
> @@ -3953,20 +3954,20 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
> * to handle fatal error */
> r = amdgpu_nbio_ras_sw_init(adev);
> if (r)
> - return r;
> + goto release_con;
>
> if (adev->nbio.ras &&
> adev->nbio.ras->init_ras_controller_interrupt) {
> r = adev->nbio.ras->init_ras_controller_interrupt(adev);
> if (r)
> - goto release_con;
> + goto free_blocks;
> }
>
> if (adev->nbio.ras &&
> adev->nbio.ras->init_ras_err_event_athub_interrupt) {
> r = adev->nbio.ras->init_ras_err_event_athub_interrupt(adev);
> if (r)
> - goto release_con;
> + goto free_blocks;
> }
>
> /* Packed socket_id to ras feature mask bits[31:29] */
> @@ -3982,7 +3983,7 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
>
> if (amdgpu_ras_fs_init(adev)) {
> r = -EINVAL;
> - goto release_con;
> + goto free_blocks;
Reviewing this shows there is a mistake in amdgpu_ras_fs_init(). If
sysfs fails to init there it still returns 0.
Please modify amdgpu_ras_fs_init() to 'return r' and then use that
value. IE:
r = amdgpu_ras_fs_init(adev);
if (r)
goto free_blocks;
> }
>
> if (amdgpu_ras_aca_is_supported(adev)) {
> @@ -3991,7 +3992,7 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
> else
> r = amdgpu_mca_init(adev);
> if (r)
> - goto release_con;
> + goto clear_ras_fs;
> }
>
> dev_info(adev->dev, "RAS INFO: ras initialized successfully, "
> @@ -3999,6 +4000,14 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
> adev->ras_hw_enabled, adev->ras_enabled);
>
> return 0;
> +
> +clear_ras_fs:
> + amdgpu_ras_fs_fini(adev);
> +free_blocks:
> + list_for_each_entry_safe(ras_node, tmp, &adev->ras_list, node) {
> + list_del(&ras_node->node);
> + kfree(ras_node);
> + }
> release_con:
> amdgpu_ras_set_context(adev, NULL);
> kfree(con);
next prev parent reply other threads:[~2025-01-16 21:02 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 1:42 [RFC v2 00/15] Enhance device state machine to better support suspend/resume Jiang Liu
2025-01-13 1:42 ` [RFC v2 01/15] drm/amdgpu: add helper functions to track status for ras manager Jiang Liu
2025-01-17 1:13 ` Wang, Yang(Kevin)
2025-01-17 5:03 ` Lazar, Lijo
2025-01-13 1:42 ` [RFC v2 02/15] drm/amdgpu: add a flag to track ras debugfs creation status Jiang Liu
2025-01-17 5:24 ` Lazar, Lijo
2025-01-13 1:42 ` [RFC v2 03/15] drm/amdgpu: free all resources on error recovery path of amdgpu_ras_init() Jiang Liu
2025-01-16 21:02 ` Mario Limonciello [this message]
2025-01-17 5:39 ` Lazar, Lijo
2025-01-13 1:42 ` [RFC v2 04/15] drm/amdgpu: introduce a flag to track refcount held for features Jiang Liu
2025-01-17 5:46 ` Lazar, Lijo
2025-01-13 1:42 ` [RFC v2 05/15] drm/amdgpu: enhance amdgpu_ras_block_late_fini() Jiang Liu
2025-01-16 21:10 ` Mario Limonciello
2025-01-17 5:54 ` Lazar, Lijo
2025-01-13 1:42 ` [RFC v2 06/15] drm/amdgpu: enhance amdgpu_ras_pre_fini() to better support SR Jiang Liu
2025-01-16 21:19 ` Mario Limonciello
2025-01-17 6:09 ` Lazar, Lijo
2025-01-13 1:42 ` [RFC v2 07/15] drm/admgpu: rename amdgpu_ras_pre_fini() to amdgpu_ras_early_fini() Jiang Liu
2025-01-16 21:25 ` Mario Limonciello
2025-01-17 1:19 ` Wang, Yang(Kevin)
2025-01-17 8:37 ` Lazar, Lijo
2025-01-13 1:42 ` [RFC v2 08/15] drm/amdgpu: make IP block state machine works in stack like way Jiang Liu
2025-01-17 8:45 ` Lazar, Lijo
2025-01-13 1:42 ` [RFC v2 09/15] drm/amdgpu_dm: enhance amdgpu_dm_early_fini() for PM ops Jiang Liu
2025-01-16 21:30 ` Mario Limonciello
2025-01-13 1:42 ` [RFC v2 10/15] drm/admgpu: make device state machine work in stack like way Jiang Liu
2025-01-13 22:27 ` Mario Limonciello
2025-01-14 1:58 ` Gerry Liu
2025-01-15 19:36 ` Mario Limonciello
2025-01-17 8:54 ` Lazar, Lijo
2025-01-13 1:42 ` [RFC v2 11/15] drm/amdgpu: convert ip block bool flags into an enum Jiang Liu
2025-01-17 8:57 ` Lazar, Lijo
2025-01-13 1:42 ` [RFC v2 12/15] drm/amdgpu: introduce IP block iterators to reduce duplicated code Jiang Liu
2025-01-13 1:42 ` [RFC v2 13/15] drm/amdgpu: walk IP blocks in reverse order when shutdown Jiang Liu
2025-01-13 22:28 ` Mario Limonciello
2025-01-13 1:42 ` [RFC v2 14/15] drm/amdgpu/nbio: improve the way to manage irq reference count Jiang Liu
2025-01-13 1:42 ` [RFC v2 15/15] drm/amdgpu/asic: make ip block operations symmetric by .early_fini() Jiang Liu
2025-01-20 6:27 ` [RFC v2 00/15] Enhance device state machine to better support suspend/resume Zhang, Hawking
2025-01-23 0:02 ` Mika Laitio
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=f2bfd02c-dc41-4e18-a59e-465b113e6288@amd.com \
--to=mario.limonciello@amd.com \
--cc=Hawking.Zhang@amd.com \
--cc=Kent.Russell@amd.com \
--cc=Xinhui.Pan@amd.com \
--cc=airlied@gmail.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=christian.koenig@amd.com \
--cc=gerry@linux.alibaba.com \
--cc=lijo.lazar@amd.com \
--cc=shuox.liu@linux.alibaba.com \
--cc=simona@ffwll.ch \
--cc=sunil.khatri@amd.com \
--cc=xiaogang.chen@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