diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-12-01 08:14:22 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-12-01 08:14:22 -0500 |
commit | 3c1c4ddffb58b9e10b3365764fe59546130b3f32 (patch) | |
tree | 7c2446dec7842a6ed003d0c023fe3345d0828c58 | |
parent | 5dc9cbc4f10d7bc5aaa17ec0accf4c6e24d9ecd6 (diff) | |
parent | c892b0d81705c566f575e489efc3c50762db1bde (diff) |
Merge tag 'mmc-v4.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson:
"MMC core:
- Ensure that debugfs files are removed properly
- Fix missing blk_put_request()
- Deal with errors from blk_get_request()
- Rewind mmc bus suspend operations at failures
- Prepend '0x' to ocr and pre_eol_info in sysfs to identify as hex
MMC host:
- sdhci-msm: Make it optional to wait for signal level changes
- sdhci: Avoid swiotlb buffer being full"
* tag 'mmc-v4.15-2' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc:
mmc: core: prepend 0x to OCR entry in sysfs
mmc: core: prepend 0x to pre_eol_info entry in sysfs
mmc: sdhci: Avoid swiotlb buffer being full
mmc: sdhci-msm: Optionally wait for signal level changes
mmc: block: Ensure that debugfs files are removed
mmc: core: Do not leave the block driver in a suspended state
mmc: block: Check return value of blk_get_request()
mmc: block: Fix missing blk_put_request()
-rw-r--r-- | drivers/mmc/core/block.c | 67 | ||||
-rw-r--r-- | drivers/mmc/core/bus.c | 3 | ||||
-rw-r--r-- | drivers/mmc/core/debugfs.c | 1 | ||||
-rw-r--r-- | drivers/mmc/core/mmc.c | 4 | ||||
-rw-r--r-- | drivers/mmc/core/sd.c | 2 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci-msm.c | 14 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci.c | 28 |
7 files changed, 98 insertions, 21 deletions
diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index ea80ff4cd7f9..ccfa98af1dd3 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c | |||
@@ -122,6 +122,10 @@ struct mmc_blk_data { | |||
122 | struct device_attribute force_ro; | 122 | struct device_attribute force_ro; |
123 | struct device_attribute power_ro_lock; | 123 | struct device_attribute power_ro_lock; |
124 | int area_type; | 124 | int area_type; |
125 | |||
126 | /* debugfs files (only in main mmc_blk_data) */ | ||
127 | struct dentry *status_dentry; | ||
128 | struct dentry *ext_csd_dentry; | ||
125 | }; | 129 | }; |
126 | 130 | ||
127 | /* Device type for RPMB character devices */ | 131 | /* Device type for RPMB character devices */ |
@@ -233,9 +237,14 @@ static ssize_t power_ro_lock_store(struct device *dev, | |||
233 | 237 | ||
234 | /* Dispatch locking to the block layer */ | 238 | /* Dispatch locking to the block layer */ |
235 | req = blk_get_request(mq->queue, REQ_OP_DRV_OUT, __GFP_RECLAIM); | 239 | req = blk_get_request(mq->queue, REQ_OP_DRV_OUT, __GFP_RECLAIM); |
240 | if (IS_ERR(req)) { | ||
241 | count = PTR_ERR(req); | ||
242 | goto out_put; | ||
243 | } | ||
236 | req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_BOOT_WP; | 244 | req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_BOOT_WP; |
237 | blk_execute_rq(mq->queue, NULL, req, 0); | 245 | blk_execute_rq(mq->queue, NULL, req, 0); |
238 | ret = req_to_mmc_queue_req(req)->drv_op_result; | 246 | ret = req_to_mmc_queue_req(req)->drv_op_result; |
247 | blk_put_request(req); | ||
239 | 248 | ||
240 | if (!ret) { | 249 | if (!ret) { |
241 | pr_info("%s: Locking boot partition ro until next power on\n", | 250 | pr_info("%s: Locking boot partition ro until next power on\n", |
@@ -248,7 +257,7 @@ static ssize_t power_ro_lock_store(struct device *dev, | |||
248 | set_disk_ro(part_md->disk, 1); | 257 | set_disk_ro(part_md->disk, 1); |
249 | } | 258 | } |
250 | } | 259 | } |
251 | 260 | out_put: | |
252 | mmc_blk_put(md); | 261 | mmc_blk_put(md); |
253 | return count; | 262 | return count; |
254 | } | 263 | } |
@@ -624,6 +633,10 @@ static int mmc_blk_ioctl_cmd(struct mmc_blk_data *md, | |||
624 | req = blk_get_request(mq->queue, | 633 | req = blk_get_request(mq->queue, |
625 | idata->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, | 634 | idata->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, |
626 | __GFP_RECLAIM); | 635 | __GFP_RECLAIM); |
636 | if (IS_ERR(req)) { | ||
637 | err = PTR_ERR(req); | ||
638 | goto cmd_done; | ||
639 | } | ||
627 | idatas[0] = idata; | 640 | idatas[0] = idata; |
628 | req_to_mmc_queue_req(req)->drv_op = | 641 | req_to_mmc_queue_req(req)->drv_op = |
629 | rpmb ? MMC_DRV_OP_IOCTL_RPMB : MMC_DRV_OP_IOCTL; | 642 | rpmb ? MMC_DRV_OP_IOCTL_RPMB : MMC_DRV_OP_IOCTL; |
@@ -691,6 +704,10 @@ static int mmc_blk_ioctl_multi_cmd(struct mmc_blk_data *md, | |||
691 | req = blk_get_request(mq->queue, | 704 | req = blk_get_request(mq->queue, |
692 | idata[0]->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, | 705 | idata[0]->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN, |
693 | __GFP_RECLAIM); | 706 | __GFP_RECLAIM); |
707 | if (IS_ERR(req)) { | ||
708 | err = PTR_ERR(req); | ||
709 | goto cmd_err; | ||
710 | } | ||
694 | req_to_mmc_queue_req(req)->drv_op = | 711 | req_to_mmc_queue_req(req)->drv_op = |
695 | rpmb ? MMC_DRV_OP_IOCTL_RPMB : MMC_DRV_OP_IOCTL; | 712 | rpmb ? MMC_DRV_OP_IOCTL_RPMB : MMC_DRV_OP_IOCTL; |
696 | req_to_mmc_queue_req(req)->drv_op_data = idata; | 713 | req_to_mmc_queue_req(req)->drv_op_data = idata; |
@@ -2550,6 +2567,8 @@ static int mmc_dbg_card_status_get(void *data, u64 *val) | |||
2550 | 2567 | ||
2551 | /* Ask the block layer about the card status */ | 2568 | /* Ask the block layer about the card status */ |
2552 | req = blk_get_request(mq->queue, REQ_OP_DRV_IN, __GFP_RECLAIM); | 2569 | req = blk_get_request(mq->queue, REQ_OP_DRV_IN, __GFP_RECLAIM); |
2570 | if (IS_ERR(req)) | ||
2571 | return PTR_ERR(req); | ||
2553 | req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_CARD_STATUS; | 2572 | req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_CARD_STATUS; |
2554 | blk_execute_rq(mq->queue, NULL, req, 0); | 2573 | blk_execute_rq(mq->queue, NULL, req, 0); |
2555 | ret = req_to_mmc_queue_req(req)->drv_op_result; | 2574 | ret = req_to_mmc_queue_req(req)->drv_op_result; |
@@ -2557,6 +2576,7 @@ static int mmc_dbg_card_status_get(void *data, u64 *val) | |||
2557 | *val = ret; | 2576 | *val = ret; |
2558 | ret = 0; | 2577 | ret = 0; |
2559 | } | 2578 | } |
2579 | blk_put_request(req); | ||
2560 | 2580 | ||
2561 | return ret; | 2581 | return ret; |
2562 | } | 2582 | } |
@@ -2583,10 +2603,15 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp) | |||
2583 | 2603 | ||
2584 | /* Ask the block layer for the EXT CSD */ | 2604 | /* Ask the block layer for the EXT CSD */ |
2585 | req = blk_get_request(mq->queue, REQ_OP_DRV_IN, __GFP_RECLAIM); | 2605 | req = blk_get_request(mq->queue, REQ_OP_DRV_IN, __GFP_RECLAIM); |
2606 | if (IS_ERR(req)) { | ||
2607 | err = PTR_ERR(req); | ||
2608 | goto out_free; | ||
2609 | } | ||
2586 | req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_EXT_CSD; | 2610 | req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_EXT_CSD; |
2587 | req_to_mmc_queue_req(req)->drv_op_data = &ext_csd; | 2611 | req_to_mmc_queue_req(req)->drv_op_data = &ext_csd; |
2588 | blk_execute_rq(mq->queue, NULL, req, 0); | 2612 | blk_execute_rq(mq->queue, NULL, req, 0); |
2589 | err = req_to_mmc_queue_req(req)->drv_op_result; | 2613 | err = req_to_mmc_queue_req(req)->drv_op_result; |
2614 | blk_put_request(req); | ||
2590 | if (err) { | 2615 | if (err) { |
2591 | pr_err("FAILED %d\n", err); | 2616 | pr_err("FAILED %d\n", err); |
2592 | goto out_free; | 2617 | goto out_free; |
@@ -2632,7 +2657,7 @@ static const struct file_operations mmc_dbg_ext_csd_fops = { | |||
2632 | .llseek = default_llseek, | 2657 | .llseek = default_llseek, |
2633 | }; | 2658 | }; |
2634 | 2659 | ||
2635 | static int mmc_blk_add_debugfs(struct mmc_card *card) | 2660 | static int mmc_blk_add_debugfs(struct mmc_card *card, struct mmc_blk_data *md) |
2636 | { | 2661 | { |
2637 | struct dentry *root; | 2662 | struct dentry *root; |
2638 | 2663 | ||
@@ -2642,28 +2667,53 @@ static int mmc_blk_add_debugfs(struct mmc_card *card) | |||
2642 | root = card->debugfs_root; | 2667 | root = card->debugfs_root; |
2643 | 2668 | ||
2644 | if (mmc_card_mmc(card) || mmc_card_sd(card)) { | 2669 | if (mmc_card_mmc(card) || mmc_card_sd(card)) { |
2645 | if (!debugfs_create_file("status", S_IRUSR, root, card, | 2670 | md->status_dentry = |
2646 | &mmc_dbg_card_status_fops)) | 2671 | debugfs_create_file("status", S_IRUSR, root, card, |
2672 | &mmc_dbg_card_status_fops); | ||
2673 | if (!md->status_dentry) | ||
2647 | return -EIO; | 2674 | return -EIO; |
2648 | } | 2675 | } |
2649 | 2676 | ||
2650 | if (mmc_card_mmc(card)) { | 2677 | if (mmc_card_mmc(card)) { |
2651 | if (!debugfs_create_file("ext_csd", S_IRUSR, root, card, | 2678 | md->ext_csd_dentry = |
2652 | &mmc_dbg_ext_csd_fops)) | 2679 | debugfs_create_file("ext_csd", S_IRUSR, root, card, |
2680 | &mmc_dbg_ext_csd_fops); | ||
2681 | if (!md->ext_csd_dentry) | ||
2653 | return -EIO; | 2682 | return -EIO; |
2654 | } | 2683 | } |
2655 | 2684 | ||
2656 | return 0; | 2685 | return 0; |
2657 | } | 2686 | } |
2658 | 2687 | ||
2688 | static void mmc_blk_remove_debugfs(struct mmc_card *card, | ||
2689 | struct mmc_blk_data *md) | ||
2690 | { | ||
2691 | if (!card->debugfs_root) | ||
2692 | return; | ||
2693 | |||
2694 | if (!IS_ERR_OR_NULL(md->status_dentry)) { | ||
2695 | debugfs_remove(md->status_dentry); | ||
2696 | md->status_dentry = NULL; | ||
2697 | } | ||
2698 | |||
2699 | if (!IS_ERR_OR_NULL(md->ext_csd_dentry)) { | ||
2700 | debugfs_remove(md->ext_csd_dentry); | ||
2701 | md->ext_csd_dentry = NULL; | ||
2702 | } | ||
2703 | } | ||
2659 | 2704 | ||
2660 | #else | 2705 | #else |
2661 | 2706 | ||
2662 | static int mmc_blk_add_debugfs(struct mmc_card *card) | 2707 | static int mmc_blk_add_debugfs(struct mmc_card *card, struct mmc_blk_data *md) |
2663 | { | 2708 | { |
2664 | return 0; | 2709 | return 0; |
2665 | } | 2710 | } |
2666 | 2711 | ||
2712 | static void mmc_blk_remove_debugfs(struct mmc_card *card, | ||
2713 | struct mmc_blk_data *md) | ||
2714 | { | ||
2715 | } | ||
2716 | |||
2667 | #endif /* CONFIG_DEBUG_FS */ | 2717 | #endif /* CONFIG_DEBUG_FS */ |
2668 | 2718 | ||
2669 | static int mmc_blk_probe(struct mmc_card *card) | 2719 | static int mmc_blk_probe(struct mmc_card *card) |
@@ -2703,7 +2753,7 @@ static int mmc_blk_probe(struct mmc_card *card) | |||
2703 | } | 2753 | } |
2704 | 2754 | ||
2705 | /* Add two debugfs entries */ | 2755 | /* Add two debugfs entries */ |
2706 | mmc_blk_add_debugfs(card); | 2756 | mmc_blk_add_debugfs(card, md); |
2707 | 2757 | ||
2708 | pm_runtime_set_autosuspend_delay(&card->dev, 3000); | 2758 | pm_runtime_set_autosuspend_delay(&card->dev, 3000); |
2709 | pm_runtime_use_autosuspend(&card->dev); | 2759 | pm_runtime_use_autosuspend(&card->dev); |
@@ -2729,6 +2779,7 @@ static void mmc_blk_remove(struct mmc_card *card) | |||
2729 | { | 2779 | { |
2730 | struct mmc_blk_data *md = dev_get_drvdata(&card->dev); | 2780 | struct mmc_blk_data *md = dev_get_drvdata(&card->dev); |
2731 | 2781 | ||
2782 | mmc_blk_remove_debugfs(card, md); | ||
2732 | mmc_blk_remove_parts(card, md); | 2783 | mmc_blk_remove_parts(card, md); |
2733 | pm_runtime_get_sync(&card->dev); | 2784 | pm_runtime_get_sync(&card->dev); |
2734 | mmc_claim_host(card->host); | 2785 | mmc_claim_host(card->host); |
diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index a4b49e25fe96..7586ff2ad1f1 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c | |||
@@ -157,6 +157,9 @@ static int mmc_bus_suspend(struct device *dev) | |||
157 | return ret; | 157 | return ret; |
158 | 158 | ||
159 | ret = host->bus_ops->suspend(host); | 159 | ret = host->bus_ops->suspend(host); |
160 | if (ret) | ||
161 | pm_generic_resume(dev); | ||
162 | |||
160 | return ret; | 163 | return ret; |
161 | } | 164 | } |
162 | 165 | ||
diff --git a/drivers/mmc/core/debugfs.c b/drivers/mmc/core/debugfs.c index 01e459a34f33..0f4a7d7b2626 100644 --- a/drivers/mmc/core/debugfs.c +++ b/drivers/mmc/core/debugfs.c | |||
@@ -314,4 +314,5 @@ err: | |||
314 | void mmc_remove_card_debugfs(struct mmc_card *card) | 314 | void mmc_remove_card_debugfs(struct mmc_card *card) |
315 | { | 315 | { |
316 | debugfs_remove_recursive(card->debugfs_root); | 316 | debugfs_remove_recursive(card->debugfs_root); |
317 | card->debugfs_root = NULL; | ||
317 | } | 318 | } |
diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c index a552f61060d2..d209fb466979 100644 --- a/drivers/mmc/core/mmc.c +++ b/drivers/mmc/core/mmc.c | |||
@@ -781,7 +781,7 @@ MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name); | |||
781 | MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); | 781 | MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); |
782 | MMC_DEV_ATTR(prv, "0x%x\n", card->cid.prv); | 782 | MMC_DEV_ATTR(prv, "0x%x\n", card->cid.prv); |
783 | MMC_DEV_ATTR(rev, "0x%x\n", card->ext_csd.rev); | 783 | MMC_DEV_ATTR(rev, "0x%x\n", card->ext_csd.rev); |
784 | MMC_DEV_ATTR(pre_eol_info, "%02x\n", card->ext_csd.pre_eol_info); | 784 | MMC_DEV_ATTR(pre_eol_info, "0x%02x\n", card->ext_csd.pre_eol_info); |
785 | MMC_DEV_ATTR(life_time, "0x%02x 0x%02x\n", | 785 | MMC_DEV_ATTR(life_time, "0x%02x 0x%02x\n", |
786 | card->ext_csd.device_life_time_est_typ_a, | 786 | card->ext_csd.device_life_time_est_typ_a, |
787 | card->ext_csd.device_life_time_est_typ_b); | 787 | card->ext_csd.device_life_time_est_typ_b); |
@@ -791,7 +791,7 @@ MMC_DEV_ATTR(enhanced_area_offset, "%llu\n", | |||
791 | MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size); | 791 | MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size); |
792 | MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult); | 792 | MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult); |
793 | MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors); | 793 | MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors); |
794 | MMC_DEV_ATTR(ocr, "%08x\n", card->ocr); | 794 | MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr); |
795 | MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en); | 795 | MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en); |
796 | 796 | ||
797 | static ssize_t mmc_fwrev_show(struct device *dev, | 797 | static ssize_t mmc_fwrev_show(struct device *dev, |
diff --git a/drivers/mmc/core/sd.c b/drivers/mmc/core/sd.c index 45bf78f32716..62b84dd8f9fe 100644 --- a/drivers/mmc/core/sd.c +++ b/drivers/mmc/core/sd.c | |||
@@ -675,7 +675,7 @@ MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid); | |||
675 | MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name); | 675 | MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name); |
676 | MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); | 676 | MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid); |
677 | MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); | 677 | MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial); |
678 | MMC_DEV_ATTR(ocr, "%08x\n", card->ocr); | 678 | MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr); |
679 | 679 | ||
680 | 680 | ||
681 | static ssize_t mmc_dsr_show(struct device *dev, | 681 | static ssize_t mmc_dsr_show(struct device *dev, |
diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 3fb7d2eec93f..c283291db705 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c | |||
@@ -29,6 +29,9 @@ | |||
29 | #define CORE_VERSION_MAJOR_MASK (0xf << CORE_VERSION_MAJOR_SHIFT) | 29 | #define CORE_VERSION_MAJOR_MASK (0xf << CORE_VERSION_MAJOR_SHIFT) |
30 | #define CORE_VERSION_MINOR_MASK 0xff | 30 | #define CORE_VERSION_MINOR_MASK 0xff |
31 | 31 | ||
32 | #define CORE_MCI_GENERICS 0x70 | ||
33 | #define SWITCHABLE_SIGNALING_VOLTAGE BIT(29) | ||
34 | |||
32 | #define CORE_HC_MODE 0x78 | 35 | #define CORE_HC_MODE 0x78 |
33 | #define HC_MODE_EN 0x1 | 36 | #define HC_MODE_EN 0x1 |
34 | #define CORE_POWER 0x0 | 37 | #define CORE_POWER 0x0 |
@@ -1028,12 +1031,23 @@ static void sdhci_msm_check_power_status(struct sdhci_host *host, u32 req_type) | |||
1028 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); | 1031 | struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); |
1029 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); | 1032 | struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); |
1030 | bool done = false; | 1033 | bool done = false; |
1034 | u32 val; | ||
1031 | 1035 | ||
1032 | pr_debug("%s: %s: request %d curr_pwr_state %x curr_io_level %x\n", | 1036 | pr_debug("%s: %s: request %d curr_pwr_state %x curr_io_level %x\n", |
1033 | mmc_hostname(host->mmc), __func__, req_type, | 1037 | mmc_hostname(host->mmc), __func__, req_type, |
1034 | msm_host->curr_pwr_state, msm_host->curr_io_level); | 1038 | msm_host->curr_pwr_state, msm_host->curr_io_level); |
1035 | 1039 | ||
1036 | /* | 1040 | /* |
1041 | * The power interrupt will not be generated for signal voltage | ||
1042 | * switches if SWITCHABLE_SIGNALING_VOLTAGE in MCI_GENERICS is not set. | ||
1043 | */ | ||
1044 | val = readl(msm_host->core_mem + CORE_MCI_GENERICS); | ||
1045 | if ((req_type & REQ_IO_HIGH || req_type & REQ_IO_LOW) && | ||
1046 | !(val & SWITCHABLE_SIGNALING_VOLTAGE)) { | ||
1047 | return; | ||
1048 | } | ||
1049 | |||
1050 | /* | ||
1037 | * The IRQ for request type IO High/LOW will be generated when - | 1051 | * The IRQ for request type IO High/LOW will be generated when - |
1038 | * there is a state change in 1.8V enable bit (bit 3) of | 1052 | * there is a state change in 1.8V enable bit (bit 3) of |
1039 | * SDHCI_HOST_CONTROL2 register. The reset state of that bit is 0 | 1053 | * SDHCI_HOST_CONTROL2 register. The reset state of that bit is 0 |
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 2f14334e42df..e9290a3439d5 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/dma-mapping.h> | 21 | #include <linux/dma-mapping.h> |
22 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
23 | #include <linux/scatterlist.h> | 23 | #include <linux/scatterlist.h> |
24 | #include <linux/swiotlb.h> | ||
24 | #include <linux/regulator/consumer.h> | 25 | #include <linux/regulator/consumer.h> |
25 | #include <linux/pm_runtime.h> | 26 | #include <linux/pm_runtime.h> |
26 | #include <linux/of.h> | 27 | #include <linux/of.h> |
@@ -3651,22 +3652,29 @@ int sdhci_setup_host(struct sdhci_host *host) | |||
3651 | spin_lock_init(&host->lock); | 3652 | spin_lock_init(&host->lock); |
3652 | 3653 | ||
3653 | /* | 3654 | /* |
3655 | * Maximum number of sectors in one transfer. Limited by SDMA boundary | ||
3656 | * size (512KiB). Note some tuning modes impose a 4MiB limit, but this | ||
3657 | * is less anyway. | ||
3658 | */ | ||
3659 | mmc->max_req_size = 524288; | ||
3660 | |||
3661 | /* | ||
3654 | * Maximum number of segments. Depends on if the hardware | 3662 | * Maximum number of segments. Depends on if the hardware |
3655 | * can do scatter/gather or not. | 3663 | * can do scatter/gather or not. |
3656 | */ | 3664 | */ |
3657 | if (host->flags & SDHCI_USE_ADMA) | 3665 | if (host->flags & SDHCI_USE_ADMA) { |
3658 | mmc->max_segs = SDHCI_MAX_SEGS; | 3666 | mmc->max_segs = SDHCI_MAX_SEGS; |
3659 | else if (host->flags & SDHCI_USE_SDMA) | 3667 | } else if (host->flags & SDHCI_USE_SDMA) { |
3660 | mmc->max_segs = 1; | 3668 | mmc->max_segs = 1; |
3661 | else /* PIO */ | 3669 | if (swiotlb_max_segment()) { |
3670 | unsigned int max_req_size = (1 << IO_TLB_SHIFT) * | ||
3671 | IO_TLB_SEGSIZE; | ||
3672 | mmc->max_req_size = min(mmc->max_req_size, | ||
3673 | max_req_size); | ||
3674 | } | ||
3675 | } else { /* PIO */ | ||
3662 | mmc->max_segs = SDHCI_MAX_SEGS; | 3676 | mmc->max_segs = SDHCI_MAX_SEGS; |
3663 | 3677 | } | |
3664 | /* | ||
3665 | * Maximum number of sectors in one transfer. Limited by SDMA boundary | ||
3666 | * size (512KiB). Note some tuning modes impose a 4MiB limit, but this | ||
3667 | * is less anyway. | ||
3668 | */ | ||
3669 | mmc->max_req_size = 524288; | ||
3670 | 3678 | ||
3671 | /* | 3679 | /* |
3672 | * Maximum segment size. Could be one segment with the maximum number | 3680 | * Maximum segment size. Could be one segment with the maximum number |