Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp260533imm; Tue, 15 May 2018 01:01:48 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoXl1cMqirTOJ0NeSNfBghgW0Om0rc2qhkb4ceHXMcL+FiWlsUmRe6nzfT40dgIxLeSha6l X-Received: by 2002:a62:4544:: with SMTP id s65-v6mr14011138pfa.150.1526371308905; Tue, 15 May 2018 01:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526371308; cv=none; d=google.com; s=arc-20160816; b=hiuXJ8dZxSLo17CPE4tBv4iN9gCsBPhgy+efgADOrYoOmzbAAkqs5pKjcOeLNWI4Lq cV/zsi6NCXqHceTkR62J3KDZVMadyscTKS9HknC0JHOWKiwTLHaqQmLhTlt3bY+vhtmp kO0a9Hbmd7y+tcKxn/IjlVEjdDTQLcYZbEtwDmaGqlYWbK3Y2VLY67fFI/n+ROtN9hTl epoS4w55Ztkfih3A8aIiqlkmopiCojzrXijU18hMs+IoDNZN3zRLaWZyI4Zdk8FSXp+o GTiH3dKaTRA3cqOz1mrgxKjCnmvNYNvt0JlipC6h7vXd1czs2UgVK2NRF3TONC2yULWw rYDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=q/VRlPzXHPZeYzapYqya0EMYAkS88H0oNLVxjsKstQA=; b=fbCf0rrZGO0zQGzkSkR8PMaiKKbM5oFhNl+zhGJLO2kO/YRJP5qpQQhrHG8QHgZNxR IACaxkwqUuAlUMsPb5+up3qXwD07N3CZoH4iAmd1rfSc1P3dfQMGSW836PfTEPxh2jAM 6YQEmq0wMcpUACEwRK7uIGlUUYemZf2Z4c/6rIfQPR4XMDVhxzsbus0vYmmWTijGq9lU wYHIZyHRczjozVuPGxDJJBtlv7XPC2bbL9LLdQqt4fOipWhnBcq1OenDW/L9O+TcZyIQ Sj7itq8J8oORT/1Oaeoa1uUrwtVHI8hVJYo8zusEP1/oMD+kgZ+ZviHedssL6Hs/SrVm VB5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=LS0/uLU2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 3-v6si2154953pla.38.2018.05.15.01.01.34; Tue, 15 May 2018 01:01:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=LS0/uLU2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752681AbeEOIAX (ORCPT + 99 others); Tue, 15 May 2018 04:00:23 -0400 Received: from mail-oi0-f45.google.com ([209.85.218.45]:42853 "EHLO mail-oi0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752368AbeEOIAS (ORCPT ); Tue, 15 May 2018 04:00:18 -0400 Received: by mail-oi0-f45.google.com with SMTP id t27-v6so13135074oij.9; Tue, 15 May 2018 01:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=q/VRlPzXHPZeYzapYqya0EMYAkS88H0oNLVxjsKstQA=; b=LS0/uLU2nSdrZfHq1P+NAUtOZ0/l2+Dw+bcAWLjQQlYsbigz8t8w4nV+CvkkyZrVv8 s8Wj31wRBOtMUXuJbtOpgLWU/dHkj75iX4wade9NzR8jEF8VyLRT2/fKpHQDm/mNDvVI UjJREJon/04nXkRUzSd9LcqY8UCLJ26FaC9cc9r6UStwEkmpqkyAJivdEdZrcdBCjxk7 7DRpdz1A55wLh8j5OkCbGdBJ+AI5e3oDBGJrv2uUGSNLFWjrpavSxWgK9f9sPn5eqwsw JgzgXUH5q6nUUnWDMgFa/QBoHKB8zDjkgO/PtrGzNdkuKTYM9rx/wTnspjCrzK0PY5uZ 93dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=q/VRlPzXHPZeYzapYqya0EMYAkS88H0oNLVxjsKstQA=; b=jo5WE1ak+ujxPi1GI/5LSgcqbC6E7o764LfBajgJgE4FafIy/59Z8nmnpXcKgZj9r3 6KtBobdKfTq4GM4uhomX+91FyVyPGraBFBncfloHmJ4bsrK/+pzt9W+OYC6OdNZRAJgJ rNA4lBCD/i54nv1arYZ/DIBfrmyj8DQ4fgbdOE0tvjJ/HmstJSflW3J1/IgS6WNoEHeT zbGn9eFU90WyIh+jCLk/dT0gkSVcFJp1TK2VzGbb7JCyx3PhtQfBfkETm+tRNdKiHOx4 M2s1EAWhhKCHE/cdJuMaoa9Xfq4tNfF6WKPg6S0FXsVsPhQhwFvl7BHsVDik+HdLV3Vo KgOw== X-Gm-Message-State: ALKqPwffw9ZU+eRVEDZ1CgWitoixx+sbzrRxTlA8eu+VSBpZLFcJ/jTc jZGIxZINReraiY+Lh2pdkmQQ6UiukoJOCxUSt1c= X-Received: by 2002:aca:1107:: with SMTP id 7-v6mr9174344oir.116.1526371217600; Tue, 15 May 2018 01:00:17 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1468:0:0:0:0:0 with HTTP; Tue, 15 May 2018 01:00:17 -0700 (PDT) In-Reply-To: References: <20180501003907.4322-1-ahs3@redhat.com> <20180501003907.4322-4-ahs3@redhat.com> <17197481-bd76-f2ec-9d6e-4cd0d94b9265@codeaurora.org> From: "Rafael J. Wysocki" Date: Tue, 15 May 2018 10:00:17 +0200 X-Google-Sender-Auth: srOnNvhR5561TuRdyWhhyQrYRGE Message-ID: Subject: Re: [PATCH v3 3/3] mailbox: ACPI: erroneous error message when parsing the ACPI PCCT To: Al Stone Cc: "Prakash, Prashanth" , ACPI Devel Maling List , Linux Kernel Mailing List , Jassi Brar , "Rafael J . Wysocki" , Len Brown Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 15, 2018 at 12:49 AM, Al Stone wrote: > On 05/14/2018 03:04 PM, Prakash, Prashanth wrote: >> >> >> On 4/30/2018 6:39 PM, Al Stone wrote: >>> There have been multiple reports of the following error message: >>> >>> [ 0.068293] Error parsing PCC subspaces from PCCT >>> >>> This error message is not correct. In multiple cases examined, the PCCT >>> (Platform Communications Channel Table) concerned is actually properly >>> constructed; the problem is that acpi_pcc_probe() which reads the PCCT >>> is making the assumption that the only valid PCCT is one that contains >>> subtables of one of two types: ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE or >>> ACPI_PCCT_TYPE_HW_REDUCED_TYPE2. The number of subtables of these >>> types are counted and as long as there is at least one of the desired >>> types, the acpi_pcc_probe() succeeds. When no subtables of these types >>> are found, regardless of whether or not any other subtable types are >>> present, the error mentioned above is reported. >>> >>> In the cases reported to me personally, the PCCT contains exactly one >>> subtable of type ACPI_PCCT_TYPE_GENERIC_SUBSPACE. The function >>> acpi_pcc_probe() does not count it as a valid subtable, so believes >>> there to be no valid subtables, and hence outputs the error message. >>> >>> An example of the PCCT being reported as erroneous yet perfectly fine >>> is the following: >>> >>> Signature : "PCCT" >>> Table Length : 0000006E >>> Revision : 05 >>> Checksum : A9 >>> Oem ID : "XXXXXX" >>> Oem Table ID : "XXXXX " >>> Oem Revision : 00002280 >>> Asl Compiler ID : "XXXX" >>> Asl Compiler Revision : 00000002 >>> >>> Flags (decoded below) : 00000001 >>> Platform : 1 >>> Reserved : 0000000000000000 >>> >>> Subtable Type : 00 [Generic Communications Subspace] >>> Length : 3E >>> >>> Reserved : 000000000000 >>> Base Address : 00000000DCE43018 >>> Address Length : 0000000000001000 >>> >>> Doorbell Register : [Generic Address Structure] >>> Space ID : 01 [SystemIO] >>> Bit Width : 08 >>> Bit Offset : 00 >>> Encoded Access Width : 01 [Byte Access:8] >>> Address : 0000000000001842 >>> >>> Preserve Mask : 00000000000000FD >>> Write Mask : 0000000000000002 >>> Command Latency : 00001388 >>> Maximum Access Rate : 00000000 >>> Minimum Turnaround Time : 0000 >>> >>> To fix this, we count up all of the possible subtable types for the >>> PCCT, and only report an error when there are none (which could mean >>> either no subtables, or no valid subtables), or there are too many. >>> We also change the logic so that if there is a valid subtable, we >>> do try to initialize it per the PCCT subtable contents. This is a >>> change in functionality; previously, the probe would have returned >>> right after the error message and would not have tried to use any >>> other subtable definition. >>> >>> Tested on my personal laptop which showed the error previously; the >>> error message no longer appears and the laptop appears to operate >>> normally. >>> >>> Signed-off-by: Al Stone >>> Cc: Jassi Brar >>> Cc: Rafael J. Wysocki >>> Cc: Len Brown >>> --- >>> drivers/mailbox/pcc.c | 96 +++++++++++++++++++++++++++++++++------------------ >>> 1 file changed, 63 insertions(+), 33 deletions(-) >>> >>> diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c >>> index 3ef7f036ceea..72af37d7e95e 100644 >>> --- a/drivers/mailbox/pcc.c >>> +++ b/drivers/mailbox/pcc.c >>> @@ -372,13 +372,37 @@ static const struct mbox_chan_ops pcc_chan_ops = { >>> .send_data = pcc_send_data, >>> }; >>> >>> +/* >>> + * >>> + * count_pcc_subspaces -- Count PCC subspaces not used in reduced HW systems. >>> + * @header: Pointer to the ACPI subtable header under the PCCT. >>> + * @end: End of subtable entry. >>> + * >>> + * Return: If we find a PCC subspace entry that is one of the types used >>> + * in reduced hardware systems, return -EINVAL. Otherwise, return 0. >>> + * >>> + * This gets called for each subtable in the PCC table. >>> + */ >>> +static int count_pcc_subspaces(struct acpi_subtable_header *header, >>> + const unsigned long end) >>> +{ >>> + struct acpi_pcct_subspace *pcct_ss = (struct acpi_pcct_subspace *) header; >>> + >>> + if ((pcct_ss->header.type <= ACPI_PCCT_TYPE_RESERVED) && >>> + (pcct_ss->header.type != ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE) && >>> + (pcct_ss->header.type != ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2)) >>> + return 0; >>> + >>> + return -EINVAL; >>> +} >>> + >>> /** >>> - * parse_pcc_subspace - Parse the PCC table and verify PCC subspace >>> - * entries. There should be one entry per PCC client. >>> + * parse_pcc_subspaces -- Count PCC subspaces used only in reduced HW systems. >>> * @header: Pointer to the ACPI subtable header under the PCCT. >>> * @end: End of subtable entry. >>> * >>> - * Return: 0 for Success, else errno. >>> + * Return: If we find a PCC subspace entry that is one of the types used >>> + * in reduced hardware systems, return 0. Otherwise, return -EINVAL. >>> * >>> * This gets called for each entry in the PCC table. >>> */ >>> @@ -393,10 +417,8 @@ static int parse_pcc_subspace(struct acpi_subtable_header *header, >>> if ((pcct_ss->header.type != >>> ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE) >>> && (pcct_ss->header.type != >>> - ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2)) { >>> - pr_err("Incorrect PCC Subspace type detected\n"); >>> + ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2)) >>> return -EINVAL; >>> - } >>> } >>> >>> return 0; >> Can't we combine parse_pcc_subspace and count_pcc_subspaces into a >> single function? parse_pcc_subspace can return 0 for supported subspace >> types and -EINVAL for others. > > I did think about that. The issue is that we have subspaces that are only > valid in reduced hardware systems, and subspaces that are not. It might make > sense to use different names, as in 'count_reduced_hw_subspaces()' and > 'count_general_subspaces()' (or something like those) but we do have the two > separate classes and hardware belonging to each of those classes. > > That being said, you raise a good point: this would only be useful if the > mailbox code needed to know the classes of subspaces were different; I saw > no such code but I could have missed it. If you're aware of any such cases, > let me know. Otherwise, I'll combine the two counting routines and test it. > >> The limitation on number of subspaces(max = 256) applies to all types of PCC >> subspaces (see Table 14-351 in ACPI 6.2). The MAX_PCC_SUBSPACES check in >> parse_pcc_subspace seems invalid as pcc_mbox_ctrl.num_chans will not be >> initialized yet at that moment. > > Good catch. Thanks. That test was there prior to my patches, but I'll pull > it out. > >> Given above, I think it is probably better to update parse_pcc_subspace to >> only check for a valid PCC subspace type. The check to make sure overall count >> of subspace is less than 256 is already present following the call to >> acpi_table_parse_entries_array(). >> >> -- >> Thanks, >> Prashanth >> > > Thanks, Prashanth. > > Rafael: do you want me to just re-send this patch or the whole series? Either > way works for me; what's easiest for you since the first two have been applied? Just this patch, please. I've applied the other two already. Thanks, Rafael