Skip to contentSkip to conversation

accel/amdxdna: Return error when setting clock failed for npu1

PATCH Superseded Lizhi Hou 2 participants 2 messages Jan 8, 2025 – Jan 9, 2025

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Lizhi Hou

author maintainer
#0 lore raw

PATCH 1/1 accel/amdxdna: Return error when setting clock failed for npu1

Due to miss returning error when setting clock, the smatch static checker reports warning:
drivers/accel/amdxdna/aie2_smu.c:68 npu1_set_dpm()
error: uninitialized symbol 'freq'.

Fixes f4d7b8a6bc8c ("accel/amdxdna: Enhance power management settings")
---
 drivers/accel/amdxdna/aie2_smu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/accel/amdxdna/aie2_smu.c +3 -1
index 73388443c676..e68aaf7cd9f2 100644
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (C) 2022-2024, Advanced Micro Devices, Inc.
+ * Copyright (C) 2022-2025, Advanced Micro Devices, Inc.
  */
 
 #include <drm/drm_device.h>
@@ -64,6 +64,7 @@ int npu1_set_dpm(struct amdxdna_dev_hdl *ndev, u32 dpm_level)
 	if (ret) {
 		XDNA_ERR(ndev->xdna, "Set npu clock to %d failed, ret %d\n",
 			 ndev->priv->dpm_clk_tbl[dpm_level].npuclk, ret);
+		return ret;
 	}
 	ndev->npuclk_freq = freq;
 
@@ -72,6 +73,7 @@ int npu1_set_dpm(struct amdxdna_dev_hdl *ndev, u32 dpm_level)
 	if (ret) {
 		XDNA_ERR(ndev->xdna, "Set h clock to %d failed, ret %d\n",
 			 ndev->priv->dpm_clk_tbl[dpm_level].hclk, ret);
+		return ret;
 	}
 	ndev->hclk_freq = freq;
 	ndev->dpm_level = dpm_level;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 18 lines · Lizhi Hou

Due to miss returning error when setting clock, the smatch static checker reports warning:
drivers/accel/amdxdna/aie2_smu.c:68 npu1_set_dpm()
error: uninitialized symbol 'freq'.

Fixes f4d7b8a6bc8c ("accel/amdxdna: Enhance power management settings")
---
  drivers/accel/amdxdna/aie2_smu.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/accel/amdxdna/aie2_smu.c +0 -0
index 73388443c676..e68aaf7cd9f2 100644

drivers/accel/amdxdna/aie2_smu.c line 3

Quoted 4 lines
drivers/accel/amdxdna/aie2_smu.c +1 -1
@@ -1,6 +1,6 @@
  // SPDX-License-Identifier: GPL-2.0
  /*
- * Copyright (C) 2022-2024, Advanced Micro Devices, Inc.
+ * Copyright (C) 2022-2025, Advanced Micro Devices, Inc.

Can you please refrain from updating the copyright in unrelated patches.
This should be it's own patch. And that being said, why even have
years in this copyright? It's just one more thing to update all the time. Maybe just drop the year entirely?

After removing that from this patch, the remaining change is obviously correct so you can include this for v2.

Quoted 19 lines
drivers/accel/amdxdna/aie2_smu.c +2 -0
   */
 
  #include <drm/drm_device.h>
@@ -64,6 +64,7 @@ int npu1_set_dpm(struct amdxdna_dev_hdl *ndev, u32 dpm_level)
  	if (ret) {
  		XDNA_ERR(ndev->xdna, "Set npu clock to %d failed, ret %d\n",
  			 ndev->priv->dpm_clk_tbl[dpm_level].npuclk, ret);
+		return ret;
  	}
  	ndev->npuclk_freq = freq;
 
@@ -72,6 +73,7 @@ int npu1_set_dpm(struct amdxdna_dev_hdl *ndev, u32 dpm_level)
  	if (ret) {
  		XDNA_ERR(ndev->xdna, "Set h clock to %d failed, ret %d\n",
  			 ndev->priv->dpm_clk_tbl[dpm_level].hclk, ret);
+		return ret;
  	}
  	ndev->hclk_freq = freq;
  	ndev->dpm_level = dpm_level;