linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mmc: dw_mmc: fix pio mode when internal dmac is enabled
@ 2015-08-03 15:04 Heiko Stübner
  2015-08-06  1:48 ` Jaehoon Chung
  2015-08-17 10:16 ` Ulf Hansson
  0 siblings, 2 replies; 6+ messages in thread
From: Heiko Stübner @ 2015-08-03 15:04 UTC (permalink / raw)
  To: Seungwon Jeon, Jaehoon Chung, Ulf Hansson; +Cc: linux-mmc, linux-kernel

The dw_mci_init_dma() may decide to not use dma, but pio instead, caused
by things like wrong dma settings in the system.

Till now the code dw_mci_init_slot() always assumed that dma is available
when CONFIG_MMC_DW_IDMAC was defined, ignoring the host->use_dma var
set during dma init.

So when now the dma init failed for whatever reason, the transfer sizes
would still be set for dma transfers, especially including the maximum
block-count calculated from host->ring_size and resulting in a

[    4.991109] ------------[ cut here ]------------
[    4.991111] kernel BUG at drivers/mmc/core/core.c:256!
[    4.991113] Internal error: Oops - BUG: 0 [#1] SMP ARM

because host->ring_size is 0 in this case and the slot init code uses
the wrong code to calculate the values.

Fix this by selecting the correct calculations using the host->use_dma
variable instead of the CONFIG_MMC_DW_IDMAC config option.

Signed-off-by: Heiko Stuebner <heiko@sntech.de>
---
 drivers/mmc/host/dw_mmc.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 40e9d8e..9ec3521 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -2391,19 +2391,20 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
 		mmc->max_seg_size = host->pdata->blk_settings->max_seg_size;
 	} else {
 		/* Useful defaults if platform data is unset. */
-#ifdef CONFIG_MMC_DW_IDMAC
-		mmc->max_segs = host->ring_size;
-		mmc->max_blk_size = 65536;
-		mmc->max_seg_size = 0x1000;
-		mmc->max_req_size = mmc->max_seg_size * host->ring_size;
-		mmc->max_blk_count = mmc->max_req_size / 512;
-#else
-		mmc->max_segs = 64;
-		mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */
-		mmc->max_blk_count = 512;
-		mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
-		mmc->max_seg_size = mmc->max_req_size;
-#endif /* CONFIG_MMC_DW_IDMAC */
+		if (host->use_dma) {
+			mmc->max_segs = host->ring_size;
+			mmc->max_blk_size = 65536;
+			mmc->max_seg_size = 0x1000;
+			mmc->max_req_size = mmc->max_seg_size * host->ring_size;
+			mmc->max_blk_count = mmc->max_req_size / 512;
+		} else {
+			mmc->max_segs = 64;
+			mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */
+			mmc->max_blk_count = 512;
+			mmc->max_req_size = mmc->max_blk_size *
+					    mmc->max_blk_count;
+			mmc->max_seg_size = mmc->max_req_size;
+		}
 	}
 
 	if (dw_mci_get_cd(mmc))
-- 
2.1.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mmc: dw_mmc: fix pio mode when internal dmac is enabled
  2015-08-03 15:04 [PATCH] mmc: dw_mmc: fix pio mode when internal dmac is enabled Heiko Stübner
@ 2015-08-06  1:48 ` Jaehoon Chung
  2015-08-17 10:16 ` Ulf Hansson
  1 sibling, 0 replies; 6+ messages in thread
From: Jaehoon Chung @ 2015-08-06  1:48 UTC (permalink / raw)
  To: Heiko Stübner, Seungwon Jeon, Ulf Hansson; +Cc: linux-mmc, linux-kernel

Hi, Heiko.

Applied this patch at my dw-mmc tree.
I will request pull on this weekend.
Thanks a lot!

Best Regards,
Jaehoon Chung

