AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Felix Kuehling <felix.kuehling@amd.com>
To: Mukul Joshi <mukul.joshi@amd.com>, amd-gfx@lists.freedesktop.org
Cc: alexander.deucher@amd.com,
	Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
Subject: Re: [PATCHv3 3/3] drm/amdkfd: Update BadOpcode Interrupt handling with MES
Date: Fri, 16 Aug 2024 19:09:14 -0400	[thread overview]
Message-ID: <a0f20b00-e65a-4e06-9618-c09c84687b73@amd.com> (raw)
In-Reply-To: <20240816180138.1171558-3-mukul.joshi@amd.com>


On 2024-08-16 14:01, Mukul Joshi wrote:
> Based on the recommendation of MEC FW, update BadOpcode interrupt
> handling by unmapping all queues, removing the queue that got the
> interrupt from scheduling and remapping rest of the queues back when
> using MES scheduler. This is done to prevent the case where unmapping
> of the bad queue can fail thereby causing a GPU reset.
>
> Signed-off-by: Mukul Joshi <mukul.joshi@amd.com>
> Acked-by: Harish Kasiviswanathan <Harish.Kasiviswanathan@amd.com>
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>


> ---
> v1->v2:
> - No change.
>
> v2->v3:
> - No change.
>
>   .../drm/amd/amdkfd/kfd_device_queue_manager.c | 51 +++++++++++++++++++
>   .../gpu/drm/amd/amdkfd/kfd_int_process_v11.c  |  9 ++--
>   drivers/gpu/drm/amd/amdkfd/kfd_priv.h         |  1 +
>   3 files changed, 58 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> index 0ca933d2099c..d7db33f378e2 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
> @@ -2875,6 +2875,57 @@ void device_queue_manager_uninit(struct device_queue_manager *dqm)
>   	kfree(dqm);
>   }
>   
> +int kfd_dqm_suspend_bad_queue_mes(struct kfd_node *knode, u32 pasid, u32 doorbell_id)
> +{
> +	struct kfd_process_device *pdd;
> +	struct kfd_process *p = kfd_lookup_process_by_pasid(pasid);
> +	struct device_queue_manager *dqm = knode->dqm;
> +	struct device *dev = dqm->dev->adev->dev;
> +	struct qcm_process_device *qpd;
> +	struct queue *q = NULL;
> +	int ret = 0;
> +
> +	if (!p)
> +		return -EINVAL;
> +
> +	dqm_lock(dqm);
> +
> +	pdd = kfd_get_process_device_data(dqm->dev, p);
> +	if (pdd) {
> +		qpd = &pdd->qpd;
> +
> +		list_for_each_entry(q, &qpd->queues_list, list) {
> +			if (q->doorbell_id == doorbell_id && q->properties.is_active) {
> +				ret = suspend_all_queues_mes(dqm);
> +				if (ret) {
> +					dev_err(dev, "Suspending all queues failed");
> +					goto out;
> +				}
> +
> +				q->properties.is_evicted = true;
> +				q->properties.is_active = false;
> +				decrement_queue_count(dqm, qpd, q);
> +
> +				ret = remove_queue_mes(dqm, q, qpd);
> +				if (ret) {
> +					dev_err(dev, "Removing bad queue failed");
> +					goto out;
> +				}
> +
> +				ret = resume_all_queues_mes(dqm);
> +				if (ret)
> +					dev_err(dev, "Resuming all queues failed");
> +
> +				break;
> +			}
> +		}
> +	}
> +
> +out:
> +	dqm_unlock(dqm);
> +	return ret;
> +}
> +
>   static int kfd_dqm_evict_pasid_mes(struct device_queue_manager *dqm,
>   				   struct qcm_process_device *qpd)
>   {
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_int_process_v11.c b/drivers/gpu/drm/amd/amdkfd/kfd_int_process_v11.c
> index f524a55eee11..b3f988b275a8 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_int_process_v11.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_int_process_v11.c
> @@ -330,11 +330,14 @@ static void event_interrupt_wq_v11(struct kfd_node *dev,
>   		if (source_id == SOC15_INTSRC_CP_END_OF_PIPE)
>   			kfd_signal_event_interrupt(pasid, context_id0, 32);
>   		else if (source_id == SOC15_INTSRC_CP_BAD_OPCODE &&
> -			 KFD_DBG_EC_TYPE_IS_PACKET(KFD_CTXID0_CP_BAD_OP_ECODE(context_id0)))
> -			kfd_set_dbg_ev_from_interrupt(dev, pasid,
> -				KFD_CTXID0_DOORBELL_ID(context_id0),
> +			 KFD_DBG_EC_TYPE_IS_PACKET(KFD_CTXID0_CP_BAD_OP_ECODE(context_id0))) {
> +			u32 doorbell_id = KFD_CTXID0_DOORBELL_ID(context_id0);
> +
> +			kfd_set_dbg_ev_from_interrupt(dev, pasid, doorbell_id,
>   				KFD_EC_MASK(KFD_CTXID0_CP_BAD_OP_ECODE(context_id0)),
>   				NULL, 0);
> +			kfd_dqm_suspend_bad_queue_mes(dev, pasid, doorbell_id);
> +		}
>   
>   		/* SDMA */
>   		else if (source_id == SOC21_INTSRC_SDMA_TRAP)
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> index f7c12d4f0abb..7bba6bed2f48 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_priv.h
> @@ -1324,6 +1324,7 @@ struct kernel_queue *kernel_queue_init(struct kfd_node *dev,
>   					enum kfd_queue_type type);
>   void kernel_queue_uninit(struct kernel_queue *kq);
>   int kfd_dqm_evict_pasid(struct device_queue_manager *dqm, u32 pasid);
> +int kfd_dqm_suspend_bad_queue_mes(struct kfd_node *knode, u32 pasid, u32 doorbell_id);
>   
>   /* Process Queue Manager */
>   struct process_queue_node {

      reply	other threads:[~2024-08-16 23:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-16 18:01 [PATCHv3 1/3] drm/amdgpu: Implement MES Suspend and Resume APIs for GFX11 Mukul Joshi
2024-08-16 18:01 ` [PATCHv3 2/3] drm/amdkfd: Update queue unmap after VM fault with MES Mukul Joshi
2024-08-16 20:04   ` Kasiviswanathan, Harish
2024-08-16 23:08   ` Felix Kuehling
2024-08-16 18:01 ` [PATCHv3 3/3] drm/amdkfd: Update BadOpcode Interrupt handling " Mukul Joshi
2024-08-16 23:09   ` Felix Kuehling [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=a0f20b00-e65a-4e06-9618-c09c84687b73@amd.com \
    --to=felix.kuehling@amd.com \
    --cc=Harish.Kasiviswanathan@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=mukul.joshi@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