public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: linux@arm.linux.org.uk (Russell King - ARM Linux)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] mxcmmc: use dmaengine API
Date: Wed, 12 Jan 2011 10:26:32 +0000	[thread overview]
Message-ID: <20110112102632.GX11039@n2100.arm.linux.org.uk> (raw)
In-Reply-To: <1294826996-13764-2-git-send-email-s.hauer@pengutronix.de>

On Wed, Jan 12, 2011 at 11:09:56AM +0100, Sascha Hauer wrote:
> +	host->dma_nents = dma_map_sg(mmc_dev(host->mmc), data->sg,
> +				     data->sg_len,  host->dma_dir);

As recently discussed, you don't need to save dma_nents - the value to
be passed to dma_unmap_sg() is data->sg_len, not host->dma_nents.

You should also do the map/unmap against the DMA engine device (which
is the device actually doing DMA) rather than the peripheral (which is
only the recipient of DMA).  The reason is - while the peripheral can
see the DMA controller, the peripheral may be able to see all RAM but
the DMA controller may have an IOMMU or limited view of RAM.

> +static int mxcmci_setup_dma(struct mmc_host *mmc)
> +{
> +	struct mxcmci_host *host = mmc_priv(mmc);
> +	struct dma_slave_config *config = &host->dma_slave_config;
> +
> +	config->direction = DMA_FROM_DEVICE;

I would like to get some concensus on removing config->direction from
the slave configuration entirely - and make all the fields below
refer purely to the peripheral device parameters.  At the moment,
the API allows them to be used ambiguously.

> +static bool filter(struct dma_chan *chan, void *param)
> +{
> +	struct mxcmci_host *host = param;
> +
> +	if (!imx_dma_is_general_purpose(chan)) {
> +		printk("no general\n");
> +		return false;
> +	}
> +
> +        chan->private = &host->dma_data;
> +
> +        return true;

Looks like something went wrong with the tabbing here?

> @@ -794,7 +823,7 @@ static int mxcmci_probe(struct platform_device *pdev)
>  	mmc->max_blk_size = 2048;
>  	mmc->max_blk_count = 65535;
>  	mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
> -	mmc->max_seg_size = mmc->max_req_size;
> +	mmc->max_seg_size = 65535;

You can get this from the DMA parameters for the DMA engine device:

	mmc->max_seg_size = dma_get_max_seg_size(dev);

where 'dev' is the DMA engine struct device - chan->dma_device->dev.

Also just spotted this left in your patch:
> +	if (!mxcmci_use_dma(host))
> +		return 0;
> +
>  	for_each_sg(data->sg, sg, data->sg_len, i) {
>  		if (sg->offset & 3 || sg->length & 3) {
> 			host->do_dma = 0;

Shouldn't this be a decision made by the DMA engine rather than the
driver?  Having looked at the MMCI code also doing this, I think this
should cause prep_slave_sg() to return NULL if it can't handle the
scatterlist.  On MMCI, we fall back to PIO if prep_slave_sg() returns
NULL.

  reply	other threads:[~2011-01-12 10:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-12 10:09 let the mxcmmc driver use the dmaengine API Sascha Hauer
2011-01-12 10:09 ` [PATCH] mxcmmc: use " Sascha Hauer
2011-01-12 10:26   ` Russell King - ARM Linux [this message]
2011-01-12 13:13     ` Sascha Hauer
2011-01-12 12:25   ` Shawn Guo
2011-01-12 12:33     ` Shawn Guo

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=20110112102632.GX11039@n2100.arm.linux.org.uk \
    --to=linux@arm.linux.org.uk \
    --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