Skip to contentSkip to conversation

nouveau, ACPI: fix regression caused by b072e53

PATCH In review Jiang Liu 2 participants 4 messages Feb 19, 2014

Subsystems (3)
lore
Share & tools
lore

Jiang Liu

author
#0 lore raw

PATCH 1/1 nouveau, ACPI: fix regression caused by b072e53

On some platforms, ACPI _DSM method (nouveau_op_dsm_muid, function 0) has special requirements on the fourth parameter, which is different from ACPI specifications. So revert to the private implementation to check availability of _DSM functions instead of using common acpi_check_dsm() interface.

---
Hi Maarten,
Thanks for bisecting. Could you please help to verify whether
this patch fixes the regression?

Thanks!
Gerry

---
 drivers/gpu/drm/nouveau/nouveau_acpi.c |   26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_acpi.c +24 -2
index 4ef83df..c6c7d0d 100644
@@ -106,6 +106,29 @@ static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *
 	return 0;
 }
 
+/*
+ * On some platforms, _DSM(nouveau_op_dsm_muid, func0) has special
+ * requirements on the fourth parameter, so a private implementation
+ * instead of using acpi_check_dsm().
+ */
+static int nouveau_check_optimus_dsm(acpi_handle handle)
+{
+	int result;
+
+	/*
+	 * Function 0 returns a Buffer containing available functions.
+	 * The args parameter is ignored for function 0, so just put 0 in it
+	 */
+	if (nouveau_optimus_dsm(handle, 0, 0, &result)
+		return 0;
+
+	/*
+	 * ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported.
+	 * If the n-th bit is enabled, function n is supported
+	 */
+	return result & 1 && result & (1 << NOUVEAU_DSM_OPTIMUS_CAPS);
+}
+
 static int nouveau_dsm(acpi_handle handle, int func, int arg)
 {
 	int ret = 0;
@@ -207,8 +230,7 @@ static int nouveau_dsm_pci_probe(struct pci_dev *pdev)
 			   1 << NOUVEAU_DSM_POWER))
 		retval |= NOUVEAU_DSM_HAS_MUX;
 
-	if (acpi_check_dsm(dhandle, nouveau_op_dsm_muid, 0x00000100,
-			   1 << NOUVEAU_DSM_OPTIMUS_CAPS))
+	if (nouveau_check_optimus_dsm(dhandle))
 		retval |= NOUVEAU_DSM_HAS_OPT;
 
 	if (retval & NOUVEAU_DSM_HAS_OPT) {
Signature · 1 line
1.7.10.4
author
#1 lore raw

Hi Maarten,
Forgot to refresh my working tree. Please help to
apply this patch on top of previous one to solve a compilation bug.

(quoted diff) +0 -0

b/drivers/gpu/drm/nouveau/no
index c6c7d0d..83face3 100644

drivers/gpu/drm/nouveau/nouveau_acpi.c +1 -1
@@ -119,7 +119,7 @@ static int nouveau_check_optimus_dsm(acpi_handle handle)
         * Function 0 returns a Buffer containing available functions.
         * The args parameter is ignored for function 0, so just put 0 in it
         */
-       if (nouveau_optimus_dsm(handle, 0, 0, &result)
+       if (nouveau_optimus_dsm(handle, 0, 0, &result))
                return 0;
 
 
Quoted 63 lines · Jiang Liu

On some platforms, ACPI _DSM method (nouveau_op_dsm_muid, function 0) has special requirements on the fourth parameter, which is different from ACPI specifications. So revert to the private implementation to check availability of _DSM functions instead of using common acpi_check_dsm() interface.

---
Hi Maarten,
Thanks for bisecting. Could you please help to verify whether
this patch fixes the regression?

Thanks!
Gerry

---
 drivers/gpu/drm/nouveau/nouveau_acpi.c |   26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_acpi.c +24 -2
index 4ef83df..c6c7d0d 100644
@@ -106,6 +106,29 @@ static int nouveau_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *
 	return 0;
 }
 
+/*
+ * On some platforms, _DSM(nouveau_op_dsm_muid, func0) has special
+ * requirements on the fourth parameter, so a private implementation
+ * instead of using acpi_check_dsm().
+ */
+static int nouveau_check_optimus_dsm(acpi_handle handle)
+{
+	int result;
+
+	/*
+	 * Function 0 returns a Buffer containing available functions.
+	 * The args parameter is ignored for function 0, so just put 0 in it
+	 */
+	if (nouveau_optimus_dsm(handle, 0, 0, &result)
+		return 0;
+
+	/*
+	 * ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported.
+	 * If the n-th bit is enabled, function n is supported
+	 */
+	return result & 1 && result & (1 << NOUVEAU_DSM_OPTIMUS_CAPS);
+}
+
 static int nouveau_dsm(acpi_handle handle, int func, int arg)
 {
 	int ret = 0;
@@ -207,8 +230,7 @@ static int nouveau_dsm_pci_probe(struct pci_dev *pdev)
 			   1 << NOUVEAU_DSM_POWER))
 		retval |= NOUVEAU_DSM_HAS_MUX;
 
-	if (acpi_check_dsm(dhandle, nouveau_op_dsm_muid, 0x00000100,
-			   1 << NOUVEAU_DSM_OPTIMUS_CAPS))
+	if (nouveau_check_optimus_dsm(dhandle))
 		retval |= NOUVEAU_DSM_HAS_OPT;
 
 	if (retval & NOUVEAU_DSM_HAS_OPT) {
Tested-by on v1 1/1
#2 lore raw
In reply to Jiang Liu

op 19-02-14 05:53, Jiang Liu schreef:

Quoted 6 lines

On some platforms, ACPI _DSM method (nouveau_op_dsm_muid, function 0) has special requirements on the fourth parameter, which is different from ACPI specifications. So revert to the private implementation to check availability of _DSM functions instead of using common acpi_check_dsm() interface.

Quoted 6 lines

---
Hi Maarten,
Thanks for bisecting. Could you please help to verify whether
this patch fixes the regression?

I was wrong about the operator precedence, seems correct after all. :-)

author
#3 lore raw
Quoted 13 lines · Maarten Lankhorst

op 19-02-14 05:53, Jiang Liu schreef:

Quoted 6 lines

On some platforms, ACPI _DSM method (nouveau_op_dsm_muid, function 0) has special requirements on the fourth parameter, which is different from ACPI specifications. So revert to the private implementation to check availability of _DSM functions instead of using common acpi_check_dsm() interface.

Quoted 6 lines

---
Hi Maarten,
Thanks for bisecting. Could you please help to verify whether
this patch fixes the regression?

Quoted 3 lines

I was wrong about the operator precedence, seems correct after all. :-)

Hi Maarten,
Thanks for testing.
Cheers!
Gerry