linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: broonie@kernel.org (Mark Brown)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] spi: atmel: Refactor spi-atmel to use SPI framework queue
Date: Wed, 8 Jan 2014 13:21:47 +0000	[thread overview]
Message-ID: <20140108132147.GF31886@sirena.org.uk> (raw)
In-Reply-To: <1389160188-4030-1-git-send-email-wenyou.yang@atmel.com>

On Wed, Jan 08, 2014 at 01:49:48PM +0800, Wenyou Yang wrote:

> The patch is based on for-next branch of
> 	git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git

Sorry, there was a patch from Richard which got applied but not pushed
out - I've pushed it now but it conflicts with this.  Can you please
rebase?  It should be a simple update from the looks of things.

> -		tasklet_schedule(&as->tasklet);
> +		atmel_spi_lock(as);
> +		complete(&as->xfer_completion);
> +		atmel_spi_unlock(as);

Why do you need to hold the lock to complete the transfer?  That seems
very odd.

> +	/*
> +	 * DMA map early, for performance (empties dcache ASAP) and
> +	 * better fault reporting.
> +	 */
> +	if ((!msg->is_dma_mapped)
> +		&& (atmel_spi_use_dma(as, xfer)	|| as->use_pdc)) {
> +		if (atmel_spi_dma_map_xfer(as, xfer) < 0)
> +			return -ENOMEM;
> +	}

Just a heads up at this point but this is most likely going to be moved
into the core soon.

> +	if (xfer->delay_usecs)
> +		udelay(xfer->delay_usecs);

If you convert to transfer_one() instead of transfer_one_message() then
this will be handled for you.  What you're doing at the minute is still
an improvement so it should be OK but it'd be worth a look.  There will
be further changes in this to factor out the DMA and message push code.

> +	if (xfer->cs_change) {
> +		cs_deactivate(as, msg->spi);
> +		udelay(1);
> +		cs_activate(as, msg->spi);
> +	}

This is buggy, cs_change should flip the polarity of /CS rather than
bounce it on and off except if set on the last transfer in a message in
which case it should cause /CS to remain asserted after the message is
finished.  Again, transfer_one() factors this out - you can at least
look at this to see what should be done.

> +	if (as->stopping)
> +		return -ESHUTDOWN;

You shouldn't need to worry about this, the core should handle this.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140108/aef6145d/attachment.sig>

      parent reply	other threads:[~2014-01-08 13:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-08  5:49 [PATCH] spi: atmel: Refactor spi-atmel to use SPI framework queue Wenyou Yang
2014-01-08 10:25 ` Richard Genoud
2014-01-09  3:53   ` Yang, Wenyou
2014-01-08 13:21 ` Mark Brown [this message]

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=20140108132147.GF31886@sirena.org.uk \
    --to=broonie@kernel.org \
    --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).