Skip to content

Commit 3c1c4dd

Browse files
committed
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()
2 parents 5dc9cbc + c892b0d commit 3c1c4dd

File tree

7 files changed

+98
-21
lines changed

7 files changed

+98
-21
lines changed

drivers/mmc/core/block.c

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ struct mmc_blk_data {
122122
struct device_attribute force_ro;
123123
struct device_attribute power_ro_lock;
124124
int area_type;
125+
126+
/* debugfs files (only in main mmc_blk_data) */
127+
struct dentry *status_dentry;
128+
struct dentry *ext_csd_dentry;
125129
};
126130

127131
/* Device type for RPMB character devices */
@@ -233,9 +237,14 @@ static ssize_t power_ro_lock_store(struct device *dev,
233237

234238
/* Dispatch locking to the block layer */
235239
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+
}
236244
req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_BOOT_WP;
237245
blk_execute_rq(mq->queue, NULL, req, 0);
238246
ret = req_to_mmc_queue_req(req)->drv_op_result;
247+
blk_put_request(req);
239248

240249
if (!ret) {
241250
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,
248257
set_disk_ro(part_md->disk, 1);
249258
}
250259
}
251-
260+
out_put:
252261
mmc_blk_put(md);
253262
return count;
254263
}
@@ -624,6 +633,10 @@ static int mmc_blk_ioctl_cmd(struct mmc_blk_data *md,
624633
req = blk_get_request(mq->queue,
625634
idata->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
626635
__GFP_RECLAIM);
636+
if (IS_ERR(req)) {
637+
err = PTR_ERR(req);
638+
goto cmd_done;
639+
}
627640
idatas[0] = idata;
628641
req_to_mmc_queue_req(req)->drv_op =
629642
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,
691704
req = blk_get_request(mq->queue,
692705
idata[0]->ic.write_flag ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN,
693706
__GFP_RECLAIM);
707+
if (IS_ERR(req)) {
708+
err = PTR_ERR(req);
709+
goto cmd_err;
710+
}
694711
req_to_mmc_queue_req(req)->drv_op =
695712
rpmb ? MMC_DRV_OP_IOCTL_RPMB : MMC_DRV_OP_IOCTL;
696713
req_to_mmc_queue_req(req)->drv_op_data = idata;
@@ -2550,13 +2567,16 @@ static int mmc_dbg_card_status_get(void *data, u64 *val)
25502567

25512568
/* Ask the block layer about the card status */
25522569
req = blk_get_request(mq->queue, REQ_OP_DRV_IN, __GFP_RECLAIM);
2570+
if (IS_ERR(req))
2571+
return PTR_ERR(req);
25532572
req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_CARD_STATUS;
25542573
blk_execute_rq(mq->queue, NULL, req, 0);
25552574
ret = req_to_mmc_queue_req(req)->drv_op_result;
25562575
if (ret >= 0) {
25572576
*val = ret;
25582577
ret = 0;
25592578
}
2579+
blk_put_request(req);
25602580

25612581
return ret;
25622582
}
@@ -2583,10 +2603,15 @@ static int mmc_ext_csd_open(struct inode *inode, struct file *filp)
25832603

25842604
/* Ask the block layer for the EXT CSD */
25852605
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+
}
25862610
req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_EXT_CSD;
25872611
req_to_mmc_queue_req(req)->drv_op_data = &ext_csd;
25882612
blk_execute_rq(mq->queue, NULL, req, 0);
25892613
err = req_to_mmc_queue_req(req)->drv_op_result;
2614+
blk_put_request(req);
25902615
if (err) {
25912616
pr_err("FAILED %d\n", err);
25922617
goto out_free;
@@ -2632,7 +2657,7 @@ static const struct file_operations mmc_dbg_ext_csd_fops = {
26322657
.llseek = default_llseek,
26332658
};
26342659

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)
26362661
{
26372662
struct dentry *root;
26382663

@@ -2642,28 +2667,53 @@ static int mmc_blk_add_debugfs(struct mmc_card *card)
26422667
root = card->debugfs_root;
26432668

26442669
if (mmc_card_mmc(card) || mmc_card_sd(card)) {
2645-
if (!debugfs_create_file("status", S_IRUSR, root, card,
2646-
&mmc_dbg_card_status_fops))
2670+
md->status_dentry =
2671+
debugfs_create_file("status", S_IRUSR, root, card,
2672+
&mmc_dbg_card_status_fops);
2673+
if (!md->status_dentry)
26472674
return -EIO;
26482675
}
26492676

26502677
if (mmc_card_mmc(card)) {
2651-
if (!debugfs_create_file("ext_csd", S_IRUSR, root, card,
2652-
&mmc_dbg_ext_csd_fops))
2678+
md->ext_csd_dentry =
2679+
debugfs_create_file("ext_csd", S_IRUSR, root, card,
2680+
&mmc_dbg_ext_csd_fops);
2681+
if (!md->ext_csd_dentry)
26532682
return -EIO;
26542683
}
26552684

26562685
return 0;
26572686
}
26582687

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+
}
26592704

26602705
#else
26612706

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)
26632708
{
26642709
return 0;
26652710
}
26662711

