Skip to contentSkip to conversation

ioatdma: fix race between updating ioat->head and IOAT_COMPLETION_PENDING

PATCH Applied Dave Jiang 2 participants 2 messages Feb 7, 2013 – Feb 12, 2013 dmaengine

lore
Share & tools
lore

Dave Jiang

author
#0 lore raw

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
index 5e8fe01..1020598 100644
@@ -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 6
 	struct 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

Applied
#1 lore raw
Quoted 11 lines · Dave Jiang

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.

Applied, thanks

--
~Vinod