summaryrefslogtreecommitdiff
path: root/chip/mchp
diff options
context:
space:
mode:
authorTom Hughes <tomhughes@chromium.org>2019-08-02 10:19:43 -0700
committerCommit Bot <commit-bot@chromium.org>2019-08-13 00:46:05 +0000
commit4609b59404bd6e32c4cdb267658511a46557dab2 (patch)
treefd2182960546330dd7b0d222e49d29be6a4643c1 /chip/mchp
parentd09bc18d46c37070e3309b4f72a33d27134dea45 (diff)
downloadchrome-ec-4609b59404bd6e32c4cdb267658511a46557dab2.tar.gz
dma: separate out DMA enable status from wait_for_bytes
When wait_for_bytes returns 0 when DMA is disabled, we can't differentiate between DMA being disabled and a transfer having completed when it has reached the end of the requested transfer. Separating out into separate functions lets us distinguish the two cases. The reason we didn't hit this in the past is that the requested receive size is generally larger than the actual amount we're sending. Since we know the amount that we're waiting for from the header, we would stop the transfer in software. BRANCH=none BUG=b:132444384 TEST=On DUTs with bloonchipper and dartmonkey: ectool --name=cros_fp testmaxtransfer TEST=make buildall -j Change-Id: I885161a3e04b7a12d597d8dc8691f599990bda8b Signed-off-by: Tom Hughes <tomhughes@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1734010 Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'chip/mchp')
-rw-r--r--chip/mchp/dma.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/chip/mchp/dma.c b/chip/mchp/dma.c
index 1c491729cd..6c9ed8dd47 100644
--- a/chip/mchp/dma.c
+++ b/chip/mchp/dma.c
@@ -194,28 +194,32 @@ void dma_xfr_start_rx(const struct dma_option *option,
/*
* Return the number of bytes transferred.
- * The number of bytes transferred can be easily determinted
+ * The number of bytes transferred can be easily determined
* from the difference in DMA memory start address register
* and memory end address register. No need to look at DMA
* transfer size field because the hardware increments memory
- * start address by unit size on each unit tranferred.
+ * start address by unit size on each unit transferred.
* Why is a signed integer being used for a count value?
*/
int dma_bytes_done(dma_chan_t *chan, int orig_count)
{
- int bcnt = 0;
+ int bcnt;
- if (chan != NULL) {
- if (chan->ctrl & MCHP_DMA_RUN) {
- bcnt = (int)chan->mem_end;
- bcnt -= (int)chan->mem_start;
- bcnt = orig_count - bcnt;
- }
- }
+ if (chan == NULL)
+ return 0;
+
+ bcnt = (int)chan->mem_end;
+ bcnt -= (int)chan->mem_start;
+ bcnt = orig_count - bcnt;
return bcnt;
}
+bool dma_is_enabled(dma_chan_t *chan)
+{
+ return (chan->ctrl & MCHP_DMA_RUN);
+}
+
int dma_bytes_done_chan(enum dma_channel ch, uint32_t orig_count)
{
uint32_t cnt;