Skip to contentSkip to conversation

: PCI Err: Event delivery utility

PATCH In review Linas Vepstas 2 participants 5 messages Jun 29, 2005 – Jun 30, 2005 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 8/13 : PCI Err: Event delivery utility

pci-err-8-pci-err-event.patch

[RFC]

PCI Error distribution utility routine. This patch defines a utility routine that hasn't yet been discussed much on the mailing list; I've made this architecture independent with the idea that various architectures may find it handy, but its not directly required, or relevant, to the overall EEH error recovery mechanism. (It could be buried in arch-dependent code or implemented differently.)

The current design has the arch dependent code detect a PCI bus error. That code uses this utility to generate a detection event. This event is then caught by PCI hotplug code, which drives the slot recovery. If the affected device drivers have recovery callbacks, these are used; all other devices are hotplugged.

There are certainly other (simpler) ways to attach the arch-specific error detection code to the hot-plug mediated recovery code; this routine is rather left-over from earlier email discussions. Should this stay, or not?

include/linux/pci.h renamed from include/linux/pci.h.linas-orig +45 -0
@@ -691,6 +691,51 @@ struct  pci_error_handlers
 	void (*resume)(struct pci_dev *dev);      /* Device driver may resume normal operations */
 };
 
+/**
+ * PCI Error notifier event flags.
+ */
+#define PEH_NOTIFY_ERROR 1
+
+/** PEH event -- structure holding pci controller data that describes
+ *  a change in the isolation status of a PCI slot.  A pointer
+ *  to this struct is passed as the data pointer in a notify callback.
+ */
+struct peh_event {
+	struct list_head     list;
+	struct pci_dev       *dev;  /* affected device */
+	enum pci_channel_state state; /* PCI bus state for the affected device */
+	int time_unavail;    /* milliseconds until device might be available */
+};
+
+/**
+ * peh_send_failure_event - generate a PCI error event
+ * @dev pci device
+ *
+ * This routine builds a PCI error event which will be delivered
+ * to all listeners on the peh_notifier_chain.
+ *
+ * This routine can be called within an interrupt context;
+ * the actual event will be delivered in a normal context
+ * (from a workqueue).
+ */
+int peh_send_failure_event (struct pci_dev *dev,
+                            enum pci_channel_state state,
+                            int time_unavail);
+
+/**
+ * peh_register_notifier - Register to find out about EEH events.
+ * @nb: notifier block to callback on events
+ */
+int peh_register_notifier(struct notifier_block *nb);
+
+/**
+ * peh_unregister_notifier - Unregister to an EEH event notifier.
+ * @nb: notifier block to callback on events
+ */
+int peh_unregister_notifier(struct notifier_block *nb);
+
+/* ---------------------------------------------------------------- */
+
 struct module;
 struct pci_driver {
 	struct list_head node;
drivers/pci/Makefile renamed from drivers/pci/Makefile.linas-orig +1 -1
@@ -3,7 +3,7 @@
 #
 
 obj-y		+= access.o bus.o probe.o remove.o pci.o quirks.o \
-			names.o pci-driver.o search.o pci-sysfs.o \
+			names.o pci-driver.o pci-error.o search.o pci-sysfs.o \
 			rom.o
 obj-$(CONFIG_PROC_FS) += proc.o
 
drivers/pci/pci-error.c renamed from drivers/pci/pci-error.c.linas-orig +152 -0

152 lines not on this page · raw message

#1 lore raw
Quoted 19 lines · Linas Vepstas

pci-err-8-pci-err-event.patch

[RFC]

PCI Error distribution utility routine. This patch defines a utility routine that hasn't yet been discussed much on the mailing list; I've made this architecture independent with the idea that various architectures may find it handy, but its not directly required, or relevant, to the overall EEH error recovery mechanism. (It could be buried in arch-dependent code or implemented differently.)

The current design has the arch dependent code detect a PCI bus error. That code uses this utility to generate a detection event. This event is then caught by PCI hotplug code, which drives the slot recovery. If the affected device drivers have recovery callbacks, these are used; all other devices are hotplugged.

Quoted 4 lines

There are certainly other (simpler) ways to attach the arch-specific error detection code to the hot-plug mediated recovery code; this routine is rather left-over from earlier email discussions. Should this stay, or not?

Certainly needs to be in a separate .h at least ... Also, you have some lifetime issues. You probably want to do a get() on pci_dev when you put it in your struct and put() it after the notifier... Oh wait, you are doing pci_dev_put() ... but no pci_dev_get() ... The later must be missing from peh_send_failure_event().

I'd keep that in arch code for now.

Ben.

#2 lore raw

On Wed, Jun 29, 2005 at 11:59:47AM +1000, Benjamin Herrenschmidt was heard to remark:

Quoted 5 lines · Linas Vepstas
Quoted 4 lines

pci-err-8-pci-err-event.patch

[RFC]

Quoted 8 lines
Quoted 2 lines

PCI Error distribution utility routine. This patch defines a utility routine that hasn't yet been discussed much on

Certainly needs to be in a separate .h at least ... Also, you have some lifetime issues. You probably want to do a get() on pci_dev when you put it in your struct and put() it after the notifier... Oh wait, you are doing pci_dev_put() ... but no pci_dev_get() ... The later must be missing from peh_send_failure_event().

I'm pretty sure this was balanced, there is a get very early on when the error is detected. But I'll review.

Quoted 1 line

I'd keep that in arch code for now.

OK, I'm moving it there. It did seem both confusing and semi-pointless after the last round of changes.

--linas

#3 lore raw
Quoted 7 lines · Linas Vepstas

I'm pretty sure this was balanced, there is a get very early on when the error is detected. But I'll review.

Quoted 1 line

I'd keep that in arch code for now.

OK, I'm moving it there. It did seem both confusing and semi-pointless after the last round of changes.

Well, it's logical for the get and put to be in the same "layer" don't you think ?

Ben.

#4 lore raw

On Thu, Jun 30, 2005 at 09:42:01AM +1000, Benjamin Herrenschmidt was heard to remark:

Quoted 5 lines · Linas Vepstas
Quoted 4 lines

I'm pretty sure this was balanced, there is a get very early on when the error is detected. But I'll review.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

I'd keep that in arch code for now.

OK, I'm moving it there. It did seem both confusing and semi-pointless after the last round of changes.

Well, it's logical for the get and put to be in the same "layer" don't you think ?

Yes, it could be made more symmetrical; I'll do that.

The get happened along with the malloc of the event structure, the put happens right before the free of the same structure.

The reason for the event was in order to get the recovery of the error out of line from the detection of the error; detection may occur in an interrupt context; recovery happens in a work queue. Thus, get may happen in that interrupt context, the put only after the work is complete.

I'll make the code more symmetrical with regards to the event malloc/free and that should make it more readable.

--linas