More specific libdrm error message

Submitted by Xie, AlexBin on Jan. 11, 2017, 9:14 p.m.

Details

Message ID CY4PR12MB16409A6D631EA457A365ECF0F2660@CY4PR12MB1640.namprd12.prod.outlook.com
State New
Headers show
Series "More specific libdrm error message" ( rev: 2 ) in AMD X.Org drivers

Not browsing as part of any series.

Commit Message

Xie, AlexBin Jan. 11, 2017, 9:14 p.m.
Hi,

Provide more specific error message if non-privileged user runs amdgpu_test

Before this change, the error message is:" WARNING - Suite initialization failed..." People might think this is a driver problem.


Tested with non-privileged user. Now the error message is like.

...
Error:Permission denied. Hint: Try to run this test program as root.
WARNING - Suite initialization failed for 'Basic Tests'.

...



Tested as root with no regression.



Please review.


Thanks,

Alex Bin Xie

Patch hide | download patch | download mbox

From 3cb44de3c4baa3db514dbcb180c4fdae128d4864 Mon Sep 17 00:00:00 2001
From: Alex Xie <AlexBin.Xie@amd.com>
Date: Wed, 11 Jan 2017 16:00:47 -0500
Subject: [PATCH libdrm] amdgpu: Provide more specific error message if
 non-privileged user runs amdgpu_test

Before this change, the error message is:" WARNING - Suite initialization failed..." People might think this is a driver problem.

Change-Id: Ib891c40ec812053f49ce5a99909455ac3137e32c
Signed-off-by: Alex Xie <AlexBin.Xie@amd.com>
---
 tests/amdgpu/basic_tests.c | 5 ++++-
 tests/amdgpu/bo_tests.c    | 6 +++++-
 tests/amdgpu/cs_tests.c    | 6 +++++-
 tests/amdgpu/vce_tests.c   | 6 +++++-
 4 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/tests/amdgpu/basic_tests.c b/tests/amdgpu/basic_tests.c
index 11f6a63..b95f3f4 100644
--- a/tests/amdgpu/basic_tests.c
+++ b/tests/amdgpu/basic_tests.c
@@ -206,8 +206,11 @@  int suite_basic_tests_init(void)
 
 	if (r == 0)
 		return CUE_SUCCESS;
-	else
+	else {
+		if ((r == -EACCES) && (errno == EACCES))
+			printf ("\n\nError:%m. Hint: Try to run this test program as root.");
 		return CUE_SINIT_FAILED;
+	}
 }
 
 int suite_basic_tests_clean(void)
diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c
index 993895d..7f4550d 100644
--- a/tests/amdgpu/bo_tests.c
+++ b/tests/amdgpu/bo_tests.c
@@ -65,8 +65,12 @@  int suite_bo_tests_init(void)
 
 	r = amdgpu_device_initialize(drm_amdgpu[0], &major_version,
 				  &minor_version, &device_handle);
-	if (r)
+	if (r) {
+		if ((r == -EACCES) && (errno == EACCES))
+			printf ("\n\nError:%m. Hint: Try to run this test program as root.");
+
 		return CUE_SINIT_FAILED;
+	}
 
 	req.alloc_size = BUFFER_SIZE;
 	req.phys_alignment = BUFFER_ALIGN;
diff --git a/tests/amdgpu/cs_tests.c b/tests/amdgpu/cs_tests.c
index a01ee48..0432332 100644
--- a/tests/amdgpu/cs_tests.c
+++ b/tests/amdgpu/cs_tests.c
@@ -76,8 +76,12 @@  int suite_cs_tests_init(void)
 
 	r = amdgpu_device_initialize(drm_amdgpu[0], &major_version,
 				     &minor_version, &device_handle);
-	if (r)
+	if (r) {
+		if ((r == -EACCES) && (errno == EACCES))
+			printf ("\n\nError:%m. Hint: Try to run this test program as root.");
+
 		return CUE_SINIT_FAILED;
+	}
 
 	family_id = device_handle->info.family_id;
 	/* VI asic POLARIS10/11 have specific external_rev_id */
diff --git a/tests/amdgpu/vce_tests.c b/tests/amdgpu/vce_tests.c
index 4915170..8c7c8c6 100644
--- a/tests/amdgpu/vce_tests.c
+++ b/tests/amdgpu/vce_tests.c
@@ -94,8 +94,12 @@  int suite_vce_tests_init(void)
 
 	r = amdgpu_device_initialize(drm_amdgpu[0], &major_version,
 				     &minor_version, &device_handle);
-	if (r)
+	if (r) {
+		if ((r == -EACCES) && (errno == EACCES))
+			printf ("\n\nError:%m. Hint: Try to run this test program as root.");
+
 		return CUE_SINIT_FAILED;
+	}
 
 	family_id = device_handle->info.family_id;
 	vce_harvest_config = device_handle->info.vce_harvest_config;
-- 
2.7.4