mmc: dw_mmc: fix pio mode when internal dmac is enabled
authorHeiko Stuebner <heiko@sntech.de>
Mon, 3 Aug 2015 15:04:10 +0000 (17:04 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 17 Aug 2015 10:44:43 +0000 (12:44 +0200)
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>
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/mmc/host/dw_mmc.c
include/linux/mmc/dw_mmc.h

index 3f070d9f4086f2fe7ec0c2727de16a469575f3df..3c0e1993e737bfa04459eda8ad10429fbbbd45f7 100644 (file)
@@ -2444,19 +2444,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 = DW_MCI_DESC_DATA_LENGTH;
-               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))
index 5be97676f1fa029a9e0b40418bc1c37b83105d44..1d88bf72c65ffc50afdaa23a8b490591c74eed20 100644 (file)
@@ -153,11 +153,7 @@ struct dw_mci {
        dma_addr_t              sg_dma;
        void                    *sg_cpu;
        const struct dw_mci_dma_ops     *dma_ops;
-#ifdef CONFIG_MMC_DW_IDMAC
        unsigned int            ring_size;
-#else
-       struct dw_mci_dma_data  *dma_data;
-#endif
        u32                     cmd_status;
        u32                     data_status;
        u32                     stop_cmdr;
This page took 0.031623 seconds and 5 git commands to generate.