• Stefan Richter's avatar
    firewire: ohci: reduce potential context_stop latency · 9ef28ccd
    Stefan Richter authored
    Stopping an isochronous reception DMA context takes two loop iterations
    in context_stop on several controllers (JMicron, NEC, VIA).  But there
    is no extra delay necessary between these two reg_read trials; the MMIO
    reads themselves are slow enough.  Hence bring back the behavior from
    before commit dd6254e5 "firewire: ohci:
    remove superfluous posted write flushes" on these controllers by means
    of an "if (i)" condition.
    
    Isochronous context stop is performed in preemptible contexts (and only
    rarely), hence this change is of little impact.  (Besides, Agere and TI
    controllers always, or almost always, have the context stopped already
    at the first ContextControl read.)
    
    More important is asynchronous transmit context stop, which is performed
    while local interrupts are disabled (on the two AT DMAs in
    bus_reset_tasklet, i.e. after a self-ID-complete event).  In my
    experience with several controllers, tested with a usermode AT-request
    transmitter as well as with FTP transmission over firewire-net, the AT
    contexts were luckily already stopped at the first ContextControl read,
    i.e. never required another MMIO read let alone mdelay.  A possible
    explanation for this is that the controllers which I tested perhaps stop
    AT DMA before they perform the self-ID reception DMA.
    
    But we cannot be sure about that and should keep the interrupts-disabled
    busy loop as short as possible.  Hence, query the ContextControl
    register in 1000 udelay(10) intervals instead of 10 udelay(1000)
    intervals.  I understand from an estimation by Clemens Ladisch that
    stopping a busy DMA context should take microseconds or at worst tens of
    microseconds, not milliseconds.
    Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
    9ef28ccd
ohci.c 94.3 KB