[PATCH 5/9] powerpc/eeh: Introduce eeh_ops->event()

Gavin Shan shangw at linux.vnet.ibm.com
Tue Feb 25 16:37:46 EST 2014


The patch introduces eeh_ops->event() so that we can pass various
events to underly platform. One reason to have that is to allocate
or free PHB diag-data for individual PEs on PowerNV platform in
future when EEH core to create or destroy PE instances.

Signed-off-by: Gavin Shan <shangw at linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/eeh.h |    6 ++++++
 arch/powerpc/kernel/eeh_pe.c   |   14 ++++++++++++++
 2 files changed, 20 insertions(+)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index a61b06f..8fd1c2d 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -71,6 +71,7 @@ struct eeh_pe {
 	struct list_head child_list;	/* Link PE to the child list	*/
 	struct list_head edevs;		/* Link list of EEH devices	*/
 	struct list_head child;		/* Child PEs			*/
+	void *data;			/* Platform dependent data	*/
 };
 
 #define eeh_pe_for_each_dev(pe, edev, tmp) \
@@ -151,6 +152,10 @@ enum {
 #define EEH_LOG_TEMP		1	/* EEH temporary error log	*/
 #define EEH_LOG_PERM		2	/* EEH permanent error log	*/
 
+/* EEH events sent to platform */
+#define EEH_EVENT_PE_ALLOC	0
+#define EEH_EVENT_PE_FREE	1
+
 struct eeh_ops {
 	char *name;
 	int (*init)(void);
@@ -168,6 +173,7 @@ struct eeh_ops {
 	int (*write_config)(struct device_node *dn, int where, int size, u32 val);
 	int (*next_error)(struct eeh_pe **pe);
 	int (*restore_config)(struct device_node *dn);
+	int (*event)(int event, void *data);
 };
 
 extern struct eeh_ops *eeh_ops;
diff --git a/arch/powerpc/kernel/eeh_pe.c b/arch/powerpc/kernel/eeh_pe.c
index 2add834..6cdc7a8 100644
--- a/arch/powerpc/kernel/eeh_pe.c
+++ b/arch/powerpc/kernel/eeh_pe.c
@@ -44,6 +44,7 @@ static LIST_HEAD(eeh_phb_pe);
 static struct eeh_pe *eeh_pe_alloc(struct pci_controller *phb, int type)
 {
 	struct eeh_pe *pe;
+	int ret;
 
 	/* Allocate PHB PE */
 	pe = kzalloc(sizeof(struct eeh_pe), GFP_KERNEL);
@@ -56,6 +57,16 @@ static struct eeh_pe *eeh_pe_alloc(struct pci_controller *phb, int type)
 	INIT_LIST_HEAD(&pe->child);
 	INIT_LIST_HEAD(&pe->edevs);
 
+	if (eeh_ops->event) {
+		ret = eeh_ops->event(EEH_EVENT_PE_ALLOC, pe);
+		if (ret) {
+			pr_warn("%s: Can't alloc PE (%d)\n",
+				__func__, ret);
+			kfree(pe);
+			return NULL;
+		}
+	}
+
 	return pe;
 }
 
@@ -77,6 +88,9 @@ static void eeh_pe_free(struct eeh_pe *pe)
 		return;
 	}
 
+	if (eeh_ops->event)
+		eeh_ops->event(EEH_EVENT_PE_FREE, pe);
+
 	kfree(pe);
 }
 
-- 
1.7.10.4



More information about the Linuxppc-dev mailing list