On 08/04/2015 12:04 AM, Heiko Stübner wrote:
> The dw_mci_init_dma() may decide to not use dma, but pio instead, caused
> by things like wrong dma settings in the system.
> 
> Till now the code dw_mci_init_slot() always assumed that dma is available
> when CONFIG_MMC_DW_IDMAC was defined, ignoring the host->use_dma var
> set during dma init.
> 
> So when now the dma init failed for whatever reason, the transfer sizes
> would still be set for dma transfers, especially including the maximum
> block-count calculated from host->ring_size and resulting in a
> 
> [    4.991109] ------------[ cut here ]------------
> [    4.991111] kernel BUG at drivers/mmc/core/core.c:256!
> [    4.991113] Internal error: Oops - BUG: 0 [#1] SMP ARM
> 
> because host->ring_size is 0 in this case and the slot init code uses
> the wrong code to calculate the values.
> 
> Fix this by selecting the correct calculations using the host->use_dma
> variable instead of the CONFIG_MMC_DW_IDMAC config option.
> 
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
>  drivers/mmc/host/dw_mmc.c | 27 ++++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 40e9d8e..9ec3521 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -2391,19 +2391,20 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
>  		mmc->max_seg_size = host->pdata->blk_settings->max_seg_size;
>  	} else {
>  		/* Useful defaults if platform data is unset. */
> -#ifdef CONFIG_MMC_DW_IDMAC
> -		mmc->max_segs = host->ring_size;
> -		mmc->max_blk_size = 65536;
> -		mmc->max_seg_size = 0x1000;
> -		mmc->max_req_size = mmc->max_seg_size * host->ring_size;
> -		mmc->max_blk_count = mmc->max_req_size / 512;
> -#else
> -		mmc->max_segs = 64;
> -		mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */
> -		mmc->max_blk_count = 512;
> -		mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
> -		mmc->max_seg_size = mmc->max_req_size;
> -#endif /* CONFIG_MMC_DW_IDMAC */
> +		if (host->use_dma) {
> +			mmc->max_segs = host->ring_size;
> +			mmc->max_blk_size = 65536;
> +			mmc->max_seg_size = 0x1000;
> +			mmc->max_req_size = mmc->max_seg_size * host->ring_size;
> +			mmc->max_blk_count = mmc->max_req_size / 512;
> +		} else {
> +			mmc->max_segs = 64;
> +			mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */
> +			mmc->max_blk_count = 512;
> +			mmc->max_req_size = mmc->max_blk_size *
> +					    mmc->max_blk_count;
> +			mmc->max_seg_size = mmc->max_req_size;
> +		}
>  	}
>  
>  	if (dw_mci_get_cd(mmc))
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mmc: dw_mmc: fix pio mode when internal dmac is enabled
  2015-08-03 15:04 [PATCH] mmc: dw_mmc: fix pio mode when internal dmac is enabled Heiko Stübner
  2015-08-06  1:48 ` Jaehoon Chung
@ 2015-08-17 10:16 ` Ulf Hansson
  2015-08-17 10:21   ` Jaehoon Chung
  1 sibling, 1 reply; 6+ messages in thread
From: Ulf Hansson @ 2015-08-17 10:16 UTC (permalink / raw)
  To: Heiko Stübner, Jaehoon Chung; +Cc: Seungwon Jeon, linux-mmc, linux-kernel

On 3 August 2015 at 17:04, Heiko Stübner <heiko@sntech.de> wrote:
> The dw_mci_init_dma() may decide to not use dma, but pio instead, caused
> by things like wrong dma settings in the system.
>
> Till now the code dw_mci_init_slot() always assumed that dma is available
> when CONFIG_MMC_DW_IDMAC was defined, ignoring the host->use_dma var
> set during dma init.
>
> So when now the dma init failed for whatever reason, the transfer sizes
> would still be set for dma transfers, especially including the maximum
> block-count calculated from host->ring_size and resulting in a
>
> [    4.991109] ------------[ cut here ]------------
> [    4.991111] kernel BUG at drivers/mmc/core/core.c:256!
> [    4.991113] Internal error: Oops - BUG: 0 [#1] SMP ARM
>
> because host->ring_size is 0 in this case and the slot init code uses
> the wrong code to calculate the values.
>
> Fix this by selecting the correct calculations using the host->use_dma
> variable instead of the CONFIG_MMC_DW_IDMAC config option.
>
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
>  drivers/mmc/host/dw_mmc.c | 27 ++++++++++++++-------------
>  1 file changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
> index 40e9d8e..9ec3521 100644
> --- a/drivers/mmc/host/dw_mmc.c
> +++ b/drivers/mmc/host/dw_mmc.c
> @@ -2391,19 +2391,20 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
>                 mmc->max_seg_size = host->pdata->blk_settings->max_seg_size;
>         } else {
>                 /* Useful defaults if platform data is unset. */
> -#ifdef CONFIG_MMC_DW_IDMAC
> -               mmc->max_segs = host->ring_size;
> -               mmc->max_blk_size = 65536;
> -               mmc->max_seg_size = 0x1000;
> -               mmc->max_req_size = mmc->max_seg_size * host->ring_size;
> -               mmc->max_blk_count = mmc->max_req_size / 512;
> -#else
> -               mmc->max_segs = 64;
> -               mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */
> -               mmc->max_blk_count = 512;
> -               mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
> -               mmc->max_seg_size = mmc->max_req_size;
> -#endif /* CONFIG_MMC_DW_IDMAC */
> +               if (host->use_dma) {
> +                       mmc->max_segs = host->ring_size;

I expect this may cause a compiler error since host->ring_size is only
available in the struct dw_mci *host when CONFIG_MMC_DW_IDMAC is set.

I have already pulled in this patch from Jaehoon's pull request.
Perhaps I should only amend the patch and change the host->ring_size
to be always available no matter if CONFIG_MMC_DW_IDMAC is set or not?

> +                       mmc->max_blk_size = 65536;
> +                       mmc->max_seg_size = 0x1000;
> +                       mmc->max_req_size = mmc->max_seg_size * host->ring_size;
> +                       mmc->max_blk_count = mmc->max_req_size / 512;
> +               } else {
> +                       mmc->max_segs = 64;
> +                       mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */
> +                       mmc->max_blk_count = 512;
> +                       mmc->max_req_size = mmc->max_blk_size *
> +                                           mmc->max_blk_count;
> +                       mmc->max_seg_size = mmc->max_req_size;
> +               }
>         }
>
>         if (dw_mci_get_cd(mmc))
> --
> 2.1.4
>
>

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mmc: dw_mmc: fix pio mode when internal dmac is enabled
  2015-08-17 10:16 ` Ulf Hansson
