Skip to contentSkip to conversation

ACPI, APEI, use general HEST table parsing in AER firmware_first setup (resend)

PATCH In review Huang Ying 3 participants 6 messages Mar 11, 2010 – Mar 13, 2010

Subsystems (5)
lore
Share & tools
lore

Huang Ying

author
#0 lore raw

cover ACPI, APEI, use general HEST table parsing in AER firmware_first setup (resend)

Changelog:

v2:

- Setup firmware_first for every PCIE end point instead of just root point.

- Wrap firmware accessing in a function instead of raw hardware, because HEST parsing involved.

author
#1 lore raw

PATCH 1/2 ACPI, APEI, Make APEI core configurable built-in instead of module

PCIE AER optionally depends on APEI HEST tabling parsing. If AER is built-in, HEST should be built-in or not configured at all instead of module. It is hard to express this elegantly in Kconfig. It is better to make APEI code part configurable built-in instead of module.

On the other hand, APEI core code is used for hardware error processing. It may run in very bad condition. It is reasonable to keep it built-in if enabled.

---
 Documentation/kernel-parameters.txt |   10 ++++----
 drivers/acpi/apei/Kconfig           |    2 -
 drivers/acpi/apei/apei-base.c       |   42 +++++-------------------------------
 drivers/acpi/apei/apei-internal.h   |    4 ---
 drivers/acpi/apei/einj.c            |    2 -
 drivers/acpi/apei/hest.c            |   34 ++++++++++++++++++++++++-----
 6 files changed, 42 insertions(+), 52 deletions(-)
Documentation/kernel-parameters.txt +5 -5
@@ -351,11 +351,6 @@ and is between 256 and 4096 characters.
 			not play well with APC CPU idle - disable it if you have
 			APC and your system crashes randomly.
 
-	apei.hest_disable= [ACPI]
-			Disable Hardware Error Source Table (HEST) support,
-			corresponding firmware-first mode error processing
-			logic will be disabled.
-
 	apic=		[APIC,X86-32] Advanced Programmable Interrupt Controller
 			Change the output verbosity whilst booting
 			Format: { quiet (default) | verbose | debug }
@@ -857,6 +852,11 @@ and is between 256 and 4096 characters.
 	hd=		[EIDE] (E)IDE hard drive subsystem geometry
 			Format: <cyl>,<head>,<sect>
 
+	hest_disable	[ACPI]
+			Disable Hardware Error Source Table (HEST) support,
+			corresponding firmware-first mode error processing
+			logic will be disabled.
+
 	highmem=nn[KMG]	[KNL,BOOT] forces the highmem zone to have an exact
 			size of <nn>. This works even on boxes that have no
 			highmem otherwise. This also works to reduce highmem
drivers/acpi/apei/Kconfig +1 -1
@@ -1,5 +1,5 @@
 config ACPI_APEI
-	tristate "ACPI Platform Error Interface (APEI)"
+	bool "ACPI Platform Error Interface (APEI)"
 	depends on X86
 	help
 	  APEI allows to report errors (for example from the chipset)
drivers/acpi/apei/apei-base.c +6 -36

55 lines not on this page · raw message

drivers/acpi/apei/apei-internal.h +1 -3
@@ -6,8 +6,6 @@
 #ifndef APEI_INTERNAL_H
 #define APEI_INTERNAL_H
 
-int hest_init(void);
-
 struct apei_exec_context;
 
 typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
@@ -93,5 +91,5 @@ int apei_exec_collect_resources(struct a
 				struct apei_resources *resources);
 
 struct dentry;
-extern struct dentry *apei_debug_dir;
+struct dentry *apei_get_debugfs_dir(void);
 #endif
drivers/acpi/apei/einj.c +1 -1
@@ -409,7 +409,7 @@ static int __init einj_init(void)
 	}
 
 	rc = -ENOMEM;