2712+
static void mmc_blk_remove_debugfs(struct mmc_card *card,
2713+
struct mmc_blk_data *md)
2714+
{
2715+
}
2716+
26672717
#endif /* CONFIG_DEBUG_FS */
26682718

26692719
static int mmc_blk_probe(struct mmc_card *card)
@@ -2703,7 +2753,7 @@ static int mmc_blk_probe(struct mmc_card *card)
27032753
}
27042754

27052755
/* Add two debugfs entries */
2706-
mmc_blk_add_debugfs(card);
2756+
mmc_blk_add_debugfs(card, md);
27072757

27082758
pm_runtime_set_autosuspend_delay(&card->dev, 3000);
27092759
pm_runtime_use_autosuspend(&card->dev);
@@ -2729,6 +2779,7 @@ static void mmc_blk_remove(struct mmc_card *card)
27292779
{
27302780
struct mmc_blk_data *md = dev_get_drvdata(&card->dev);
27312781

2782+
mmc_blk_remove_debugfs(card, md);
27322783
mmc_blk_remove_parts(card, md);
27332784
pm_runtime_get_sync(&card->dev);
27342785
mmc_claim_host(card->host);

drivers/mmc/core/bus.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ static int mmc_bus_suspend(struct device *dev)
157157
return ret;
158158

159159
ret = host->bus_ops->suspend(host);
160+
if (ret)
161+
pm_generic_resume(dev);
162+
160163
return ret;
161164
}
162165

drivers/mmc/core/debugfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,4 +314,5 @@ void mmc_add_card_debugfs(struct mmc_card *card)
314314
void mmc_remove_card_debugfs(struct mmc_card *card)
315315
{
316316
debugfs_remove_recursive(card->debugfs_root);
317+
card->debugfs_root = NULL;
317318
}

drivers/mmc/core/mmc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,7 @@ MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
781781
MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
782782
MMC_DEV_ATTR(prv, "0x%x\n", card->cid.prv);
783783
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);
785785
MMC_DEV_ATTR(life_time, "0x%02x 0x%02x\n",
786786
card->ext_csd.device_life_time_est_typ_a,
787787
card->ext_csd.device_life_time_est_typ_b);
@@ -791,7 +791,7 @@ MMC_DEV_ATTR(enhanced_area_offset, "%llu\n",
791791
MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size);
792792
MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult);
793793
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);
795795
MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en);
796796

797797
static ssize_t mmc_fwrev_show(struct device *dev,

drivers/mmc/core/sd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ MMC_DEV_ATTR(manfid, "0x%06x\n", card->cid.manfid);
675675
MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
676676
MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
677677
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);
679679

680680

681681
static ssize_t mmc_dsr_show(struct device *dev,

drivers/mmc/host/sdhci-msm.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@
2929
#define CORE_VERSION_MAJOR_MASK (0xf << CORE_VERSION_MAJOR_SHIFT)
3030
#define CORE_VERSION_MINOR_MASK 0xff
3131

32+
#define CORE_MCI_GENERICS 0x70
33+
#define SWITCHABLE_SIGNALING_VOLTAGE BIT(29)
34+
3235
#define CORE_HC_MODE 0x78
3336
#define HC_MODE_EN 0x1
3437
#define CORE_POWER 0x0
@@ -1028,11 +1031,22 @@ static void sdhci_msm_check_power_status(struct sdhci_host *host, u32 req_type)
10281031
struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
10291032
struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host);
10301033
bool done = false;
1034+
u32 val;
10311035

10321036
pr_debug("%s: %s: request %d curr_pwr_state %x curr_io_level %x\n",
10331037
mmc_hostname(host->mmc), __func__, req_type,
10341038
msm_host->curr_pwr_state, msm_host->curr_io_level);
10351039

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+
10361050
/*
10371051
* The IRQ for request type IO High/LOW will be generated when -
10381052
* there is a state change in 1.8V enable bit (bit 3) of

drivers/mmc/host/sdhci.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/dma-mapping.h>
2222
#include <linux/slab.h>
2323
#include <linux/scatterlist.h>
24+
#include <linux/swiotlb.h>
2425
#include <linux/regulator/consumer.h>
2526
#include <linux/pm_runtime.h>
2627
#include <linux/of.h>
@@ -3650,23 +3651,30 @@ int sdhci_setup_host(struct sdhci_host *host)
36503651

36513652
spin_lock_init(&host->lock);
36523653

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+
36533661
/*
36543662
* Maximum number of segments. Depends on if the hardware
36553663
* can do scatter/gather or not.
36563664
*/
3657-
if (host->flags & SDHCI_USE_ADMA)
3665+
if (host->flags & SDHCI_USE_ADMA) {
36583666
mmc->max_segs = SDHCI_MAX_SEGS;
3659-
else if (host->flags & SDHCI_USE_SDMA)
3667+
} else if (host->flags & SDHCI_USE_SDMA) {
36603668
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 */
36623676
mmc->max_segs = SDHCI_MAX_SEGS;
3663-
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;
3677+
}
36703678

36713679
/*
36723680
* Maximum segment size. Could be one segment with the maximum number

0 commit comments

Comments
 (0)