Skip to contentSkip to conversation

ACPI / APEI: Add support to notify the vendor specific HW errors

PATCH Superseded Shiju Jose 1 participant 4 messages May 29, 2020

Subsystems (5)

v8 of 15 Superseded Latest is v15 →

lore
Share & tools
lore

Shiju Jose

author
#0 lore raw

v8 cover ACPI / APEI: Add support to notify the vendor specific HW errors

Presently the vendor drivers are unable to do the recovery for the vendor specific recoverable HW errors because APEI driver does not support reporting the error to the vendor drivers.

patch set
1. add new interface to the APEI driver for reporting the vendor specific non-fatal HW errors to the drivers.

2. add driver to handle HiSilicon hip PCIe controller's errors.

V8:
1. Removed reporting the standard errors through the interface because of the conflict with the changes in the memory error handling path.
2. Fix comments by Dan Carpenter.

V7:
1. Add changes in the APEI driver suggested by Borislav Petkov, for queuing up all the non-fatal HW errors to the work queue and notify the registered kernel drivers from the bottom half using blocking notifier, common interface for both standard and vendor-spcific errors.
2. Fix for further feedbacks in v5 HIP PCIe error handler driver by Bjorn Helgaas.

V6:
1. Fix few changes in the patch subject line suggested by Bjorn Helgaas.

V5:
1. Fix comments from James Morse.
1.1 Changed the notification method to use the atomic_notifier_chain. 1.2 Add the error handled status for the user space.

V4:
1. Fix for the following smatch warning in the PCIe error driver, reported by kbuild test robot<[email protected]>:
warn: should '((((1))) << (9 + i))' be a 64 bit type? if (err->val_bits & BIT(HISI_PCIE_LOCAL_VALID_ERR_MISC + i))
^^^ This should be BIT_ULL() because it goes up to 9 + 32.

V3:
1. Fix the comments from Bjorn Helgaas.

V2:
1. Changes in the HiSilicon PCIe controller's error handling driver for the comments from Bjorn Helgaas.

2. Changes in the APEI interface to support reporting the vendor error for module with multiple devices, but use the same section type. In the error handler will use socket id/sub module id etc to distinguish the device.

V1:
1. Fix comments from James Morse.

2. add driver to handle HiSilicon hip08 PCIe controller's errors, which is an application of the above interface.

Shiju Jose (1):
ACPI / APEI: Add support to notify the vendor specific HW errors

Yicong Yang (1):
PCI: hip: Add handling of HiSilicon HIP PCIe controller errors

 drivers/acpi/apei/ghes.c                 | 126 ++++++++-
 drivers/pci/controller/Kconfig           |   8 +
 drivers/pci/controller/Makefile          |   1 +
 drivers/pci/controller/pcie-hisi-error.c | 321 +++++++++++++++++++++++
 include/acpi/ghes.h                      |  28 ++
 5 files changed, 483 insertions(+), 1 deletion(-)
 create mode 100644 drivers/pci/controller/pcie-hisi-error.c
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v8 1/2 ACPI / APEI: Add support to notify the vendor specific HW errors

Add support to report the vendor specific non-fatal HW errors to the drivers for the error recovery.

---
 drivers/acpi/apei/ghes.c | 126 ++++++++++++++++++++++++++++++++++++++-
 include/acpi/ghes.h      |  28 +++++++++
 2 files changed, 153 insertions(+), 1 deletion(-)
drivers/acpi/apei/ghes.c +125 -1
index 24c9642e8fc7..d89a74dfae6a 100644
@@ -33,6 +33,7 @@
 #include <linux/irq_work.h>
 #include <linux/llist.h>
 #include <linux/genalloc.h>
+#include <linux/kfifo.h>
 #include <linux/pci.h>
 #include <linux/pfn.h>
 #include <linux/aer.h>
@@ -63,6 +64,11 @@
 #define GHES_ESTATUS_CACHES_SIZE	4
 
 #define GHES_ESTATUS_IN_CACHE_MAX_NSEC	10000000000ULL
+
+#define GHES_EVENT_RING_SIZE	256
+#define GHES_GDATA_POOL_MIN_ALLOC_ORDER	3
+#define GHES_GDATA_POOL_MIN_SIZE	65536
+
 /* Prevent too many caches are allocated because of RCU */
 #define GHES_ESTATUS_CACHE_ALLOCED_MAX	(GHES_ESTATUS_CACHES_SIZE * 3 / 2)
 
