From: Brian Norris <briannorris-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Shawn Lin <shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Cc: Mark Brown <broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
Heiko Stuebner <heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org>,
Tomeu Vizoso
<tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Eddie Cai <eddie.cai-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
Brian Norris
<computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
Caesar Wang <wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.org>,
hhb-TNX95d0MmH7DzftRWevZcw@public.gmane.org
Subject: Re: [PATCH] spi: rockchip: limit transfers to (64K - 1) bytes
Date: Thu, 14 Jul 2016 19:31:52 -0700 [thread overview]
Message-ID: <20160715023152.GA145248@google.com> (raw)
In-Reply-To: <131afa39-4287-0fb8-61f4-146283dc7cf0-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
Hi Shawn,
On Fri, Jul 15, 2016 at 09:56:59AM +0800, Shawn Lin wrote:
> 在 2016/7/15 9:30, Brian Norris 写道:
> >The Rockchip SPI controller's length register only supports 16-bits,
> >yielding a maximum length of 64KiB (the CTRLR1 register holds "length -
> >1"). Trying to transfer more than that (e.g., with a large SPI flash
> >read) will cause the driver to hang.
>
> Brian, are you using dma or pio?
I forgot to mention, I'm using PIO. (The rk3399.dts in linux-next
doesn't even have the 'dma{s,-names}' properties listed for spi[0-5].)
> From huibing's feedback for rk3399, you can see...
>
> root@rk3399:/ # echo read 0 1 0x10001 > /sys/slt/SPI.0/SPI.0
I don't know what that file is, but presumably it's some kind of bare
SPI test interface you have in your private tree?
> [148360.004332] f0041200: DMAMOV CCR 0x804200
> [148360.004772] f0041206: DMAMOV SAR 0xff1d0800
> [148360.005161] f004120c: DMAMOV DAR 0xc9f60000
> [148360.005549] f0041212: DMALP_0 255
> [148360.005866] f0041214: DMALP_1 255
> [148360.006178] f0041216: DMAWFPB 13
> [148360.006483] f0041218: DMALDPB 13
> [148360.006788] f004121a: DMASTA
> [148360.007061] f004121b: DMAFLUSHP 13
> [148360.007380] f004121d: DMALPENDA_1 bjmpto_7
> [148360.007763] f004121f: DMALPENDA_0 bjmpto_b
> [148360.008144] f0041221: DMAWFPB 13
> [148360.008448] f0041223: DMALDPB 13
> [148360.008752] f0041225: DMASTA
> [148360.009026] f0041226: DMAFLUSHP 13
> [148360.009344] f0041228: DMASEV 1
> [148360.009633] f004122a: DMAEND
> [148360.147993] slt_spi_test spi32766.0: SPI transfer timed out
> [148360.148653] spi read 65537*1 cost 144493us speed:453KB/S
And this means a 64KiB + 1 transfer using DMA timed out?
> root@rk3399:/ #
> root@rk3399:/ # echo read 0 1 0x10000 > /sys/slt/SPI.0/SPI.0
>
> [148365.172429] f0041200: DMAMOV CCR 0x804200
> [148365.172863] f0041206: DMAMOV SAR 0xff1d0800
> [148365.173252] f004120c: DMAMOV DAR 0xc9f90000
> [148365.173641] f0041212: DMALP_0 255
> [148365.173958] f0041214: DMALP_1 255
> [148365.174270] f0041216: DMAWFPB 13
> [148365.174574] f0041218: DMALDPB 13
> [148365.174878] f004121a: DMASTA
> [148365.175152] f004121b: DMAFLUSHP 13
> [148365.175471] f004121d: DMALPENDA_1 bjmpto_7
> [148365.175852] f004121f: DMALPENDA_0 bjmpto_b
> [148365.176234] f0041221: DMASEV 1
> [148365.176522] f0041223: DMAEND
> [148365.207421] spi read 65536*1 cost 35144us speed:1864KB/S
And a 64KiB transfer using DMA completed successfully?
So maybe there's a driver bug in the PIO path that gives us an
off-by-one error. I poked around a bit and couldn't figure out anything,
so I sent this. Technically, this patch is still valid (even if not
optimal) for the DMA case too...
If you can't figure out what the difference is, and you really don't
want to unnecessarily limit the DMA case, then a last resort hack could
be to say:
static size_t rockchip_spi_max_transfer_size(struct spi_device *device)
{
if (using dma) // this is obviously pseudocode
return SZ_64K;
else
return SZ_64K - 1;
}
or something like that.
Brian
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2016-07-15 2:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-15 1:30 [PATCH] spi: rockchip: limit transfers to (64K - 1) bytes Brian Norris
[not found] ` <1468546259-136659-1-git-send-email-briannorris-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2016-07-15 1:56 ` Shawn Lin
[not found] ` <131afa39-4287-0fb8-61f4-146283dc7cf0-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-07-15 2:31 ` Brian Norris [this message]
2016-07-15 2:42 ` Shawn Lin
[not found] ` <b855036c-86b3-3515-86ae-24de820564ff-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2016-07-15 3:09 ` Brian Norris
2016-07-20 16:44 ` Applied "spi: rockchip: limit transfers to (64K - 1) bytes" to the spi tree Mark Brown
2016-07-20 17:01 ` Brian Norris
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=20160715023152.GA145248@google.com \
--to=briannorris-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=computersforpeace-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=eddie.cai-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=heiko-4mtYJXux2i+zQB+pC5nmwQ@public.gmane.org \
--cc=hhb-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rockchip-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=shawn.lin-TNX95d0MmH7DzftRWevZcw@public.gmane.org \
--cc=tomeu.vizoso-ZGY8ohtN/8qB+jHODAdFcQ@public.gmane.org \
--cc=wxt-TNX95d0MmH7DzftRWevZcw@public.gmane.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).