From: "Lazar, Lijo" <lijo.lazar@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, Hawking.Zhang@amd.com,
mario.limonciello@amd.com, xiaogang.chen@amd.com,
Kent.Russell@amd.com, shuox.liu@linux.alibaba.com,
amd-gfx@lists.freedesktop.org
Subject: Re: [RFC v2 01/15] drm/amdgpu: add helper functions to track status for ras manager
Date: Fri, 17 Jan 2025 10:33:31 +0530 [thread overview]
Message-ID: <5b47219f-3ef1-4795-ae4d-ff04c88833c8@amd.com> (raw)
In-Reply-To: <789f547f5101fe763a9244d1bda560dd562cb604.1736732062.git.gerry@linux.alibaba.com>
On 1/13/2025 7:12 AM, Jiang Liu wrote:
> Add helper functions to track status for ras manager and ip blocks.
>
> Signed-off-by: Jiang Liu <gerry@linux.alibaba.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 38 +++++++++++++++++++++++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 37 ++++++++++++++++++++++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h | 10 +++++++
> 3 files changed, 85 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index 5e55a44f9eef..f0f773659faf 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -377,12 +377,28 @@ int amdgpu_ip_block_resume(struct amdgpu_ip_block *ip_block);
>
> #define AMDGPU_MAX_IP_NUM 16
>
> +enum amdgpu_marker {
> + // Markers for IRQs, used for both ip blocks and ras blocks.
> + AMDGPU_MARKER_IRQ0 = 32,
> + AMDGPU_MARKER_IRQ1,
> + AMDGPU_MARKER_IRQ2,
> + AMDGPU_MARKER_IRQ3,
> + AMDGPU_MARKER_IRQ4,
> + AMDGPU_MARKER_IRQ5,
> + AMDGPU_MARKER_IRQ6,
> + AMDGPU_MARKER_IRQ7,
> + AMDGPU_MARKER_IRQ_MAX = 63,
> +};
> +
> +#define AMDGPU_MARKER_IRQ(idx) (AMDGPU_MARKER_IRQ0 + (idx))
> +
> struct amdgpu_ip_block_status {
> bool valid;
> bool sw;
> bool hw;
> bool late_initialized;
> bool hang;
> + uint64_t markers;
> };
>
This fine grained levels maintained at IP layer doesn't look like a
proper solution. It's either IP or RAS block has the required IRQs
enabled or disabled. Unwinding them needs to be tracked at IRQ object
layer and not here.
Thanks,
Lijo
> struct amdgpu_ip_block_version {
> @@ -410,6 +426,28 @@ amdgpu_device_ip_get_ip_block(struct amdgpu_device *adev,
> int amdgpu_device_ip_block_add(struct amdgpu_device *adev,
> const struct amdgpu_ip_block_version *ip_block_version);
>
> +static inline void amdgpu_ip_block_set_marker(struct amdgpu_ip_block *ip_block,
> + enum amdgpu_marker marker)
> +{
> + WARN_ON(marker > 63);
> + WARN_ON(ip_block->status.markers & (0x1ull << marker));
> + ip_block->status.markers |= 0x1ull << (int)marker;
> +}
> +
> +static inline bool amdgpu_ip_block_test_and_clear_marker(struct amdgpu_ip_block *ip_block,
> + enum amdgpu_marker marker)
> +{
> + bool set = false;
> + uint64_t value = 0x1ull << (int)marker;
> +
> + if ((ip_block->status.markers & value) != 0) {
> + ip_block->status.markers &= ~value;
> + set = true;
> + }
> +
> + return set;
> +}
> +
> /*
> * BIOS.
> */
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> index f0924aa3f4e4..5e19d820ab34 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
> @@ -5207,3 +5207,40 @@ bool amdgpu_ras_is_rma(struct amdgpu_device *adev)
>
> return con->is_rma;
> }
> +
> +bool amdgpu_ras_test_marker(struct amdgpu_device *adev,
> + struct ras_common_if *head, int marker)
> +{
> + struct ras_manager *obj = amdgpu_ras_find_obj(adev, head);
> +
> + if (obj && obj->markers & (0x1ull << marker))
> + return true;
> +
> + return false;
> +}
> +
> +void amdgpu_ras_set_marker(struct amdgpu_device *adev,
> + struct ras_common_if *head, int marker)
> +{
> + struct ras_manager *obj = amdgpu_ras_find_obj(adev, head);
> +
> + WARN_ON(marker > 63);
> + WARN_ON(obj->markers & (0x1ull << marker));
> + if (obj)
> + obj->markers |= 0x1ull << marker;
> +}
> +
> +bool amdgpu_ras_test_and_clear_marker(struct amdgpu_device *adev,
> + struct ras_common_if *head, int marker)
> +{
> + bool set = false;
> + uint64_t value = 0x1ull << marker;
> + struct ras_manager *obj = amdgpu_ras_find_obj(adev, head);
> +
> + if (obj && (obj->markers & value) != 0) {
> + obj->markers &= ~value;
> + set = true;
> + }
> +
> + return set;
> +}
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
> index 82db986c36a0..35881087b17b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.h
> @@ -634,6 +634,8 @@ struct ras_manager {
> struct ras_common_if head;
> /* reference count */
> int use;
> + /* Flags for status tracking */
> + uint64_t markers;
> /* ras block link */
> struct list_head node;
> /* the device */
> @@ -977,4 +979,12 @@ void amdgpu_ras_event_log_print(struct amdgpu_device *adev, u64 event_id,
> const char *fmt, ...);
>
> bool amdgpu_ras_is_rma(struct amdgpu_device *adev);
> +
> +bool amdgpu_ras_test_marker(struct amdgpu_device *adev,
> + struct ras_common_if *head, int marker);
> +void amdgpu_ras_set_marker(struct amdgpu_device *adev,
> + struct ras_common_if *head, int marker);
> +bool amdgpu_ras_test_and_clear_marker(struct amdgpu_device *adev,
> + struct ras_common_if *head,
> + int marker);
> #endif
next prev parent reply other threads:[~2025-01-17 5:03 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 [this message]
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
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=5b47219f-3ef1-4795-ae4d-ff04c88833c8@amd.com \
--to=lijo.lazar@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=mario.limonciello@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