@@ -122,6 +128,19 @@ static DEFINE_MUTEX(ghes_list_mutex);
  */
 static DEFINE_SPINLOCK(ghes_notify_lock_irq);
 
+struct ghes_event_entry {
+	struct acpi_hest_generic_data *gdata;
+	int error_severity;
+};
+
+static DEFINE_KFIFO(ghes_event_ring, struct ghes_event_entry,
+		    GHES_EVENT_RING_SIZE);
+
+static DEFINE_SPINLOCK(ghes_event_ring_lock);
+
+static struct gen_pool *ghes_gdata_pool;
+static unsigned long ghes_gdata_pool_size_request;
+
 static struct gen_pool *ghes_estatus_pool;
 static unsigned long ghes_estatus_pool_size_request;
 
@@ -188,6 +207,40 @@ int ghes_estatus_pool_init(int num_ghes)
 	return -ENOMEM;
 }
 
+int ghes_gdata_pool_init(void)
+{
+	unsigned long addr, len;
+	int rc;
+
+	ghes_gdata_pool = gen_pool_create(GHES_GDATA_POOL_MIN_ALLOC_ORDER, -1);
+	if (!ghes_gdata_pool)
+		return -ENOMEM;
+
+	if (ghes_gdata_pool_size_request < GHES_GDATA_POOL_MIN_SIZE)
+		ghes_gdata_pool_size_request = GHES_GDATA_POOL_MIN_SIZE;
+
+	len = ghes_gdata_pool_size_request;
+	addr = (unsigned long)vmalloc(PAGE_ALIGN(len));
+	if (!addr)
+		goto err_pool_alloc;
+
+	vmalloc_sync_mappings();
+
+	rc = gen_pool_add(ghes_gdata_pool, addr, PAGE_ALIGN(len), -1);
+	if (rc)
+		goto err_pool_add;
+
+	return 0;
+
+err_pool_add:
+	vfree((void *)addr);
+
+err_pool_alloc:
+	gen_pool_destroy(ghes_gdata_pool);
+
+	return -ENOMEM;
+}
+
 static int map_gen_v2(struct ghes *ghes)
 {
 	return apei_map_generic_address(&ghes->generic_v2->read_ack_register);
@@ -247,6 +300,10 @@ static struct ghes *ghes_new(struct acpi_hest_generic *generic)
 		goto err_unmap_status_addr;
 	}
 
+	ghes_gdata_pool_size_request += generic->records_to_preallocate *
+					generic->max_sections_per_record *
+					generic->max_raw_data_length;
+
 	return ghes;
 
 err_unmap_status_addr:
@@ -490,6 +547,48 @@ static void ghes_handle_aer(struct acpi_hest_generic_data *gdata)
 #endif
 }
 
