* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
@ 2011-11-23 9:13 Huang Shijie
2011-11-23 10:58 ` Wolfram Sang
0 siblings, 1 reply; 11+ messages in thread
From: Huang Shijie @ 2011-11-23 9: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 is not full, but the an Aging DMA request
will be received by the SDMA controller if we enable the
IDDMAEN(UCR4[6]).
The UART driver needs to know the count of the real received bytes,
and push them to upper layer.
So reuse the `private` field of dma_chan{}. Store the count of received bytes
to it, and use it in the UART driver.
Signed-off-by: Huang Shijie <b32955@freescale.com>
---
drivers/dma/imx-sdma.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index f993955..19ce579 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -501,6 +501,8 @@ static void sdma_handle_channel_loop(struct sdma_channel *sdmac)
static void mxc_sdma_handle_channel_normal(struct sdma_channel *sdmac)
{
struct sdma_buffer_descriptor *bd;
+ struct dma_chan *chan = &sdmac->chan;
+ unsigned int count;
int i, error = 0;
/*
@@ -512,8 +514,12 @@ static void mxc_sdma_handle_channel_normal(struct sdma_channel *sdmac)
if (bd->mode.status & (BD_DONE | BD_RROR))
error = -EIO;
+ count += bd->mode.count;
}
+ /* save the real count we received or transmitted. */
+ chan->private = (void *)count;
+
if (error)
sdmac->status = DMA_ERROR;
else
--
1.7.3.2
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
2011-11-23 9:13 [PATCH] IMX/SDMA : save the real count for one DMA transaction Huang Shijie
@ 2011-11-23 10:58 ` Wolfram Sang
2011-11-23 11:04 ` Huang Shijie
0 siblings, 1 reply; 11+ messages in thread
From: Wolfram Sang @ 2011-11-23 10:58 UTC (permalink / raw)
To: linux-arm-kernel
> + /* save the real count we received or transmitted. */
> + chan->private = (void *)count;
And if someone later needs another variable which is private?
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20111123/f7f9bd81/attachment.sig>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
2011-11-23 10:58 ` Wolfram Sang
@ 2011-11-23 11:04 ` Huang Shijie
2011-11-23 11:06 ` Wolfram Sang
0 siblings, 1 reply; 11+ messages in thread
From: Huang Shijie @ 2011-11-23 11:04 UTC (permalink / raw)
To: linux-arm-kernel
Hi,
>> + /* save the real count we received or transmitted. */
>> + chan->private = (void *)count;
> And if someone later needs another variable which is private?
>
I ever wanted to add an new parameter `void *` to dma_aync_tx_callback,
but it seemed i have
to change a lot of files.
Do you have any better suggestion?
thanks
Huang Shijie
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
2011-11-23 11:04 ` Huang Shijie
@ 2011-11-23 11:06 ` Wolfram Sang
2011-11-23 11:13 ` Huang Shijie
0 siblings, 1 reply; 11+ messages in thread
From: Wolfram Sang @ 2011-11-23 11:06 UTC (permalink / raw)
To: linux-arm-kernel
> >> + /* save the real count we received or transmitted. */
> >> + chan->private = (void *)count;
> > And if someone later needs another variable which is private?
> >
> I ever wanted to add an new parameter `void *` to dma_aync_tx_callback,
> but it seemed i have
> to change a lot of files.
>
> Do you have any better suggestion?
Use a private struct and put count in there.
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20111123/79e7a6d7/attachment.sig>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
2011-11-23 11:06 ` Wolfram Sang
@ 2011-11-23 11:13 ` Huang Shijie
2011-11-23 11:18 ` Wolfram Sang
0 siblings, 1 reply; 11+ messages in thread
From: Huang Shijie @ 2011-11-23 11:13 UTC (permalink / raw)
To: linux-arm-kernel
>>>> + /* save the real count we received or transmitted. */
>>>> + chan->private = (void *)count;
>>> And if someone later needs another variable which is private?
>>>
>> I ever wanted to add an new parameter `void *` to dma_aync_tx_callback,
>> but it seemed i have
>> to change a lot of files.
>>
>> Do you have any better suggestion?
> Use a private struct and put count in there.
>
Where to put the private struct? in the imx-sdma.c ?
If i put it there, how can i get it in the UART driver with the current
DMA API?
thanks
Huang Shijie
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
2011-11-23 11:13 ` Huang Shijie
@ 2011-11-23 11:18 ` Wolfram Sang
2011-11-23 11:29 ` Huang Shijie
0 siblings, 1 reply; 11+ messages in thread
From: Wolfram Sang @ 2011-11-23 11:18 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Nov 23, 2011 at 07:13:23PM +0800, Huang Shijie wrote:
>
> >>>> + /* save the real count we received or transmitted. */
> >>>> + chan->private = (void *)count;
> >>> And if someone later needs another variable which is private?
> >>>
> >> I ever wanted to add an new parameter `void *` to dma_aync_tx_callback,
> >> but it seemed i have
> >> to change a lot of files.
> >>
> >> Do you have any better suggestion?
> > Use a private struct and put count in there.
> >
> Where to put the private struct? in the imx-sdma.c ?
> If i put it there, how can i get it in the UART driver with the current
> DMA API?
So, in the UART driver you assume that void* is an int? Or how do you
currently use count?
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20111123/ad9bf81d/attachment.sig>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
2011-11-23 11:18 ` Wolfram Sang
@ 2011-11-23 11:29 ` Huang Shijie
2011-11-23 11:36 ` Wolfram Sang
2011-11-23 11:40 ` Vinod Koul
0 siblings, 2 replies; 11+ messages in thread
From: Huang Shijie @ 2011-11-23 11:29 UTC (permalink / raw)
To: linux-arm-kernel
> On Wed, Nov 23, 2011 at 07:13:23PM +0800, Huang Shijie wrote:
>>>>>> + /* save the real count we received or transmitted. */
>>>>>> + chan->private = (void *)count;
>>>>> And if someone later needs another variable which is private?
>>>>>
>>>> I ever wanted to add an new parameter `void *` to dma_aync_tx_callback,
>>>> but it seemed i have
>>>> to change a lot of files.
>>>>
>>>> Do you have any better suggestion?
>>> Use a private struct and put count in there.
>>>
>> Where to put the private struct? in the imx-sdma.c ?
>> If i put it there, how can i get it in the UART driver with the current
>> DMA API?
> So, in the UART driver you assume that void* is an int? Or how do you
> currently use count?
>
In the UART driver, I use the following lines:
-------------------------------------------------------
+ struct dma_chan *chan = sport->dma_chan_rx;
+ unsigned int count = (unsigned int)chan->private;
-------------------------------------------------------
Best Regards
Huang Shijie
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
2011-11-23 11:29 ` Huang Shijie
@ 2011-11-23 11:36 ` Wolfram Sang
2011-11-24 2:56 ` Huang Shijie
2011-11-23 11:40 ` Vinod Koul
1 sibling, 1 reply; 11+ messages in thread
From: Wolfram Sang @ 2011-11-23 11:36 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, Nov 23, 2011 at 07:29:20PM +0800, Huang Shijie wrote:
>
> > On Wed, Nov 23, 2011 at 07:13:23PM +0800, Huang Shijie wrote:
> >>>>>> + /* save the real count we received or transmitted. */
> >>>>>> + chan->private = (void *)count;
> >>>>> And if someone later needs another variable which is private?
> >>>>>
> >>>> I ever wanted to add an new parameter `void *` to dma_aync_tx_callback,
> >>>> but it seemed i have
> >>>> to change a lot of files.
> >>>>
> >>>> Do you have any better suggestion?
> >>> Use a private struct and put count in there.
> >>>
> >> Where to put the private struct? in the imx-sdma.c ?
> >> If i put it there, how can i get it in the UART driver with the current
> >> DMA API?
> > So, in the UART driver you assume that void* is an int? Or how do you
> > currently use count?
> >
> In the UART driver, I use the following lines:
> -------------------------------------------------------
> + struct dma_chan *chan = sport->dma_chan_rx;
> + unsigned int count = (unsigned int)chan->private;
> -------------------------------------------------------
And why can't you use a struct here? chan->private->count?
Even then, I doubt if you can get this into mainline. But when you try,
please always post a user for this change (or a reference to it), that
is, the uart-driver. Otherwise there is no reason to include a change.
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20111123/76eabb09/attachment.sig>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
2011-11-23 11:36 ` Wolfram Sang
@ 2011-11-24 2:56 ` Huang Shijie
0 siblings, 0 replies; 11+ messages in thread
From: Huang Shijie @ 2011-11-24 2:56 UTC (permalink / raw)
To: linux-arm-kernel
? 2011?11?23? 19:36, Wolfram Sang ??:
> On Wed, Nov 23, 2011 at 07:29:20PM +0800, Huang Shijie wrote:
>>> On Wed, Nov 23, 2011 at 07:13:23PM +0800, Huang Shijie wrote:
>>>>>>>> + /* save the real count we received or transmitted. */
>>>>>>>> + chan->private = (void *)count;
>>>>>>> And if someone later needs another variable which is private?
>>>>>>>
>>>>>> I ever wanted to add an new parameter `void *` to dma_aync_tx_callback,
>>>>>> but it seemed i have
>>>>>> to change a lot of files.
>>>>>>
>>>>>> Do you have any better suggestion?
>>>>> Use a private struct and put count in there.
>>>>>
>>>> Where to put the private struct? in the imx-sdma.c ?
>>>> If i put it there, how can i get it in the UART driver with the current
>>>> DMA API?
>>> So, in the UART driver you assume that void* is an int? Or how do you
>>> currently use count?
>>>
>> In the UART driver, I use the following lines:
>> -------------------------------------------------------
>> + struct dma_chan *chan = sport->dma_chan_rx;
>> + unsigned int count = (unsigned int)chan->private;
>> -------------------------------------------------------
> And why can't you use a struct here? chan->private->count?
>
> Even then, I doubt if you can get this into mainline. But when you try,
I wish to post the UART code as well as this patch.
But the PINMUX driver of mx6q is not ready now(so do the mx23/28).
I have to send out this single patch now.
thanks.
Huang Shijie
> please always post a user for this change (or a reference to it), that
> is, the uart-driver. Otherwise there is no reason to include a change.
>
> Regards,
>
> Wolfram
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
2011-11-23 11:29 ` Huang Shijie
2011-11-23 11:36 ` Wolfram Sang
@ 2011-11-23 11:40 ` Vinod Koul
2011-11-24 2:42 ` Huang Shijie
1 sibling, 1 reply; 11+ messages in thread
From: Vinod Koul @ 2011-11-23 11:40 UTC (permalink / raw)
To: linux-arm-kernel
On Wed, 2011-11-23 at 19:29 +0800, Huang Shijie wrote:
> > On Wed, Nov 23, 2011 at 07:13:23PM +0800, Huang Shijie wrote:
> >>>>>> + /* save the real count we received or transmitted. */
> >>>>>> + chan->private = (void *)count;
> >>>>> And if someone later needs another variable which is private?
> >>>>>
> >>>> I ever wanted to add an new parameter `void *` to dma_aync_tx_callback,
> >>>> but it seemed i have
> >>>> to change a lot of files.
> >>>>
> >>>> Do you have any better suggestion?
> >>> Use a private struct and put count in there.
> >>>
> >> Where to put the private struct? in the imx-sdma.c ?
> >> If i put it there, how can i get it in the UART driver with the current
> >> DMA API?
> > So, in the UART driver you assume that void* is an int? Or how do you
> > currently use count?
> >
> In the UART driver, I use the following lines:
> -------------------------------------------------------
> + struct dma_chan *chan = sport->dma_chan_rx;
> + unsigned int count = (unsigned int)chan->private;
> -------------------------------------------------------
Chan->private is a depreciated field, and will be removed soon...
possibly 3.3, so obviosly any usage of it is incorrect
Why dont you use .device_tx_status callback and return the number of
bytes remaining to be transmitted in residue value of the struct
dma_tx_state. That should be size - count.
--
~Vinod
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH] IMX/SDMA : save the real count for one DMA transaction.
2011-11-23 11:40 ` Vinod Koul
@ 2011-11-24 2:42 ` Huang Shijie
0 siblings, 0 replies; 11+ messages in thread
From: Huang Shijie @ 2011-11-24 2:42 UTC (permalink / raw)
To: linux-arm-kernel
? 2011?11?23? 19:40, Vinod Koul ??:
> On Wed, 2011-11-23 at 19:29 +0800, Huang Shijie wrote:
>>> On Wed, Nov 23, 2011 at 07:13:23PM +0800, Huang Shijie wrote:
>>>>>>>> + /* save the real count we received or transmitted. */
>>>>>>>> + chan->private = (void *)count;
>>>>>>> And if someone later needs another variable which is private?
>>>>>>>
>>>>>> I ever wanted to add an new parameter `void *` to dma_aync_tx_callback,
>>>>>> but it seemed i have
>>>>>> to change a lot of files.
>>>>>>
>>>>>> Do you have any better suggestion?
>>>>> Use a private struct and put count in there.
>>>>>
>>>> Where to put the private struct? in the imx-sdma.c ?
>>>> If i put it there, how can i get it in the UART driver with the current
>>>> DMA API?
>>> So, in the UART driver you assume that void* is an int? Or how do you
>>> currently use count?
>>>
>> In the UART driver, I use the following lines:
>> -------------------------------------------------------
>> + struct dma_chan *chan = sport->dma_chan_rx;
>> + unsigned int count = (unsigned int)chan->private;
>> -------------------------------------------------------
> Chan->private is a depreciated field, and will be removed soon...
> possibly 3.3, so obviosly any usage of it is incorrect
>
> Why dont you use .device_tx_status callback and return the number of
> bytes remaining to be transmitted in residue value of the struct
> dma_tx_state. That should be size - count.
>
Thanks a lot.
Huang Shijie
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2011-11-24 2:56 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-23 9:13 [PATCH] IMX/SDMA : save the real count for one DMA transaction Huang Shijie
2011-11-23 10:58 ` Wolfram Sang
2011-11-23 11:04 ` Huang Shijie
2011-11-23 11:06 ` Wolfram Sang
2011-11-23 11:13 ` Huang Shijie
2011-11-23 11:18 ` Wolfram Sang
2011-11-23 11:29 ` Huang Shijie
2011-11-23 11:36 ` Wolfram Sang
2011-11-24 2:56 ` Huang Shijie
2011-11-23 11:40 ` Vinod Koul
2011-11-24 2:42 ` Huang Shijie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).