Skip to contentSkip to conversation

accel/amdxdna: Return errors for failed debug BO commands

PATCH In review Lizhi Hou 2 participants 2 messages May 29 – May 31

Subsystems (2)
lore
Share & tools
lore

Lizhi Hou

author maintainer
#0 lore raw

PATCH 1/1 accel/amdxdna: Return errors for failed debug BO commands

The config and sync debug BO commands currently may report success even when the operation fails.

Capture the firmware return status and propagate the corresponding error to userspace.

Fixes 7ea046838021 ("accel/amdxdna: Support firmware debug buffer")
---
 drivers/accel/amdxdna/aie2_ctx.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/accel/amdxdna/aie2_ctx.c +5 -8
index 2ad343728782..da89b3701f5b 100644
@@ -305,17 +305,13 @@ aie2_sched_drvcmd_resp_handler(void *handle, void __iomem *data, size_t size)
 	struct amdxdna_sched_job *job = handle;
 	int ret = 0;
 
-	if (unlikely(!data))
-		goto out;
-
-	if (unlikely(size != sizeof(u32))) {
+	if (unlikely(!data || size != sizeof(u32))) {
+		job->drv_cmd->result = U32_MAX;
 		ret = -EINVAL;
-		goto out;
+	} else {
+		job->drv_cmd->result = readl(data);
 	}
 
-	job->drv_cmd->result = readl(data);
-
-out:
 	aie2_sched_notify(job);
 	return ret;
 }
@@ -940,6 +936,7 @@ static int aie2_hwctx_cfg_debug_bo(struct amdxdna_hwctx *hwctx, u32 bo_hdl,
 	aie2_cmd_wait(hwctx, seq);
 	if (cmd.result) {
 		XDNA_ERR(xdna, "Response failure 0x%x", cmd.result);
+		ret = -EINVAL;
 		goto put_obj;
 	}
 
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Lizhi Hou

The config and sync debug BO commands currently may report success even when the operation fails.

Capture the firmware return status and propagate the corresponding error to userspace.

Fixes 7ea046838021 ("accel/amdxdna: Support firmware debug buffer")
Quoted 38 lines
---
  drivers/accel/amdxdna/aie2_ctx.c | 13 +++++--------
  1 file changed, 5 insertions(+), 8 deletions(-)
drivers/accel/amdxdna/aie2_ctx.c +5 -8
index 2ad343728782..da89b3701f5b 100644
@@ -305,17 +305,13 @@ aie2_sched_drvcmd_resp_handler(void *handle, void __iomem *data, size_t size)
  	struct amdxdna_sched_job *job = handle;
  	int ret = 0;
 
-	if (unlikely(!data))
-		goto out;
-
-	if (unlikely(size != sizeof(u32))) {
+	if (unlikely(!data || size != sizeof(u32))) {
+		job->drv_cmd->result = U32_MAX;
  		ret = -EINVAL;
-		goto out;
+	} else {
+		job->drv_cmd->result = readl(data);
  	}
 
-	job->drv_cmd->result = readl(data);
-
-out:
  	aie2_sched_notify(job);
  	return ret;
  }
@@ -940,6 +936,7 @@ static int aie2_hwctx_cfg_debug_bo(struct amdxdna_hwctx *hwctx, u32 bo_hdl,
  	aie2_cmd_wait(hwctx, seq);
  	if (cmd.result) {
  		XDNA_ERR(xdna, "Response failure 0x%x", cmd.result);
+		ret = -EINVAL;
  		goto put_obj;
  	}