Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'mmc-fixes-for-3.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc

Pull MMC fixes from Chris Ball:
- Build fix for omap_hsmmc with OF against 3.4-rc1.
- Fix CONFIG_MMC_UNSAFE_RESUME semantics regression against 3.3, which
broke hotplug card detection when UNSAFE_RESUME is set.
- Fix a race condition in omap_hsmmc with runtime PM.
- Fix two libertas SDIO-powered-resume regressions.
- Small fixes for discard/sanitize, dw_mmc, cd-gpio and esdhc-imx.

* tag 'mmc-fixes-for-3.4-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/cjb/mmc:
mmc: core: Do not pre-claim host in suspend
mmc: dw_mmc: prevent NULL dereference for dma_ops
mmc: unbreak sdhci-esdhc-imx on i.MX25
mmc: cd-gpio: Include header to pickup exported symbol prototypes
mmc: sdhci: refine non-removable card checking for card detection
mmc: dw_mmc: Fix switch from DMA to PIO
mmc: remove MMC bus legacy suspend/resume method
mmc: omap_hsmmc: Get rid of of_have_populated_dt() usage
mmc: omap_hsmmc: build fix for CONFIG_OF=y and CONFIG_MMC_OMAP_HS=m
mmc: fixes for eMMC v4.5 sanitize operation
mmc: fixes for eMMC v4.5 discard operation

