ioatdma: fix race between updating ioat->head and IOAT_COMPLETION_PENDING
PATCH 1/1 ioatdma: fix race between updating ioat->head and IOAT_COMPLETION_PENDING
There is a race that can hit during __cleanup() when the ioat->head pointer is incremented during descriptor submission. The __cleanup() can clear the PENDING flag when it does not see any active descriptors. This causes new submitted descriptors to be ignored because the COMPLETION_PENDING flag is cleared. This was introduced when code was adapted from ioatdma v1 to ioatdma v2. For v2 and v3, IOAT_COMPLETION_PENDING flag will be abandoned and a new flag IOAT_CHAN_ACTIVE will be utilized. This flag will also be protected under the prep_lock when being modified in order to avoid the race.
--- drivers/dma/ioat/dma.h | 1 drivers/dma/ioat/dma_v2.c | 113 +++++++++++++++++++++++++-------------------- drivers/dma/ioat/dma_v3.c | 111 +++++++++++++++++++++++++------------------- 3 files changed, 128 insertions(+), 97 deletions(-)
drivers/dma/ioat/dma.h +1 -0
@@ -97,6 +97,7 @@ struct ioat_chan_common {#define IOAT_KOBJ_INIT_FAIL 3#define IOAT_RESHAPE_PENDING 4#define IOAT_RUN 5 +#define IOAT_CHAN_ACTIVE 6struct timer_list timer;#define COMPLETION_TIMEOUT msecs_to_jiffies(100)#define IDLE_TIMEOUT msecs_to_jiffies(2000)
drivers/dma/ioat/dma_v2.c +64 -49
138 lines not on this page · raw message
drivers/dma/ioat/dma_v3.c +63 -48
130 lines not on this page · raw message
Vinod Koul
AppliedQuoted 11 lines · Dave Jiang
There is a race that can hit during
__cleanup()when theioat->headpointer is incremented during descriptor submission. The__cleanup()can clear the PENDING flag when it does not see any active descriptors. This causes new submitted descriptors to be ignored because theCOMPLETION_PENDINGflag is cleared. This was introduced when code was adapted from ioatdma v1 to ioatdma v2. For v2 and v3,IOAT_COMPLETION_PENDINGflag will be abandoned and a new flagIOAT_CHAN_ACTIVEwill be utilized. This flag will also be protected under theprep_lockwhen being modified in order to avoid the race.Signed-off-by Dave Jiang <[email protected]>Reviewed-by Dan Williams <[email protected]>
Applied, thanks
--
~Vinod