+static BLOCKING_NOTIFIER_HEAD(ghes_event_notify_list);
+
+/**
+ * ghes_register_event_notifier - register an event notifier
+ * for the non-fatal HW errors.
+ * @nb: pointer to the notifier_block structure of the event handler.
+ *
+ * return 0 : SUCCESS, non-zero : FAIL
+ */
+int ghes_register_event_notifier(struct notifier_block *nb)
+{
+	return blocking_notifier_chain_register(&ghes_event_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(ghes_register_event_notifier);
+
+/**
+ * ghes_unregister_event_notifier - unregister the previously
+ * registered event notifier.
+ * @nb: pointer to the notifier_block structure of the event handler.
+ */
+void ghes_unregister_event_notifier(struct notifier_block *nb)
+{
+	blocking_notifier_chain_unregister(&ghes_event_notify_list, nb);
+}
+EXPORT_SYMBOL_GPL(ghes_unregister_event_notifier);
+
+static void ghes_event_work_func(struct work_struct *work)
+{
+	struct ghes_event_entry entry;
+	u32 len;
+
+	while (kfifo_get(&ghes_event_ring, &entry)) {
+		blocking_notifier_call_chain(&ghes_event_notify_list,
+					     entry.error_severity,
+					     entry.gdata);
+		len = acpi_hest_get_record_size(entry.gdata);
+		gen_pool_free(ghes_gdata_pool, (unsigned long)entry.gdata, len);
+	}
+}
+
+static DECLARE_WORK(ghes_event_work, ghes_event_work_func);
+
 static void ghes_do_proc(struct ghes *ghes,
 			 const struct acpi_hest_generic_status *estatus)
 {
@@ -498,6 +597,8 @@ static void ghes_do_proc(struct ghes *ghes,
 	guid_t *sec_type;
 	const guid_t *fru_id = &guid_null;
 	char *fru_text = "";
+	struct ghes_event_entry event_entry;
+	u32 len;
 
 	sev = ghes_severity(estatus->error_severity);
 	apei_estatus_for_each_section(estatus, gdata) {
@@ -527,6 +628,21 @@ static void ghes_do_proc(struct ghes *ghes,
 		} else {
 			void *err = acpi_hest_get_payload(gdata);
 
+			len = acpi_hest_get_record_size(gdata);
+			event_entry.gdata =
+				(void *)gen_pool_alloc(ghes_gdata_pool, len);
+			if (event_entry.gdata) {
+				memcpy(event_entry.gdata, gdata, len);
+				event_entry.error_severity = sev;
+
+				if (kfifo_in_spinlocked(&ghes_event_ring,
+							&event_entry, 1,
+							&ghes_event_ring_lock))
+					schedule_work(&ghes_event_work);
+				else
+					pr_warn(GHES_PFX "ghes event queue full\n");
+			}
+
 			log_non_standard_event(sec_type, fru_id, fru_text,
 					       sec_sev, err,
 					       gdata->error_data_length);
@@ -1334,7 +1450,7 @@ static int __init ghes_init(void)
 
 	rc = platform_driver_register(&ghes_platform_driver);
 	if (rc)
-		goto err;
+		goto exit;
 
 	rc = apei_osc_setup();
 	if (rc == 0 && osc_sb_apei_support_acked)
@@ -1346,8 +1462,16 @@ static int __init ghes_init(void)
 	else
 		pr_info(GHES_PFX "Failed to enable APEI firmware first mode.\n");
 
+	rc = ghes_gdata_pool_init();
+	if (rc) {
+		pr_warn(GHES_PFX "ghes_gdata_pool_init failed\n");
+		goto err;
+	}
+
 	return 0;
 err:
+	platform_driver_unregister(&ghes_platform_driver);
+exit:
 	return rc;
 }
 device_initcall(ghes_init);
include/acpi/ghes.h +28 -0
index e3f1cddb4ac8..a3dd82069069 100644
@@ -50,6 +50,34 @@ enum {
 	GHES_SEV_PANIC = 0x3,
 };
 
+
+#ifdef CONFIG_ACPI_APEI_GHES
+/**
+ * ghes_register_event_notifier - register an event notifier
+ * for the non-fatal HW errors.
+ * @nb: pointer to the notifier_block structure of the event notifier.
+ *
+ * Return : 0 - SUCCESS, non-zero - FAIL.
+ */
+int ghes_register_event_notifier(struct notifier_block *nb);
+
+/**
+ * ghes_unregister_event_notifier - unregister the previously
+ * registered event notifier.
+ * @nb: pointer to the notifier_block structure of the event notifier.
+ */
+void ghes_unregister_event_notifier(struct notifier_block *nb);
+#else
+static inline int ghes_register_event_notifier(struct notifier_block *nb)
+{
+	return -ENODEV;
+}
+
+static inline void ghes_unregister_event_notifier(struct notifier_block *nb)
+{
+}
+#endif
+
 int ghes_estatus_pool_init(int num_ghes);
 
 /* From drivers/edac/ghes_edac.c */
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v8 2/2 PCI: hip: Add handling of HiSilicon HIP PCIe controller errors

In reply to Shiju Jose

From: Yicong Yang <[email protected]>

The HiSilicon HIP PCIe controller is capable of handling errors on root port and perform port reset separately at each root port.

This patch add error handling driver for HIP PCIe controller to log and report recoverable errors. Perform root port reset and restore link status after the recovery.

Following are some of the PCIe controller's recoverable errors
1. completion transmission timeout error.
2. CRS retry counter over the threshold error.
3. ECC 2 bit errors
4. AXI bresponse/rresponse errors etc.

The driver placed in the drivers/pci/controller/ because the HIP PCIe controller does not use DWC ip.

--

drivers/pci/controller/Kconfig           |   8 +
drivers/pci/controller/Makefile          |   1 +
drivers/pci/controller/pcie-hisi-error.c | 336 +++++++++++++++++++++++++++++++
3 files changed, 345 insertions(+)
create mode 100644 drivers/pci/controller/pcie-hisi-error.c
---
 drivers/pci/controller/Kconfig           |   8 +
 drivers/pci/controller/Makefile          |   1 +
 drivers/pci/controller/pcie-hisi-error.c | 321 +++++++++++++++++++++++
 3 files changed, 330 insertions(+)
 create mode 100644 drivers/pci/controller/pcie-hisi-error.c
drivers/pci/controller/Kconfig +8 -0
index 91bfdb784829..7ba4b94f8604 100644
@@ -258,6 +258,14 @@ config PCI_HYPERV_INTERFACE
 	  The Hyper-V PCI Interface is a helper driver allows other drivers to
 	  have a common interface with the Hyper-V PCI frontend driver.
 
+config PCIE_HISI_ERR
+	depends on ARM64 || COMPILE_TEST
+	depends on ACPI
+	bool "HiSilicon HIP PCIe controller error handling driver"
+	help
+	  Say Y here if you want error handling support
+	  for the PCIe controller's errors on HiSilicon HIP SoCs
+
 source "drivers/pci/controller/dwc/Kconfig"
 source "drivers/pci/controller/mobiveil/Kconfig"
 source "drivers/pci/controller/cadence/Kconfig"
drivers/pci/controller/Makefile +1 -0
index 158c59771824..ab3a528bf988 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o
 obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o
 obj-$(CONFIG_VMD) += vmd.o
 obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o
+obj-$(CONFIG_PCIE_HISI_ERR) += pcie-hisi-error.o
 # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
 obj-y				+= dwc/
 obj-y				+= mobiveil/
drivers/pci/controller/pcie-hisi-error.c new file +321 -0

321 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#3 lore raw
In reply to Shiju Jose

Please ignore this patch set. Resending soon.

Thanks,
Shiju

Quoted 89 lines

-----Original Message-----
From: Shiju Jose
Sent: 29 May 2020 18:39
To: [email protected]; [email protected]; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: Shiju Jose <[email protected]>; Linuxarm <[email protected]>; yangyicong <[email protected]>
Subject: [PATCH v8 0/2] ACPI / APEI: Add support to notify the vendor specific HW errors

Presently the vendor drivers are unable to do the recovery for the vendor specific recoverable HW errors because APEI driver does not support reporting the error to the vendor drivers.

patch set
1. add new interface to the APEI driver for reporting the vendor specific non-fatal HW errors to the drivers.

2. add driver to handle HiSilicon hip PCIe controller's errors.

V8:
1. Removed reporting the standard errors through the interface because of the conflict with the changes in the memory error handling path.
2. Fix comments by Dan Carpenter.

V7:
1. Add changes in the APEI driver suggested by Borislav Petkov, for queuing up all the non-fatal HW errors to the work queue and notify the registered kernel drivers from the bottom half using blocking notifier, common interface for both standard and vendor-spcific errors.
2. Fix for further feedbacks in v5 HIP PCIe error handler driver by Bjorn Helgaas.

V6:
1. Fix few changes in the patch subject line suggested by Bjorn Helgaas.

V5:
1. Fix comments from James Morse.
1.1 Changed the notification method to use the atomic_notifier_chain. 1.2 Add the error handled status for the user space.

V4:
1. Fix for the following smatch warning in the PCIe error driver, reported by kbuild test robot<[email protected]>:
warn: should '((((1))) << (9 + i))' be a 64 bit type? if (err->val_bits & BIT(HISI_PCIE_LOCAL_VALID_ERR_MISC + i))
^^^ This should be BIT_ULL() because it goes up to 9 + 32.

V3:
1. Fix the comments from Bjorn Helgaas.

V2:
1. Changes in the HiSilicon PCIe controller's error handling driver for the comments from Bjorn Helgaas.

2. Changes in the APEI interface to support reporting the vendor error for module with multiple devices, but use the same section type. In the error handler will use socket id/sub module id etc to distinguish the device.

V1:
1. Fix comments from James Morse.

2. add driver to handle HiSilicon hip08 PCIe controller's errors, which is an application of the above interface.

Shiju Jose (1):
ACPI / APEI: Add support to notify the vendor specific HW errors

Yicong Yang (1):
PCI: hip: Add handling of HiSilicon HIP PCIe controller errors

drivers/acpi/apei/ghes.c                 | 126 ++++++++-
drivers/pci/controller/Kconfig           |   8 +
drivers/pci/controller/Makefile          |   1 +
drivers/pci/controller/pcie-hisi-error.c | 321 +++++++++++++++++++++++
include/acpi/ghes.h                      |  28 ++
5 files changed, 483 insertions(+), 1 deletion(-)  create mode 100644

drivers/pci/controller/pcie-hisi-error.c

--
2.17.1