@ 2015-08-17 10:21   ` Jaehoon Chung
  2015-08-17 10:34     ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Jaehoon Chung @ 2015-08-17 10:21 UTC (permalink / raw)
  To: Ulf Hansson, Heiko Stübner; +Cc: Seungwon Jeon, linux-mmc, linux-kernel

Hi, Ulf.

On 08/17/2015 07:16 PM, Ulf Hansson wrote:
> On 3 August 2015 at 17:04, Heiko Stübner <heiko@sntech.de> wrote:
>> The dw_mci_init_dma() may decide to not use dma, but pio instead, caused
>> by things like wrong dma settings in the system.
>>
>> Till now the code dw_mci_init_slot() always assumed that dma is available
>> when CONFIG_MMC_DW_IDMAC was defined, ignoring the host->use_dma var
>> set during dma init.
>>
>> So when now the dma init failed for whatever reason, the transfer sizes
>> would still be set for dma transfers, especially including the maximum
>> block-count calculated from host->ring_size and resulting in a
>>
>> [    4.991109] ------------[ cut here ]------------
>> [    4.991111] kernel BUG at drivers/mmc/core/core.c:256!
>> [    4.991113] Internal error: Oops - BUG: 0 [#1] SMP ARM
>>
>> because host->ring_size is 0 in this case and the slot init code uses
>> the wrong code to calculate the values.
>>
>> Fix this by selecting the correct calculations using the host->use_dma
>> variable instead of the CONFIG_MMC_DW_IDMAC config option.
>>
>> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
>> ---
>>  drivers/mmc/host/dw_mmc.c | 27 ++++++++++++++-------------
>>  1 file changed, 14 insertions(+), 13 deletions(-)
>>
>> diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
>> index 40e9d8e..9ec3521 100644
>> --- a/drivers/mmc/host/dw_mmc.c
>> +++ b/drivers/mmc/host/dw_mmc.c
>> @@ -2391,19 +2391,20 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)
>>                 mmc->max_seg_size = host->pdata->blk_settings->max_seg_size;
>>         } else {
>>                 /* Useful defaults if platform data is unset. */
>> -#ifdef CONFIG_MMC_DW_IDMAC
>> -               mmc->max_segs = host->ring_size;
>> -               mmc->max_blk_size = 65536;
>> -               mmc->max_seg_size = 0x1000;
>> -               mmc->max_req_size = mmc->max_seg_size * host->ring_size;
>> -               mmc->max_blk_count = mmc->max_req_size / 512;
>> -#else
>> -               mmc->max_segs = 64;
>> -               mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */
>> -               mmc->max_blk_count = 512;
>> -               mmc->max_req_size = mmc->max_blk_size * mmc->max_blk_count;
>> -               mmc->max_seg_size = mmc->max_req_size;
>> -#endif /* CONFIG_MMC_DW_IDMAC */
>> +               if (host->use_dma) {
>> +                       mmc->max_segs = host->ring_size;
> 
> I expect this may cause a compiler error since host->ring_size is only
> available in the struct dw_mci *host when CONFIG_MMC_DW_IDMAC is set.
> 
> I have already pulled in this patch from Jaehoon's pull request.
> Perhaps I should only amend the patch and change the host->ring_size
> to be always available no matter if CONFIG_MMC_DW_IDMAC is set or not?

Sorry for this. if you can, i think good that CONFIG_MMC_DW_IDMAC is removed at struct dw_mci.
Could you amend it?
If you want to get patch, i will send patch at now.

Best Regards,
Jaehoon Chung
> 
>> +                       mmc->max_blk_size = 65536;
>> +                       mmc->max_seg_size = 0x1000;
>> +                       mmc->max_req_size = mmc->max_seg_size * host->ring_size;
>> +                       mmc->max_blk_count = mmc->max_req_size / 512;
>> +               } else {
>> +                       mmc->max_segs = 64;
>> +                       mmc->max_blk_size = 65536; /* BLKSIZ is 16 bits */
>> +                       mmc->max_blk_count = 512;
>> +                       mmc->max_req_size = mmc->max_blk_size *
>> +                                           mmc->max_blk_count;
>> +                       mmc->max_seg_size = mmc->max_req_size;
>> +               }
>>         }
>>
>>         if (dw_mci_get_cd(mmc))
>> --
>> 2.1.4
>>
>>
> 
> Kind regards
> Uffe
> 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mmc: dw_mmc: fix pio mode when internal dmac is enabled
  2015-08-17 10:21   ` Jaehoon Chung
