All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nouveau, ACPI: fix regression caused by b072e53
@ 2014-02-20  9:23 Jiang Liu
  2014-02-20 20:27 ` Rafael J. Wysocki
  0 siblings, 1 reply; 10+ messages in thread
From: Jiang Liu @ 2014-02-20  9:23 UTC (permalink / raw)
  To: David Airlie, Rafael J. Wysocki, Jiang Liu, Dave Airlie, Emil Velikov
  Cc: dri-devel, linux-kernel

Fix regression caused by commit b072e53, which breaks loading nouveau
driver on optimus laptops.

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.

Reported-and-Tested-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
---
 drivers/gpu/drm/nouveau/nouveau_acpi.c |   26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index 4ef83df..83face3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -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) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] nouveau, ACPI: fix regression caused by b072e53
  2014-02-20  9:23 [PATCH] nouveau, ACPI: fix regression caused by b072e53 Jiang Liu
@ 2014-02-20 20:27 ` Rafael J. Wysocki
  2014-02-21  5:40   ` Jiang Liu
  2014-02-21  6:04     ` Dave Airlie
  0 siblings, 2 replies; 10+ messages in thread
From: Rafael J. Wysocki @ 2014-02-20 20:27 UTC (permalink / raw)
  To: Jiang Liu
  Cc: David Airlie, Dave Airlie, Emil Velikov, dri-devel, linux-kernel

On 2/20/2014 10:23 AM, Jiang Liu wrote:
> Fix regression caused by commit b072e53, which breaks loading nouveau
> driver on optimus laptops.
>
> 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.
>
> Reported-and-Tested-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>

I'm taking this, because the commit that introduced the regression went 
in through my tree.

In the future I'll appreciate CCing ACPI-related patches to linux-acpi, 
however.

Thanks,
Rafael


> ---
>   drivers/gpu/drm/nouveau/nouveau_acpi.c |   26 ++++++++++++++++++++++++--
>   1 file changed, 24 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
> index 4ef83df..83face3 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
> @@ -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) {


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] nouveau, ACPI: fix regression caused by b072e53
  2014-02-20 20:27 ` Rafael J. Wysocki
@ 2014-02-21  5:40   ` Jiang Liu
  2014-02-21  6:04     ` Dave Airlie
  1 sibling, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-02-21  5:40 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: David Airlie, Dave Airlie, Emil Velikov, dri-devel, linux-kernel

Thanks, Rafael.
Will cc ACPI maillist next time.

On 2014/2/21 4:27, Rafael J. Wysocki wrote:
> On 2/20/2014 10:23 AM, Jiang Liu wrote:
>> Fix regression caused by commit b072e53, which breaks loading nouveau
>> driver on optimus laptops.
>>
>> 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.
>>
>> Reported-and-Tested-by: Maarten Lankhorst
>> <maarten.lankhorst@canonical.com>
>> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
> 
> I'm taking this, because the commit that introduced the regression went
> in through my tree.
> 
> In the future I'll appreciate CCing ACPI-related patches to linux-acpi,
> however.
> 
> Thanks,
> Rafael
> 
> 
>> ---
>>   drivers/gpu/drm/nouveau/nouveau_acpi.c |   26
>> ++++++++++++++++++++++++--
>>   1 file changed, 24 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c
>> b/drivers/gpu/drm/nouveau/nouveau_acpi.c
>> index 4ef83df..83face3 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
>> @@ -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) {
> 
> -- 
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] nouveau, ACPI: fix regression caused by b072e53
  2014-02-20 20:27 ` Rafael J. Wysocki
@ 2014-02-21  6:04     ` Dave Airlie
  2014-02-21  6:04     ` Dave Airlie
  1 sibling, 0 replies; 10+ messages in thread
From: Dave Airlie @ 2014-02-21  6:04 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Jiang Liu, David Airlie, Dave Airlie, Emil Velikov, dri-devel, LKML

On Fri, Feb 21, 2014 at 6:27 AM, Rafael J. Wysocki
<rafael.j.wysocki@intel.com> wrote:
> On 2/20/2014 10:23 AM, Jiang Liu wrote:
>>
>> Fix regression caused by commit b072e53, which breaks loading nouveau
>> driver on optimus laptops.
>>
>> 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.
>>
>> Reported-and-Tested-by: Maarten Lankhorst
>> <maarten.lankhorst@canonical.com>
>> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
>
>
> I'm taking this, because the commit that introduced the regression went in
> through my tree.
>
> In the future I'll appreciate CCing ACPI-related patches to linux-acpi,
> however.

Thanks,

Acked-by: Dave Airlie <airlied@redhat.com>

Dave.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] nouveau, ACPI: fix regression caused by b072e53
@ 2014-02-21  6:04     ` Dave Airlie
  0 siblings, 0 replies; 10+ messages in thread
From: Dave Airlie @ 2014-02-21  6:04 UTC (permalink / raw)
  To: Rafael J. Wysocki; +Cc: Emil Velikov, LKML, dri-devel, Dave Airlie, Jiang Liu

On Fri, Feb 21, 2014 at 6:27 AM, Rafael J. Wysocki
<rafael.j.wysocki@intel.com> wrote:
> On 2/20/2014 10:23 AM, Jiang Liu wrote:
>>
>> Fix regression caused by commit b072e53, which breaks loading nouveau
>> driver on optimus laptops.
>>
>> 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.
>>
>> Reported-and-Tested-by: Maarten Lankhorst
>> <maarten.lankhorst@canonical.com>
>> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
>
>
> I'm taking this, because the commit that introduced the regression went in
> through my tree.
>
> In the future I'll appreciate CCing ACPI-related patches to linux-acpi,
> however.

Thanks,

Acked-by: Dave Airlie <airlied@redhat.com>

Dave.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] nouveau, ACPI: fix regression caused by b072e53
  2014-02-19 10:12   ` Maarten Lankhorst
  (?)
