On Wed, 2018-09-05 at 14:35 -0600, Keith Busch wrote: > diff --git a/drivers/pci/pcie/err.c b/drivers/pci/pcie/err.c > index 2264001f695b..1ee7206689b5 100644 > --- a/drivers/pci/pcie/err.c > +++ b/drivers/pci/pcie/err.c > @@ -52,9 +52,9 @@ static int report_error_detected(struct pci_dev *dev, > const struct pci_error_handlers *err_handler; > > device_lock(&dev->dev); > - dev->error_state = state; > > - if (!dev->driver || > + if (!cmpxchg(&dev->error_state, state, pci_channel_io_normal) || > + !dev->driver || > !dev->driver->err_handler || > !dev->driver->err_handler->error_detected) { > /* (CC some of our folks) Should we make this some kind of helper (pci_set_channel_state) ? We should then use it in EEH and powerpc PAPR specific hotplug as well. We could also implement the rule about the valid transition in the helper itself. (Feel free to merge this patch as-is, what I suggest can be done on top of this). Cheers, Ben.