Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp616677iol; Thu, 9 Jun 2022 10:09:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgPt28K89pOGqElAgGsU7X3zhd6bAvOJ1TBKzOrP3m6dWOBujEobqX6Wv3lb1z02Ec2zJp X-Received: by 2002:a17:902:728f:b0:168:b18e:9e0d with SMTP id d15-20020a170902728f00b00168b18e9e0dmr1838587pll.174.1654794549310; Thu, 09 Jun 2022 10:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654794549; cv=none; d=google.com; s=arc-20160816; b=qwrssMaCPMYONrzS3EOR/9GCXzYis/kZYdip92tr+wyvAZ2gcBE6HlZqreWJ0cHoju 8MfohcXgIpGW5Px1iTHrxk/Y8DI2wldy9Js7lfXlDt4xbbDYXL/p/ntoSsPw88ZoeO/5 aoAPuoXzUZGbd32uthFrR73e8lWUZxxUHHWXIWkIMRrrzEPClBjApgNoSXhS06+D6/7X h47Cf+REk/qLk9NowuHYITlFLIK9PUv3pVBryZ4pCC0QBcn63cEeOYFgDZpe9wao6RfB Zsr/rCTRF2fMnPcDk2i0JUjCxmDmnQz1jcckFKdzwRfmcLG7XKIv/DCMRNHHXkROdQTi u6jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=L/sjdWC0GS+tRAh6Vs/BzO5ThKtSyT6V2dJOpuhJPMA=; b=NqiN+Xo6Cr0nhyRdFKTbPD5kxBpPtqLeiUtIrO92DfF7nxNabVk2/Gi6St2VGgphjU QHclLXZxoPs4XPOAF5a7zkIcTNn7lSAziS7Chodc6NXJhPhc999KiIBwBd+bvnk+6hEa pO4uXdoY3ox09apwSIPJl56EGKjMrvnztXa0NxFwBsLYJE46Eljpn3vHxQpRaFwu08HE D0gbaYURySF21KMk24GsjK4o5aiqCwtw6VvXoMOJ0jfmSuC8AT7NucvEg0qDNj731rld MyxXGuhdmxIoTDbl9SRe5uLMSRXExNlMmo34b+SiliM6BAXk3GYO/GX4U7VEdZu/Z9lm TcLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JPnRdvX9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e10-20020a63690a000000b003fe4274ccf7si5693108pgc.547.2022.06.09.10.08.55; Thu, 09 Jun 2022 10:09:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=JPnRdvX9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344119AbiFIQaQ (ORCPT + 99 others); Thu, 9 Jun 2022 12:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234492AbiFIQaP (ORCPT ); Thu, 9 Jun 2022 12:30:15 -0400 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 270C3287F49; Thu, 9 Jun 2022 09:30:14 -0700 (PDT) Received: by mail-ej1-x631.google.com with SMTP id n10so48567003ejk.5; Thu, 09 Jun 2022 09:30:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=L/sjdWC0GS+tRAh6Vs/BzO5ThKtSyT6V2dJOpuhJPMA=; b=JPnRdvX9X4TXxEyeuJ8Yxp02z/JfppJq5UtxO2GCEse22e4eHn4PrjnOJ4CFGWF89B A2K8cKZ3rjg3a76o76wceKBOkfdyYRymE/pGv2ajxNK1SmoPANCajnCvqlCYknx6W+7U IfRYjm1ZJDYZcAPYH7oIIzIZ4jHlDDwtOEMri8QV2a0JKjf6onrMj8T27uQwo6ECNJm7 +dAGXQ4jy9FKGfQop+MKkwTsnNm72qRaBLsKo70jIVPJYPzS4h/gW9YicZXUhDYaZuBq NQ51eGFVI+HNEhBwuV3nsjRvAoHJ3fff6bSqZK5zSLKUooF/9oEq4Cn3LpSbc3xQDbtq PL/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=L/sjdWC0GS+tRAh6Vs/BzO5ThKtSyT6V2dJOpuhJPMA=; b=CBXCka8ErUY7YHUVQnmThc9eVyYiGUbuzXcycKW743bSrmxtVnzzK/N6Ee9jZFUphR NaQ9tXT+cYdmayGKtgxQPPG+Zel3i+flRphrV2akcd/olxMWRC7OVBXel9y25UBcEeAB EifjR9HzGymu3kODImkmmG2bemNBjrOt171ZExUgmj4i/qp6ByKfCkbxjXioiahsnZOT fNGrd84m2ZNbx2wOqMInMLgWerT12xBP3myDNgIqBmSLpU646qV2HU2bxfnUfigF+U3A Eu+e248ksa6ckI8aggLaJSsUXk88hO1VJtPwAuJuuujfZLcEicT4S7d184T8eHE311Dt JCKw== X-Gm-Message-State: AOAM530RBajsRoWrZAc6Nz+9PHBYRej5xQtio1/cHjICRoO265YdvHCn OkDbHVJHoqkLWX5eSYnaX+CzWIS6hvWFfnRWfgA= X-Received: by 2002:a17:906:1193:b0:70d:cf39:a4db with SMTP id n19-20020a170906119300b0070dcf39a4dbmr31469936eja.44.1654792212477; Thu, 09 Jun 2022 09:30:12 -0700 (PDT) MIME-Version: 1.0 References: <20220608212923.8585-1-jorge.lopez2@hp.com> <20220608212923.8585-2-jorge.lopez2@hp.com> In-Reply-To: <20220608212923.8585-2-jorge.lopez2@hp.com> From: Andy Shevchenko Date: Thu, 9 Jun 2022 18:29:36 +0200 Message-ID: Subject: Re: [PATCH v3 1/1] Resolve WMI query failures on some devices To: Jorge Lopez Cc: Hans de Goede , balalic.enver@gmail.com, Platform Driver , Linux Kernel Mailing List , Mark Gross Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 8, 2022 at 11:32 PM Jorge Lopez wrote: > > WMI queries fail on some devices where the ACPI method HWMC > unconditionally attempts to create Fields beyond the buffer > if the buffer is too small, this breaks essential features > such as power profiles: > > CreateByteField (Arg1, 0x10, D008) > CreateByteField (Arg1, 0x11, D009) > CreateByteField (Arg1, 0x12, D010) > CreateDWordField (Arg1, 0x10, D032) > CreateField (Arg1, 0x80, 0x0400, D128) > > In cases where args->data had zero length, ACPI BIOS Error > (bug): AE_AML_BUFFER_LIMIT, Field [D008] at bit > offset/length 128/8 exceeds size of target Buffer (128 bits) > (20211217/dsopcode-198) was obtained. > > ACPI BIOS Error (bug): AE_AML_BUFFER_LIMIT, Field [D009] at bit > offset/length 136/8 exceeds size of target Buffer (136bits) > (20211217/dsopcode-198) > > The original code created a buffer size of 128 bytes regardless if > the WMI call required a smaller buffer or not. This particular > behavior occurs in older BIOS and reproduced in OMEN laptops. Newer > BIOS handles buffer sizes properly and meets the latest specification > requirements. This is the reason why testing with a dynamically > allocated buffer did not uncover any failures with the test systems at > hand. > > This patch was tested on several OMEN, Elite, and Zbooks. It was > confirmed the patch resolves HPWMI_FAN GET/SET calls in an OMEN > Laptop 15-ek0xxx. No problems were reported when testing on several Elite > and Zbooks notebooks. Perfect! Reviewed-by: Andy Shevchenko Also needs a Fixes tag: Fixes: 4b4967cbd268 ("platform/x86: hp-wmi: Changing bios_args.data to be dynamically allocated") (I believe Hans can help you and add it on the fly) > Signed-off-by: Jorge Lopez > > --- > Based on the latest platform-drivers-x86.git/for-next > --- > drivers/platform/x86/hp-wmi.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c > index 0e9a25b56e0e..d3540dd62d06 100644 > --- a/drivers/platform/x86/hp-wmi.c > +++ b/drivers/platform/x86/hp-wmi.c > @@ -290,14 +290,16 @@ static int hp_wmi_perform_query(int query, enum hp_wmi_command command, > struct bios_return *bios_return; > union acpi_object *obj = NULL; > struct bios_args *args = NULL; > - int mid, actual_outsize, ret; > + int mid, actual_insize, actual_outsize; > size_t bios_args_size; > + int ret; > > mid = encode_outsize_for_pvsz(outsize); > if (WARN_ON(mid < 0)) > return mid; > > - bios_args_size = struct_size(args, data, insize); > + actual_insize = max(insize, 128); > + bios_args_size = struct_size(args, data, actual_insize); > args = kmalloc(bios_args_size, GFP_KERNEL); > if (!args) > return -ENOMEM; > -- > 2.25.1 > -- With Best Regards, Andy Shevchenko