From: Frode Isaksen <fisaksen-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
To: Sekhar Nori <nsekhar-l0cyMroinI0@public.gmane.org>,
khilman-rdvid1DuHRBWk0Htik3J/w@public.gmane.org,
ptitiano-rdvid1DuHRBWk0Htik3J/w@public.gmane.org,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Peter Ujfalusi <peter.ujfalusi-l0cyMroinI0@public.gmane.org>
Subject: Re: [PATCH 3/8] spi: davinci: limit the transfer size if DMA enabled
Date: Tue, 14 Feb 2017 17:40:11 +0100 [thread overview]
Message-ID: <bc92a0b1-7d21-cd66-94e5-a09b35d251cb@baylibre.com> (raw)
In-Reply-To: <c0d6c236-1302-e910-8c41-cd82e0fac39b-l0cyMroinI0@public.gmane.org>
On 14/02/2017 16:29, Sekhar Nori wrote:
> On Tuesday 14 February 2017 04:57 PM, Frode Isaksen wrote:
>>
>> On 13/02/2017 06:59, Sekhar Nori wrote:
>>> + Peter
>>>
>>> On Friday 10 February 2017 08:59 PM, Frode Isaksen wrote:
>>>> Limit the transfer size to 20 scatter/gather pages if
>>>> DMA is enabled.
>>>> The eDMA DMA engine is limited to 20 SG entries in one DMA
>>>> transaction. If this number is exceeded, DMA receive fails.
>>>> This error occurs with large vmalloc'ed buffers.
>>> This needs more explanation because there is support available in edma
>>> driver for long SG lists by breaking them down into transfers using 20
>>> PaRAM entries at a time. If thats not working for you, that needs
>>> further debug.
>> The SPI controller has a FIFO of only 1 word, so at 1Mbps, filling the
>> FIFO will take only 8us. Handling the DMA interrupt and re-programming
>> the PaRAM entries takes much longer than that. At 1Mbps, about 50 bytes
>> is lost on Rx, @ 2Mbps 100 bytes and @ 5Mbps about 260 bytes hinting
>> towards a time setting up a new DMA transfer > 400us. If the Tx and Rx
>> buffers are identically aligned there are no errors, because the
>> re-programming of the Tx and Rx PaRAM entries happens at the same time.
>> I have also verified this with a scope. In the Tx direction, there is a
>> pause in the transfer of 600us after the 20th SG entrey (when setting up
>> new PaRAM entries). Since setting up Rx PaRAM is identical, this shows
>> that breaking down the transfer is not working in the Rx direction for
>> SPI caused by the relative high bit rate and small FIFO.
> SPI is synchronous transfer so it does not need a large FIFO. If DMA is
> not able to replenish the TX shift register, the master should hold the
> clock until the time it is ready with data. On the scope do you see
> master continuing to pulse the clock while it is waiting for data to
> arrive from DMA to its TX shift register ? That should not be happening.
Take the example of a long Rx-only transfer using vmalloc'ed buffer. The
dummy Tx buffer will be a contiguous buffer (1 SG entry) and clock and
dummy data will be continuous during the transfer with no pause. On the
Rx side, the PaRAM entries needs to be reloaded after 20*4096 bytes
Rx'ed. Handling the interrupt, reloading the PaRAM's and resuming DMA
takes ~600 us. Since the slave is still transmitting, data will be lost,
since the FIFO is only 1 word and 1 byte takes 8us @ 1MHz.
The 600us came from timing a transmit with vmalloc'ed buffer. The time
between the last byte in the 20th SG entry and the next byte is 600us
measured with a scope. The assumption is that handling interrupt and
reloading PaRAM's is more or less the same on Tx and Rx side. This time
seems to be confirmed by the number of bytes lost on the Rx side as well
which is approximately 50 x XMHz.
Hope this clarifies..
Another solution to this would be to have the dummy Tx buffer and Rx
buffer to be identical (same type of allocation, same length, same
offset), but this requires changes in the SPI framework.
Thanks,
Frode
Thanks,
Frode
>
> Thanks,
> Sekhar
--
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:[~2017-02-14 16:40 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-10 15:29 Enable DMA for daVinci SPI controller Frode Isaksen
2017-02-10 15:29 ` [PATCH 1/8] spi: davinci: Use SPI framework to handle DMA mapping Frode Isaksen
[not found] ` <1486740584-17875-2-git-send-email-fisaksen-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2017-02-13 11:30 ` Mark Brown
[not found] ` <1486740584-17875-1-git-send-email-fisaksen-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2017-02-10 15:29 ` [PATCH 2/8] spi: davinci: enable DMA when channels are defined in DT Frode Isaksen
[not found] ` <1486740584-17875-3-git-send-email-fisaksen-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2017-02-13 11:32 ` Mark Brown
2017-02-10 15:29 ` [PATCH 3/8] spi: davinci: limit the transfer size if DMA enabled Frode Isaksen
[not found] ` <1486740584-17875-4-git-send-email-fisaksen-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
2017-02-10 19:07 ` Kevin Hilman
2017-02-13 5:59 ` Sekhar Nori
2017-02-14 11:27 ` Frode Isaksen
2017-02-14 15:29 ` Sekhar Nori
[not found] ` <c0d6c236-1302-e910-8c41-cd82e0fac39b-l0cyMroinI0@public.gmane.org>
2017-02-14 16:40 ` Frode Isaksen [this message]
2017-03-21 22:02 ` Peter Ujfalusi
[not found] ` <b4d8bd90-cd33-560f-5102-20c2375dac70-l0cyMroinI0@public.gmane.org>
2017-03-22 11:11 ` Frode Isaksen
2017-03-22 11:35 ` Sekhar Nori
[not found] ` <95c7bc96-2de9-043d-880e-4de9f0b2308a-l0cyMroinI0@public.gmane.org>
2017-03-22 12:20 ` Peter Ujfalusi
[not found] ` <c85c9e88-c40b-88b3-f47d-6d5f5cc1fa00-l0cyMroinI0@public.gmane.org>
2017-03-22 13:30 ` Frode Isaksen
2017-02-10 15:29 ` [PATCH 4/8] spi: davinci: flush caches when performing DMA Frode Isaksen
2017-02-10 15:29 ` [PATCH 5/8] spi: davinci: do not use DMA if transfer length is less than 16 Frode Isaksen
2017-02-10 15:29 ` [PATCH 6/8] spi: loopback-test: set HW loopback mode if loopback set Frode Isaksen
2017-02-10 15:29 ` [PATCH 7/8] spi: loopback-test: add option to use vmalloc'ed buffers Frode Isaksen
2017-02-10 15:29 ` [PATCH 8/8] spi: loopback-test: limit length to spi_max_transfer_size() Frode Isaksen
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=bc92a0b1-7d21-cd66-94e5-a09b35d251cb@baylibre.com \
--to=fisaksen-rdvid1duhrbwk0htik3j/w@public.gmane.org \
--cc=broonie-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
--cc=khilman-rdvid1DuHRBWk0Htik3J/w@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nsekhar-l0cyMroinI0@public.gmane.org \
--cc=peter.ujfalusi-l0cyMroinI0@public.gmane.org \
--cc=ptitiano-rdvid1DuHRBWk0Htik3J/w@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).