• Finn Thain's avatar
    via-cuda: Avoid TREQ race condition · a6466243
    Finn Thain authored
    When a read transaction completes, one of several things will happen:
    a new transfer is started by the driver, a new transfer request
    is raised by the Cuda (i.e. TREQ asserted), or both happen at once.
    
    When both happen at once, there is a race condition between the TREQ test
    in the read_done state and the same test in cuda_start(). Moreover, the
    former test uses a stale TREQ value.
    
    Theoretically, this can result in the undesirable outcome that the
    interrupt handler completes with the state machine 'idle' when it should
    instead start the next transaction.
    
    Avoid this race by calling cuda_start() first and then confirming that it
    succeeded. If not, test the current TREQ value before entering the
    'reading' state.
    Tested-by: default avatarStan Johnson <userm57@yahoo.com>
    Signed-off-by: default avatarFinn Thain <fthain@telegraphics.com.au>
    Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
    a6466243
via-cuda.c 15.5 KB