[Nouveau] [PATCH 5/8] acpi: Check returned object type by Optimus _DSM locally
Samuel Pitoiset
samuel.pitoiset at gmail.com
Tue May 26 01:08:19 PDT 2015
On 05/26/2015 12:22 AM, Pierre Moreau wrote:
> 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.
>
> 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 073f7d7..7aeaf7d 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 AE_ERROR;
> - } 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 AE_ERROR;
> }
>
> return 0;
How do you handle the case where result is NULL and the type is
ACPI_TYPE_BUFFER ?
Because you don't return any error. Is that expected?
More information about the dri-devel
mailing list