+88 -83
+40 -18
drivers/mmc/card/block.c
··· 873 873 { 874 874 struct mmc_blk_data *md = mq->data; 875 875 struct mmc_card *card = md->queue.card; 876 - unsigned int from, nr, arg; 876 + unsigned int from, nr, arg, trim_arg, erase_arg; 877 877 int err = 0, type = MMC_BLK_SECDISCARD; 878 878 879 879 if (!(mmc_can_secure_erase_trim(card) || mmc_can_sanitize(card))) { ··· 881 881 goto out; 882 882 } 883 883 884 - /* The sanitize operation is supported at v4.5 only */ 885 - if (mmc_can_sanitize(card)) { 886 - err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 887 - EXT_CSD_SANITIZE_START, 1, 0); 888 - goto out; 889 - } 890 - 891 884 from = blk_rq_pos(req); 892 885 nr = blk_rq_sectors(req); 893 886 894 - if (mmc_can_trim(card) && !mmc_erase_group_aligned(card, from, nr)) 895 - arg = MMC_SECURE_TRIM1_ARG; 896 - else 897 - arg = MMC_SECURE_ERASE_ARG; 887 + /* The sanitize operation is supported at v4.5 only */ 888 + if (mmc_can_sanitize(card)) { 889 + erase_arg = MMC_ERASE_ARG; 890 + trim_arg = MMC_TRIM_ARG; 891 + } else { 892 + erase_arg = MMC_SECURE_ERASE_ARG; 893 + trim_arg = MMC_SECURE_TRIM1_ARG; 894 + } 895 + 896 + if (mmc_erase_group_aligned(card, from, nr)) 897 + arg = erase_arg; 898 + else if (mmc_can_trim(card)) 899 + arg = trim_arg; 900 + else { 901 + err = -EINVAL; 902 + goto out; 903 + } 898 904 retry: 899 905 if (card->quirks & MMC_QUIRK_INAND_CMD38) { 900 906 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, ··· 910 904 INAND_CMD38_ARG_SECERASE, 911 905 0); 912 906 if (err) 913 - goto out; 907 + goto out_retry; 914 908 } 909 + 915 910 err = mmc_erase(card, from, nr, arg); 916 - if (!err && arg == MMC_SECURE_TRIM1_ARG) { 911 + if (err == -EIO) 912 + goto out_retry; 913 + if (err) 914 + goto out; 915 + 916 + if (arg == MMC_SECURE_TRIM1_ARG) { 917 917 if (card->quirks & MMC_QUIRK_INAND_CMD38) { 918 918 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 919 919 INAND_CMD38_ARG_EXT_CSD, 920 920 INAND_CMD38_ARG_SECTRIM2, 921 921 0); 922 922 if (err) 923 - goto out; 923 + goto out_retry; 924 924 } 925 + 925 926 err = mmc_erase(card, from, nr, MMC_SECURE_TRIM2_ARG); 927 + if (err == -EIO) 928 + goto out_retry; 929 + if (err) 930 + goto out; 926 931 } 927 - out: 928 - if (err == -EIO && !mmc_blk_reset(md, card->host, type)) 932 + 933 + if (mmc_can_sanitize(card)) 934 + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 935 + EXT_CSD_SANITIZE_START, 1, 0); 936 + out_retry: 937 + if (err && !mmc_blk_reset(md, card->host, type)) 929 938 goto retry; 930 939 if (!err) 931 940 mmc_blk_reset_success(md, type); 941 + out: 932 942 spin_lock_irq(&md->lock); 933 943 __blk_end_request(req, err, blk_rq_bytes(req)); 934 944 spin_unlock_irq(&md->lock); ··· 1824 1802 } 1825 1803 1826 1804 #ifdef CONFIG_PM 1827 - static int mmc_blk_suspend(struct mmc_card *card, pm_message_t state) 1805 + static int mmc_blk_suspend(struct mmc_card *card) 1828 1806 { 1829 1807 struct mmc_blk_data *part_md; 1830 1808 struct mmc_blk_data *md = mmc_get_drvdata(card);
+1 -1
drivers/mmc/card/queue.c
··· 139 139 140 140 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, q); 141 141 q->limits.max_discard_sectors = max_discard; 142 - if (card->erased_byte == 0) 142 + if (card->erased_byte == 0 && !mmc_can_discard(card)) 143 143 q->limits.discard_zeroes_data = 1; 144 144 q->limits.discard_granularity = card->pref_erase << 9; 145 145 /* granularity must not be greater than max. discard */
+9 -17
drivers/mmc/core/bus.c
··· 122 122 return 0; 123 123 } 124 124 125 - static int mmc_bus_suspend(struct device *dev, pm_message_t state) 125 + static int mmc_bus_suspend(struct device *dev) 126 126 { 127 127 struct mmc_driver *drv = to_mmc_driver(dev->driver); 128 128 struct mmc_card *card = mmc_dev_to_card(dev); 129 129 int ret = 0; 130 130 131 131 if (dev->driver && drv->suspend) 132 - ret = drv->suspend(card, state); 132 + ret = drv->suspend(card); 133 133 return ret; 134 134 } 135 135 ··· 165 165 return pm_runtime_suspend(dev); 166 166 } 167 167 168 - static const struct dev_pm_ops mmc_bus_pm_ops = { 169 - .runtime_suspend = mmc_runtime_suspend, 170 - .runtime_resume = mmc_runtime_resume, 171 - .runtime_idle = mmc_runtime_idle, 172 - }; 173 - 174 - #define MMC_PM_OPS_PTR (&mmc_bus_pm_ops) 175 - 176 - #else /* !CONFIG_PM_RUNTIME */ 177 - 178 - #define MMC_PM_OPS_PTR NULL 179 - 180 168 #endif /* !CONFIG_PM_RUNTIME */ 169 + 170 + static const struct dev_pm_ops mmc_bus_pm_ops = { 171 + SET_RUNTIME_PM_OPS(mmc_runtime_suspend, mmc_runtime_resume, 172 + mmc_runtime_idle) 173 + SET_SYSTEM_SLEEP_PM_OPS(mmc_bus_suspend, mmc_bus_resume) 174 + }; 181 175 182 176 static struct bus_type mmc_bus_type = { 183 177 .name = "mmc", ··· 180 186 .uevent = mmc_bus_uevent, 181 187 .probe = mmc_bus_probe, 182 188 .remove = mmc_bus_remove, 183 - .suspend = mmc_bus_suspend, 184 - .resume = mmc_bus_resume, 185 - .pm = MMC_PM_OPS_PTR, 189 + .pm = &mmc_bus_pm_ops, 186 190 }; 187 191 188 192 int mmc_register_bus(void)
+1
drivers/mmc/core/cd-gpio.c
··· 12 12 #include <linux/gpio.h> 13 13 #include <linux/interrupt.h> 14 14 #include <linux/jiffies.h> 15 + #include <linux/mmc/cd-gpio.h> 15 16 #include <linux/mmc/host.h> 16 17 #include <linux/module.h> 17 18 #include <linux/slab.h>
+26 -38
drivers/mmc/core/core.c
··· 1409 1409 { 1410 1410 unsigned int erase_timeout; 1411 1411 1412 - if (card->ext_csd.erase_group_def & 1) { 1412 + if (arg == MMC_DISCARD_ARG || 1413 + (arg == MMC_TRIM_ARG && card->ext_csd.rev >= 6)) { 1414 + erase_timeout = card->ext_csd.trim_timeout; 1415 + } else if (card->ext_csd.erase_group_def & 1) { 1413 1416 /* High Capacity Erase Group Size uses HC timeouts */ 1414 1417 if (arg == MMC_TRIM_ARG) 1415 1418 erase_timeout = card->ext_csd.trim_timeout; ··· 1684 1681 { 1685 1682 if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_GB_CL_EN) 1686 1683 return 1; 1687 - if (mmc_can_discard(card)) 1688 - return 1; 1689 1684 return 0; 1690 1685 } 1691 1686 EXPORT_SYMBOL(mmc_can_trim); ··· 1702 1701 1703 1702 int mmc_can_sanitize(struct mmc_card *card) 1704 1703 { 1704 + if (!mmc_can_trim(card) && !mmc_can_erase(card)) 1705 + return 0; 1705 1706 if (card->ext_csd.sec_feature_support & EXT_CSD_SEC_SANITIZE) 1706 1707 return 1; 1707 1708 return 0; ··· 2238 2235 mmc_card_is_removable(host)) 2239 2236 return err; 2240 2237 2238 + mmc_claim_host(host); 2241 2239 if (card && mmc_card_mmc(card) && 2242 2240 (card->ext_csd.cache_size > 0)) { 2243 2241 enable = !!enable; ··· 2256 2252 card->ext_csd.cache_ctrl = enable; 2257 2253 } 2258 2254 } 2255 + mmc_release_host(host); 2259 2256 2260 2257 return err; 2261 2258 } ··· 2274 2269 2275 2270 cancel_delayed_work(&host->detect); 2276 2271 mmc_flush_scheduled_work(); 2277 - if (mmc_try_claim_host(host)) { 2278 - err = mmc_cache_ctrl(host, 0); 2279 - mmc_release_host(host); 2280 - } else { 2281 - err = -EBUSY; 2282 - } 2283 2272 2273 + err = mmc_cache_ctrl(host, 0); 2284 2274 if (err) 2285 2275 goto out; 2286 2276 2287 2277 mmc_bus_get(host); 2288 2278 if (host->bus_ops && !host->bus_dead) { 2289 2279 2290 - /* 2291 - * A long response time is not acceptable for device drivers 2292 - * when doing suspend. Prevent mmc_claim_host in the suspend 2293 - * sequence, to potentially wait "forever" by trying to 2294 - * pre-claim the host. 2295 - */ 2296 - if (mmc_try_claim_host(host)) { 2297 - if (host->bus_ops->suspend) { 2298 - err = host->bus_ops->suspend(host); 2299 - } 2300 - mmc_release_host(host); 2280 + if (host->bus_ops->suspend) 2281 + err = host->bus_ops->suspend(host); 2301 2282 2302 - if (err == -ENOSYS || !host->bus_ops->resume) { 2303 - /* 2304 - * We simply "remove" the card in this case. 2305 - * It will be redetected on resume. (Calling 2306 - * bus_ops->remove() with a claimed host can 2307 - * deadlock.) 2308 - */ 2309 - if (host->bus_ops->remove) 2310 - host->bus_ops->remove(host); 2311 - mmc_claim_host(host); 2312 - mmc_detach_bus(host); 2313 - mmc_power_off(host); 2314 - mmc_release_host(host); 2315 - host->pm_flags = 0; 2316 - err = 0; 2317 - } 2318 - } else { 2319 - err = -EBUSY; 2283 + if (err == -ENOSYS || !host->bus_ops->resume) { 2284 + /* 2285 + * We simply "remove" the card in this case. 2286 + * It will be redetected on resume. (Calling 2287 + * bus_ops->remove() with a claimed host can 2288 + * deadlock.) 2289 + */ 2290 + if (host->bus_ops->remove) 2291 + host->bus_ops->remove(host); 2292 + mmc_claim_host(host); 2293 + mmc_detach_bus(host); 2294 + mmc_power_off(host); 2295 + mmc_release_host(host); 2296 + host->pm_flags = 0; 2297 + err = 0; 2320 2298 } 2321 2299 } 2322 2300 mmc_bus_put(host);
+5 -2
drivers/mmc/host/dw_mmc.c
··· 526 526 return -ENODEV; 527 527 528 528 sg_len = dw_mci_pre_dma_transfer(host, data, 0); 529 - if (sg_len < 0) 529 + if (sg_len < 0) { 530 + host->dma_ops->stop(host); 530 531 return sg_len; 532 + } 531 533 532 534 host->using_dma = 1; 533 535 ··· 1881 1879 if (!host->dma_ops) 1882 1880 goto no_dma; 1883 1881 1884 - if (host->dma_ops->init) { 1882 + if (host->dma_ops->init && host->dma_ops->start && 1883 + host->dma_ops->stop && host->dma_ops->cleanup) { 1885 1884 if (host->dma_ops->init(host)) { 1886 1885 dev_err(&host->dev, "%s: Unable to initialize " 1887 1886 "DMA Controller.\n", __func__);
+3 -3
drivers/mmc/host/omap_hsmmc.c
··· 249 249 * the pbias cell programming support is still missing when 250 250 * booting with Device tree 251 251 */ 252 - if (of_have_populated_dt() && !vdd) 252 + if (dev->of_node && !vdd) 253 253 return 0; 254 254 255 255 if (mmc_slot(host).before_set_reg) ··· 1549 1549 * can't be allowed when booting with device 1550 1550 * tree. 1551 1551 */ 1552 - (!of_have_populated_dt())) { 1552 + !host->dev->of_node) { 1553 1553 /* 1554 1554 * The mmc_select_voltage fn of the core does 1555 1555 * not seem to set the power_mode to ··· 1741 1741 .data = &omap4_reg_offset, 1742 1742 }, 1743 1743 {}, 1744 - } 1744 + }; 1745 1745 MODULE_DEVICE_TABLE(of, omap_mmc_of_match); 1746 1746 1747 1747 static struct omap_mmc_platform_data *of_get_hsmmc_pdata(struct device *dev)
+1 -2
drivers/mmc/host/sdhci-esdhc-imx.c
··· 467 467 clk_prepare_enable(clk); 468 468 pltfm_host->clk = clk; 469 469 470 - if (!is_imx25_esdhc(imx_data)) 471 - host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; 470 + host->quirks |= SDHCI_QUIRK_BROKEN_TIMEOUT_VAL; 472 471 473 472 if (is_imx25_esdhc(imx_data) || is_imx35_esdhc(imx_data)) 474 473 /* Fix errata ENGcm07207 present on i.MX25 and i.MX35 */
+1 -1
drivers/mmc/host/sdhci.c
··· 147 147 u32 present, irqs; 148 148 149 149 if ((host->quirks & SDHCI_QUIRK_BROKEN_CARD_DETECTION) || 150 - !mmc_card_is_removable(host->mmc)) 150 + (host->mmc->caps & MMC_CAP_NONREMOVABLE)) 151 151 return; 152 152 153 153 present = sdhci_readl(host, SDHCI_PRESENT_STATE) &
+1 -1
include/linux/mmc/card.h
··· 481 481 struct device_driver drv; 482 482 int (*probe)(struct mmc_card *); 483 483 void (*remove)(struct mmc_card *); 484 - int (*suspend)(struct mmc_card *, pm_message_t); 484 + int (*suspend)(struct mmc_card *); 485 485 int (*resume)(struct mmc_card *); 486 486 }; 487 487