From: "Chen, Xiaogang" <xiaogang.chen@amd.com>
To: Jiang Liu <gerry@linux.alibaba.com>,
amd-gfx@lists.freedesktop.org, kent.russell@amd.com,
shuox.liu@linux.alibaba.com
Subject: Re: [PATCH 1/6] amdgpu: add flags to track sysfs initialization status
Date: Thu, 2 Jan 2025 17:07:39 -0600 [thread overview]
Message-ID: <c1a4e8a6-2d6e-4e30-a6db-24c0a17b635d@amd.com> (raw)
In-Reply-To: <737a46d7273d625ef8a1146925296bbdf57f2274.1735795671.git.gerry@linux.alibaba.com>
On 1/1/2025 11:36 PM, Jiang Liu wrote:
> Add flags to track sysfs initialization status, so we can correctly
> clean them up on error recover paths.
>
> Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 3 ++
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 34 +++++++++++++++++-----
> 2 files changed, 30 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 22c7e9669162..e4b13e729770 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -1157,6 +1157,9 @@ struct amdgpu_device {
> bool in_runpm;
> bool has_pr3;
>
> + bool sysfs_en;
> + bool fru_sysfs_en;
> + bool reg_state_sysfs_en;
> bool ucode_sysfs_en;
>
> struct amdgpu_fru_info *fru_info;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index d1bb9e85b6d7..3244966b0c39 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -4533,8 +4533,13 @@ int amdgpu_device_init(struct amdgpu_device *adev,
> adev->ucode_sysfs_en = true;
>
> r = sysfs_create_files(&adev->dev->kobj, amdgpu_dev_attributes);
> - if (r)
> + if (r) {
> dev_err(adev->dev, "Could not create amdgpu device attr\n");
> + adev->sysfs_en = false;
> + } else {
> + adev->sysfs_en = true;
> + }
> +
not need use {}
> #ifdef HAVE_PCI_DRIVER_DEV_GROUPS
> r = devm_device_add_group(adev->dev, &amdgpu_board_attrs_group);
> if (r)
> @@ -4542,8 +4547,21 @@ int amdgpu_device_init(struct amdgpu_device *adev,
> "Could not create amdgpu board attributes\n");
> #endif
>
> - amdgpu_fru_sysfs_init(adev);
> - amdgpu_reg_state_sysfs_init(adev);
> + r = amdgpu_fru_sysfs_init(adev);
> + if (r) {
> + dev_err(adev->dev, "Could not create amdgpu fru attr\n");
> + adev->fru_sysfs_en = false;
> + } else {
> + adev->fru_sysfs_en = true;
> + }
not need use {}
> +
> + r = amdgpu_reg_state_sysfs_init(adev);
> + if (r) {
> + dev_err(adev->dev, "Could not create amdgpu reg state attr\n");
> + adev->reg_state_sysfs_en = false;
> + } else {
> + adev->reg_state_sysfs_en = true;
> + }
same as above
>
> if (IS_ENABLED(CONFIG_PERF_EVENTS))
> r = amdgpu_pmu_init(adev);
> @@ -4666,10 +4684,12 @@ void amdgpu_device_fini_hw(struct amdgpu_device *adev)
> amdgpu_pm_sysfs_fini(adev);
> if (adev->ucode_sysfs_en)
> amdgpu_ucode_sysfs_fini(adev);
> - sysfs_remove_files(&adev->dev->kobj, amdgpu_dev_attributes);
> - amdgpu_fru_sysfs_fini(adev);
> -
> - amdgpu_reg_state_sysfs_fini(adev);
> + if (adev->sysfs_en)
> + sysfs_remove_files(&adev->dev->kobj, amdgpu_dev_attributes);
> + if (adev->fru_sysfs_en)
> + amdgpu_fru_sysfs_fini(adev);
> + if (adev->reg_state_sysfs_en)
> + amdgpu_reg_state_sysfs_fini(adev);
If creations of these sys entries fail does kernel send warnings or just
ignore that when delete these entries? Seems kernel keeps silence for
this case.
Regards
Xiaogang
>
> /* disable ras feature must before hw fini */
> amdgpu_ras_pre_fini(adev);
next prev parent reply other threads:[~2025-01-02 23:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-02 5:36 [PATCH 0/6] Fix several bugs in error handling during device Jiang Liu
2025-01-02 5:36 ` [PATCH 1/6] amdgpu: add flags to track sysfs initialization status Jiang Liu
2025-01-02 23:07 ` Chen, Xiaogang [this message]
2025-01-03 13:46 ` Russell, Kent
2025-01-03 4:04 ` Lazar, Lijo
2025-01-02 5:36 ` [PATCH 2/6] amdgpu: fix invalid memory access in kfd_cleanup_nodes() Jiang Liu
2025-01-02 23:08 ` Chen, Xiaogang
2025-01-03 2:22 ` Gerry Liu
2025-01-03 5:44 ` Chen, Xiaogang
2025-01-03 5:55 ` Gerry Liu
2025-01-03 6:19 ` Chen, Xiaogang
2025-01-03 7:05 ` Gerry Liu
2025-01-03 17:33 ` Chen, Xiaogang
2025-01-04 14:18 ` Gerry Liu
2025-01-02 5:36 ` [PATCH 3/6] amdgpu: clear adev->in_suspend flag when fails to suspend Jiang Liu
2025-01-02 5:36 ` [PATCH 4/6] amdgpu: fix use after free bug related to amdgpu_driver_release_kms() Jiang Liu
2025-01-03 5:20 ` Lazar, Lijo
2025-01-03 5:58 ` Chen, Xiaogang
2025-01-03 7:02 ` Gerry Liu
2025-01-03 7:43 ` Shuo Liu
2025-01-03 17:34 ` Chen, Xiaogang
2025-01-04 14:21 ` Gerry Liu
2025-01-02 5:36 ` [PATCH 5/6] amdgpu: fix invalid memory access in amdgpu_fence_driver_sw_fini() Jiang Liu
2025-01-02 23:09 ` Chen, Xiaogang
2025-01-03 2:35 ` Gerry Liu
2025-01-02 5:36 ` [PATCH 6/6] amdgpu: get rid of false warnings caused by amdgpu_irq_put() Jiang Liu
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=c1a4e8a6-2d6e-4e30-a6db-24c0a17b635d@amd.com \
--to=xiaogang.chen@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=gerry@linux.alibaba.com \
--cc=kent.russell@amd.com \
--cc=shuox.liu@linux.alibaba.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