Skip to content

Commit

Permalink
ACPI, APEI, PCIE AER, use general HEST table parsing in AER firmware_…
Browse files Browse the repository at this point in the history
…first setup

Now, a dedicated HEST tabling parsing code is used for PCIE AER
firmware_first setup. It is rebased on general HEST tabling parsing
code of APEI. The firmware_first setup code is moved from PCI core to
AER driver too, because it is only AER related.

Signed-off-by: Huang Ying <[email protected]>
Signed-off-by: Andi Kleen <[email protected]>
Reviewed-by: Hidetoshi Seto <[email protected]>
Acked-by: Jesse Barnes <[email protected]>
Signed-off-by: Len Brown <[email protected]>
  • Loading branch information
yhuang-intel authored and lenb committed May 20, 2010
1 parent ea8c071 commit affb72c
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 165 deletions.
1 change: 0 additions & 1 deletion drivers/acpi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ obj-y += acpi.o \
# All the builtin files are in the "acpi." module_param namespace.
acpi-y += osl.o utils.o reboot.o
acpi-y += atomicio.o
acpi-y += hest.o

# sleep related files
acpi-y += wakeup.o
Expand Down
139 changes: 0 additions & 139 deletions drivers/acpi/hest.c

This file was deleted.

17 changes: 17 additions & 0 deletions drivers/pci/pcie/aer/aerdrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,21 @@ static inline int aer_osc_setup(struct pcie_device *pciedev)
}
#endif

#ifdef CONFIG_ACPI_APEI
extern int pcie_aer_get_firmware_first(struct pci_dev *pci_dev);
#else
static inline int pcie_aer_get_firmware_first(struct pci_dev *pci_dev)
{
if (pci_dev->__aer_firmware_first_valid)
return pci_dev->__aer_firmware_first;
return 0;
}
#endif

static inline void pcie_aer_force_firmware_first(struct pci_dev *pci_dev,
int enable)
{
pci_dev->__aer_firmware_first = !!enable;
pci_dev->__aer_firmware_first_valid = 1;
}
#endif /* _AERDRV_H_ */
77 changes: 77 additions & 0 deletions drivers/pci/pcie/aer/aerdrv_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/acpi.h>
#include <linux/pci-acpi.h>
#include <linux/delay.h>
#include <acpi/apei.h>
#include "aerdrv.h"

/**
Expand Down Expand Up @@ -53,3 +54,79 @@ int aer_osc_setup(struct pcie_device *pciedev)

return 0;
}

#ifdef CONFIG_ACPI_APEI
static inline int hest_match_pci(struct acpi_hest_aer_common *p,
struct pci_dev *pci)
{
return (0 == pci_domain_nr(pci->bus) &&
p->bus == pci->bus->number &&
p->device == PCI_SLOT(pci->devfn) &&
p->function == PCI_FUNC(pci->devfn));
}

struct aer_hest_parse_info {
struct pci_dev *pci_dev;
int firmware_first;
};

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 ((info->pci_dev->is_pcie &&
info->pci_dev->pcie_type == pcie_type) || bridge)
ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
} else
if (hest_match_pci(p, info->pci_dev))
ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
info->firmware_first = ff;

return 0;
}

static void aer_set_firmware_first(struct pci_dev *pci_dev)
{
int rc;
struct aer_hest_parse_info info = {
.pci_dev = pci_dev,
.firmware_first = 0,
};

rc = apei_hest_parse(aer_hest_parse, &info);

if (rc)
pci_dev->__aer_firmware_first = 0;
else
pci_dev->__aer_firmware_first = info.firmware_first;
pci_dev->__aer_firmware_first_valid = 1;
}

int pcie_aer_get_firmware_first(struct pci_dev *dev)
{
if (!dev->__aer_firmware_first_valid)
aer_set_firmware_first(dev);
return dev->__aer_firmware_first;
}
#endif
8 changes: 4 additions & 4 deletions drivers/pci/pcie/aer/aerdrv_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int pci_enable_pcie_error_reporting(struct pci_dev *dev)
u16 reg16 = 0;
int pos;

if (dev->aer_firmware_first)
if (pcie_aer_get_firmware_first(dev))
return -EIO;

pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
Expand Down Expand Up @@ -64,7 +64,7 @@ int pci_disable_pcie_error_reporting(struct pci_dev *dev)
u16 reg16 = 0;
int pos;

if (dev->aer_firmware_first)
if (pcie_aer_get_firmware_first(dev))
return -EIO;

pos = pci_pcie_cap(dev);
Expand Down Expand Up @@ -859,7 +859,7 @@ void aer_delete_rootport(struct aer_rpc *rpc)
*/
int aer_init(struct pcie_device *dev)
{
if (dev->port->aer_firmware_first) {
if (pcie_aer_get_firmware_first(dev->port)) {
dev_printk(KERN_DEBUG, &dev->device,
"PCIe errors handled by platform firmware.\n");
goto out;
Expand All @@ -873,7 +873,7 @@ int aer_init(struct pcie_device *dev)
if (forceload) {
dev_printk(KERN_DEBUG, &dev->device,
"aerdrv forceload requested.\n");
dev->port->aer_firmware_first = 0;
pcie_aer_force_firmware_first(dev->port, 0);
return 0;
}
return -ENXIO;
Expand Down
8 changes: 0 additions & 8 deletions drivers/pci/probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <linux/module.h>
#include <linux/cpumask.h>
#include <linux/pci-aspm.h>
#include <acpi/acpi_hest.h>
#include "pci.h"

#define CARDBUS_LATENCY_TIMER 176 /* secondary latency timer */
Expand Down Expand Up @@ -904,12 +903,6 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev)
pdev->is_hotplug_bridge = 1;
}

static void set_pci_aer_firmware_first(struct pci_dev *pdev)
{
if (acpi_hest_firmware_first_pci(pdev))
pdev->aer_firmware_first = 1;
}

#define LEGACY_IO_RESOURCE (IORESOURCE_IO | IORESOURCE_PCI_FIXED)

/**
Expand Down Expand Up @@ -939,7 +932,6 @@ int pci_setup_device(struct pci_dev *dev)
dev->multifunction = !!(hdr_type & 0x80);
dev->error_state = pci_channel_io_normal;
set_pcie_port_type(dev);
set_pci_aer_firmware_first(dev);

list_for_each_entry(slot, &dev->bus->slots, list)
if (PCI_SLOT(dev->devfn) == slot->number)
Expand Down
12 changes: 0 additions & 12 deletions include/acpi/acpi_hest.h

This file was deleted.

3 changes: 2 additions & 1 deletion include/linux/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ struct pci_dev {
unsigned int is_virtfn:1;
unsigned int reset_fn:1;
unsigned int is_hotplug_bridge:1;
unsigned int aer_firmware_first:1;
unsigned int __aer_firmware_first_valid:1;
unsigned int __aer_firmware_first:1;
pci_dev_flags_t dev_flags;
atomic_t enable_cnt; /* pci_enable_device has been called */

Expand Down

0 comments on commit affb72c

Please sign in to comment.