From: Lizhi Hou <lizhi.hou@amd.com>
To: Jackie Liu <liu.yun@linux.dev>, <mamin506@gmail.com>
Cc: <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH 2/2] accel/amdxdna: fix error code being silently swallowed in hwctx status queries
Date: Wed, 3 Jun 2026 09:52:21 -0700 [thread overview]
Message-ID: <cd920aab-40a8-aa57-e33b-67c01cca6f91@amd.com> (raw)
In-Reply-To: <20260603013543.94835-2-liu.yun@linux.dev>
On 6/2/26 18:35, Jackie Liu wrote:
> From: Jackie Liu <liuyun01@kylinos.cn>
>
> Both aie2_get_hwctx_status() and aie2_query_ctx_status_array() iterate
> over hardware contexts calling amdxdna_hwctx_walk() with a callback
> that can fail with -ENOMEM (allocation failure) or -EFAULT
> (copy_to_user failure). When the walk fails, the loop correctly breaks
> but the functions always return 0 to userspace, swallowing the error.
>
> This means userspace receives no indication that the data may be
> incomplete or that the operation failed. Save the error code and
> return it to properly propagate failures to userspace.
>
> Fixes: 81233d5419cf ("accel/amdxdna: Fix uninitialized return value")
The retrieving information can be partially done. The amount of valid
results is indicated by the returned buffer_size, element_size, and
num_element fields. Thus, 0 is returned. So user space will not consider
this is a broken error and still get the partial results.
Lizhi
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
> drivers/accel/amdxdna/aie2_pci.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/aie2_pci.c b/drivers/accel/amdxdna/aie2_pci.c
> index 4500b9ccb02e..0ff87fafd049 100644
> --- a/drivers/accel/amdxdna/aie2_pci.c
> +++ b/drivers/accel/amdxdna/aie2_pci.c
> @@ -908,7 +908,7 @@ static int aie2_get_hwctx_status(struct amdxdna_client *client,
> struct amdxdna_drm_get_array array_args;
> struct amdxdna_dev *xdna = client->xdna;
> struct amdxdna_client *tmp_client;
> - int ret;
> + int ret = 0;
>
> drm_WARN_ON(&xdna->ddev, !mutex_is_locked(&xdna->dev_lock));
>
> @@ -923,7 +923,7 @@ static int aie2_get_hwctx_status(struct amdxdna_client *client,
> }
>
> args->buffer_size -= (u32)(array_args.buffer - args->buffer);
> - return 0;
> + return ret;
> }
>
> static int aie2_query_resource_info(struct amdxdna_client *client,
> @@ -1105,7 +1105,7 @@ static int aie2_query_ctx_status_array(struct amdxdna_client *client,
> struct amdxdna_drm_get_array array_args;
> struct amdxdna_dev *xdna = client->xdna;
> struct amdxdna_client *tmp_client;
> - int ret;
> + int ret = 0;
>
> drm_WARN_ON(&xdna->ddev, !mutex_is_locked(&xdna->dev_lock));
>
> @@ -1131,7 +1131,7 @@ static int aie2_query_ctx_status_array(struct amdxdna_client *client,
> args->num_element = (u32)((array_args.buffer - args->buffer) /
> args->element_size);
>
> - return 0;
> + return ret;
> }
>
> static int aie2_get_array(struct amdxdna_client *client,
next prev parent reply other threads:[~2026-06-03 16:52 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-03 1:35 [PATCH 1/2] accel/amdxdna: fix memory leak in amdxdna_iommu_alloc() when iommu_map() fails Jackie Liu
2026-06-03 1:35 ` [PATCH 2/2] accel/amdxdna: fix error code being silently swallowed in hwctx status queries Jackie Liu
2026-06-03 16:52 ` Lizhi Hou [this message]
2026-06-03 16:29 ` [PATCH 1/2] accel/amdxdna: fix memory leak in amdxdna_iommu_alloc() when iommu_map() fails Lizhi Hou
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=cd920aab-40a8-aa57-e33b-67c01cca6f91@amd.com \
--to=lizhi.hou@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=liu.yun@linux.dev \
--cc=mamin506@gmail.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