* [PATCH v2] IMX/SDMA : save the real count for one DMA transaction.
@ 2011-12-01 2:13 Huang Shijie
2011-12-01 12:02 ` Lothar Waßmann
0 siblings, 1 reply; 2+ messages in thread
From: Huang Shijie @ 2011-12-01 2:13 UTC (permalink / raw)
To: linux-arm-kernel
When we use the SDMA in the UART driver(such as imx6q), we will
meet one situation:
Assume we set 64 bytes for the RX DMA buffer.
The receiving DMA buffer has received some data, but not full.
An Aging DMA request will be received by the SDMA controller if we enable the
IDDMAEN(UCR4[6]) in this case.
So the UART driver needs to know the count of the real received bytes,
and push them to upper layer.
Add two new fields to sdmac, and update the `residue` in sdma_tx_status().
Signed-off-by: Huang Shijie <b32955@freescale.com>
---
drivers/dma/imx-sdma.c | 10 ++++++++--
1 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index f993955..05ba3a8 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -268,6 +268,7 @@ struct sdma_channel {
struct dma_async_tx_descriptor desc;
dma_cookie_t last_completed;
enum dma_status status;
+ unsigned int chn_count, chn_real_count;
};
#define IMX_DMA_SG_LOOP (1 << 0)
@@ -503,6 +504,7 @@ static void mxc_sdma_handle_channel_normal(struct sdma_channel *sdmac)
struct sdma_buffer_descriptor *bd;
int i, error = 0;
+ sdmac->chn_real_count = 0;
/*
* non loop mode. Iterate over all descriptors, collect
* errors and call callback function
@@ -512,6 +514,7 @@ static void mxc_sdma_handle_channel_normal(struct sdma_channel *sdmac)
if (bd->mode.status & (BD_DONE | BD_RROR))
error = -EIO;
+ sdmac->chn_real_count += bd->mode.count;
}
if (error)
@@ -519,9 +522,9 @@ static void mxc_sdma_handle_channel_normal(struct sdma_channel *sdmac)
else
sdmac->status = DMA_SUCCESS;
+ sdmac->last_completed = sdmac->desc.cookie;
if (sdmac->desc.callback)
sdmac->desc.callback(sdmac->desc.callback_param);
- sdmac->last_completed = sdmac->desc.cookie;
}
static void mxc_sdma_handle_channel(struct sdma_channel *sdmac)
@@ -941,6 +944,7 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
goto err_out;
}
+ sdmac->chn_count = 0;
for_each_sg(sgl, sg, sg_len, i) {
struct sdma_buffer_descriptor *bd = &sdmac->bd[i];
int param;
@@ -957,6 +961,7 @@ static struct dma_async_tx_descriptor *sdma_prep_slave_sg(
}
bd->mode.count = count;
+ sdmac->chn_count += count;
if (sdmac->word_size > DMA_SLAVE_BUSWIDTH_4_BYTES) {
ret = -EINVAL;
@@ -1119,7 +1124,8 @@ static enum dma_status sdma_tx_status(struct dma_chan *chan,
last_used = chan->cookie;
- dma_set_tx_state(txstate, sdmac->last_completed, last_used, 0);
+ dma_set_tx_state(txstate, sdmac->last_completed, last_used,
+ sdmac->chn_count - sdmac->chn_real_count);
return sdmac->status;
}
--
1.7.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* [PATCH v2] IMX/SDMA : save the real count for one DMA transaction.
2011-12-01 2:13 [PATCH v2] IMX/SDMA : save the real count for one DMA transaction Huang Shijie
@ 2011-12-01 12:02 ` Lothar Waßmann
0 siblings, 0 replies; 2+ messages in thread
From: Lothar Waßmann @ 2011-12-01 12:02 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
Huang Shijie writes:
> When we use the SDMA in the UART driver(such as imx6q), we will
> meet one situation:
> Assume we set 64 bytes for the RX DMA buffer.
> The receiving DMA buffer has received some data, but not full.
> An Aging DMA request will be received by the SDMA controller if we enable the
> IDDMAEN(UCR4[6]) in this case.
>
> So the UART driver needs to know the count of the real received bytes,
> and push them to upper layer.
>
> Add two new fields to sdmac, and update the `residue` in sdma_tx_status().
>
> Signed-off-by: Huang Shijie <b32955@freescale.com>
> ---
> drivers/dma/imx-sdma.c | 10 ++++++++--
> 1 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
> index f993955..05ba3a8 100644
> --- a/drivers/dma/imx-sdma.c
> +++ b/drivers/dma/imx-sdma.c
> @@ -268,6 +268,7 @@ struct sdma_channel {
> struct dma_async_tx_descriptor desc;
> dma_cookie_t last_completed;
> enum dma_status status;
> + unsigned int chn_count, chn_real_count;
>
It would be clearer and more maintenance friendly to have each struct
member definition on a separate line.
Lothar Wa?mann
--
___________________________________________________________
Ka-Ro electronics GmbH | Pascalstra?e 22 | D - 52076 Aachen
Phone: +49 2408 1402-0 | Fax: +49 2408 1402-10
Gesch?ftsf?hrer: Matthias Kaussen
Handelsregistereintrag: Amtsgericht Aachen, HRB 4996
www.karo-electronics.de | info at karo-electronics.de
___________________________________________________________
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-12-01 12:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-01 2:13 [PATCH v2] IMX/SDMA : save the real count for one DMA transaction Huang Shijie
2011-12-01 12:02 ` Lothar Waßmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox