[PATCH v2 6/9] acpi: Check returned object type by Optimus _DSM locally

Pierre Moreau pierre.morrow at free.fr
Wed May 27 23:40:46 PDT 2015


Most _DSM will return an integer value of 0x80000002 when given an unknown
UUID, revision ID or function ID. Checking locally allows us to differentiate
that case from other ACPI errors, and to not report a "failed to evaluate _DSM"
if 0x80000002 is returned which was confusing.

Changes since v1:
* Replace ACPI errors with standard kernel ones

Signed-off-by: Pierre Moreau <pierre.morrow at free.fr>
---
 drm/nouveau/nouveau_acpi.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drm/nouveau/nouveau_acpi.c b/drm/nouveau/nouveau_acpi.c
index b837ab1..44a7328 100644
--- a/drm/nouveau/nouveau_acpi.c
+++ b/drm/nouveau/nouveau_acpi.c
@@ -88,12 +88,12 @@ static int nouveau_evaluate_optimus_dsm(acpi_handle handle, int func, int arg, u
 	for (i = 0; i < 4; i++)
 		args_buff[i] = (arg >> i * 8) & 0xFF;
 
-	obj = acpi_evaluate_dsm_typed(handle, nouveau_op_dsm_muid, nouveau_op_dsm_rid,
-				      func, &argv4, ACPI_TYPE_BUFFER);
+	obj = acpi_evaluate_dsm(handle, nouveau_op_dsm_muid, nouveau_op_dsm_rid,
+			        func, &argv4);
 	if (!obj) {
 		acpi_handle_info(handle, "failed to evaluate _DSM\n");
 		return -EINVAL;
-	} else {
+	} else if (obj->type == ACPI_TYPE_BUFFER) {
 		if (result && obj->buffer.length == 4) {
 			*result  = obj->buffer.pointer[0];
 			*result |= (obj->buffer.pointer[1] << 8);
@@ -101,6 +101,15 @@ static int nouveau_evaluate_optimus_dsm(acpi_handle handle, int func, int arg, u
 			*result |= (obj->buffer.pointer[3] << 24);
 		}
 		ACPI_FREE(obj);
+	} else if (obj->type == ACPI_TYPE_INTEGER &&
+		   obj->integer.value == 0x80000002) {
+		acpi_handle_debug(handle, "failed to query Optimus _DSM\n");
+		ACPI_FREE(obj);
+		return -ENODEV;
+	} else {
+		acpi_handle_err(handle, "unexpected returned value by Optimus _DSM\n");
+		ACPI_FREE(obj);
+		return -EINVAL;
 	}
 
 	return 0;
-- 
2.4.2



More information about the dri-devel mailing list