@ 2014-02-19 14:12   ` Jiang Liu
  -1 siblings, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-02-19 14:12 UTC (permalink / raw)
  To: Maarten Lankhorst, David Airlie, Rafael J. Wysocki, Dave Airlie,
	Emil Velikov
  Cc: dri-devel, linux-kernel



On 2014/2/19 18:12, Maarten Lankhorst wrote:
> op 19-02-14 05:53, Jiang Liu schreef:
>> 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.
>>
>> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
>> ---
>> Hi Maarten,
>>     Thanks for bisecting. Could you please help to verify whether
>> this patch fixes the regression?
>>
> Tested-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>
> 
> I was wrong about the operator precedence, seems correct after all. :-)
Hi Maarten,
	Thanks for testing.
Cheers!
Gerry

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] nouveau, ACPI: fix regression caused by b072e53
  2014-02-19  4:53 Jiang Liu
@ 2014-02-19 10:12   ` Maarten Lankhorst
  2014-02-19 10:12   ` Maarten Lankhorst
  1 sibling, 0 replies; 10+ messages in thread
From: Maarten Lankhorst @ 2014-02-19 10:12 UTC (permalink / raw)
  To: Jiang Liu, David Airlie, Rafael J. Wysocki, Dave Airlie, Emil Velikov
  Cc: dri-devel, linux-kernel

op 19-02-14 05:53, Jiang Liu schreef:
> 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.
>
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
> ---
> Hi Maarten,
> 	Thanks for bisecting. Could you please help to verify whether
> this patch fixes the regression?
>
Tested-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] nouveau, ACPI: fix regression caused by b072e53
@ 2014-02-19 10:12   ` Maarten Lankhorst
  0 siblings, 0 replies; 10+ messages in thread
From: Maarten Lankhorst @ 2014-02-19 10:12 UTC (permalink / raw)
  To: Jiang Liu, David Airlie, Rafael J. Wysocki, Dave Airlie, Emil Velikov
  Cc: linux-kernel, dri-devel

op 19-02-14 05:53, Jiang Liu schreef:
> 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.
>
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
> ---
> Hi Maarten,
> 	Thanks for bisecting. Could you please help to verify whether
> this patch fixes the regression?
>
Tested-by: Maarten Lankhorst <maarten.lankhorst@canonical.com>

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] nouveau, ACPI: fix regression caused by b072e53
  2014-02-19  4:53 Jiang Liu
@ 2014-02-19  9:47 ` Jiang Liu
  2014-02-19 10:12   ` Maarten Lankhorst
  1 sibling, 0 replies; 10+ messages in thread
From: Jiang Liu @ 2014-02-19  9:47 UTC (permalink / raw)
  To: Maarten Lankhorst, David Airlie, Rafael J. Wysocki, Dave Airlie,
	Emil Velikov
  Cc: dri-devel, linux-kernel

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

diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c
b/drivers/gpu/drm/nouveau/no
index c6c7d0d..83face3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -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;



On 2014/2/19 12:53, Jiang Liu wrote:
> 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.
> 
> Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
> ---
> 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(-)
> 
> diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
> index 4ef83df..c6c7d0d 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
> @@ -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) {
> 

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] nouveau, ACPI: fix regression caused by b072e53
@ 2014-02-19  4:53 Jiang Liu
  2014-02-19  9:47 ` Jiang Liu
  2014-02-19 10:12   ` Maarten Lankhorst
  0 siblings, 2 replies; 10+ messages in thread
From: Jiang Liu @ 2014-02-19  4:53 UTC (permalink / raw)
  To: Maarten Lankhorst, David Airlie, Rafael J. Wysocki, Jiang Liu,
	Dave Airlie, Emil Velikov
  Cc: dri-devel, linux-kernel

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.

Signed-off-by: Jiang Liu <jiang.liu@linux.intel.com>
---
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(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_acpi.c b/drivers/gpu/drm/nouveau/nouveau_acpi.c
index 4ef83df..c6c7d0d 100644
--- a/drivers/gpu/drm/nouveau/nouveau_acpi.c
+++ b/drivers/gpu/drm/nouveau/nouveau_acpi.c
@@ -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) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-02-21  6:04 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-20  9:23 [PATCH] nouveau, ACPI: fix regression caused by b072e53 Jiang Liu
2014-02-20 20:27 ` Rafael J. Wysocki
2014-02-21  5:40   ` Jiang Liu
2014-02-21  6:04   ` Dave Airlie
2014-02-21  6:04     ` Dave Airlie
  -- strict thread matches above, loose matches on Subject: below --
2014-02-19  4:53 Jiang Liu
2014-02-19  9:47 ` Jiang Liu
2014-02-19 10:12 ` Maarten Lankhorst
2014-02-19 10:12   ` Maarten Lankhorst
2014-02-19 14:12   ` Jiang Liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.