From: Bjorn Helgaas <bhelgaas@google.com>
To: Betty Dall <betty.dall@hp.com>
Cc: rjw@sisk.pl, ying.huang@intel.com, linux-acpi@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
gong.chen@linux.intel.com
Subject: Re: [PATCH v2 1/3] PCI/AER: Fix incorrect return from aer_hest_parse()
Date: Tue, 4 Jun 2013 07:13:24 -0600 [thread overview]
Message-ID: <20130604131324.GA4829@google.com> (raw)
In-Reply-To: <1369924769-17183-2-git-send-email-betty.dall@hp.com>
On Thu, May 30, 2013 at 08:39:27AM -0600, Betty Dall wrote:
> The function aer_hest_parse() is called to determine if the given
> PCI device is firmware first or not. The code loops through each
> section of the HEST table to look for a match. The bug is that
> the function always returns whether the last HEST section is firmware
> first. The fix stops the iteration once the info.firmware_first
> variable is set. This is similar to how the function aer_hest_parse_aff()
> stops the iteration.
>
> Signed-off-by: Betty Dall <betty.dall@hp.com>
> ---
>
> drivers/pci/pcie/aer/aerdrv_acpi.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
>
> diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c
> index 5194a7d..39b8671 100644
> --- a/drivers/pci/pcie/aer/aerdrv_acpi.c
> +++ b/drivers/pci/pcie/aer/aerdrv_acpi.c
> @@ -42,6 +42,9 @@ static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
> u8 bridge = 0;
> int ff = 0;
>
> + if (info->firmware_first)
> + return 0;
> +
> switch (hest_hdr->type) {
> case ACPI_HEST_TYPE_AER_ROOT_PORT:
> pcie_type = PCI_EXP_TYPE_ROOT_PORT;
1) I think dev->__aer_firmware_first should be initialized somewhere in the
pci_scan_single_device() path, e.g., maybe pci_init_capabilities(). It's
known at device add-time and never changes, so there's no point in doing
the lazy setup we do now. That would let us get rid of
__aer_firmware_first_valid, too (along with the pointless "__" prefix).
This is just an observation, not a requirement for this patch set.
2) This is a band-aid that covers up the real problem, which is that we
update info->firmware_first even for non-matching devices. I think we
should do something like the following instead:
commit c67612f272f1792a08f012f1b5ca37d5cfde5de4
Author: Bjorn Helgaas <bhelgaas@google.com>
Date: Mon Jun 3 16:49:12 2013 -0600
PCI/AER: Don't parse HEST table for non-PCIe devices
AER is a PCIe-only capability, so there's no point in trying to match
a HEST PCIe structure with a non-PCIe device.
Previously, a HEST global AER bridge entry (type 8) could incorrectly
match *any* bridge, even a legacy PCI-PCI bridge, and a non-global
HEST entry could match a legacy PCI device.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c
index 5194a7d..4f798ab 100644
--- a/drivers/pci/pcie/aer/aerdrv_acpi.c
+++ b/drivers/pci/pcie/aer/aerdrv_acpi.c
@@ -59,8 +59,7 @@ static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
p = (struct acpi_hest_aer_common *)(hest_hdr + 1);
if (p->flags & ACPI_HEST_GLOBAL) {
- if ((pci_is_pcie(info->pci_dev) &&
- pci_pcie_type(info->pci_dev) == pcie_type) || bridge)
+ if ((pci_pcie_type(info->pci_dev) == pcie_type) || bridge)
ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
} else
if (hest_match_pci(p, info->pci_dev))
@@ -89,6 +88,9 @@ static void aer_set_firmware_first(struct pci_dev *pci_dev)
int pcie_aer_get_firmware_first(struct pci_dev *dev)
{
+ if (!pci_is_pcie(dev))
+ return 0;
+
if (!dev->__aer_firmware_first_valid)
aer_set_firmware_first(dev);
return dev->__aer_firmware_first;
commit 947da50270686b0d70f4bc2f7323ef7229489ecb
Author: Bjorn Helgaas <bhelgaas@google.com>
Date: Mon Jun 3 15:42:00 2013 -0600
PCI/AER: Factor out HEST device type matching
This factors out the matching of HEST structure type and PCIe device type
to improve readability. No functional change.
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c
index 4f798ab..56e2d94 100644
--- a/drivers/pci/pcie/aer/aerdrv_acpi.c
+++ b/drivers/pci/pcie/aer/aerdrv_acpi.c
@@ -29,6 +29,22 @@ static inline int hest_match_pci(struct acpi_hest_aer_common *p,
p->function == PCI_FUNC(pci->devfn));
}
+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 &&
+ (dev->class >> 16) == PCI_BASE_CLASS_BRIDGE))
+ return true;
+ return false;
+}
+
struct aer_hest_parse_info {
struct pci_dev *pci_dev;
int firmware_first;
@@ -38,28 +54,11 @@ static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
{
struct aer_hest_parse_info *info = data;
struct acpi_hest_aer_common *p;
- u8 pcie_type = 0;
- u8 bridge = 0;
int ff = 0;
- switch (hest_hdr->type) {
- case ACPI_HEST_TYPE_AER_ROOT_PORT:
- pcie_type = PCI_EXP_TYPE_ROOT_PORT;
- break;
- case ACPI_HEST_TYPE_AER_ENDPOINT:
- pcie_type = PCI_EXP_TYPE_ENDPOINT;
- break;
- case ACPI_HEST_TYPE_AER_BRIDGE:
- if ((info->pci_dev->class >> 16) == PCI_BASE_CLASS_BRIDGE)
- bridge = 1;
- break;
- default:
- return 0;
- }
-
p = (struct acpi_hest_aer_common *)(hest_hdr + 1);
if (p->flags & ACPI_HEST_GLOBAL) {
- if ((pci_pcie_type(info->pci_dev) == pcie_type) || bridge)
+ if (hest_match_type(hest_hdr, info->pci_dev))
ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
} else
if (hest_match_pci(p, info->pci_dev))
commit e9f977a04d96a54c4f6aa0b831e725dab2154364
Author: Bjorn Helgaas <bhelgaas@google.com>
Date: Mon Jun 3 19:47:27 2013 -0600
PCI/AER: Set dev->__aer_firmware_first only for matching devices
Previously, we always updated info->firmware_first, even for HEST entries
that didn't match the device. Therefore, if the last HEST descriptor was
a PCIe structure that didn't match the device, we always cleared
dev->__aer_firmware_first.
Based-on-patch-by: Betty Dall <betty.dall@hp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c
index 56e2d94..2bedad8 100644
--- a/drivers/pci/pcie/aer/aerdrv_acpi.c
+++ b/drivers/pci/pcie/aer/aerdrv_acpi.c
@@ -54,16 +54,16 @@ static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
{
struct aer_hest_parse_info *info = data;
struct acpi_hest_aer_common *p;
- int ff = 0;
+ int ff;
p = (struct acpi_hest_aer_common *)(hest_hdr + 1);
- if (p->flags & ACPI_HEST_GLOBAL) {
+ ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
+ if (p->flags & ACPI_HEST_GLOBAL)
if (hest_match_type(hest_hdr, info->pci_dev))
- ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
- } else
+ info->firmware_first = ff;
+ else
if (hest_match_pci(p, info->pci_dev))
- ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
- info->firmware_first = ff;
+ info->firmware_first = ff;
return 0;
}
next prev parent reply other threads:[~2013-06-04 13:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-30 14:39 [PATCH v2 0/3] PCI/ACPI: Fix firmware first error recovery with root port in reset Betty Dall
2013-05-30 14:39 ` [PATCH v2 1/3] PCI/AER: Fix incorrect return from aer_hest_parse() Betty Dall
2013-06-02 0:38 ` Bjorn Helgaas
2013-06-03 21:18 ` Betty Dall
2013-06-04 17:39 ` Bjorn Helgaas
2013-06-04 7:42 ` Chen Gong
2013-06-04 13:13 ` Bjorn Helgaas [this message]
2013-06-05 2:48 ` Chen Gong
2013-06-05 13:38 ` Bjorn Helgaas
2013-05-30 14:39 ` [PATCH v2 2/3] ACPI/APEI: Force fatal AER severity when bus has been reset Betty Dall
2013-06-04 7:53 ` Chen Gong
2013-06-04 16:20 ` Betty Dall
2013-06-04 17:54 ` Bjorn Helgaas
2013-06-05 1:56 ` Chen Gong
2013-05-30 14:39 ` [PATCH v2 3/3] PCI/AER: Provide reset_link for firmware first root port Betty Dall
2013-06-04 8:36 ` Chen Gong
2013-06-04 18:31 ` Bjorn Helgaas
2013-06-04 21:38 ` Betty Dall
2013-06-04 22:15 ` Bjorn Helgaas
2013-06-05 1:56 ` Chen Gong
2013-06-05 13:22 ` Betty Dall
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=20130604131324.GA4829@google.com \
--to=bhelgaas@google.com \
--cc=betty.dall@hp.com \
--cc=gong.chen@linux.intel.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=rjw@sisk.pl \
--cc=ying.huang@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.