• Ian Armstrong's avatar
    V4L/DVB: ivtv: Fix race condition for queued udma transfers · b6e436b2
    Ian Armstrong authored
    There are several DMA related interrupts which wake up the dma_waitq. The udma
    routines use this queue while they wait for their transfer to complete. When
    woken, the udma routine will check the IVTV_F_I_UDMA_PENDING & IVTV_F_I_UDMA
    flags to see if the transfer is still queued or has finished. However, a small
    window exists between the IVTV_F_I_UDMA_PENDING flag being cleared and the
    IVTV_F_I_UDMA flag being set. Given that the completion of an unrelated DMA
    transfer may wake up the udma routine, it's possible for this check to fail
    and the udma routine will start unmapping pages when the transfer has only
    just started. The result of this is unpredictable.
    
    This fix simply delays the clearing of the IVTV_F_I_UDMA_PENDING flag until
    after IVTV_F_I_UDMA has been set.
    Signed-off-by: default avatarIan Armstrong <ian@iarmst.demon.co.uk>
    Signed-off-by: default avatarAndy Walls <awalls@radix.net>
    Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
    b6e436b2
ivtv-irq.c 29.7 KB