[PATCH 2/5] umr: Reorg and print the message on ppt-read

Luben Tuikov luben.tuikov at amd.com
Sun Mar 27 10:42:11 UTC 2022


Reorganize the logic and actually print the error message when the ASIC
doesn't support the power-play table feature.

Cc: Tom StDenis <tom.stdenis at amd.com>
Cc: Jinzhou.Su <Jinzhou.Su at amd.com>
Signed-off-by: Luben Tuikov <luben.tuikov at amd.com>
---
 src/app/pp_table.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/src/app/pp_table.c b/src/app/pp_table.c
index 9ab42a9ae2296c..33c2d01e897ef3 100644
--- a/src/app/pp_table.c
+++ b/src/app/pp_table.c
@@ -20,27 +20,32 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  *
  */
+
+#include <errno.h>
 #include "umrapp.h"
 #include "smu_pptable_navi10.h"
 
-int umr_print_pp_table(struct umr_asic *asic, const char* param)
+int umr_print_pp_table(struct umr_asic *asic, const char *param)
 {
-	FILE* fp;
-	int ret = -1;
+	FILE *fp;
+	int res;
 	char name[256];
 
 	snprintf(name, sizeof(name)-1, \
-		"/sys/class/drm/card%d/device/pp_table", asic->instance);
+		 "/sys/class/drm/card%d/device/pp_table", asic->instance);
 	fp = fopen(name, "r");
-	if (fp) {
-		if (strcmp(asic->asicname, "navi10") == 0 || strcmp(asic->asicname, "navi14") == 0) {
-			ret = umr_navi10_pptable_print(param, fp);
-		}
-		fclose(fp);
+	if (!fp) {
+		asic->err_msg("fopen: %s: %d\n", strerror(errno), errno);
+		return -errno;
+	}
+	if (strcmp(asic->asicname, "navi10") == 0 ||
+	    strcmp(asic->asicname, "navi14") == 0) {
+		res = umr_navi10_pptable_print(param, fp);
 	} else {
-		printf("Powerplay table feature only support on Navi10/Navi14 now.");
-		return -1;
+		asic->err_msg("The powerplay table feature is currently supported only on Navi10/Navi14.\n");
+		res = -1;
 	}
+	fclose(fp);
 
-	return ret;
+	return res;
 }
-- 
2.35.1.607.gf01e51a7cf



More information about the amd-gfx mailing list