diff options
author | Vinod Koul <vinod.koul@intel.com> | 2016-07-16 10:40:17 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2016-07-16 10:40:17 -0400 |
commit | 9c4d7e648161414d02a316fa05dfd8f030dfc762 (patch) | |
tree | 372d51d25316c03d7d99b57943439c91c0e6983f | |
parent | 00357c4517c909c022cfb4a997020cd82560bd80 (diff) | |
parent | 55bd582b4d8c2266bc43cbae2ddfce31b489618f (diff) |
Merge branch 'topic/sh' into for-linus
-rw-r--r-- | drivers/dma/sh/rcar-dmac.c | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index dfb17926297b..0dd953884d1d 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c | |||
@@ -311,7 +311,7 @@ static bool rcar_dmac_chan_is_busy(struct rcar_dmac_chan *chan) | |||
311 | { | 311 | { |
312 | u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR); | 312 | u32 chcr = rcar_dmac_chan_read(chan, RCAR_DMACHCR); |
313 | 313 | ||
314 | return (chcr & (RCAR_DMACHCR_DE | RCAR_DMACHCR_TE)) == RCAR_DMACHCR_DE; | 314 | return !!(chcr & (RCAR_DMACHCR_DE | RCAR_DMACHCR_TE)); |
315 | } | 315 | } |
316 | 316 | ||
317 | static void rcar_dmac_chan_start_xfer(struct rcar_dmac_chan *chan) | 317 | static void rcar_dmac_chan_start_xfer(struct rcar_dmac_chan *chan) |
@@ -510,7 +510,7 @@ static void rcar_dmac_desc_put(struct rcar_dmac_chan *chan, | |||
510 | 510 | ||
511 | spin_lock_irqsave(&chan->lock, flags); | 511 | spin_lock_irqsave(&chan->lock, flags); |
512 | list_splice_tail_init(&desc->chunks, &chan->desc.chunks_free); | 512 | list_splice_tail_init(&desc->chunks, &chan->desc.chunks_free); |
513 | list_add_tail(&desc->node, &chan->desc.free); | 513 | list_add(&desc->node, &chan->desc.free); |
514 | spin_unlock_irqrestore(&chan->lock, flags); | 514 | spin_unlock_irqrestore(&chan->lock, flags); |
515 | } | 515 | } |
516 | 516 | ||
@@ -990,6 +990,8 @@ static void rcar_dmac_free_chan_resources(struct dma_chan *chan) | |||
990 | list_splice_init(&rchan->desc.done, &list); | 990 | list_splice_init(&rchan->desc.done, &list); |
991 | list_splice_init(&rchan->desc.wait, &list); | 991 | list_splice_init(&rchan->desc.wait, &list); |
992 | 992 | ||
993 | rchan->desc.running = NULL; | ||
994 | |||
993 | list_for_each_entry(desc, &list, node) | 995 | list_for_each_entry(desc, &list, node) |
994 | rcar_dmac_realloc_hwdesc(rchan, desc, 0); | 996 | rcar_dmac_realloc_hwdesc(rchan, desc, 0); |
995 | 997 | ||
@@ -1143,6 +1145,7 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan, | |||
1143 | struct rcar_dmac_desc *desc = chan->desc.running; | 1145 | struct rcar_dmac_desc *desc = chan->desc.running; |
1144 | struct rcar_dmac_xfer_chunk *running = NULL; | 1146 | struct rcar_dmac_xfer_chunk *running = NULL; |
1145 | struct rcar_dmac_xfer_chunk *chunk; | 1147 | struct rcar_dmac_xfer_chunk *chunk; |
1148 | enum dma_status status; | ||
1146 | unsigned int residue = 0; | 1149 | unsigned int residue = 0; |
1147 | unsigned int dptr = 0; | 1150 | unsigned int dptr = 0; |
1148 | 1151 | ||
@@ -1150,12 +1153,38 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan, | |||
1150 | return 0; | 1153 | return 0; |
1151 | 1154 | ||
1152 | /* | 1155 | /* |
1156 | * If the cookie corresponds to a descriptor that has been completed | ||
1157 | * there is no residue. The same check has already been performed by the | ||
1158 | * caller but without holding the channel lock, so the descriptor could | ||
1159 | * now be complete. | ||
1160 | */ | ||
1161 | status = dma_cookie_status(&chan->chan, cookie, NULL); | ||
1162 | if (status == DMA_COMPLETE) | ||
1163 | return 0; | ||
1164 | |||
1165 | /* | ||
1153 | * If the cookie doesn't correspond to the currently running transfer | 1166 | * If the cookie doesn't correspond to the currently running transfer |
1154 | * then the descriptor hasn't been processed yet, and the residue is | 1167 | * then the descriptor hasn't been processed yet, and the residue is |
1155 | * equal to the full descriptor size. | 1168 | * equal to the full descriptor size. |
1156 | */ | 1169 | */ |
1157 | if (cookie != desc->async_tx.cookie) | 1170 | if (cookie != desc->async_tx.cookie) { |
1158 | return desc->size; | 1171 | list_for_each_entry(desc, &chan->desc.pending, node) { |
1172 | if (cookie == desc->async_tx.cookie) | ||
1173 | return desc->size; | ||
1174 | } | ||
1175 | list_for_each_entry(desc, &chan->desc.active, node) { | ||
1176 | if (cookie == desc->async_tx.cookie) | ||
1177 | return desc->size; | ||
1178 | } | ||
1179 | |||
1180 | /* | ||
1181 | * No descriptor found for the cookie, there's thus no residue. | ||
1182 | * This shouldn't happen if the calling driver passes a correct | ||
1183 | * cookie value. | ||
1184 | */ | ||
1185 | WARN(1, "No descriptor for cookie!"); | ||
1186 | return 0; | ||
1187 | } | ||
1159 | 1188 | ||
1160 | /* | 1189 | /* |
1161 | * In descriptor mode the descriptor running pointer is not maintained | 1190 | * In descriptor mode the descriptor running pointer is not maintained |
@@ -1202,6 +1231,10 @@ static enum dma_status rcar_dmac_tx_status(struct dma_chan *chan, | |||
1202 | residue = rcar_dmac_chan_get_residue(rchan, cookie); | 1231 | residue = rcar_dmac_chan_get_residue(rchan, cookie); |
1203 | spin_unlock_irqrestore(&rchan->lock, flags); | 1232 | spin_unlock_irqrestore(&rchan->lock, flags); |
1204 | 1233 | ||
1234 | /* if there's no residue, the cookie is complete */ | ||
1235 | if (!residue) | ||
1236 | return DMA_COMPLETE; | ||
1237 | |||
1205 | dma_set_residue(txstate, residue); | 1238 | dma_set_residue(txstate, residue); |
1206 | 1239 | ||
1207 | return status; | 1240 | return status; |