Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1101596rdb; Wed, 6 Dec 2023 08:36:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJKn1YMvHrGeTCqK4mD6YroyveQRQqSFoCdfBRq6WK6sqz5Tz30GC1hKeu518ScEGRBibF X-Received: by 2002:a17:90a:11:b0:286:b271:b96d with SMTP id 17-20020a17090a001100b00286b271b96dmr826074pja.32.1701880576721; Wed, 06 Dec 2023 08:36:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701880576; cv=none; d=google.com; s=arc-20160816; b=aeplC4kTv7HbfnT7Fz5Eh8cOKfm1MEDSxR/rZnNV86c8myUoWH6TscR3CohQrWMBwu /aU1HAJNMPyRs8js0vMumzyORc77zEFcOINproT2Ngxx2KCzMsemx457thQbmvFffC8z EN5Myx43prUUiSDZ1cLHTmDklVjkuECNeNzeYpoz/RhvtQzl+LZY46AKVuvy7kwMG8nT RTyvl71WUqlBgfGEFHWI5VCT0DFK3POp6xOm3ZH7RIOmj8CRq5XtG65IKAnUib1VBK0n Z45f5pXTgr0hFy7Drr9swEnYmjpMmKyPHu2/Hg8400ySjs1nxmgTGrytleqc6R43FnUh Y9dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=54okeIM7gp3Z95OkTgGZmXHJ+av9Og3XAb1b1zb5O98=; fh=2lrUEWDt3TxxQzw7aIkvaX6ygMnEJl8n9hjTF/61Bxs=; b=nvnuncvsSQak33h4ZE+cQqyiKAWwUaGSeP6C0+XMS/+99c6KzbMEvgk3yO2gzytarl 7W7Z1XluV0I6tjU7+LI3mWYrSt8ZwcK5lCwODwee1wKGX9vB/10Mv8IPUjOZVHaXuQpe JMBp1c+HPBN4Bo0nEkgDQXBY7/ArHg9Sd52GOID2mFjsWtnbEeoPkb2l2Zb3BCd3BGQT Gf/OHhnIu8XK38MW7f1UsL2TunHyzZJIHaLzQKcutuzavdXa8nMoxKZhshVnhv4C8Tx2 IIsZHW4LB3+uVF1nvNNPWTQo1pRFsH+ay7flql8kOb4CSb0bwnnHYAWOEHaqLwXCJoJX +Vog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id nh20-20020a17090b365400b00286e9d394d0si62375pjb.23.2023.12.06.08.36.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 08:36:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 64F788369F5C; Wed, 6 Dec 2023 08:36:13 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442584AbjLFQfy convert rfc822-to-8bit (ORCPT + 99 others); Wed, 6 Dec 2023 11:35:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442672AbjLFQfq (ORCPT ); Wed, 6 Dec 2023 11:35:46 -0500 Received: from mail-oo1-f43.google.com (mail-oo1-f43.google.com [209.85.161.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E67FDD5F; Wed, 6 Dec 2023 08:35:51 -0800 (PST) Received: by mail-oo1-f43.google.com with SMTP id 006d021491bc7-58dd5193db4so592109eaf.1; Wed, 06 Dec 2023 08:35:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701880551; x=1702485351; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RnltdkPvqiE0SLkWecJ3YZb5+WkHMQll5p7sUNdf2Nw=; b=KLFYnSj5A2GEi0815JIOu16WVwyCM4TwKUg0CkAKkBuXmMHSPAqf8hCSY4HsJKE5Uz duZTaMnz7yUc2dDboSo49kjntBpifWo/DRCe+J3yUqZIAovkgc5PkBeAZ4sjKUT8WHZE il090OiPf5XdhulAOkV1WPHkpJxBc1ClNKN/FE5kxb5iXaQmUromJV+IbDcn78k1R+pl qqu2FHGwjP9a5ROly3LUeQL/itbzqQRxZ0lxj7w8hRS3KdGvg3z1j4Np3BL/t+8Q9ild QXgLUO9T3k2dBGDaOKiFZyANrdjCh5BlckfBYt0fUeqzCbpnkgH6F6vWEmxq+OjppM85 kQtQ== X-Gm-Message-State: AOJu0Ywxmj6d/jMCFQPbYBulspPhWDYpMBoIz6cHU6FlxVD9hALLYcxa X7HYUJQRu4O9BnMjqIS3sUNccFnykVB2wlFYHEo= X-Received: by 2002:a05:6870:b4a0:b0:1fb:5e42:5096 with SMTP id y32-20020a056870b4a000b001fb5e425096mr1917272oap.5.1701880551180; Wed, 06 Dec 2023 08:35:51 -0800 (PST) MIME-Version: 1.0 References: <20231115091612.580685-1-LeoLiu-oc@zhaoxin.com> <20231115091612.580685-2-LeoLiu-oc@zhaoxin.com> In-Reply-To: <20231115091612.580685-2-LeoLiu-oc@zhaoxin.com> From: "Rafael J. Wysocki" Date: Wed, 6 Dec 2023 17:35:38 +0100 Message-ID: Subject: Re: [PATCH 1/3] ACPI/APEI: Add hest_parse_pcie_aer() To: LeoLiu-oc Cc: rafael@kernel.org, lenb@kernel.org, james.morse@arm.com, tony.luck@intel.com, bp@alien8.de, bhelgaas@google.com, robert.moore@intel.com, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, acpica-devel@lists.linux.dev, CobeChen@zhaoxin.com, TonyWWang@zhaoxin.com, ErosZhang@zhaoxin.com, LeoLiu@zhaoxin.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 06 Dec 2023 08:36:13 -0800 (PST) On Wed, Nov 15, 2023 at 10:16 AM LeoLiu-oc wrote: > > From: leoliu-oc > > The purpose of the function apei_hest_parse_aer() is used to parse and > extract register value from HEST PCIe AER structures. > > Signed-off-by: leoliu-oc > --- > drivers/acpi/apei/hest.c | 77 ++++++++++++++++++++++++++++++++++++++-- > include/acpi/actbl1.h | 7 ++++ > include/acpi/apei.h | 8 +++++ > 3 files changed, 90 insertions(+), 2 deletions(-) > > diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c > index 6aef1ee5e1bd..7fb797fdc1b1 100644 > --- a/drivers/acpi/apei/hest.c > +++ b/drivers/acpi/apei/hest.c > @@ -22,6 +22,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -86,9 +87,81 @@ static int hest_esrc_len(struct acpi_hest_header *hest_hdr) > return len; > }; > > -typedef int (*apei_hest_func_t)(struct acpi_hest_header *hest_hdr, void *data); > +#ifdef CONFIG_ACPI_APEI > +static bool hest_match_pci_devfn(struct acpi_hest_aer_common *p, > + struct pci_dev *dev) > +{ > + return ACPI_HEST_SEGMENT(p->bus) == pci_domain_nr(dev->bus) && > + ACPI_HEST_BUS(p->bus) == dev->bus->number && > + p->device == PCI_SLOT(dev->devfn) && > + p->function == PCI_FUNC(dev->devfn); > +} > + > +static bool hest_source_is_pcie_aer(struct acpi_hest_header *hest_hdr, > + struct pci_dev *dev) > +{ > + u16 hest_type = hest_hdr->type; > + u8 pcie_type = pci_pcie_type(dev); > + struct acpi_hest_aer_common *common; > + > + common = (struct acpi_hest_aer_common *)(hest_hdr + 1); > + > + switch (hest_type) { > + case ACPI_HEST_TYPE_AER_ROOT_PORT: > + if (pcie_type != PCI_EXP_TYPE_ROOT_PORT) > + return false; > + break; > + case ACPI_HEST_TYPE_AER_ENDPOINT: > + if (pcie_type != PCI_EXP_TYPE_ENDPOINT) > + return false; > + break; > + case ACPI_HEST_TYPE_AER_BRIDGE: > + if (pcie_type != PCI_EXP_TYPE_PCI_BRIDGE && > + pcie_type != PCI_EXP_TYPE_PCIE_BRIDGE) > + return false; > + break; > + default: > + return false; > + break; > + } > + > + if (common->flags & ACPI_HEST_GLOBAL) > + return true; > + > + if (hest_match_pci_devfn(common, dev)) > + return true; > + > + return false; > +} > + > +int hest_parse_pcie_aer(struct acpi_hest_header *hest_hdr, void *data) > +{ > + struct hest_parse_aer_info *info = data; > + > + if (!hest_source_is_pcie_aer(hest_hdr, info->pci_dev)) > + return 0; > + > + switch (hest_hdr->type) { > + case ACPI_HEST_TYPE_AER_ROOT_PORT: > + info->hest_aer_root_port = (struct acpi_hest_aer_root *)hest_hdr; > + return 1; > + break; > + case ACPI_HEST_TYPE_AER_ENDPOINT: > + info->hest_aer_endpoint = (struct acpi_hest_aer *)hest_hdr; > + return 1; > + break; > + case ACPI_HEST_TYPE_AER_BRIDGE: > + info->hest_aer_bridge = (struct acpi_hest_aer_bridge *)hest_hdr; > + return 1; > + break; > + default: > + return 0; > + break; > + } > +} > +#endif > > -static int apei_hest_parse(apei_hest_func_t func, void *data) > +int apei_hest_parse(apei_hest_func_t func, void *data) > { > struct acpi_hest_header *hest_hdr; > int i, rc, len; > diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h > index a33375e055ad..90c27dc5325f 100644 > --- a/include/acpi/actbl1.h > +++ b/include/acpi/actbl1.h This is an ACPICA header and it cannot be modified just like this. The way to do that is to submit a pull request with the desired change to the upstream ACPICA project on GitHub and add a Link tag pointing to the upstream PR to the corresponding Linux patch. Then, the Linux patch can only be applied after the corresponding upstream PR has been merged. Thanks! > @@ -1629,6 +1629,13 @@ struct acpi_hest_generic_status { > u32 error_severity; > }; > > +struct hest_parse_aer_info { > + struct pci_dev *pci_dev; > + struct acpi_hest_aer *hest_aer_endpoint; > + struct acpi_hest_aer_root *hest_aer_root_port; > + struct acpi_hest_aer_bridge *hest_aer_bridge; > +}; > + > /* Values for block_status flags above */ > > #define ACPI_HEST_UNCORRECTABLE (1) > diff --git a/include/acpi/apei.h b/include/acpi/apei.h > index dc60f7db5524..d12e6b6c4546 100644 > --- a/include/acpi/apei.h > +++ b/include/acpi/apei.h > @@ -33,10 +33,18 @@ void __init acpi_ghes_init(void); > static inline void acpi_ghes_init(void) { } > #endif > > +typedef int (*apei_hest_func_t)(struct acpi_hest_header *hest_hdr, void *data); > +int apei_hest_parse(apei_hest_func_t func, void *data); > + > #ifdef CONFIG_ACPI_APEI > void __init acpi_hest_init(void); > +int hest_parse_pcie_aer(struct acpi_hest_header *hest_hdr, void *data); > #else > static inline void acpi_hest_init(void) { } > +static inline int hest_parse_pcie_aer(struct acpi_hest_header *hest_hdr, void *data) > +{ > + return 0; > +} > #endif > > int erst_write(const struct cper_record_header *record); > -- > 2.34.1 >