Re: [PATCH] synchronize_irq needs a barrier





In general, I tend to think that for this function to make any sense
(that is, to synchronize anything at all), it needs a barrier or you are
just making a decision based on a totally random value of desc->status
since it can have been re-ordered, speculatively loaded, pre-fetched,
whatever'ed... :-).

Take a real life example:

drivers/message/fusion/mptbase.c

/* Disable interrupts! */
CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF);

ioc->active = 0;
synchronize_irq(pdev->irq);

And we aren't in a spinlock here.

That's just a random example grepped.... I think I see a few more. Then,
some drivers like tg3 actually do an smp_mb() before calling
synchronize_irq(). But then, some don't.

I think trying to have all drivers be correct here is asking for
trouble, we'd rather have synchronize_irq() be uber-safe. It's not like
it was used in hot path anyway.

Ben.




-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • [PATCH] scsi/sata write barrier support
    ... only the old PATA drivers supported barrier writes ... A note on this patch. ... function to struct request, it's folded into this one right now. ...
    (Linux-Kernel)
  • Re: [RFD] BIO_RW_BARRIER - what it means for devices, filesystems, and dm/md.
    ... disks which don't support flush but do have a "cache dirty" status bit you can poll at times like shutdown. ... If there are no drivers which support these, ... filesystem or whatever always sends barrier requests where it thinks ... Since this is device dependent, it really should be in the device driver, and requests should have status of success, failure, or feature unavailability. ...
    (Linux-Kernel)
  • Re: NIP arrived.
    ... >>mitigates the effect of the dangerous behaviour of drivers. ... > A crash barrier will save accidents from happening that do not ... Saying the accident would not ...
    (uk.rec.driving)
  • Re: When KeEnterCriticalRegion ?
    ... File system drivers care about this, ... > APC path or synchronize at DISPATCH_LEVEL using a spin lock. ...
    (microsoft.public.development.device.drivers)
  • Re: MMIO and gcc re-ordering issue
    ... explicit rmb/wmb/mb's on x86) to ... drivers who want to order memory consistent accesses vs. MMIO? ... Is the cost of a barrier in an MMIO operation so high that we ...
    (Linux-Kernel)