From patchwork Fri Jul 29 15:49:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Tissoires X-Patchwork-Id: 9252633 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A50FE60757 for ; Fri, 29 Jul 2016 15:49:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9582928375 for ; Fri, 29 Jul 2016 15:49:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 88C0628387; Fri, 29 Jul 2016 15:49:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E27F928383 for ; Fri, 29 Jul 2016 15:49:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753063AbcG2Ptq (ORCPT ); Fri, 29 Jul 2016 11:49:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59642 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752978AbcG2Pth (ORCPT ); Fri, 29 Jul 2016 11:49:37 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D20E661E53; Fri, 29 Jul 2016 15:49:36 +0000 (UTC) Received: from plouf.banquise.eu.com (ovpn-112-62.ams2.redhat.com [10.36.112.62]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u6TFnSbZ026062; Fri, 29 Jul 2016 11:49:33 -0400 From: Benjamin Tissoires To: Stephen Just , Robert Moore , Lv Zheng , "Rafael J. Wysocki" , Len Brown , Sebastian Reichel , Dmitry Eremin-Solenikov , David Woodhouse Cc: linux-acpi@vger.kernel.org, devel@acpica.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] ACPICA: adapt buffer length for Field Attrib Raw Process in Ops Region Date: Fri, 29 Jul 2016 17:49:25 +0200 Message-Id: <1469807366-24642-2-git-send-email-benjamin.tissoires@redhat.com> In-Reply-To: <1469807366-24642-1-git-send-email-benjamin.tissoires@redhat.com> References: <1469807366-24642-1-git-send-email-benjamin.tissoires@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Fri, 29 Jul 2016 15:49:36 +0000 (UTC) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Detected on the Surface 3: The MSHW0011 driver uses Field Attrib Raw Process to return information for the ACPI Battery. The DSDT declares a parameter of 2 though functions like _BST or _BIX require a much bigger out buffer. It looks like the incoming buffer has the requested size and we can work around the issue by using this input size as the output and parameters size. Link: https://bugzilla.kernel.org/show_bug.cgi?id=106231 Signed-off-by: Benjamin Tissoires --- drivers/acpi/acpica/exfield.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/acpi/acpica/exfield.c b/drivers/acpi/acpica/exfield.c index d7d3ee3..a1bd041 100644 --- a/drivers/acpi/acpica/exfield.c +++ b/drivers/acpi/acpica/exfield.c @@ -413,6 +413,17 @@ acpi_ex_write_data_to_field(union acpi_operand_object *source_desc, * Data[x-1]: (Bytes 2-x of the arbitrary length data buffer) */ length += 2; + + /* + * When using Field Attrib Raw Process, it looks like + * the parameter access_length can be wrong and the + * required output buffer can be much bigger. + * So just take the incoming buffer length as the + * reference. + */ + if (accessor_type == AML_FIELD_ATTRIB_RAW_PROCESS) + length = source_desc->buffer.length; + function = ACPI_WRITE | (accessor_type << 16); } else { /* IPMI */