From: b32955@freescale.com (Huang Shijie)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 2/3] serial: mxs-auart: add the DMA support for mx28
Date: Thu, 25 Oct 2012 17:15:43 +0800 [thread overview]
Message-ID: <5089033F.9040100@freescale.com> (raw)
In-Reply-To: <1351145272.7077.8.camel@vkoul-udesk3>
? 2012?10?25? 14:07, Vinod Koul ??:
> On Thu, 2012-10-25 at 13:50 +0800, Huang Shijie wrote:
>> ? 2012?10?25? 12:18, Vinod Koul ??:
>>>> +
>>>> +static int mxs_auart_dma_tx(struct mxs_auart_port *s, int size)
>>>> +{
>>>> + struct dma_async_tx_descriptor *desc;
>>>> + struct scatterlist *sgl =&s->tx_sgl;
>>>> + struct dma_chan *channel = s->tx_dma_chan;
>>>> + u32 pio;
>>>> +
>>>> + /* [1] : send PIO. Note, the first pio word is CTRL1. */
>>>> + pio = AUART_CTRL1_XFER_COUNT(size);
>>>> + desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)&pio,
>>>> + 1, DMA_TRANS_NONE, 0);
>>> this seems like a hack. API expects a scatterlist as argument.
>>> Same thing about direction, NONE doesnt mean anything for dma transfer.
>> It's not a hack. this DMA descriptor is used to set the registers.
>> Please see the code in drivers/dma/mxs-dma.c:mxs_dam_prep_slave_sg().
> yes it is, and also an abuse of the api.
> prep_slave_sg() expects a scatter list and you are passing something
> else and using DMA_TRANS_NONE to do that, which makes no sense!!!
>
> If you have to setup your registers you need to setup based on what APIs
> passed you and not by abusing.
>
yes. I have to setup the register. Could you told me which API is the
right API?
It seems to the mxs-dma needs a patch again.
>>>> + if (!desc) {
>>>> + dev_err(s->dev, "step 1 error\n");
>>>> + return -EINVAL;
>>>> + }
>>>> +
>>>> + /* [2] : set DMA buffer. */
>>>> + sg_init_one(sgl, s->tx_dma_buf, size);
>>>> + dma_map_sg(s->dev, sgl, 1, DMA_TO_DEVICE);
>>>> + desc = dmaengine_prep_slave_sg(channel, sgl,
>>>> + 1, DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
>>>> + if (!desc) {
>>>> + dev_err(s->dev, "step 2 error\n");
>>>> + return -EINVAL;
>>>> + }
>>>> +
>>>> + /* [3] : submit the DMA */
>>>> + desc->callback = dma_tx_callback;
>>>> + desc->callback_param = s;
>>>> + dmaengine_submit(desc);
>>>> + dma_async_issue_pending(channel);
>>>> + return 0;
>>>> +}
>>>> +
>>>>
>>>> +static bool mxs_auart_dma_filter(struct dma_chan *chan, void *param)
>>>> +{
>>>> + struct mxs_auart_port *s = param;
>>>> +
>>>> + if (!mxs_dma_is_apbx(chan))
>>>> + return false;
>>>> +
>>>> + if (s->dma_channel == chan->chan_id) {
>>>> + chan->private =&s->dma_data;
>>> dont use chan->private. You need to dmaengine_slave_config API
>> please see the drivers/dma/mxs-dma.c:mxs_dam_alloc_chan_resoures().
>>
>> The mxs-dma driver uses ->private to store the channel interrupt number.
> And which it should not be doing. private is not supposed to be used for
> passing info. If it is generic add to slave config.
>
Could you give me an example which do not use the private?
The imx-sdma also uses the private to pass some info.
thanks
Huang Shijie
next prev parent reply other threads:[~2012-10-25 9:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-24 10:27 [PATCH v2 0/3] serial: mxs-auart: add DMA support for auart in mx28 Huang Shijie
2012-10-24 10:27 ` [PATCH v2 1/3] serial: mxs-auart: distinguish the different SOCs Huang Shijie
2012-10-24 10:27 ` [PATCH v2 2/3] serial: mxs-auart: add the DMA support for mx28 Huang Shijie
2012-10-25 4:18 ` Vinod Koul
2012-10-25 5:50 ` Huang Shijie
2012-10-25 6:07 ` Vinod Koul
2012-10-25 9:15 ` Huang Shijie [this message]
2012-10-25 11:08 ` Vinod Koul
2012-11-05 3:16 ` Huang Shijie
2012-11-13 9:42 ` Lauri Hintsala
2012-11-15 3:20 ` Huang Shijie
2012-11-15 7:22 ` Lauri Hintsala
2012-11-15 9:11 ` Huang Shijie
2012-11-15 11:51 ` Lauri Hintsala
2012-10-24 10:27 ` [PATCH v2 3/3] ARM: dts: enable dma support for auart0 in mx28 Huang Shijie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5089033F.9040100@freescale.com \
--to=b32955@freescale.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).