All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lizhi Hou" <lizhi.hou@amd.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH V1 1/2] accel/amdxdna: Check the fence error after waiting for a driver command
Date: Tue, 17 Nov 2026 19:44:03 +0000	[thread overview]
Message-ID: <sashiko-outbox-219517@kernel.org> (raw)
In-Reply-To: <20261117192157.154516-1-lizhi.hou@amd.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] accel/amdxdna: false -EINVAL in aie2_cmd_wait() when fence is
  garbage-collected
--

commit c14f81e589ab4e7ef12c7146189062d34baca05a
Author: Lizhi Hou <lizhi.hou@amd.com>

accel/amdxdna: Check the fence error after waiting for a driver command

This commit returns the out_fence error from aie2_cmd_wait() and checks
that return value in aie2_hwctx_cfg_debug_bo() and
aie2_hwctx_sync_debug_bo() so driver commands that fail before reaching
firmware are not treated as successful.

> diff --git a/drivers/accel/amdxdna/aie2_ctx.c b/drivers/accel/amdxdna/aie2_ctx.c
> index 74d7019268cb6..87bd6117e943f 100644
> --- a/drivers/accel/amdxdna/aie2_ctx.c
> +++ b/drivers/accel/amdxdna/aie2_ctx.c
> @@ -980,20 +980,30 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 size
>  	return ret;
>  }
>  
> -static void aie2_cmd_wait(struct amdxdna_hwctx *hwctx, u64 seq)
> +static int aie2_cmd_wait(struct amdxdna_hwctx *hwctx, u64 seq)
>  {
>  	struct dma_fence *out_fence = aie2_cmd_get_out_fence(hwctx, seq);
>  	struct amdxdna_dev *xdna = hwctx->client->xdna;
> +	int ret;
>  
>  	if (!out_fence) {
>  		XDNA_ERR(xdna, "Failed to get fence");
> -		return;
> +		return -EINVAL;
>  	}

[Severity: Medium]
Can aie2_cmd_wait() return -EINVAL for a command that already succeeded if
a concurrent submission on the same hwctx advances hwctx->priv->syncobj
before aie2_cmd_get_out_fence() runs?

drivers/accel/amdxdna/aie2_ctx.c:aie2_cmd_get_out_fence() {
    ...
	ret = dma_fence_chain_find_seqno(&fence,  seq);
	if (ret)
		goto out;

	out_fence = dma_fence_get(dma_fence_chain_contained(fence));
    ...
}

aie2_cmd_submit() drops hwctx->priv->io_lock after adding the timeline
point to hwctx->priv->syncobj, and regular command submissions via
amdxdna_drm_submit_cmd_ioctl() do not hold xdna->dev_lock:

CPU0                                  CPU1
aie2_hwctx_cfg_debug_bo()
  amdxdna_cmd_submit(..., &seq)
    ...
    drm_syncobj_add_point(..., seq)
    mutex_unlock(&hwctx->priv->io_lock)
  <job at seq finishes and signals>
                                      amdxdna_drm_submit_cmd_ioctl()
                                        ...
                                        drm_syncobj_add_point(..., seq + 1)
  aie2_cmd_wait(hwctx, seq)
    aie2_cmd_get_out_fence(hwctx, seq)
      dma_fence_chain_find_seqno(&fence, seq)
        dma_fence_chain_walk()
          /* seq is signaled: sets fence = NULL, returns 0 */
    if (!out_fence)
      return -EINVAL;  <-- false failure

When aie2_hwctx_cfg_debug_bo() hits this race, it jumps to put_cmd without
updating abo->assigned_hwctx even though firmware already executed
ATTACH_DEBUG_BO or DETACH_DEBUG_BO, leaving abo->assigned_hwctx out of
sync with firmware.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261117192157.154516-1-lizhi.hou@amd.com?part=1

      parent reply	other threads:[~2026-11-17 19:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 19:21 [PATCH V1 1/2] accel/amdxdna: Check the fence error after waiting for a driver command Lizhi Hou
2026-11-17 19:21 ` [PATCH V1 2/2] accel/amdxdna: Abort jobs when the firmware context is gone Lizhi Hou
2026-11-17 19:44 ` 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=sashiko-outbox-219517@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lizhi.hou@amd.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.