Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp142877rwi; Wed, 26 Oct 2022 22:16:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6WWdViFgPqfs+RslGnZzgpTsDXjWWeNFO9/aaGcnaEb1B2pcvxrMFHu5Ll0fseP3mrzde0 X-Received: by 2002:a05:6402:2402:b0:45c:a1ce:94d8 with SMTP id t2-20020a056402240200b0045ca1ce94d8mr8919251eda.50.1666847791801; Wed, 26 Oct 2022 22:16:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666847791; cv=none; d=google.com; s=arc-20160816; b=co54fcyMFShaRWq28VP0RGc6mNjz95IbqYqvnAtQWSSeZC5xJYCwvC7a4rZj3E7f4B L9Ylpi5+ckwLpacNT3mrbwM2t60qc7iwQqzamiZV9v0vfHlCHr0rJt6bgZGoFPtWZXSg SAccBz0kheM5r62n/IDbptMj4T0fNw9aE0w/3wzab7ppDhR4kunfK6k4fxGbp4irLF6a SEMOfJAFL3ZrBmA/Q1+SNPE3YanXlpP/2BTx6RlOkxiuNi/JRIag3l071mbg9qAfrdyp le/JcRAxfMp8IoPTYXMe80wGbnZjJO1+nUi3qKa77NW8ZsAMJH0H77K/UylsZoOHjIr6 QW0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=7TPLNYx54By6AbkowMxn+o1a0dhPeylZe/bXMHDDWg0=; b=aD5nunc2ETHnNlC95DwugBbR/GVmpMv8lehNvjX+Ob6lJG2syrC88C6VgcVGo4jC6f yeIpOo4CAqh/B5KGEoqG4BByPcoZzHeT0Jeq9w6rGeNsA2kM6cc+4D8f59CNKC2aBZjc kj9zS58cZa4i/DcxiChV+LuyW6F/Tek9xf6g6rQw0jyS9+qdMWkkExPOmijMeFq5NcIJ WmuzFoWoOxmbaTDIvBQLhQZ6XeowHAVsonYcfMb2jPNkEyyWTX/nWYXz0r+u8itivPG/ eMh5nlJDUEmCoO5ijKYooY/TiSVVkjFa2J6LY5apVMFer1/3NB/4uGxcUF2Odn67D0gM dFqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Nukh5lyM; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc40-20020a17090716a800b00791a4f70674si565248ejc.24.2022.10.26.22.16.06; Wed, 26 Oct 2022 22:16:31 -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=@intel.com header.s=Intel header.b=Nukh5lyM; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234260AbiJ0E7O (ORCPT + 99 others); Thu, 27 Oct 2022 00:59:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234259AbiJ0E7D (ORCPT ); Thu, 27 Oct 2022 00:59:03 -0400 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E45915819A; Wed, 26 Oct 2022 21:59:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666846741; x=1698382741; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=VIboXZAzPOAyqYw2WVL+sf/zfuy9m8FGbkzVfNiyFOo=; b=Nukh5lyMS4N81XwHuDdamTBBB+XJcSeLXUj52fLhSCkpTcGE9RvVDgDb 5JFsSZYcG26G4XJORIS4mjIWtG3IfAx9vh9IQP3iBb5Ftsm8DNQh2QQMx nOdA3a6Z1hSZpCo61jSJ7BU5VaDlNAkub1sZtUatV928aQoRVj0t6r+aw XwsnUqLKl5BPsdtx0wEy5XRighr4dvz/5aWBEGCOtKq7GBDdrJP0XWFpL kh0R+BgYD3COtEgWPUznvyPUzQriMaDHXmdsXjhzk6bGa17VNQ2nJ7C7X eG+dqGnst5wQaTXyQ35EvVl0gG4J6CpMAeBjkVBilkCJvoRxYj0SffV+a Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="295538600" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="295538600" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 21:59:01 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10512"; a="774854441" X-IronPort-AV: E=Sophos;i="5.95,215,1661842800"; d="scan'208";a="774854441" Received: from holmeskx-mobl.amr.corp.intel.com (HELO [10.209.105.249]) ([10.209.105.249]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2022 21:59:00 -0700 Message-ID: Date: Wed, 26 Oct 2022 21:58:59 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0 Thunderbird/102.2.2 Subject: Re: [PATCH 1/5] ACPI/APEI: Add apei_hest_parse_aer() Content-Language: en-US To: LeoLiu-oc , rafael@kernel.org, lenb@kernel.org, james.morse@arm.com, tony.luck@intel.com, bp@alien8.de, robert.moore@intel.com, ying.huang@intel.com, rdunlap@infradead.org, bhelgaas@google.com, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devel@acpica.org Cc: CobeChen@zhaoxin.com, TonyWWang@zhaoxin.com, ErosZhang@zhaoxin.com References: <20221027031518.2855743-1-LeoLiu-oc@zhaoxin.com> From: Sathyanarayanan Kuppuswamy In-Reply-To: <20221027031518.2855743-1-LeoLiu-oc@zhaoxin.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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 10/26/22 8:15 PM, LeoLiu-oc wrote: > From: leoliu-oc > > apei_hest_parse_aer() is used to parse and record the PCI Express AER > Structure in the HEST Table. > > Signed-off-by: leoliu-oc Does this code compile? It looks like there are some compile time issues. > --- > drivers/acpi/apei/hest.c | 119 ++++++++++++++++++++++++++++++++++++++- > include/acpi/actbl1.h | 69 +++++++++++++++++++++++ > include/acpi/apei.h | 7 +++ > 3 files changed, 194 insertions(+), 1 deletion(-) > > diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c > index 6aef1ee5e1bd..0bfdc18758f5 100644 > --- a/drivers/acpi/apei/hest.c > +++ b/drivers/acpi/apei/hest.c > @@ -25,6 +25,7 @@ > #include > #include > #include > +#include > > #include "apei-internal.h" > > @@ -86,7 +87,48 @@ 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); You are still using apei_hest_func_t. Why remove it? > +static inline bool hest_source_is_pcie_aer(struct acpi_hest_header *hest_hdr) > +{ > + if (hest_hdr->type == ACPI_HEST_TYPE_AER_ROOT_PORT || > + hest_hdr->type == ACPI_HEST_TYPE_AER_ENDPOINT || > + hest_hdr->type == ACPI_HEST_TYPE_AER_BRIDGE) > + return true; > + return false; > +} > + > +static inline bool hest_match_type(struct acpi_hest_header *hest_hdr, > + struct pci_dev *dev) > +{ > + u16 hest_type = hest_hdr->type; > + u8 pcie_type = pci_pcie_type(dev); > + > + if ((hest_type == ACPI_HEST_TYPE_AER_ROOT_PORT && > + pcie_type == PCI_EXP_TYPE_ROOT_PORT) || > + (hest_type == ACPI_HEST_TYPE_AER_ENDPOINT && > + pcie_type == PCI_EXP_TYPE_ENDPOINT) || > + (hest_type == ACPI_HEST_TYPE_AER_BRIDGE && > + (pcie_type == PCI_EXP_TYPE_PCI_BRIDGE || pcie_type == PCI_EXP_TYPE_PCIE_BRIDGE))) > + return true; > + return false; > +} > + > +static inline bool hest_match_pci_devfn(struct acpi_hest_aer_common *p, > + struct pci_dev *pci) > +{ > + return ACPI_HEST_SEGMENT(p->bus) == pci_domain_nr(pci->bus) && > + ACPI_HEST_BUS(p->bus) == pci->bus->number && > + p->device == PCI_SLOT(pci->devfn) && > + p->function == PCI_FUNC(pci->devfn); > +} > + > +static inline bool hest_match_pci(struct acpi_hest_header *hest_hdr, > + struct acpi_hest_aer_common *p, struct pci_dev *pci) > +{ > + if (hest_match_type(hest_hdr, pci)) > + return(hest_match_pci_devfn(p, pci)); I think it is return hest_match_pci_devfn(p, pci); > + else > + return false; > +} > > static int apei_hest_parse(apei_hest_func_t func, void *data) > { > @@ -124,6 +166,81 @@ static int apei_hest_parse(apei_hest_func_t func, void *data) > return 0; > } > > +/* > + * apei_hest_parse_aer - Find the AER structure in the HEST Table and > + * match it with the PCI device. > + * > + * @hest_hdr: To save the acpi aer error source in hest table > + * > + * Return 1 if the pci dev matched with the acpi aer error source in > + * hest table, else return 0. > + */ > +int apei_hest_parse_aer(struct acpi_hest_header *hest_hdr, void *data) > +{ > + struct acpi_hest_parse_aer_info *info = data; > + struct acpi_hest_aer_endpoint *acpi_hest_aer_endpoint = NULL; > + struct acpi_hest_aer_root_port *acpi_hest_aer_root_port = NULL; > + struct acpi_hest_aer_for_bridge *acpi_hest_aer_for_bridge = NULL; > + > + if (!hest_source_is_pcie_aer(hest_hdr)) > + return 0; > + > + if (hest_hdr->type == ACPI_HEST_TYPE_AER_ROOT_PORT) { > + acpi_hest_aer_root_port = (struct acpi_hest_aer_root_port *)(hest_hdr + 1); > + if (acpi_hest_aer_root_port->flags & ACPI_HEST_GLOBAL) { > + if (hest_match_type(hest_hdr, info->pci_dev)) { > + info->acpi_hest_aer_root_port = acpi_hest_aer_root_port; > + info->hest_matched_with_dev = 1; > + } else > + info->hest_matched_with_dev = 0; > + } else { > + if (hest_match_pci(hest_hdr, > + (struct acpi_hest_aer_common *)acpi_hest_aer_root_port, > + info->pci_dev)) { > + info->acpi_hest_aer_root_port = acpi_hest_aer_root_port; > + info->hest_matched_with_dev = 1; > + } else > + info->hest_matched_with_dev = 0; > + } > + } else if (hest_hdr->type == ACPI_HEST_TYPE_AER_ENDPOINT) { > + acpi_hest_aer_endpoint = (struct acpi_hest_aer_endpoint *)(hest_hdr + 1); > + if (acpi_hest_aer_endpoint->flags & ACPI_HEST_GLOBAL) { > + if (hest_match_type(hest_hdr, info->pci_dev)) { > + info->acpi_hest_aer_endpoint = acpi_hest_aer_endpoint; > + info->hest_matched_with_dev = 1; > + } else > + info->hest_matched_with_dev = 0; > + } else { > + if (hest_match_pci(hest_hdr, > + (struct acpi_hest_aer_common *)acpi_hest_aer_endpoint, > + info->pci_dev)) { > + info->acpi_hest_aer_endpoint = acpi_hest_aer_endpoint; > + info->hest_matched_with_dev = 1; > + } else > + info->hest_matched_with_dev = 0; > + } > + } else if (hest_hdr->type == ACPI_HEST_TYPE_AER_BRIDGE) { > + acpi_hest_aer_for_bridge = > + (struct acpi_hest_aer_for_bridge *)(hest_hdr + 1); > + if (acpi_hest_aer_for_bridge->flags & ACPI_HEST_GLOBAL) { > + if (hest_match_type(hest_hdr, info->pci_dev)) { > + info->acpi_hest_aer_for_bridge = acpi_hest_aer_for_bridge; > + info->hest_matched_with_dev = 1; > + } else > + info->hest_matched_with_dev = 0; > + } else { > + if (hest_match_pci(hest_hdr, > + (struct acpi_hest_aer_common *)acpi_hest_aer_for_bridge, > + info->pci_dev)) { > + info->acpi_hest_aer_for_bridge = acpi_hest_aer_for_bridge; > + info->hest_matched_with_dev = 1; > + } else > + info->hest_matched_with_dev = 0; > + } > + } > + return info->hest_matched_with_dev; > +} > + > /* > * Check if firmware advertises firmware first mode. We need FF bit to be set > * along with a set of MC banks which work in FF mode. > diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h > index 15c78678c5d3..7f52035512b2 100644 > --- a/include/acpi/actbl1.h > +++ b/include/acpi/actbl1.h > @@ -1385,6 +1385,75 @@ struct acpi_hest_aer_bridge { > u32 advanced_capabilities2; > }; > > +struct acpi_hest_parse_aer_info { > + struct pci_dev *pci_dev; > + int hest_matched_with_dev; > + struct acpi_hest_aer_endpoint *acpi_hest_aer_endpoint; > + struct acpi_hest_aer_root_port *acpi_hest_aer_root_port; > + struct acpi_hest_aer_for_bridge *acpi_hest_aer_for_bridge; > +}; > + > +/* HEST Sub-structure for PCIE EndPoint Structure (6) */ > + > +struct acpi_hest_aer_root_port { > + u16 reserved1; > + u8 flags; > + u8 enabled; > + u32 records_to_preallocate; > + u32 max_sections_per_record; > + u32 bus; /* Bus and Segment numbers */ > + u16 device; > + u16 function; > + u16 device_control; > + u16 reserved2; > + u32 uncorrectable_mask; > + u32 uncorrectable_severity; > + u32 correctable_mask; > + u32 advanced_capabilities; > + u32 root_error_command; > +}; > + > +/* HEST Sub-structure for PCIE EndPoint Structure (7) */ > + > +struct acpi_hest_aer_endpoint { > + u16 reserved1; > + u8 flags; > + u8 enabled; > + u32 records_to_preallocate; > + u32 max_sections_per_record; > + u32 bus; /* Bus and Segment numbers */ > + u16 device; > + u16 function; > + u16 device_control; > + u16 reserved2; > + u32 uncorrectable_mask; > + u32 uncorrectable_severity; > + u32 correctable_mask; > + u32 advanced_capabilities; > +}; > + > +/* HEST Sub-structure for PCIE/PCI Bridge Structure (8) */ > + > +struct acpi_hest_aer_for_bridge { > + u16 reserved1; > + u8 flags; > + u8 enabled; > + u32 records_to_preallocate; > + u32 max_sections_per_record; > + u32 bus; > + u16 device; > + u16 function; > + u16 device_control; > + u16 reserved2; > + u32 uncorrectable_mask; > + u32 uncorrectable_severity; > + u32 correctable_mask; > + u32 advanced_capabilities; > + u32 uncorrectable_mask2; > + u32 uncorrectable_severity2; > + u32 advanced_capabilities2; > +}; > + > /* 9: Generic Hardware Error Source */ > > struct acpi_hest_generic { > diff --git a/include/acpi/apei.h b/include/acpi/apei.h > index dc60f7db5524..8a0b2b9edbaf 100644 > --- a/include/acpi/apei.h > +++ b/include/acpi/apei.h > @@ -33,10 +33,17 @@ 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); > + > #ifdef CONFIG_ACPI_APEI > void __init acpi_hest_init(void); > +int apei_hest_parse_aer(struct acpi_hest_header *hest_hdr, void *data); > #else > static inline void acpi_hest_init(void) { } > +static inline int apei_hest_parse_aer(struct acpi_hest_header *hest_hdr, void *data) > +{ > + return -EINVAL; > +} > #endif > > int erst_write(const struct cper_record_header *record); -- Sathyanarayanan Kuppuswamy Linux Kernel Developer