-	einj_debug_dir = debugfs_create_dir("einj", apei_debug_dir);
+	einj_debug_dir = debugfs_create_dir("einj", apei_get_debugfs_dir());
 	if (!einj_debug_dir)
 		goto err_cleanup;
 	fentry = debugfs_create_file("available_error_type", S_IRUSR,
drivers/acpi/apei/hest.c +28 -6
@@ -40,6 +40,9 @@
 
 #define HEST_PFX "HEST: "
 
+int hest_disable;
+EXPORT_SYMBOL_GPL(hest_disable);
+
 /* HEST table parsing */
 
 static struct acpi_table_hest *hest_tab;
@@ -118,30 +121,49 @@ int apei_hest_parse(apei_hest_func_t fun
 }
 EXPORT_SYMBOL_GPL(apei_hest_parse);
 
-int __init hest_init(void)
+static int __init setup_hest_disable(char *str)
+{
+	hest_disable = 1;
+	return 0;
+}
+
+__setup("hest_disable", setup_hest_disable);
+
+static int __init hest_init(void)
 {
 	acpi_status status;
-	int rc;
+	int rc = 0;
 
 	if (acpi_disabled)
-		return -ENODEV;
+		goto err;
+
+	if (hest_disable) {
+		pr_info(HEST_PFX "HEST tabling parsing is disabled.\n");
+		goto err;
+	}
 
 	status = acpi_get_table(ACPI_SIG_HEST, 0,
 				(struct acpi_table_header **)&hest_tab);
 	if (status == AE_NOT_FOUND) {
 		pr_info(HEST_PFX "Table is not found!\n");
-		return -ENODEV;
+		goto err;
 	} else if (ACPI_FAILURE(status)) {
 		const char *msg = acpi_format_exception(status);
 		pr_info(HEST_PFX "Failed to get table, %s\n", msg);
-		return -EINVAL;
+		rc = -EINVAL;
+		goto err;
 	}
 
 	rc = apei_hest_parse(hest_void_parse, NULL);
 	if (rc)
-		return rc;
+		goto err;
 
 	pr_info(HEST_PFX "HEST table parsing is initialized.\n");
 
 	return 0;
+err:
+	hest_disable = 1;
+	return rc;
 }
+
+subsys_initcall(hest_init);
author
#2 lore raw

PATCH 2/2 ACPI, APEI, PCIE AER, use general HEST table parsing in AER firmware_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.

---
 drivers/acpi/Makefile              |    1 
 drivers/acpi/hest.c                |  135 -------------------------------------
 drivers/pci/pcie/aer/aerdrv.h      |    9 ++
 drivers/pci/pcie/aer/aerdrv_acpi.c |   70 +++++++++++++++++++
 drivers/pci/pcie/aer/aerdrv_core.c |   15 +++-
 drivers/pci/probe.c                |    8 --
 include/acpi/acpi_hest.h           |   12 ---
 include/linux/pci.h                |    3 
 8 files changed, 92 insertions(+), 161 deletions(-)
 delete mode 100644 drivers/acpi/hest.c
 delete mode 100644 include/acpi/acpi_hest.h
drivers/acpi/Makefile +0 -1
@@ -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
drivers/acpi/hest.c deleted +0 -135

135 lines not on this page · raw message

drivers/pci/pcie/aer/aerdrv.h +9 -0
@@ -134,4 +134,13 @@ static inline int aer_osc_setup(struct p
 }
 #endif
 
+#ifdef CONFIG_ACPI_APEI
+extern void aer_set_firmware_first(struct pci_dev *pci_dev);
+#else
+static inline void aer_set_firmware_first(struct pci_dev *pci_dev)
+{
+	pci_dev->__aer_firmware_first_valid = 1;
+}
+#endif
+
 #endif /* _AERDRV_H_ */
drivers/pci/pcie/aer/aerdrv_acpi.c +70 -0

79 lines not on this page · raw message

drivers/pci/pcie/aer/aerdrv_core.c +11 -4
@@ -30,12 +30,19 @@ static int nosourceid;
 module_param(forceload, bool, 0);
 module_param(nosourceid, bool, 0);
 
+static 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;
+}
+
 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);
