* [PATCH] tmio_mmc_dma: fix PIO fallback on SDHI
@ 2013-08-01 21:17 Sergei Shtylyov
2013-08-01 21:26 ` Sergei Shtylyov
2013-08-02 11:35 ` Guennadi Liakhovetski
0 siblings, 2 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2013-08-01 21:17 UTC (permalink / raw)
To: linux-mmc, g.liakhovetski, ian, cjb; +Cc: linux-sh, max.filippov
I'm testing SH-Mobile SDHI driver in DMA mode with a new DMA controller using
'bonnie++' and getting DMA error after which the tmio_mmc_dma.c code falls back
to PIO but all commands time out after that. It turned out that the fallback
code calls tmio_mmc_enable_dma() with RX/TX channels already freed and pointers
to them cleared, so that the function bails out early instead of clearing the
DMA bit in the CTL_DMA_ENABLE register. Fixing the RX/TX channel check so that
it takes place only when enabling DMA helps with the PIO fallback.
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
---
The patch is against Chris Ball's 'mmc.git' repo, 'master' branch.
drivers/mmc/host/tmio_mmc_dma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: mmc/drivers/mmc/host/tmio_mmc_dma.c
===================================================================
--- mmc.orig/drivers/mmc/host/tmio_mmc_dma.c
+++ mmc/drivers/mmc/host/tmio_mmc_dma.c
@@ -25,7 +25,7 @@
void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
{
- if (!host->chan_tx || !host->chan_rx)
+ if (enable && !(host->chan_tx && host->chan_rx))
return;
#if defined(CONFIG_SUPERH) || defined(CONFIG_ARCH_SHMOBILE)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tmio_mmc_dma: fix PIO fallback on SDHI
2013-08-01 21:17 [PATCH] tmio_mmc_dma: fix PIO fallback on SDHI Sergei Shtylyov
@ 2013-08-01 21:26 ` Sergei Shtylyov
2013-08-02 11:35 ` Guennadi Liakhovetski
1 sibling, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2013-08-01 21:26 UTC (permalink / raw)
To: linux-mmc, g.liakhovetski, ian, cjb; +Cc: linux-sh, max.filippov
Hello.
On 08/02/2013 01:17 AM, Sergei Shtylyov wrote:
> I'm testing SH-Mobile SDHI driver in DMA mode with a new DMA controller using
> 'bonnie++' and getting DMA error after which the tmio_mmc_dma.c code falls back
> to PIO but all commands time out after that. It turned out that the fallback
> code calls tmio_mmc_enable_dma() with RX/TX channels already freed and pointers
> to them cleared, so that the function bails out early instead of clearing the
> DMA bit in the CTL_DMA_ENABLE register. Fixing the RX/TX channel check so that
> it takes place only when enabling DMA helps with the PIO fallback.
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Forgot to mark the patch for stable. The bug was introduced by commit
162f43e31c5a376ec16336e5d0ac973373d54c89 (mmc: tmio: fix a deadlock) back in
2011 -- should probably have mentioned that in the changelog too.
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tmio_mmc_dma: fix PIO fallback on SDHI
2013-08-01 21:17 [PATCH] tmio_mmc_dma: fix PIO fallback on SDHI Sergei Shtylyov
2013-08-01 21:26 ` Sergei Shtylyov
@ 2013-08-02 11:35 ` Guennadi Liakhovetski
2013-08-02 18:10 ` Sergei Shtylyov
1 sibling, 1 reply; 4+ messages in thread
From: Guennadi Liakhovetski @ 2013-08-02 11:35 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: linux-mmc, ian, cjb, linux-sh, max.filippov
Hi Sergei,
Thanks for your patch.
On Fri, 2 Aug 2013, Sergei Shtylyov wrote:
> I'm testing SH-Mobile SDHI driver in DMA mode with a new DMA controller using
> 'bonnie++' and getting DMA error after which the tmio_mmc_dma.c code falls back
> to PIO but all commands time out after that. It turned out that the fallback
> code calls tmio_mmc_enable_dma() with RX/TX channels already freed and pointers
> to them cleared, so that the function bails out early instead of clearing the
> DMA bit in the CTL_DMA_ENABLE register. Fixing the RX/TX channel check so that
> it takes place only when enabling DMA helps with the PIO fallback.
>
> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
>
> ---
> The patch is against Chris Ball's 'mmc.git' repo, 'master' branch.
>
> drivers/mmc/host/tmio_mmc_dma.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Index: mmc/drivers/mmc/host/tmio_mmc_dma.c
> ===================================================================
> --- mmc.orig/drivers/mmc/host/tmio_mmc_dma.c
> +++ mmc/drivers/mmc/host/tmio_mmc_dma.c
> @@ -25,7 +25,7 @@
>
> void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
> {
> - if (!host->chan_tx || !host->chan_rx)
> + if (enable && !(host->chan_tx && host->chan_rx))
> return;
Ok, I see the problem and this does fix it. But it adds complexity to the
driver - one more condition to an if. Whereas, I think, it can be avoided
if we just move calls to
tmio_mmc_enable_dma(host, false);
in tmio_mmc_start_dma_rx() and tmio_mmc_start_dma_tx() a couple of lines
up - before clearing ->chan_rx and ->chan_tx pointers? That should work
too at no cost. I think that would be a better fix, could you, please,
try?
Thanks
Guennadi
> #if defined(CONFIG_SUPERH) || defined(CONFIG_ARCH_SHMOBILE)
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] tmio_mmc_dma: fix PIO fallback on SDHI
2013-08-02 11:35 ` Guennadi Liakhovetski
@ 2013-08-02 18:10 ` Sergei Shtylyov
0 siblings, 0 replies; 4+ messages in thread
From: Sergei Shtylyov @ 2013-08-02 18:10 UTC (permalink / raw)
To: Guennadi Liakhovetski; +Cc: linux-mmc, ian, cjb, linux-sh, max.filippov
On 08/02/2013 03:35 PM, Guennadi Liakhovetski wrote:
>> I'm testing SH-Mobile SDHI driver in DMA mode with a new DMA controller using
>> 'bonnie++' and getting DMA error after which the tmio_mmc_dma.c code falls back
>> to PIO but all commands time out after that. It turned out that the fallback
>> code calls tmio_mmc_enable_dma() with RX/TX channels already freed and pointers
>> to them cleared, so that the function bails out early instead of clearing the
>> DMA bit in the CTL_DMA_ENABLE register. Fixing the RX/TX channel check so that
>> it takes place only when enabling DMA helps with the PIO fallback.
>> Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
>> ---
>> The patch is against Chris Ball's 'mmc.git' repo, 'master' branch.
>> drivers/mmc/host/tmio_mmc_dma.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>> Index: mmc/drivers/mmc/host/tmio_mmc_dma.c
>> ===================================================================
>> --- mmc.orig/drivers/mmc/host/tmio_mmc_dma.c
>> +++ mmc/drivers/mmc/host/tmio_mmc_dma.c
>> @@ -25,7 +25,7 @@
>>
>> void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
>> {
>> - if (!host->chan_tx || !host->chan_rx)
>> + if (enable && !(host->chan_tx && host->chan_rx))
>> return;
> Ok, I see the problem and this does fix it. But it adds complexity to the
> driver - one more condition to an if.
So what?
> Whereas, I think, it can be avoided if we just move calls to
> tmio_mmc_enable_dma(host, false);
> in tmio_mmc_start_dma_rx() and tmio_mmc_start_dma_tx() a couple of lines
Well, not couple. :-P
> up - before clearing ->chan_rx and ->chan_tx pointers? That should work
> too at no cost.
Well, it was my first variant. However, not knowing the hardware well, I
deemed it not quite safe to clear the DMA bit before shutting down the DMA
channels, so came up with the second version (which I consider more logically
correct).
> I think that would be a better fix, could you, please, try?
I tried it but mystically fixing the PIO fallback makes DMA error less
frequent. IIRC, I didn't see DMA error with the first variant of the fix, so
I'll have to retry it...
> Thanks
> Guennadi
WBR, Sergei
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-08-02 18:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-01 21:17 [PATCH] tmio_mmc_dma: fix PIO fallback on SDHI Sergei Shtylyov
2013-08-01 21:26 ` Sergei Shtylyov
2013-08-02 11:35 ` Guennadi Liakhovetski
2013-08-02 18:10 ` Sergei Shtylyov
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).