@ 2015-08-17 10:34     ` Ulf Hansson
  2015-08-17 10:37       ` Heiko Stuebner
  0 siblings, 1 reply; 6+ messages in thread
From: Ulf Hansson @ 2015-08-17 10:34 UTC (permalink / raw)
  To: Jaehoon Chung; +Cc: Heiko Stübner, Seungwon Jeon, linux-mmc, linux-kernel

[...]

>>> -               mmc->max_seg_size = mmc->max_req_size;
>>> -#endif /* CONFIG_MMC_DW_IDMAC */
>>> +               if (host->use_dma) {
>>> +                       mmc->max_segs = host->ring_size;
>>
>> I expect this may cause a compiler error since host->ring_size is only
>> available in the struct dw_mci *host when CONFIG_MMC_DW_IDMAC is set.
>>
>> I have already pulled in this patch from Jaehoon's pull request.
>> Perhaps I should only amend the patch and change the host->ring_size
>> to be always available no matter if CONFIG_MMC_DW_IDMAC is set or not?
>
> Sorry for this. if you can, i think good that CONFIG_MMC_DW_IDMAC is removed at struct dw_mci.
> Could you amend it?
> If you want to get patch, i will send patch at now.

No worries, I amend the patch myself.

Kind regards
Uffe

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mmc: dw_mmc: fix pio mode when internal dmac is enabled
  2015-08-17 10:34     ` Ulf Hansson
@ 2015-08-17 10:37       ` Heiko Stuebner
  0 siblings, 0 replies; 6+ messages in thread
From: Heiko Stuebner @ 2015-08-17 10:37 UTC (permalink / raw)
  To: Ulf Hansson; +Cc: Jaehoon Chung, Seungwon Jeon, linux-mmc, linux-kernel

Am Montag, 17. August 2015, 12:34:09 schrieb Ulf Hansson:
> [...]
> 
> >>> -               mmc->max_seg_size = mmc->max_req_size;
> >>> -#endif /* CONFIG_MMC_DW_IDMAC */
> >>> +               if (host->use_dma) {
> >>> +                       mmc->max_segs = host->ring_size;
> >> 
> >> I expect this may cause a compiler error since host->ring_size is only
> >> available in the struct dw_mci *host when CONFIG_MMC_DW_IDMAC is set.
> >> 
> >> I have already pulled in this patch from Jaehoon's pull request.
> >> Perhaps I should only amend the patch and change the host->ring_size
> >> to be always available no matter if CONFIG_MMC_DW_IDMAC is set or not?
> > 
> > Sorry for this. if you can, i think good that CONFIG_MMC_DW_IDMAC is
> > removed at struct dw_mci. Could you amend it?
> > If you want to get patch, i will send patch at now.
> 
> No worries, I amend the patch myself.

thanks and sorry for missing that bit.


Heiko

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-17 10:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-03 15:04 [PATCH] mmc: dw_mmc: fix pio mode when internal dmac is enabled Heiko Stübner
2015-08-06  1:48 ` Jaehoon Chung
2015-08-17 10:16 ` Ulf Hansson
2015-08-17 10:21   ` Jaehoon Chung
2015-08-17 10:34     ` Ulf Hansson
2015-08-17 10:37       ` Heiko Stuebner

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).