@@ -63,7 +70,7 @@ int pci_disable_pcie_error_reporting(str
 	u16 reg16 = 0;
 	int pos;
 
-	if (dev->aer_firmware_first)
+	if (pcie_aer_get_firmware_first(dev))
 		return -EIO;
 
 	pos = pci_pcie_cap(dev);
@@ -858,7 +865,7 @@ void aer_delete_rootport(struct aer_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;
@@ -872,7 +879,7 @@ out:
 	if (forceload) {
 		dev_printk(KERN_DEBUG, &dev->device,
 			   "aerdrv forceload requested.\n");
-		dev->port->aer_firmware_first = 0;
+		dev->port->__aer_firmware_first = 0;
 		return 0;
 	}
 	return -ENXIO;
drivers/pci/probe.c +0 -8
@@ -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 */
@@ -900,12 +899,6 @@ void set_pcie_hotplug_bridge(struct pci_
 		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)
 
 /**
@@ -935,7 +928,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)
include/acpi/acpi_hest.h deleted +0 -12
@@ -1,12 +0,0 @@
-#ifndef __ACPI_HEST_H
-#define __ACPI_HEST_H
-
-#include <linux/pci.h>
-
-#ifdef CONFIG_ACPI
-extern int acpi_hest_firmware_first_pci(struct pci_dev *pci);
-#else
-static inline int acpi_hest_firmware_first_pci(struct pci_dev *pci) { return 0; }
-#endif
-
-#endif
include/linux/pci.h +2 -1
@@ -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 */
 
#3 lore raw

Re: [PATCH -v2 2/2] ACPI, APEI, PCIE AER, use general HEST table parsing in AER firmware_first setup

Quoted 7 lines · Huang Ying
drivers/acpi/hest.c deleted +0 -1
-EXPORT_SYMBOL_GPL(acpi_hest_firmware_first_pci);
drivers/pci/pcie/aer/aerdrv.h +0 -0
@@ -134,4 +134,13 @@ static inline int aer_osc_setup(struct p
 }
 #endif
 

drivers/pci/pcie/aer/aerdrv.h static inline int aer_osc_setup(struct p · line 146

Quoted 10 lines
drivers/pci/pcie/aer/aerdrv.h +9 -0
+#ifdef CONFIG_ACPI_APEI
+extern void aer_set_firmware_first(struct pci_dev *pci_dev);
+#else
+static inline void aer_set_firmware_first(struct pci_dev *pci_dev)
+{
+	pci_dev->__aer_firmware_first_valid = 1;
+}
+#endif
+
 #endif /* _AERDRV_H_ */

How about having aer_get_firmware_first() in this header too?

drivers/pci/pcie/aer/aerdrv_acpi.c

Quoted 2 lines
drivers/pci/pcie/aer/aerdrv_acpi.c +0 -0

:

Quoted 1 line

+#ifdef CONFIG_ACPI_APEI

:

drivers/pci/pcie/aer/aerdrv_acpi.c int aer_osc_setup(struct pcie_device *pc · line 110

Quoted 2 lines
drivers/pci/pcie/aer/aerdrv_acpi.c +2 -0
+void aer_set_firmware_first(struct pci_dev *pci_dev)
+{

:

Quoted 5 lines
drivers/pci/pcie/aer/aerdrv_acpi.c +2 -0
+}
+#endif

drivers/pci/pcie/aer/aerdrv_core.c static int nosourceid; · line 39

Quoted 10 lines
drivers/pci/pcie/aer/aerdrv_core.c +7 -0
@@ -30,12 +30,19 @@ static int nosourceid;
 module_param(forceload, bool, 0);
 module_param(nosourceid, bool, 0);
 
+static 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;
+}
+

Then you can put pcie_aer_get_firmware_first() to next to pcie_aer_set_firmware_first() in aerdrv_acpi.c, which is the best file for these functions I think.

drivers/pci/pcie/aer/aerdrv_core.c out: · line 885

Quoted 9 lines
drivers/pci/pcie/aer/aerdrv_core.c +1 -1
@@ -872,7 +879,7 @@ out:
 	if (forceload) {
 		dev_printk(KERN_DEBUG, &dev->device,
 			   "aerdrv forceload requested.\n");
-		dev->port->aer_firmware_first = 0;
+		dev->port->__aer_firmware_first = 0;
 		return 0;
 	}
 	return -ENXIO;

I'd like to see a purpose-oriented method here, something like pcie_aer_force_firmware_first_to(dev, forcedvalue).

Or, it would be more better, change pcie_aer_set_firmware_first() (= currently used by APEI only) to static with better name.

E.g.
Before: After:

  # get a flag that tells @dev is firmware first or not
    pcie_aer_get_firmware_first(dev)
			=> pcie_aer_get_firmware_first(dev) # no change
  # set a flag that tells @dev is firmware first or not
    dev->port->__aer_firmware_first = X
			=> pcie_aer_set_firmware_first(dev, X)
  # parse hest to know @dev is firmware first or not
    pcie_aer_set_firmware_first(dev)
			=> aer_parse_hest_for(dev)

include/linux/pci.h struct pci_dev { · line 317

Quoted 11 lines
include/linux/pci.h +2 -1
@@ -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 */

BTW, what the prefix "__" for?

I recommend you to separate this 2/2 patch into 2 pieces, one for PCI addressed to Jesse, and another is for ACPI. i.e.:

[PATCH] PCIE, AER: arrange pcie_aer_{get,set}_firmware_first [PATCH 1/2] ACPI, APEI: Make APEI core configurable built-in [PATCH 2/2] ACPI, APEI: use general HEST table parsing in AER

You can make 3rd patch to contain only *acpi* changes, remove of acpi/hest.c and modify of pcie/aer/aerdrv_acpi.c.
Then it will be easy-to-pull for Len, right?

Thanks,
H.Seto

author
#4 lore raw

Re: [PATCH -v2 2/2] ACPI, APEI, PCIE AER, use general HEST table parsing in AER firmware_first setup

Quoted 72 lines · Hidetoshi Seto
Quoted 7 lines · Huang Ying
drivers/acpi/hest.c deleted +0 -1
-EXPORT_SYMBOL_GPL(acpi_hest_firmware_first_pci);
drivers/pci/pcie/aer/aerdrv.h +0 -0
@@ -134,4 +134,13 @@ static inline int aer_osc_setup(struct p
 }
 #endif
 

drivers/pci/pcie/aer/aerdrv.h static inline int aer_osc_setup(struct p · line 146

Quoted 10 lines
drivers/pci/pcie/aer/aerdrv.h +9 -0
+#ifdef CONFIG_ACPI_APEI
+extern void aer_set_firmware_first(struct pci_dev *pci_dev);
+#else
+static inline void aer_set_firmware_first(struct pci_dev *pci_dev)
+{
+	pci_dev->__aer_firmware_first_valid = 1;
+}
+#endif
+
 #endif /* _AERDRV_H_ */

How about having aer_get_firmware_first() in this header too?

drivers/pci/pcie/aer/aerdrv_acpi.c

Quoted 2 lines
drivers/pci/pcie/aer/aerdrv_acpi.c +0 -0

:

Quoted 1 line

+#ifdef CONFIG_ACPI_APEI

:

drivers/pci/pcie/aer/aerdrv_acpi.c int aer_osc_setup(struct pcie_device *pc · line 110

Quoted 2 lines
drivers/pci/pcie/aer/aerdrv_acpi.c +2 -0
+void aer_set_firmware_first(struct pci_dev *pci_dev)
+{

:

Quoted 5 lines
drivers/pci/pcie/aer/aerdrv_acpi.c +2 -0
+}
+#endif

drivers/pci/pcie/aer/aerdrv_core.c static int nosourceid; · line 39

Quoted 10 lines
drivers/pci/pcie/aer/aerdrv_core.c +7 -0
@@ -30,12 +30,19 @@ static int nosourceid;
 module_param(forceload, bool, 0);
 module_param(nosourceid, bool, 0);
 
+static 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;
+}
+

Then you can put pcie_aer_get_firmware_first() to next to pcie_aer_set_firmware_first() in aerdrv_acpi.c, which is the best file for these functions I think.

drivers/pci/pcie/aer/aerdrv_core.c out: · line 885

Quoted 9 lines
drivers/pci/pcie/aer/aerdrv_core.c +1 -1
@@ -872,7 +879,7 @@ out:
 	if (forceload) {
 		dev_printk(KERN_DEBUG, &dev->device,
 			   "aerdrv forceload requested.\n");
-		dev->port->aer_firmware_first = 0;
+		dev->port->__aer_firmware_first = 0;
 		return 0;
 	}
 	return -ENXIO;

I'd like to see a purpose-oriented method here, something like pcie_aer_force_firmware_first_to(dev, forcedvalue).

Or, it would be more better, change pcie_aer_set_firmware_first() (= currently used by APEI only) to static with better name.

E.g.
Before: After:

  # get a flag that tells @dev is firmware first or not
    pcie_aer_get_firmware_first(dev)
			=> pcie_aer_get_firmware_first(dev) # no change
Quoted 7 lines
  # set a flag that tells @dev is firmware first or not
    dev->port->__aer_firmware_first = X
			=> pcie_aer_set_firmware_first(dev, X)
  # parse hest to know @dev is firmware first or not
    pcie_aer_set_firmware_first(dev)
			=> aer_parse_hest_for(dev)

Sounds reasonable. After putting current pcie_aer_set_firmware_first implementation into aerdrv_core.c, we can make it static. And we can add pcie_aer_force_firmware_first for forced setting.

Quoted 5 lines
Quoted 5 lines
include/linux/pci.h +0 -0
@@ -311,7 +311,8 @@ struct pci_dev {
 	unsigned int	is_virtfn:1;
 	unsigned int	reset_fn:1;
Quoted 8 lines

include/linux/pci.h struct pci_dev { · line 317

Quoted 6 lines
include/linux/pci.h +2 -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 */

BTW, what the prefix "__" for?

I want to warn users that this is a internal interface, don't use it directly.

Quoted 11 lines

I recommend you to separate this 2/2 patch into 2 pieces, one for PCI addressed to Jesse, and another is for ACPI. i.e.:

[PATCH] PCIE, AER: arrange pcie_aer_{get,set}_firmware_first [PATCH 1/2] ACPI, APEI: Make APEI core configurable built-in [PATCH 2/2] ACPI, APEI: use general HEST table parsing in AER

You can make 3rd patch to contain only *acpi* changes, remove of acpi/hest.c and modify of pcie/aer/aerdrv_acpi.c.
Then it will be easy-to-pull for Len, right?

Cross maintainers merging is painful after all. Even I split the patches as you proposed, I may need to wait another 2 merge windows to merge the code. To make it goes more smoothly, I suggest to merge all the code in Len's tree after getting ack from Jesse.

Hi, Len and Jesse, how about my suggestion?

Best Regards,
Huang Ying

#5 lore raw

Re: [PATCH -v2 2/2] ACPI, APEI, PCIE AER, use general HEST table parsing in AER firmware_first setup

Quoted 114 lines · On Fri, 12 Mar 2010 15:59:40 +0800 Huang Ying <[email protected]> wrote:
Quoted 72 lines · Hidetoshi Seto
Quoted 7 lines · Huang Ying
drivers/acpi/hest.c deleted +0 -1
-EXPORT_SYMBOL_GPL(acpi_hest_firmware_first_pci);
drivers/pci/pcie/aer/aerdrv.h +0 -0
@@ -134,4 +134,13 @@ static inline int aer_osc_setup(struct p
 }
 #endif
 

drivers/pci/pcie/aer/aerdrv.h static inline int aer_osc_setup(struct p · line 146

Quoted 10 lines
drivers/pci/pcie/aer/aerdrv.h +9 -0
+#ifdef CONFIG_ACPI_APEI
+extern void aer_set_firmware_first(struct pci_dev *pci_dev);
+#else
+static inline void aer_set_firmware_first(struct pci_dev *pci_dev)
+{
+	pci_dev->__aer_firmware_first_valid = 1;
+}
+#endif
+
 #endif /* _AERDRV_H_ */

How about having aer_get_firmware_first() in this header too?

drivers/pci/pcie/aer/aerdrv_acpi.c

Quoted 2 lines
drivers/pci/pcie/aer/aerdrv_acpi.c +0 -0

:

Quoted 1 line

+#ifdef CONFIG_ACPI_APEI

:

drivers/pci/pcie/aer/aerdrv_acpi.c int aer_osc_setup(struct pcie_device *pc · line 110

Quoted 2 lines
drivers/pci/pcie/aer/aerdrv_acpi.c +2 -0
+void aer_set_firmware_first(struct pci_dev *pci_dev)
+{

:

Quoted 5 lines
drivers/pci/pcie/aer/aerdrv_acpi.c +2 -0
+}
+#endif

drivers/pci/pcie/aer/aerdrv_core.c static int nosourceid; · line 39

Quoted 10 lines
drivers/pci/pcie/aer/aerdrv_core.c +7 -0
@@ -30,12 +30,19 @@ static int nosourceid;
 module_param(forceload, bool, 0);
 module_param(nosourceid, bool, 0);
 
+static 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;
+}
+

Then you can put pcie_aer_get_firmware_first() to next to pcie_aer_set_firmware_first() in aerdrv_acpi.c, which is the best file for these functions I think.

drivers/pci/pcie/aer/aerdrv_core.c out: · line 885

Quoted 9 lines
drivers/pci/pcie/aer/aerdrv_core.c +1 -1
@@ -872,7 +879,7 @@ out:
 	if (forceload) {
 		dev_printk(KERN_DEBUG, &dev->device,
 			   "aerdrv forceload requested.\n");
-		dev->port->aer_firmware_first = 0;
+		dev->port->__aer_firmware_first = 0;
 		return 0;
 	}
 	return -ENXIO;

I'd like to see a purpose-oriented method here, something like pcie_aer_force_firmware_first_to(dev, forcedvalue).

Or, it would be more better, change pcie_aer_set_firmware_first() (= currently used by APEI only) to static with better name.

E.g.
Before: After:

  # get a flag that tells @dev is firmware first or not
    pcie_aer_get_firmware_first(dev)
			=> pcie_aer_get_firmware_first(dev) # no change
Quoted 7 lines
  # set a flag that tells @dev is firmware first or not
    dev->port->__aer_firmware_first = X
			=> pcie_aer_set_firmware_first(dev, X)
  # parse hest to know @dev is firmware first or not
    pcie_aer_set_firmware_first(dev)
			=> aer_parse_hest_for(dev)

Sounds reasonable. After putting current pcie_aer_set_firmware_first implementation into aerdrv_core.c, we can make it static. And we can add pcie_aer_force_firmware_first for forced setting.

Quoted 5 lines
Quoted 5 lines
include/linux/pci.h +0 -0
@@ -311,7 +311,8 @@ struct pci_dev {
 	unsigned int	is_virtfn:1;
 	unsigned int	reset_fn:1;
Quoted 8 lines

include/linux/pci.h struct pci_dev { · line 317

Quoted 6 lines
include/linux/pci.h +2 -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 */

BTW, what the prefix "__" for?

I want to warn users that this is a internal interface, don't use it directly.

Quoted 11 lines

I recommend you to separate this 2/2 patch into 2 pieces, one for PCI addressed to Jesse, and another is for ACPI. i.e.:

[PATCH] PCIE, AER: arrange pcie_aer_{get,set}_firmware_first [PATCH 1/2] ACPI, APEI: Make APEI core configurable built-in [PATCH 2/2] ACPI, APEI: use general HEST table parsing in AER

You can make 3rd patch to contain only *acpi* changes, remove of acpi/hest.c and modify of pcie/aer/aerdrv_acpi.c.
Then it will be easy-to-pull for Len, right?

Quoted 6 lines

Cross maintainers merging is painful after all. Even I split the patches as you proposed, I may need to wait another 2 merge windows to merge the code. To make it goes more smoothly, I suggest to merge all the code in Len's tree after getting ack from Jesse.

Hi, Len and Jesse, how about my suggestion?

Yeah, it seems like the bulk of it is ACPI related, so going through Len's tree is fine with me. The PCI portion seems reasonable assuming you include Hidetoshi-san's suggestions, you can add my Ack for now (I'll yell if I find something I don't like in your next post).

Thanks,

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center