Re: [PATCH/RFC] I/O-check interface for driver's error handling

linux-os
2005-03-02T18:03:47Z

On Wed, 2 Mar 2005, Linas Vepstas wrote:

> On Wed, Mar 02, 2005 at 11:28:01AM +0900, Hidetoshi Seto was heard to remark:
>>
>> Note that here is a difficulty: the MCA handler on some arch would run on
>> special context - MCA environment. In other words, since some MCA handler
[SNIPPED...]

>
> /**
> * queue up a pci error event to be dispatched to all listeners
> * of the pci error notifier call chain. This routine is safe to call
> * within an interrupt context. The actual event delivery
> * will be from a workque thread.
> */
>
> void eeh_queue_failure(struct pci_dev *dev)
> {
> struct eeh_event *event;
>
> event = kmalloc(sizeof(*event), GFP_ATOMIC);
> if (event = NULL) {
> printk (KERN_ERR "EEH: out of memory, event not handled\n");
> return 1;
> }
>
> event->dev = dev;
> event->reset_state = rets[0];
> event->time_unavail = rets[2];
>
> /* We may be called in an interrupt context */
> spin_lock_irqsave(&eeh_eventlist_lock, flags);
^^^^^^^^^^^^^^^^^^
> list_add(&event->list, &eeh_eventlist);
> spin_unlock_irqrestore(&eeh_eventlist_lock, flags);
^^^^^^^^^^^^^^^^^^^^^

I don't think this is SMP safe from interrupt-context.
You need the lock when you are building the event-list,
not just when you queue it.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.