diff mbox

mmc: dw_mmc: fix the error handling for dma operation

Message ID 20161117075347.9061-1-jh80.chung@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jaehoon Chung Nov. 17, 2016, 7:53 a.m. UTC
When OWN bit of dma descriptor is not cleared, then it returns -EINVAL.
Then it has to fall back to PIO mode for current transfer.

Host controller was already set to bits relevant to DMA operation.
If needs to use the PIO mode, Host controller has to stop the DMA
operation. (It's more stable than now.)

When it occurred error, it's not running any request.

Fixes: 3b2a067b98b4 ("mmc: dw_mmc: avoid race condition of cpu and IDMAC")

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
---
 drivers/mmc/host/dw_mmc.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Shawn Lin Nov. 17, 2016, 8:08 a.m. UTC | #1
Hi Jaehoon,

在 2016/11/17 15:53, Jaehoon Chung 写道:
> When OWN bit of dma descriptor is not cleared, then it returns -EINVAL.
> Then it has to fall back to PIO mode for current transfer.
>
> Host controller was already set to bits relevant to DMA operation.
> If needs to use the PIO mode, Host controller has to stop the DMA
> operation. (It's more stable than now.)
>

It looks good to me, but

> When it occurred error, it's not running any request.
>
> Fixes: 3b2a067b98b4 ("mmc: dw_mmc: avoid race condition of cpu and IDMAC")
>

I think the real fixes tag should indicate the another commit,
3fc7eaef44dbcbcd60 ("mmc: dw_mmc: Add external dma interface support")

otherwise,

Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>

> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
> ---
>  drivers/mmc/host/dw_mmc.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 9341b18..080003b 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -1058,6 +1058,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
>  	spin_unlock_irqrestore(&host->irq_lock, irqflags);
>
>  	if (host->dma_ops->start(host, sg_len)) {
> +		host->dma_ops->stop(host);
>  		/* We can't do DMA, try PIO for this one */
>  		dev_dbg(host->dev,
>  			"%s: fall back to PIO mode for current transfer\n",
>
Jaehoon Chung Nov. 17, 2016, 8:25 a.m. UTC | #2
On 11/17/2016 05:08 PM, Shawn Lin wrote:
> Hi Jaehoon,
> 
> 在 2016/11/17 15:53, Jaehoon Chung 写道:
>> When OWN bit of dma descriptor is not cleared, then it returns -EINVAL.
>> Then it has to fall back to PIO mode for current transfer.
>>
>> Host controller was already set to bits relevant to DMA operation.
>> If needs to use the PIO mode, Host controller has to stop the DMA
>> operation. (It's more stable than now.)
>>
> 
> It looks good to me, but
> 
>> When it occurred error, it's not running any request.
>>
>> Fixes: 3b2a067b98b4 ("mmc: dw_mmc: avoid race condition of cpu and IDMAC")
>>
> 
> I think the real fixes tag should indicate the another commit,
> 3fc7eaef44dbcbcd60 ("mmc: dw_mmc: Add external dma interface support")

You're right. 
But my main problem is "checking OWN bit".  Thanks for noticing this commit. :)
Some time..OWN bit is never released.. 

Best Regards,
Jaehoon Chung

> 
> otherwise,
> 
> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
> 
>> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
>> ---
>>  drivers/mmc/host/dw_mmc.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
>> index 9341b18..080003b 100644
>> --- a/drivers/mmc/host/dw_mmc.c
>> +++ b/drivers/mmc/host/dw_mmc.c
>> @@ -1058,6 +1058,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
>>      spin_unlock_irqrestore(&host->irq_lock, irqflags);
>>
>>      if (host->dma_ops->start(host, sg_len)) {
>> +        host->dma_ops->stop(host);
>>          /* We can't do DMA, try PIO for this one */
>>          dev_dbg(host->dev,
>>              "%s: fall back to PIO mode for current transfer\n",
>>
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jaehoon Chung Nov. 18, 2016, 7:15 a.m. UTC | #3
Hi Shawn,

On 11/17/2016 05:25 PM, Jaehoon Chung wrote:
> On 11/17/2016 05:08 PM, Shawn Lin wrote:
>> Hi Jaehoon,
>>
>> 在 2016/11/17 15:53, Jaehoon Chung 写道:
>>> When OWN bit of dma descriptor is not cleared, then it returns -EINVAL.
>>> Then it has to fall back to PIO mode for current transfer.
>>>
>>> Host controller was already set to bits relevant to DMA operation.
>>> If needs to use the PIO mode, Host controller has to stop the DMA
>>> operation. (It's more stable than now.)
>>>
>>
>> It looks good to me, but
>>
>>> When it occurred error, it's not running any request.
>>>
>>> Fixes: 3b2a067b98b4 ("mmc: dw_mmc: avoid race condition of cpu and IDMAC")
>>>
>>
>> I think the real fixes tag should indicate the another commit,
>> 3fc7eaef44dbcbcd60 ("mmc: dw_mmc: Add external dma interface support")
> 
> You're right. 
> But my main problem is "checking OWN bit".  Thanks for noticing this commit. :)
> Some time..OWN bit is never released.. 

I think your the suggested commit is more correct than me.
After modifying fixes commit ID, then will apply. Thanks!

Best Regards,
Jaehoon Chung

> 
> Best Regards,
> Jaehoon Chung
> 
>>
>> otherwise,
>>
>> Reviewed-by: Shawn Lin <shawn.lin@rock-chips.com>
>>
>>> Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
>>> ---
>>>  drivers/mmc/host/dw_mmc.c | 1 +
>>>  1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
>>> index 9341b18..080003b 100644
>>> --- a/drivers/mmc/host/dw_mmc.c
>>> +++ b/drivers/mmc/host/dw_mmc.c
>>> @@ -1058,6 +1058,7 @@ static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
>>>      spin_unlock_irqrestore(&host->irq_lock, irqflags);
>>>
>>>      if (host->dma_ops->start(host, sg_len)) {
>>> +        host->dma_ops->stop(host);
>>>          /* We can't do DMA, try PIO for this one */
>>>          dev_dbg(host->dev,
>>>              "%s: fall back to PIO mode for current transfer\n",
>>>
>>
>>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
> 
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 9341b18..080003b 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1058,6 +1058,7 @@  static int dw_mci_submit_data_dma(struct dw_mci *host, struct mmc_data *data)
 	spin_unlock_irqrestore(&host->irq_lock, irqflags);
 
 	if (host->dma_ops->start(host, sg_len)) {
+		host->dma_ops->stop(host);
 		/* We can't do DMA, try PIO for this one */
 		dev_dbg(host->dev,
 			"%s: fall back to PIO mode for current transfer\n",