Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1236592
| From | Robert Jarzmik <robert.jarzmik@free.fr> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 2/2] dma: pxa_dma: fix residue corner case |
| Date | 2015-09-30 19:50 +0200 |
| Message-ID | <qetFU-3Ao-17@gated-at.bofh.it> (permalink) |
| References | <qetFU-3Ao-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
A very tiny temporal window exists in the residue calculation where :
- upon entering residue calculation, the transfer is ongoing
- when reading the current transfer pointer, it just changed to
the "finisher/linker" descriptor
In this case, the residue returned is the whole transfer length instead
of 0. Fix it.
This appears almost in one extreme case, where the driver is used
by older clients which inquire for residue in interrupt context, such
as the smsc91x ethernet driver, in a tight loop :
interrupt_handler()
dmaengine_submit()
do {
dmaengine_tx_status()
} while (residue > 0 || status != DMA_ERROR)
Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
---
Since v1: reworded the commit message for typos
---
drivers/dma/pxa_dma.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index 7d3ff56caa0a..51f294e4227c 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -1185,6 +1185,16 @@ static unsigned int pxad_residue(struct pxad_chan *chan,
else
curr = phy_readl_relaxed(chan->phy, DTADR);
+ /*
+ * curr has to be actually read before checking descriptor
+ * completion, so that a curr inside a status updater
+ * descriptor implies the following test returns true, and
+ * preventing reordering of curr load and the test.
+ */
+ rmb();
+ if (is_desc_completed(vd))
+ goto out;
+
for (i = 0; i < sw_desc->nb_desc - 1; i++) {
hw_desc = sw_desc->hw_desc[i];
if (sw_desc->hw_desc[0]->dcmd & PXA_DCMD_INCSRCADDR)
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 1/2] dma: pxa_dma: fix the no-requestor case Robert Jarzmik <robert.jarzmik@free.fr> - 2015-09-30 19:50 +0200 [PATCH v2 2/2] dma: pxa_dma: fix residue corner case Robert Jarzmik <robert.jarzmik@free.fr> - 2015-09-30 19:50 +0200 Re: [PATCH v2 1/2] dma: pxa_dma: fix the no-requestor case Vinod Koul <vinod.koul@intel.com> - 2015-10-01 04:20 +0200
csiph-web