Received: by 10.192.165.148 with SMTP id m20csp584610imm; Fri, 27 Apr 2018 04:18:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZokWUEJ2LqXULK0qygfFw/dz3rXU/zOarkPbD6SAD6BR4bX9qr2rVorC8KonpunVx6J3xEL X-Received: by 2002:a17:902:3c5:: with SMTP id d63-v6mr1908716pld.163.1524827896184; Fri, 27 Apr 2018 04:18:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524827896; cv=none; d=google.com; s=arc-20160816; b=erSjAxk9R5s7r1wQVaTAn+xKGxxxnxsucbM1YhRmU62ff9yM6DQ3r1R6taUkeWPgXg jNUyxn1PxMnfwp2I/mRIgGo4HcU+qlO8Re9PHiueWb+93ttCvoHUOo6J6ccwsvUMh9gx HsYO/G8j+IlEy3v+K4BbVWyZ8PSY0+X2nPsbYQNUvk6IoaduEJAMviqSXcGPHocTmNBT q+b6tsJD7JGw106vqfxCB5t/U1cOO6P1JyUD24CagPVlGF5vWSCnOdjwHuDphSFUt0kp 2zQnQ/mc8h2Gi+Si9qNaWcPWIEn2jc33vfFR3pC7JiR2v43eN3ljIRWoACdXZkbTXzP0 egTw== 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=sl+qi4SVLUm+1Fd+8QzWMwym31/NXOHv+PZCn9zP6wE=; b=d9rZcDk6o6ZSwyFwRxWlKDcJIH8j5fkcVk+nrEqUMD8iJtGkYx706jVBz5UobquMMv AlEdu9CWMXXtnqEMtY9Guk4NTvs6iJYrR9XbsLIFOMYDTKEK03hfR+/jlPIsi+mzU27l /iZb1APKE+uOU0b8ng6STGv7R6xKiy7qFqiR5gHKbeNqc2bzJhHh54OkUTDTCvdPEy+P Sk5UZe1GPMhxp653QVplXNbPe11MWO/oGN/TOhpJYDvKND0PpPKJec+5qcNWiikq9uEE uOYFceQ6322EDe00lFmTwSTgI6x6W5yg5N+iJBo3s1VkreFSk8SDg57WBU8jhSUxi2gD Z53w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=r7Y5Wr2f; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y22-v6si1039507pll.161.2018.04.27.04.18.01; Fri, 27 Apr 2018 04:18:16 -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=r7Y5Wr2f; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757353AbeD0LQz (ORCPT + 99 others); Fri, 27 Apr 2018 07:16:55 -0400 Received: from mail-ot0-f196.google.com ([74.125.82.196]:32988 "EHLO mail-ot0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbeD0LQx (ORCPT ); Fri, 27 Apr 2018 07:16:53 -0400 Received: by mail-ot0-f196.google.com with SMTP id l22-v6so1608009otj.0; Fri, 27 Apr 2018 04:16:52 -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=sl+qi4SVLUm+1Fd+8QzWMwym31/NXOHv+PZCn9zP6wE=; b=r7Y5Wr2fiyK8gKXVClb4RYZLgWTciFN+QDqfOqax1cTlRrY3gFRoW3VassV2eMKT3D JtCyncDY87iJkZd0DPPThovLuHjX/uX7vVyJOqVCPNXw79xap+laA3g9lQyT3f2yzNw3 LLFyGVavm9zDo9Gn0HyRk4wkqS+ewHAx5VdxUQfnLdu3ywJnOUlpR05dOU60kxZqkh7P GhjfLfZUjv137FABYwGprAV5UIPfiypc3TqGXxpuzq1NhkBMI+G8SIv8XRxZH64GHjw8 QwOPCO74ktsk5Er8uZtc98ZOCaZDITevX9aTmw1TuuJ5vVeA5LdKgbAyQqavB2iY2JAN f0cg== 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=sl+qi4SVLUm+1Fd+8QzWMwym31/NXOHv+PZCn9zP6wE=; b=BZxC574y5V98554YEZg0lq59fotHCHdAPCpSzxL4QMap/UNO8r700sot6L5NirVSPj Z1gRFRiUj6V2MY8hbyc0rRyMZgV2WXvgcIi04wqYnYM7TPenj8fd77bFU58v62CD40zb DaEvNHIMjFotAID2tHRC5mRHwvau6v3oj2+D9Y/jL/Q2905hD6WAnorZ0I1ATGDqbLyV Oue8nvbzyH/4V6iEWh335d4SpKuP6erQGNOENoftvUcRq/f7JTwF+vqrhcOjp4KQNhgc tO34XgutO2deTaWMufBX5bYfblwJ3pKPTpJYpPOxpxMbKRcfpP4orjOoW9kEIrFElVh/ GRbg== X-Gm-Message-State: ALQs6tAaEdQM50VWFsZNRDXDxmFg1BnY1fL0Ur3YxaRqQyXmOKDb0R5o ZLwPDhYu20HYLuKIb28XgYtKw8Tuugs2iIXEgPw= X-Received: by 2002:a9d:5990:: with SMTP id u16-v6mr1040545oth.370.1524827812400; Fri, 27 Apr 2018 04:16:52 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:1468:0:0:0:0:0 with HTTP; Fri, 27 Apr 2018 04:16:52 -0700 (PDT) In-Reply-To: <20180424193505.6934-4-ahs3@redhat.com> References: <20180424193505.6934-1-ahs3@redhat.com> <20180424193505.6934-4-ahs3@redhat.com> From: "Rafael J. Wysocki" Date: Fri, 27 Apr 2018 13:16:52 +0200 X-Google-Sender-Auth: Vo2qB3pZOIJPvJplF4V4rIIesI0 Message-ID: Subject: Re: [PATCH v2 3/3] mailbox: ACPI: erroneous error message when parsing the ACPI PCCT To: Al Stone Cc: 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, Apr 24, 2018 at 9:35 PM, Al Stone wrote: > There have been multiple reports of the following error message: > > [ 0.068293] Error parsing PCC subspaces from PCCT > [cut] > > 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 | 99 +++++++++++++++++++++++++++++++++++++-------------- > 1 file changed, 73 insertions(+), 26 deletions(-) > > diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c > index 3ef7f036ceea..cc77a2f1694f 100644 > --- a/drivers/mailbox/pcc.c > +++ b/drivers/mailbox/pcc.c > @@ -372,6 +372,35 @@ static const struct mbox_chan_ops pcc_chan_ops = { > .send_data = pcc_send_data, > }; > > +/* > + * > + * count_pcc_subspaces -- Count the PCC subspaces that are not used in > + * reduced hardware systems. One line here, please. > + * @header: Pointer to the ACPI subtable header under the PCCT. > + * @end: End of subtable entry. > + * > + * Return: 0 for Success, else errno. The only errno returned appears to be -EINVAL, so maybe say when that is returned and then "or 0 otherwise". > + * > + * This gets called for each entry 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; This can be one line (ignore warnings from checkpatch about that). > + > + 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)) { This can be one line too. > + pr_warn("PCCT count: useful subtype = %d\n", > + pcct_ss->header.type); Why pr_warn()? > + return 0; > + } > + pr_warn("PCCT count: unwanted subtype = %d\n", pcct_ss->header.type); > + return -EINVAL; > +} > + > /** > * parse_pcc_subspace - Parse the PCC table and verify PCC subspace > * entries. There should be one entry per PCC client. > @@ -395,10 +424,14 @@ static int parse_pcc_subspace(struct acpi_subtable_header *header, > && (pcct_ss->header.type != > ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2)) { > pr_err("Incorrect PCC Subspace type detected\n"); > + pr_warn("PCCT parse: unwanted subtype = %d\n", > + pcct_ss->header.type); Maybe merge the two messages? > return -EINVAL; > } > } > > + pcct_ss = (struct acpi_pcct_hw_reduced *) header; > + pr_warn("PCCT parse: useful subtype = %d\n", pcct_ss->header.type); > return 0; > } > > @@ -449,8 +482,8 @@ static int __init acpi_pcc_probe(void) > struct acpi_table_header *pcct_tbl; > struct acpi_subtable_header *pcct_entry; > struct acpi_table_pcct *acpi_pcct_tbl; > + struct acpi_subtable_proc proc[ACPI_PCCT_TYPE_RESERVED]; > int count, i, rc; > - int sum = 0; > acpi_status status = AE_OK; > > /* Search for PCCT */ > @@ -459,43 +492,50 @@ static int __init acpi_pcc_probe(void) > if (ACPI_FAILURE(status) || !pcct_tbl) > return -ENODEV; > > - count = acpi_table_parse_entries(ACPI_SIG_PCCT, > - sizeof(struct acpi_table_pcct), > - ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE, > - parse_pcc_subspace, MAX_PCC_SUBSPACES); > - sum += (count > 0) ? count : 0; > - > - count = acpi_table_parse_entries(ACPI_SIG_PCCT, > - sizeof(struct acpi_table_pcct), > - ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2, > - parse_pcc_subspace, MAX_PCC_SUBSPACES); > - sum += (count > 0) ? count : 0; > + /* Set up the subtable handlers */ > + for (i = ACPI_PCCT_TYPE_GENERIC_SUBSPACE; > + i < ACPI_PCCT_TYPE_RESERVED; I would append the line below to this one. > + i++) { > + proc[i].id = i; > + if (i == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE || > + i == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) > + proc[i].handler = parse_pcc_subspace; > + else > + proc[i].handler = count_pcc_subspaces; > + proc[i].count = 0; Why don't you move the count initialization above the if ()? > + } > > - if (sum == 0 || sum >= MAX_PCC_SUBSPACES) { > - pr_err("Error parsing PCC subspaces from PCCT\n"); > + count = acpi_table_parse_entries_array(ACPI_SIG_PCCT, > + sizeof(struct acpi_table_pcct), proc, > + ACPI_PCCT_TYPE_RESERVED, MAX_PCC_SUBSPACES); > + if (count == 0) { > + pr_warn("PCCT provided but has no subspaces defined\n"); > + return -EINVAL; > + } else if (count > MAX_PCC_SUBSPACES) { > + pr_warn("Too many PCC subspaces defined in PCCT\n"); Do we need such detailed information to be printed here? If you said something like "Invalid PCCT format", you could merge the two if () branches. > return -EINVAL; > } > > pcc_mbox_channels = kzalloc(sizeof(struct mbox_chan) * > - sum, GFP_KERNEL); > + count, GFP_KERNEL); One line, please. > if (!pcc_mbox_channels) { > pr_err("Could not allocate space for PCC mbox channels\n"); > return -ENOMEM; > } > > - pcc_doorbell_vaddr = kcalloc(sum, sizeof(void *), GFP_KERNEL); > + pcc_doorbell_vaddr = kcalloc(count, sizeof(void *), GFP_KERNEL); > if (!pcc_doorbell_vaddr) { > rc = -ENOMEM; > goto err_free_mbox; > } > > - pcc_doorbell_ack_vaddr = kcalloc(sum, sizeof(void *), GFP_KERNEL); > + pcc_doorbell_ack_vaddr = kcalloc(count, sizeof(void *), GFP_KERNEL); > if (!pcc_doorbell_ack_vaddr) { > rc = -ENOMEM; > goto err_free_db_vaddr; > } > > - pcc_doorbell_irq = kcalloc(sum, sizeof(int), GFP_KERNEL); > + pcc_doorbell_irq = kcalloc(count, sizeof(int), GFP_KERNEL); > if (!pcc_doorbell_irq) { > rc = -ENOMEM; > goto err_free_db_ack_vaddr; > @@ -509,18 +549,25 @@ static int __init acpi_pcc_probe(void) > if (acpi_pcct_tbl->flags & ACPI_PCCT_DOORBELL) > pcc_mbox_ctrl.txdone_irq = true; > > - for (i = 0; i < sum; i++) { > + for (i = 0; i < count; i++) { > struct acpi_generic_address *db_reg; > - struct acpi_pcct_hw_reduced *pcct_ss; > + struct acpi_pcct_subspace *pcct_ss; > pcc_mbox_channels[i].con_priv = pcct_entry; > > - pcct_ss = (struct acpi_pcct_hw_reduced *) pcct_entry; > + if (pcct_entry->type == ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE || > + pcct_entry->type == > + ACPI_PCCT_TYPE_HW_REDUCED_SUBSPACE_TYPE2) { Again, please merge the two lines above. > + struct acpi_pcct_hw_reduced *pcct_hrss; > + > + pcct_hrss = (struct acpi_pcct_hw_reduced *) pcct_entry; > > - if (pcc_mbox_ctrl.txdone_irq) { > - rc = pcc_parse_subspace_irq(i, pcct_ss); > - if (rc < 0) > - goto err; > + if (pcc_mbox_ctrl.txdone_irq) { > + rc = pcc_parse_subspace_irq(i, pcct_hrss); > + if (rc < 0) > + goto err; > + } > } > + pcct_ss = (struct acpi_pcct_subspace *) pcct_entry; > > /* If doorbell is in system memory cache the virt address */ > db_reg = &pcct_ss->doorbell_register; > @@ -531,7 +578,7 @@ static int __init acpi_pcc_probe(void) > ((unsigned long) pcct_entry + pcct_entry->length); > } > > - pcc_mbox_ctrl.num_chans = sum; > + pcc_mbox_ctrl.num_chans = count; > > pr_info("Detected %d PCC Subspaces\n", pcc_mbox_ctrl.num_chans); > > --