From: SRINIVASAN SHANMUGAM <srinivasan.shanmugam@amd.com>
To: Alex Deucher <alexander.deucher@amd.com>, amd-gfx@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/amdkfd: add an interface to query whether is KFD is active
Date: Mon, 28 Oct 2024 20:49:42 +0530 [thread overview]
Message-ID: <d599d954-e8cd-41f1-ac78-5720b6c8219b@amd.com> (raw)
In-Reply-To: <20241028145242.3672515-1-alexander.deucher@amd.com>
The series is:
Acked-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com>
On 10/28/2024 8:22 PM, Alex Deucher wrote:
> Add an interface to query whether KFD has any active queues.
>
> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c | 9 ++++++++
> drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 7 ++++++
> drivers/gpu/drm/amd/amdkfd/kfd_device.c | 25 ++++++++++++++++++++++
> drivers/gpu/drm/amd/amdkfd/kfd_priv.h | 1 +
> 4 files changed, 42 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> index b545940e512b..82f1c6a19d79 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
> @@ -890,6 +890,15 @@ int amdgpu_amdkfd_start_sched(struct amdgpu_device *adev, uint32_t node_id)
> return kgd2kfd_start_sched(adev->kfd.dev, node_id);
> }
>
> +/* check if there are KFD queues active */
> +bool amdgpu_amdkfd_compute_active(struct amdgpu_device *adev, uint32_t node_id)
> +{
> + if (!adev->kfd.init_complete)
> + return 0;
> +
> + return kgd2kfd_compute_active(adev->kfd.dev, node_id);
> +}
> +
> /* Config CGTT_SQ_CLK_CTRL */
> int amdgpu_amdkfd_config_sq_perfmon(struct amdgpu_device *adev, uint32_t xcp_id,
> bool core_override_enable, bool reg_override_enable, bool perfmon_override_enable)
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
> index 7e0a22072536..f47f4555437b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
> @@ -268,6 +268,7 @@ int amdgpu_amdkfd_start_sched(struct amdgpu_device *adev, uint32_t node_id);
> int amdgpu_amdkfd_stop_sched(struct amdgpu_device *adev, uint32_t node_id);
> int amdgpu_amdkfd_config_sq_perfmon(struct amdgpu_device *adev, uint32_t xcp_id,
> bool core_override_enable, bool reg_override_enable, bool perfmon_override_enable);
> +bool amdgpu_amdkfd_compute_active(struct amdgpu_device *adev, uint32_t node_id);
>
>
> /* Read user wptr from a specified user address space with page fault
> @@ -431,6 +432,7 @@ int kgd2kfd_check_and_lock_kfd(void);
> void kgd2kfd_unlock_kfd(void);
> int kgd2kfd_start_sched(struct kfd_dev *kfd, uint32_t node_id);
> int kgd2kfd_stop_sched(struct kfd_dev *kfd, uint32_t node_id);
> +bool kgd2kfd_compute_active(struct kfd_dev *kfd, uint32_t node_id);
> #else
> static inline int kgd2kfd_init(void)
> {
> @@ -511,5 +513,10 @@ static inline int kgd2kfd_stop_sched(struct kfd_dev *kfd, uint32_t node_id)
> {
> return 0;
> }
> +
> +bool kgd2kfd_compute_active(struct kfd_dev *kfd, uint32_t node_id)
> +{
> + return false;
> +}
> #endif
> #endif /* AMDGPU_AMDKFD_H_INCLUDED */
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device.c b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
> index b1ce73c7a9ab..9d8bdead6e65 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device.c
> @@ -1404,6 +1404,13 @@ void kfd_dec_compute_active(struct kfd_node *node)
> WARN_ONCE(count < 0, "Compute profile ref. count error");
> }
>
> +bool kfd_compute_active(struct kfd_node *node)
> +{
> + if (atomic_read(&node->kfd->compute_profile))
> + return true;
> + return false;
> +}
> +
> void kgd2kfd_smi_event_throttle(struct kfd_dev *kfd, uint64_t throttle_bitmask)
> {
> /*
> @@ -1497,6 +1504,24 @@ int kgd2kfd_stop_sched(struct kfd_dev *kfd, uint32_t node_id)
> return node->dqm->ops.halt(node->dqm);
> }
>
> +bool kgd2kfd_compute_active(struct kfd_dev *kfd, uint32_t node_id)
> +{
> + struct kfd_node *node;
> +
> + if (!kfd->init_complete)
> + return false;
> +
> + if (node_id >= kfd->num_nodes) {
> + dev_warn(kfd->adev->dev, "Invalid node ID: %u exceeds %u\n",
> + node_id, kfd->num_nodes - 1);
> + return false;
> + }
> +
> + node = kfd->nodes[node_id];
> +
> + return kfd_compute_active(node);
> +}
> +
> #if defined(CONFIG_DEBUG_FS)
>
> /* This function will send a package to HIQ to hang the HWS
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> index 9e5ca0b93b2a..f9140fdb8132 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> @@ -1518,6 +1518,7 @@ bool kfd_is_locked(void);
> /* Compute profile */
> void kfd_inc_compute_active(struct kfd_node *dev);
> void kfd_dec_compute_active(struct kfd_node *dev);
> +bool kfd_compute_active(struct kfd_node *dev);
>
> /* Cgroup Support */
> /* Check with device cgroup if @kfd device is accessible */
prev parent reply other threads:[~2024-10-28 15:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 14:52 [PATCH 1/2] drm/amdkfd: add an interface to query whether is KFD is active Alex Deucher
2024-10-28 14:52 ` [PATCH 2/2] drm/amdgpu: fix fairness in enforce isolation handling Alex Deucher
2024-10-28 15:19 ` SRINIVASAN SHANMUGAM [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=d599d954-e8cd-41f1-ac78-5720b6c8219b@amd.com \
--to=srinivasan.shanmugam@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
/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