• Stefan Richter's avatar
    ieee1394: sbp2: safer initialization of status fifo · 3e98eab4
    Stefan Richter authored
    Sbp2's copy of the status fifo was cleared when management ORBs or new
    command ORBs were prepared.  The latter had potential for a race
    condition if the block layer's soft IRQ and the 1394 LLD's interrupt
    handler ran on different CPUs.  It would also yield wrong status if a
    command was completed with non-zero completion status before other
    commands that had zero completion status, and no new command was
    enqueued in the meantime.
    
    Now, the status buffer is cleared right before it is written.  Thus it
    ends up in the following simpler and safer access pattern:
     - sbp2_alloc_device: allocates and implicitly clears once,
     - sbp2_handle_status_write: clears, writes, and reads,
     - sbp2_query_logins, sbp2_login_device, sbp2_reconnect_device: read.
    The latter three do not race with sbp2_handle_status_write because of
    how the protocol works.
    
    As a tiny optimization, the first two quadlets of the status never need
    to be cleared.
    Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
    3e98eab4
sbp2.c 78.1 KB