diff options
| author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2016-06-30 11:15:18 -0400 |
|---|---|---|
| committer | Vinod Koul <vinod.koul@intel.com> | 2016-07-08 01:39:10 -0400 |
| commit | 55bd582b4d8c2266bc43cbae2ddfce31b489618f (patch) | |
| tree | fda48990a482ed0d73b72f678c14b7d94f721621 | |
| parent | 48c73659abae103a2f8531f825ce7a3f8dedbb39 (diff) | |
dmaengine: rcar-dmac: Fix residue reporting for pending descriptors
Cookies corresponding to pending transfers have a residue value equal to
the full size of the corresponding descriptor. The driver miscomputes
that and uses the size of the active descriptor instead. Fix it.
Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
[geert: Also check desc.active list]
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
| -rw-r--r-- | drivers/dma/sh/rcar-dmac.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c index 561476c1e741..0dd953884d1d 100644 --- a/drivers/dma/sh/rcar-dmac.c +++ b/drivers/dma/sh/rcar-dmac.c | |||
| @@ -1145,6 +1145,7 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan, | |||
| 1145 | struct rcar_dmac_desc *desc = chan->desc.running; | 1145 | struct rcar_dmac_desc *desc = chan->desc.running; |
| 1146 | struct rcar_dmac_xfer_chunk *running = NULL; | 1146 | struct rcar_dmac_xfer_chunk *running = NULL; |
| 1147 | struct rcar_dmac_xfer_chunk *chunk; | 1147 | struct rcar_dmac_xfer_chunk *chunk; |
| 1148 | enum dma_status status; | ||
| 1148 | unsigned int residue = 0; | 1149 | unsigned int residue = 0; |
| 1149 | unsigned int dptr = 0; | 1150 | unsigned int dptr = 0; |
| 1150 | 1151 | ||
| @@ -1152,12 +1153,38 @@ static unsigned int rcar_dmac_chan_get_residue(struct rcar_dmac_chan *chan, | |||
| 1152 | return 0; | 1153 | return 0; |
| 1153 | 1154 | ||
| 1154 | /* | 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 | /* | ||
| 1155 | * If the cookie doesn't correspond to the currently running transfer | 1166 | * If the cookie doesn't correspond to the currently running transfer |
| 1156 | * 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 |
| 1157 | * equal to the full descriptor size. | 1168 | * equal to the full descriptor size. |
| 1158 | */ | 1169 | */ |
| 1159 | if (cookie != desc->async_tx.cookie) | 1170 | if (cookie != desc->async_tx.cookie) { |
| 1160 | 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 | } | ||
| 1161 | 1188 | ||
| 1162 | /* | 1189 | /* |
| 1163 | * In descriptor mode the descriptor running pointer is not maintained | 1190 | * In descriptor mode the descriptor running pointer is not maintained |
