dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ulisses Paixao" <ulissespaixao@usp.br>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 RESEND] drm/amd/amdgpu: remove duplicated code in gfx_v11 and gfx_v12
Date: Sun, 21 Jun 2026 11:48:05 +0000	[thread overview]
Message-ID: <20260621114806.59E951F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260620160407.8195-1-ulissespaixao@usp.br>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The refactored `amdgpu_gfx_handle_priv_fault` removes the `if (!adev->gfx.disable_kq)` guard, which can cause spurious scheduler faults and GPU resets when kernel queues are disabled.
--

commit 29fea06b4689e38bf654d74c9ec057d4896972a0
Author: Ulisses Paixao <ulissespaixao@usp.br>

drm/amd/amdgpu: remove duplicated code in gfx_v11 and gfx_v12

This commit refactors duplicated ring-searching logic from
gfx_v11_0_handle_priv_fault and gfx_v12_0_handle_priv_fault into a common
function amdgpu_gfx_handle_priv_fault in amdgpu_gfx.c.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> index 0506b90f318e4..120843a8d1ba2 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
[ ... ]
> @@ -855,6 +855,40 @@ int amdgpu_gfx_enable_kgq(struct amdgpu_device *adev, int xcc_id)
>  	return r;
>  }
>  
> +/**
> + * amdgpu_gfx_handle_priv_fault - Handle privileged instruction fault
> + *
> + * @adev: amdgpu_device pointer
> + * @me_id: micro-engine ID of the faulty ring
> + * @pipe_id: pipe ID of the faulty ring
> + * @queue_id: queue ID of the faulty ring
> + *
> + * This function handles privileged instruction faults by identifying
> + * the faulty ring (gfx or compute) and triggering a scheduler fault
> + */
> +void amdgpu_gfx_handle_priv_fault(struct amdgpu_device *adev,
> +					u8 me_id, u8 pipe_id, u8 queue_id)
> +{
> +	struct amdgpu_ring *ring;
> +	int i;
> +
> +	for (i = 0; i < adev->gfx.num_gfx_rings; i++) {
> +		ring = &adev->gfx.gfx_ring[i];
> +		if (ring->me == me_id && ring->pipe == pipe_id &&
> +		    ring->queue == queue_id) {
> +			drm_sched_fault(&ring->sched);

[Severity: High]
Is it possible we lost the check for !adev->gfx.disable_kq during this
refactoring?

If kernel queues are disabled (e.g. when MES is managing user queues), the
kernel rings might still exist but not be actively handling submissions.
If a privileged instruction fault originates from a user queue with an
overlapping me_id, pipe_id, and queue_id, could this match an idle kernel
ring and incorrectly trigger drm_sched_fault(&ring->sched)?

This could lead to an unwarranted GPU reset via the TDR handler rather than
leaving the event for proper user queue fault handling.

> +			return;
> +		}
> +	}
[ ... ]
> diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> index 6346f16c4e613..83fc2dbe8f7f5 100644
> --- a/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
> @@ -6684,37 +6684,12 @@ static void gfx_v11_0_handle_priv_fault(struct amdgpu_device *adev,
>  					struct amdgpu_iv_entry *entry)
>  {
>  	u8 me_id, pipe_id, queue_id;
> -	struct amdgpu_ring *ring;
> -	int i;
>  
>  	me_id = (entry->ring_id & 0x0c) >> 2;
>  	pipe_id = (entry->ring_id & 0x03) >> 0;
>  	queue_id = (entry->ring_id & 0x70) >> 4;
>  
> -	if (!adev->gfx.disable_kq) {

[Severity: High]
For context, here is where the guard was dropped from the original version
specific handler.

> -		switch (me_id) {
> -		case 0:
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260620160407.8195-1-ulissespaixao@usp.br?part=1

      reply	other threads:[~2026-06-21 11:48 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-29 17:36 [PATCH] drm/amd/amdgpu: remove duplicated code in gfx_v11 and gfx_v12 Ulisses Paixao
2026-04-30  6:21 ` Christian König
2026-05-05  2:14   ` [PATCH v2] " Ulisses Paixao
2026-05-05  7:16     ` Christian König
2026-05-05  7:40     ` Lazar, Lijo
2026-05-05 17:50       ` [PATCH v3] " Ulisses Paixao
2026-05-25  8:51         ` Guilherme Ivo Bozi
2026-06-20 16:04           ` [PATCH v3 RESEND] " Ulisses Paixao
2026-06-21 11:48             ` sashiko-bot [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=20260621114806.59E951F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=ulissespaixao@usp.br \
    /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