aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2016-02-12 12:48:55 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2016-02-12 12:48:55 -0500
commit5952cc779eba58e9c3e0280cb646683e6de4b799 (patch)
tree55548a0f5abbe4c4126b78f8e6c180c4f71731f5
parent0df34ad9b703222ead899465b054070758b317f1 (diff)
parenta5ebb87db84392edfd3142c3a6a78431d820a789 (diff)
Merge tag 'mmc-v4.5-rc2' of git://git.linaro.org/people/ulf.hansson/mmc
Pull MMC fixes from Ulf Hansson: "Here are some mmc fixes intended for v4.5 rc4. MMC core: - Fix an sysfs ABI regression - Return an error in a specific error path dealing with mmc ioctls MMC host: - sdhci-pci|acpi: Fix card detect race for Intel BXT/APL - sh_mmcif: Correct TX DMA channel allocation - mmc_spi: Fix error handling for dma mapping errors - sdhci-of-at91: Fix an unbalance issue for the runtime PM usage count - pxamci: Fix the device-tree probe deferral path - pxamci: Fix read-only GPIO polarity" * tag 'mmc-v4.5-rc2' of git://git.linaro.org/people/ulf.hansson/mmc: Revert "mmc: block: don't use parameter prefix if built as module" mmc: sdhci-acpi: Fix card detect race for Intel BXT/APL mmc: sdhci-pci: Fix card detect race for Intel BXT/APL mmc: sdhci: Allow override of get_cd() called from sdhci_request() mmc: sdhci: Allow override of mmc host operations mmc: sh_mmcif: Correct TX DMA channel allocation mmc: block: return error on failed mmc_blk_get() mmc: pxamci: fix the device-tree probe deferral path mmc: mmc_spi: add checks for dma mapping error mmc: sdhci-of-at91: fix pm runtime unbalanced issue in error path mmc: pxamci: fix again read-only gpio detection polarity
-rw-r--r--drivers/mmc/card/block.c7
-rw-r--r--drivers/mmc/host/mmc_spi.c15
-rw-r--r--drivers/mmc/host/pxamci.c37
-rw-r--r--drivers/mmc/host/sdhci-acpi.c30
-rw-r--r--drivers/mmc/host/sdhci-of-at91.c1
-rw-r--r--drivers/mmc/host/sdhci-pci-core.c31
-rw-r--r--drivers/mmc/host/sdhci.c5
-rw-r--r--drivers/mmc/host/sdhci.h1
-rw-r--r--drivers/mmc/host/sh_mmcif.c2
9 files changed, 93 insertions, 36 deletions
diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 5914263090fc..fe207e542032 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -47,13 +47,10 @@
47#include "queue.h" 47#include "queue.h"
48 48
49MODULE_ALIAS("mmc:block"); 49MODULE_ALIAS("mmc:block");
50
51#ifdef KERNEL
52#ifdef MODULE_PARAM_PREFIX 50#ifdef MODULE_PARAM_PREFIX
53#undef MODULE_PARAM_PREFIX 51#undef MODULE_PARAM_PREFIX
54#endif 52#endif
55#define MODULE_PARAM_PREFIX "mmcblk." 53#define MODULE_PARAM_PREFIX "mmcblk."
56#endif
57 54
58#define INAND_CMD38_ARG_EXT_CSD 113 55#define INAND_CMD38_ARG_EXT_CSD 113
59#define INAND_CMD38_ARG_ERASE 0x00 56#define INAND_CMD38_ARG_ERASE 0x00
@@ -655,8 +652,10 @@ static int mmc_blk_ioctl_multi_cmd(struct block_device *bdev,
655 } 652 }
656 653
657 md = mmc_blk_get(bdev->bd_disk); 654 md = mmc_blk_get(bdev->bd_disk);
658 if (!md) 655 if (!md) {
656 err = -EINVAL;
659 goto cmd_err; 657 goto cmd_err;
658 }
660 659
661 card = md->queue.card; 660 card = md->queue.card;
662 if (IS_ERR(card)) { 661 if (IS_ERR(card)) {
diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 1c1b45ef3faf..3446097a43c0 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -925,6 +925,10 @@ mmc_spi_data_do(struct mmc_spi_host *host, struct mmc_command *cmd,
925 925
926 dma_addr = dma_map_page(dma_dev, sg_page(sg), 0, 926 dma_addr = dma_map_page(dma_dev, sg_page(sg), 0,
927 PAGE_SIZE, dir); 927 PAGE_SIZE, dir);
928 if (dma_mapping_error(dma_dev, dma_addr)) {
929 data->error = -EFAULT;
930 break;
931 }
928 if (direction == DMA_TO_DEVICE) 932 if (direction == DMA_TO_DEVICE)
929 t->tx_dma = dma_addr + sg->offset; 933 t->tx_dma = dma_addr + sg->offset;
930 else 934 else
@@ -1393,10 +1397,12 @@ static int mmc_spi_probe(struct spi_device *spi)
1393 host->dma_dev = dev; 1397 host->dma_dev = dev;
1394 host->ones_dma = dma_map_single(dev, ones, 1398 host->ones_dma = dma_map_single(dev, ones,
1395 MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE); 1399 MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE);
1400 if (dma_mapping_error(dev, host->ones_dma))
1401 goto fail_ones_dma;
1396 host->data_dma = dma_map_single(dev, host->data, 1402 host->data_dma = dma_map_single(dev, host->data,
1397 sizeof(*host->data), DMA_BIDIRECTIONAL); 1403 sizeof(*host->data), DMA_BIDIRECTIONAL);
1398 1404 if (dma_mapping_error(dev, host->data_dma))
1399 /* REVISIT in theory those map operations can fail... */ 1405 goto fail_data_dma;
1400 1406
1401 dma_sync_single_for_cpu(host->dma_dev, 1407 dma_sync_single_for_cpu(host->dma_dev,
1402 host->data_dma, sizeof(*host->data), 1408 host->data_dma, sizeof(*host->data),
@@ -1462,6 +1468,11 @@ fail_glue_init:
1462 if (host->dma_dev) 1468 if (host->dma_dev)
1463 dma_unmap_single(host->dma_dev, host->data_dma, 1469 dma_unmap_single(host->dma_dev, host->data_dma,
1464 sizeof(*host->data), DMA_BIDIRECTIONAL); 1470 sizeof(*host->data), DMA_BIDIRECTIONAL);
1471fail_data_dma:
1472 if (host->dma_dev)
1473 dma_unmap_single(host->dma_dev, host->ones_dma,
1474 MMC_SPI_BLOCKSIZE, DMA_TO_DEVICE);
1475fail_ones_dma:
1465 kfree(host->data); 1476 kfree(host->data);
1466 1477
1467fail_nobuf1: 1478fail_nobuf1:
diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c
index ce08896b9d69..da824772bbb4 100644
--- a/drivers/mmc/host/pxamci.c
+++ b/drivers/mmc/host/pxamci.c
@@ -86,7 +86,7 @@ struct pxamci_host {
86static inline void pxamci_init_ocr(struct pxamci_host *host) 86static inline void pxamci_init_ocr(struct pxamci_host *host)
87{ 87{
88#ifdef CONFIG_REGULATOR 88#ifdef CONFIG_REGULATOR
89 host->vcc = regulator_get_optional(mmc_dev(host->mmc), "vmmc"); 89 host->vcc = devm_regulator_get_optional(mmc_dev(host->mmc), "vmmc");
90 90
91 if (IS_ERR(host->vcc)) 91 if (IS_ERR(host->vcc))
92 host->vcc = NULL; 92 host->vcc = NULL;
@@ -654,12 +654,8 @@ static int pxamci_probe(struct platform_device *pdev)
654 654
655 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 655 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
656 irq = platform_get_irq(pdev, 0); 656 irq = platform_get_irq(pdev, 0);
657 if (!r || irq < 0) 657 if (irq < 0)
658 return -ENXIO; 658 return irq;
659
660 r = request_mem_region(r->start, SZ_4K, DRIVER_NAME);
661 if (!r)
662 return -EBUSY;
663 659
664 mmc = mmc_alloc_host(sizeof(struct pxamci_host), &pdev->dev); 660 mmc = mmc_alloc_host(sizeof(struct pxamci_host), &pdev->dev);
665 if (!mmc) { 661 if (!mmc) {
@@ -695,7 +691,7 @@ static int pxamci_probe(struct platform_device *pdev)
695 host->pdata = pdev->dev.platform_data; 691 host->pdata = pdev->dev.platform_data;
696 host->clkrt = CLKRT_OFF; 692 host->clkrt = CLKRT_OFF;
697 693
698 host->clk = clk_get(&pdev->dev, NULL); 694 host->clk = devm_clk_get(&pdev->dev, NULL);
699 if (IS_ERR(host->clk)) { 695 if (IS_ERR(host->clk)) {
700 ret = PTR_ERR(host->clk); 696 ret = PTR_ERR(host->clk);
701 host->clk = NULL; 697 host->clk = NULL;
@@ -727,9 +723,9 @@ static int pxamci_probe(struct platform_device *pdev)
727 host->irq = irq; 723 host->irq = irq;
728 host->imask = MMC_I_MASK_ALL; 724 host->imask = MMC_I_MASK_ALL;
729 725
730 host->base = ioremap(r->start, SZ_4K); 726 host->base = devm_ioremap_resource(&pdev->dev, r);
731 if (!host->base) { 727 if (IS_ERR(host->base)) {
732 ret = -ENOMEM; 728 ret = PTR_ERR(host->base);
733 goto out; 729 goto out;
734 } 730 }
735 731
@@ -742,7 +738,8 @@ static int pxamci_probe(struct platform_device *pdev)
742 writel(64, host->base + MMC_RESTO); 738 writel(64, host->base + MMC_RESTO);
743 writel(host->imask, host->base + MMC_I_MASK); 739 writel(host->imask, host->base + MMC_I_MASK);
744 740
745 ret = request_irq(host->irq, pxamci_irq, 0, DRIVER_NAME, host); 741 ret = devm_request_irq(&pdev->dev, host->irq, pxamci_irq, 0,
742 DRIVER_NAME, host);
746 if (ret) 743 if (ret)
747 goto out; 744 goto out;
748 745
@@ -804,7 +801,7 @@ static int pxamci_probe(struct platform_device *pdev)
804 dev_err(&pdev->dev, "Failed requesting gpio_ro %d\n", gpio_ro); 801 dev_err(&pdev->dev, "Failed requesting gpio_ro %d\n", gpio_ro);
805 goto out; 802 goto out;
806 } else { 803 } else {
807 mmc->caps |= host->pdata->gpio_card_ro_invert ? 804 mmc->caps2 |= host->pdata->gpio_card_ro_invert ?
808 0 : MMC_CAP2_RO_ACTIVE_HIGH; 805 0 : MMC_CAP2_RO_ACTIVE_HIGH;
809 } 806 }
810 807
@@ -833,14 +830,9 @@ out:
833 dma_release_channel(host->dma_chan_rx); 830 dma_release_channel(host->dma_chan_rx);
834 if (host->dma_chan_tx) 831 if (host->dma_chan_tx)
835 dma_release_channel(host->dma_chan_tx); 832 dma_release_channel(host->dma_chan_tx);
836 if (host->base)
837 iounmap(host->base);
838 if (host->clk)
839 clk_put(host->clk);
840 } 833 }
841 if (mmc) 834 if (mmc)
842 mmc_free_host(mmc); 835 mmc_free_host(mmc);
843 release_resource(r);
844 return ret; 836 return ret;
845} 837}
846 838
@@ -859,9 +851,6 @@ static int pxamci_remove(struct platform_device *pdev)
859 gpio_ro = host->pdata->gpio_card_ro; 851 gpio_ro = host->pdata->gpio_card_ro;
860 gpio_power = host->pdata->gpio_power; 852 gpio_power = host->pdata->gpio_power;
861 } 853 }
862 if (host->vcc)
863 regulator_put(host->vcc);
864
865 if (host->pdata && host->pdata->exit) 854 if (host->pdata && host->pdata->exit)
866 host->pdata->exit(&pdev->dev, mmc); 855 host->pdata->exit(&pdev->dev, mmc);
867 856
@@ -870,16 +859,10 @@ static int pxamci_remove(struct platform_device *pdev)
870 END_CMD_RES|PRG_DONE|DATA_TRAN_DONE, 859 END_CMD_RES|PRG_DONE|DATA_TRAN_DONE,
871 host->base + MMC_I_MASK); 860 host->base + MMC_I_MASK);
872 861
873 free_irq(host->irq, host);
874 dmaengine_terminate_all(host->dma_chan_rx); 862 dmaengine_terminate_all(host->dma_chan_rx);
875 dmaengine_terminate_all(host->dma_chan_tx); 863 dmaengine_terminate_all(host->dma_chan_tx);
876 dma_release_channel(host->dma_chan_rx); 864 dma_release_channel(host->dma_chan_rx);
877 dma_release_channel(host->dma_chan_tx); 865 dma_release_channel(host->dma_chan_tx);
878 iounmap(host->base);
879
880 clk_put(host->clk);
881
882 release_resource(host->res);
883 866
884 mmc_free_host(mmc); 867 mmc_free_host(mmc);
885 } 868 }
diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c
index f6047fc94062..a5cda926d38e 100644
--- a/drivers/mmc/host/sdhci-acpi.c
+++ b/drivers/mmc/host/sdhci-acpi.c
@@ -146,6 +146,33 @@ static const struct sdhci_acpi_chip sdhci_acpi_chip_int = {
146 .ops = &sdhci_acpi_ops_int, 146 .ops = &sdhci_acpi_ops_int,
147}; 147};
148 148
149static int bxt_get_cd(struct mmc_host *mmc)
150{
151 int gpio_cd = mmc_gpio_get_cd(mmc);
152 struct sdhci_host *host = mmc_priv(mmc);
153 unsigned long flags;
154 int ret = 0;
155
156 if (!gpio_cd)
157 return 0;
158
159 pm_runtime_get_sync(mmc->parent);
160
161 spin_lock_irqsave(&host->lock, flags);
162
163 if (host->flags & SDHCI_DEVICE_DEAD)
164 goto out;
165
166 ret = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
167out:
168 spin_unlock_irqrestore(&host->lock, flags);
169
170 pm_runtime_mark_last_busy(mmc->parent);
171 pm_runtime_put_autosuspend(mmc->parent);
172
173 return ret;
174}
175
149static int sdhci_acpi_emmc_probe_slot(struct platform_device *pdev, 176static int sdhci_acpi_emmc_probe_slot(struct platform_device *pdev,
150 const char *hid, const char *uid) 177 const char *hid, const char *uid)
151{ 178{
@@ -196,6 +223,9 @@ static int sdhci_acpi_sd_probe_slot(struct platform_device *pdev,
196 223
197 /* Platform specific code during sd probe slot goes here */ 224 /* Platform specific code during sd probe slot goes here */
198 225
226 if (hid && !strcmp(hid, "80865ACA"))
227 host->mmc_host_ops.get_cd = bxt_get_cd;
228
199 return 0; 229 return 0;
200} 230}
201 231
diff --git a/drivers/mmc/host/sdhci-of-at91.c b/drivers/mmc/host/sdhci-of-at91.c
index 7e7d8f0c9438..9cb86fb25976 100644
--- a/drivers/mmc/host/sdhci-of-at91.c
+++ b/drivers/mmc/host/sdhci-of-at91.c
@@ -217,6 +217,7 @@ static int sdhci_at91_probe(struct platform_device *pdev)
217pm_runtime_disable: 217pm_runtime_disable:
218 pm_runtime_disable(&pdev->dev); 218 pm_runtime_disable(&pdev->dev);
219 pm_runtime_set_suspended(&pdev->dev); 219 pm_runtime_set_suspended(&pdev->dev);
220 pm_runtime_put_noidle(&pdev->dev);
220clocks_disable_unprepare: 221clocks_disable_unprepare:
221 clk_disable_unprepare(priv->gck); 222 clk_disable_unprepare(priv->gck);
222 clk_disable_unprepare(priv->mainck); 223 clk_disable_unprepare(priv->mainck);
diff --git a/drivers/mmc/host/sdhci-pci-core.c b/drivers/mmc/host/sdhci-pci-core.c
index cc851b065d0a..df3b8eced8c4 100644
--- a/drivers/mmc/host/sdhci-pci-core.c
+++ b/drivers/mmc/host/sdhci-pci-core.c
@@ -330,6 +330,33 @@ static void spt_read_drive_strength(struct sdhci_host *host)
330 sdhci_pci_spt_drive_strength = 0x10 | ((val >> 12) & 0xf); 330 sdhci_pci_spt_drive_strength = 0x10 | ((val >> 12) & 0xf);
331} 331}
332 332
333static int bxt_get_cd(struct mmc_host *mmc)
334{
335 int gpio_cd = mmc_gpio_get_cd(mmc);
336 struct sdhci_host *host = mmc_priv(mmc);
337 unsigned long flags;
338 int ret = 0;
339
340 if (!gpio_cd)
341 return 0;
342
343 pm_runtime_get_sync(mmc->parent);
344
345 spin_lock_irqsave(&host->lock, flags);
346
347 if (host->flags & SDHCI_DEVICE_DEAD)
348 goto out;
349
350 ret = !!(sdhci_readl(host, SDHCI_PRESENT_STATE) & SDHCI_CARD_PRESENT);
351out:
352 spin_unlock_irqrestore(&host->lock, flags);
353
354 pm_runtime_mark_last_busy(mmc->parent);
355 pm_runtime_put_autosuspend(mmc->parent);
356
357 return ret;
358}
359
333static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot) 360static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
334{ 361{
335 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE | 362 slot->host->mmc->caps |= MMC_CAP_8_BIT_DATA | MMC_CAP_NONREMOVABLE |
@@ -362,6 +389,10 @@ static int byt_sd_probe_slot(struct sdhci_pci_slot *slot)
362 slot->cd_con_id = NULL; 389 slot->cd_con_id = NULL;
363 slot->cd_idx = 0; 390 slot->cd_idx = 0;
364 slot->cd_override_level = true; 391 slot->cd_override_level = true;
392 if (slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_BXT_SD ||
393 slot->chip->pdev->device == PCI_DEVICE_ID_INTEL_APL_SD)
394 slot->host->mmc_host_ops.get_cd = bxt_get_cd;
395
365 return 0; 396 return 0;
366} 397}
367 398
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index d622435d1bcc..add9fdfd1d8f 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -1360,7 +1360,7 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
1360 sdhci_runtime_pm_get(host); 1360 sdhci_runtime_pm_get(host);
1361 1361
1362 /* Firstly check card presence */ 1362 /* Firstly check card presence */
1363 present = sdhci_do_get_cd(host); 1363 present = mmc->ops->get_cd(mmc);
1364 1364
1365 spin_lock_irqsave(&host->lock, flags); 1365 spin_lock_irqsave(&host->lock, flags);
1366 1366
@@ -2849,6 +2849,8 @@ struct sdhci_host *sdhci_alloc_host(struct device *dev,
2849 2849
2850 host = mmc_priv(mmc); 2850 host = mmc_priv(mmc);
2851 host->mmc = mmc; 2851 host->mmc = mmc;
2852 host->mmc_host_ops = sdhci_ops;
2853 mmc->ops = &host->mmc_host_ops;
2852 2854
2853 return host; 2855 return host;
2854} 2856}
@@ -3037,7 +3039,6 @@ int sdhci_add_host(struct sdhci_host *host)
3037 /* 3039 /*
3038 * Set host parameters. 3040 * Set host parameters.
3039 */ 3041 */
3040 mmc->ops = &sdhci_ops;
3041 max_clk = host->max_clk; 3042 max_clk = host->max_clk;
3042 3043
3043 if (host->ops->get_min_clock) 3044 if (host->ops->get_min_clock)
diff --git a/drivers/mmc/host/sdhci.h b/drivers/mmc/host/sdhci.h
index 7654ae5d2b4e..0115e9907bf8 100644
--- a/drivers/mmc/host/sdhci.h
+++ b/drivers/mmc/host/sdhci.h
@@ -430,6 +430,7 @@ struct sdhci_host {
430 430
431 /* Internal data */ 431 /* Internal data */
432 struct mmc_host *mmc; /* MMC structure */ 432 struct mmc_host *mmc; /* MMC structure */
433 struct mmc_host_ops mmc_host_ops; /* MMC host ops */
433 u64 dma_mask; /* custom DMA mask */ 434 u64 dma_mask; /* custom DMA mask */
434 435
435#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE) 436#if defined(CONFIG_LEDS_CLASS) || defined(CONFIG_LEDS_CLASS_MODULE)
diff --git a/drivers/mmc/host/sh_mmcif.c b/drivers/mmc/host/sh_mmcif.c
index 1ca8a1359cbc..6234eab38ff3 100644
--- a/drivers/mmc/host/sh_mmcif.c
+++ b/drivers/mmc/host/sh_mmcif.c
@@ -445,7 +445,7 @@ static void sh_mmcif_request_dma(struct sh_mmcif_host *host)
445 pdata->slave_id_rx); 445 pdata->slave_id_rx);
446 } else { 446 } else {
447 host->chan_tx = dma_request_slave_channel(dev, "tx"); 447 host->chan_tx = dma_request_slave_channel(dev, "tx");
448 host->chan_tx = dma_request_slave_channel(dev, "rx"); 448 host->chan_rx = dma_request_slave_channel(dev, "rx");
449 } 449 }
450 dev_dbg(dev, "%s: got channel TX %p RX %p\n", __func__, host->chan_tx, 450 dev_dbg(dev, "%s: got channel TX %p RX %p\n", __func__, host->chan_tx,
451 host->chan_rx); 451 host->chan_rx);