mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: LeoLiu-oc <leoliu-oc@zhaoxin.com>
To: Yazen Ghannam <yazen.ghannam@amd.com>
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>, <avadhut.naik@amd.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>
Subject: Re: [PATCH v4 1/3] ACPI/APEI: Add hest_parse_pcie_aer()
Date: Wed, 26 Feb 2025 17:39:48 +0800	[thread overview]
Message-ID: <ab631e27-ee35-47b9-879b-2b8d6a245512@zhaoxin.com> (raw)
In-Reply-To: <20241211192048.GA1960478@yaz-khff2.amd.com>



在 2024/12/12 3:20, Yazen Ghannam 写道:
> 
> 
> [这封邮件来自外部发件人 谨防风险]
> 
> On Thu, Dec 05, 2024 at 07:40:46PM +0800, LeoLiu-oc wrote:
>> From: LeoLiuoc <LeoLiu-oc@zhaoxin.com>
>>
>> The purpose of the function apei_hest_parse_aer() is used to parse and
>> extract register value from HEST PCIe AER structures. This applies to
>> all hardware platforms that has a PCI Express AER structure in HEST.
>>
>> Signed-off-by: LeoLiuoc <LeoLiu-oc@zhaoxin.com>
>> ---
>>   drivers/acpi/apei/hest.c | 77 ++++++++++++++++++++++++++++++++++++++--
>>   include/acpi/apei.h      | 17 +++++++++
>>   2 files changed, 92 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c
>> index 20d757687e3d..13075f5aea25 100644
>> --- a/drivers/acpi/apei/hest.c
>> +++ b/drivers/acpi/apei/hest.c
>> @@ -22,6 +22,7 @@
>>   #include <linux/kdebug.h>
>>   #include <linux/highmem.h>
>>   #include <linux/io.h>
>> +#include <linux/pci.h>
>>   #include <linux/platform_device.h>
>>   #include <acpi/apei.h>
>>   #include <acpi/ghes.h>
>> @@ -132,9 +133,81 @@ static bool is_ghes_assist_struct(struct acpi_hest_header *hest_hdr)
>>        return false;
>>   }
>>
>> -typedef int (*apei_hest_func_t)(struct acpi_hest_header *hest_hdr, void *data);
>> +#ifdef CONFIG_ACPI_APEI
> 
> Why is this needed? The entire hest.c file is only built if
> CONFIG_ACPI_APEI is enabled.
> 
I agree with your point.

>> +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);
> 
> It may be nice to align all these lines on the "==".
> 
Okay, I will make the changes in the next version

>> +}
>> +
>> +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;
> 
> The breaks should be indented to the "if". Same for the rest of the
> file.
> 
I agree with your point of view and will make modifications in the next 
version.

>> +     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/apei.h b/include/acpi/apei.h
>> index dc60f7db5524..82d3cdf53e22 100644
>> --- a/include/acpi/apei.h
>> +++ b/include/acpi/apei.h
>> @@ -23,6 +23,15 @@ enum hest_status {
>>        HEST_NOT_FOUND,
>>   };
>>
>> +#ifdef CONFIG_ACPI_APEI
>> +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;
> 
> These three pointers are mutually exclusive. Can you save just one
> pointer and then cast it when checking the "port_type" in patch 3?
> 
>> +};
>> +#endif
> 
> I think the #ifdef is not needed, because this is not declaring an
> instance of the struct.
> 
I agree with your point of view and will make modifications in the next 
version.

>> +
>>   extern int hest_disable;
>>   extern int erst_disable;
>>   #ifdef CONFIG_ACPI_APEI_GHES
>> @@ -33,10 +42,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);
>> +
> 
> Minor nit: this could be done as a separate patch.
> 
> Patch 1: Move apei_hest_parse() to apei.h
> Patch 2: Add new hest_parse_pcie_aer()
> 
Ok, your suggestion is very reasonable, I will modify it in the next 
version.

Leoliu-oc
Best Regards

>>   #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);
>> --
> 
> Thanks,
> Yazen


  reply	other threads:[~2025-02-27  5:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-05 11:40 [PATCH v4 0/3] Parse the HEST PCIe AER and set to relevant registers LeoLiu-oc
2024-12-05 11:40 ` [PATCH v4 1/3] ACPI/APEI: Add hest_parse_pcie_aer() LeoLiu-oc
2024-12-11 19:20   ` Yazen Ghannam
2025-02-26  9:39     ` LeoLiu-oc [this message]
2024-12-05 11:40 ` [PATCH v4 2/3] PCI: Add AER bits #defines for PCIe to PCI/PCI-X Bridge LeoLiu-oc
2024-12-05 11:40 ` [PATCH v4 3/3] PCI/ACPI: Add pci_acpi_program_hest_aer_params() LeoLiu-oc
2024-12-11 19:47   ` Yazen Ghannam
2025-02-26  9:41     ` LeoLiu-oc

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab631e27-ee35-47b9-879b-2b8d6a245512@zhaoxin.com \
    --to=leoliu-oc@zhaoxin.com \
    --cc=CobeChen@zhaoxin.com \
    --cc=ErosZhang@zhaoxin.com \
    --cc=TonyWWang@zhaoxin.com \
    --cc=acpica-devel@lists.linux.dev \
    --cc=avadhut.naik@amd.com \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=james.morse@arm.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=robert.moore@intel.com \
    --cc=tony.luck@intel.com \
    --cc=yazen.ghannam@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®