Skip to content

Commit 3a8ed36

Browse files
committed
Merge tag 'mmc-v5.0-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc
Pull MMC fixes from Ulf Hansson: "MMC core: - Fix NULL ptr crash for a special test case - Align max segment size with logical block size to prevent bugs in v5.1-rc1. MMC host: - cqhci: Minor fixes - tmio: Prevent interrupt storm - tmio: Fixup SD/MMC card initialization - spi: Allow card to be detected during probe - sdhci-esdhc-imx: Fixup fix for ERR004536" * tag 'mmc-v5.0-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: mmc: sdhci-esdhc-imx: correct the fix of ERR004536 mmc: core: align max segment size with logical block size mmc: cqhci: Fix a tiny potential memory leak on error condition mmc: cqhci: fix space allocated for transfer descriptor mmc: core: Fix NULL ptr crash from mmc_should_fail_request mmc: tmio: fix access width of Block Count Register mmc: tmio_mmc_core: don't claim spurious interrupts mmc: spi: Fix card detection during probe
2 parents 3f25a59 + e30be06 commit 3a8ed36

File tree

9 files changed

+44
-19
lines changed

9 files changed

+44
-19
lines changed

drivers/mmc/core/block.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,12 +2380,6 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,
23802380
snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
23812381
"mmcblk%u%s", card->host->index, subname ? subname : "");
23822382

2383-
if (mmc_card_mmc(card))
2384-
blk_queue_logical_block_size(md->queue.queue,
2385-
card->ext_csd.data_sector_size);
2386-
else
2387-
blk_queue_logical_block_size(md->queue.queue, 512);
2388-
23892383
set_capacity(md->disk, size);
23902384

23912385
if (mmc_host_cmd23(card->host)) {

drivers/mmc/core/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ static void mmc_should_fail_request(struct mmc_host *host,
9595
if (!data)
9696
return;
9797

98-
if (cmd->error || data->error ||
98+
if ((cmd && cmd->error) || data->error ||
9999
!should_fail(&host->fail_mmc_request, data->blksz * data->blocks))
100100
return;
101101

drivers/mmc/core/queue.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
355355
{
356356
struct mmc_host *host = card->host;
357357
u64 limit = BLK_BOUNCE_HIGH;
358+
unsigned block_size = 512;
358359

359360
if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask)
360361
limit = (u64)dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT;
@@ -368,7 +369,13 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)
368369
blk_queue_max_hw_sectors(mq->queue,
369370
min(host->max_blk_count, host->max_req_size / 512));
370371
blk_queue_max_segments(mq->queue, host->max_segs);
371-
blk_queue_max_segment_size(mq->queue, host->max_seg_size);
372+
373+
if (mmc_card_mmc(card))
374+
block_size = card->ext_csd.data_sector_size;
375+
376+
blk_queue_logical_block_size(mq->queue, block_size);
377+
blk_queue_max_segment_size(mq->queue,
378+
round_down(host->max_seg_size, block_size));
372379

373380
INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler);
374381
INIT_WORK(&mq->complete_work, mmc_blk_mq_complete_work);

drivers/mmc/host/cqhci.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static int cqhci_host_alloc_tdl(struct cqhci_host *cq_host)
201201
cq_host->desc_size = cq_host->slot_sz * cq_host->num_slots;
202202

203203
cq_host->data_size = cq_host->trans_desc_len * cq_host->mmc->max_segs *
204-
(cq_host->num_slots - 1);
204+
cq_host->mmc->cqe_qdepth;
205205

206206
pr_debug("%s: cqhci: desc_size: %zu data_sz: %zu slot-sz: %d\n",
207207
mmc_hostname(cq_host->mmc), cq_host->desc_size, cq_host->data_size,
@@ -217,12 +217,21 @@ static int cqhci_host_alloc_tdl(struct cqhci_host *cq_host)
217217
cq_host->desc_size,
218218
&cq_host->desc_dma_base,
219219
GFP_KERNEL);
220+
if (!cq_host->desc_base)
221+
return -ENOMEM;
222+
220223
cq_host->trans_desc_base = dmam_alloc_coherent(mmc_dev(cq_host->mmc),
221224
cq_host->data_size,
222225
&cq_host->trans_desc_dma_base,
223226
GFP_KERNEL);
224-
if (!cq_host->desc_base || !cq_host->trans_desc_base)
227+
if (!cq_host->trans_desc_base) {
228+
dmam_free_coherent(mmc_dev(cq_host->mmc), cq_host->desc_size,
229+
cq_host->desc_base,
230+
cq_host->desc_dma_base);
231+
cq_host->desc_base = NULL;
232+
cq_host->desc_dma_base = 0;
225233
return -ENOMEM;
234+
}
226235

227236
pr_debug("%s: cqhci: desc-base: 0x%p trans-base: 0x%p\n desc_dma 0x%llx trans_dma: 0x%llx\n",
228237
mmc_hostname(cq_host->mmc), cq_host->desc_base, cq_host->trans_desc_base,

drivers/mmc/host/mmc_spi.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,6 +1450,7 @@ static int mmc_spi_probe(struct spi_device *spi)
14501450
mmc->caps &= ~MMC_CAP_NEEDS_POLL;
14511451
mmc_gpiod_request_cd_irq(mmc);
14521452
}
1453+
mmc_detect_change(mmc, 0);
14531454

14541455
/* Index 1 is write protect/read only */
14551456
status = mmc_gpiod_request_ro(mmc, NULL, 1, false, 0, NULL);

drivers/mmc/host/renesas_sdhi_sys_dmac.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static const struct renesas_sdhi_of_data of_rcar_gen2_compatible = {
6565
.scc_offset = 0x0300,
6666
.taps = rcar_gen2_scc_taps,
6767
.taps_num = ARRAY_SIZE(rcar_gen2_scc_taps),
68+
.max_blk_count = 0xffffffff,
6869
};
6970

7071
/* Definitions for sampling clocks */

drivers/mmc/host/sdhci-esdhc-imx.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1095,11 +1095,12 @@ static void sdhci_esdhc_imx_hwinit(struct sdhci_host *host)
10951095
writel(readl(host->ioaddr + SDHCI_HOST_CONTROL)
10961096
| ESDHC_BURST_LEN_EN_INCR,
10971097
host->ioaddr + SDHCI_HOST_CONTROL);
1098+
10981099
/*
1099-
* erratum ESDHC_FLAG_ERR004536 fix for MX6Q TO1.2 and MX6DL
1100-
* TO1.1, it's harmless for MX6SL
1101-
*/
1102-
writel(readl(host->ioaddr + 0x6c) | BIT(7),
1100+
* erratum ESDHC_FLAG_ERR004536 fix for MX6Q TO1.2 and MX6DL
1101+
* TO1.1, it's harmless for MX6SL
1102+
*/
1103+
writel(readl(host->ioaddr + 0x6c) & ~BIT(7),
11031104
host->ioaddr + 0x6c);
11041105

11051106
/* disable DLL_CTRL delay line settings */

drivers/mmc/host/tmio_mmc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ static inline void sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host,
277277
iowrite16(val >> 16, host->ctl + ((addr + 2) << host->bus_shift));
278278
}
279279

280+
static inline void sd_ctrl_write32(struct tmio_mmc_host *host, int addr, u32 val)
281+
{
282+
iowrite32(val, host->ctl + (addr << host->bus_shift));
283+
}
284+
280285
static inline void sd_ctrl_write32_rep(struct tmio_mmc_host *host, int addr,
281286
const u32 *buf, int count)
282287
{

drivers/mmc/host/tmio_mmc_core.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#include <linux/regulator/consumer.h>
4444
#include <linux/mmc/sdio.h>
4545
#include <linux/scatterlist.h>
46+
#include <linux/sizes.h>
4647
#include <linux/spinlock.h>
4748
#include <linux/swiotlb.h>
4849
#include <linux/workqueue.h>
@@ -629,15 +630,15 @@ static bool __tmio_mmc_sdcard_irq(struct tmio_mmc_host *host, int ireg,
629630
return false;
630631
}
631632

632-
static void __tmio_mmc_sdio_irq(struct tmio_mmc_host *host)
633+
static bool __tmio_mmc_sdio_irq(struct tmio_mmc_host *host)
633634
{
634635
struct mmc_host *mmc = host->mmc;
635636
struct tmio_mmc_data *pdata = host->pdata;
636637
unsigned int ireg, status;
637638
unsigned int sdio_status;
638639

639640
if (!(pdata->flags & TMIO_MMC_SDIO_IRQ))
640-
return;
641+
return false;
641642

642643
status = sd_ctrl_read16(host, CTL_SDIO_STATUS);
643644
ireg = status & TMIO_SDIO_MASK_ALL & ~host->sdio_irq_mask;
@@ -650,6 +651,8 @@ static void __tmio_mmc_sdio_irq(struct tmio_mmc_host *host)
650651

651652
if (mmc->caps & MMC_CAP_SDIO_IRQ && ireg & TMIO_SDIO_STAT_IOIRQ)
652653
mmc_signal_sdio_irq(mmc);
654+
655+
return ireg;
653656
}
654657

655658
irqreturn_t tmio_mmc_irq(int irq, void *devid)
@@ -668,9 +671,10 @@ irqreturn_t tmio_mmc_irq(int irq, void *devid)
668671
if (__tmio_mmc_sdcard_irq(host, ireg, status))
669672
return IRQ_HANDLED;
670673

671-
__tmio_mmc_sdio_irq(host);
674+
if (__tmio_mmc_sdio_irq(host))
675+
return IRQ_HANDLED;
672676

673-
return IRQ_HANDLED;
677+
return IRQ_NONE;
674678
}
675679
EXPORT_SYMBOL_GPL(tmio_mmc_irq);
676680

@@ -700,7 +704,10 @@ static int tmio_mmc_start_data(struct tmio_mmc_host *host,
700704

701705
/* Set transfer length / blocksize */
702706
sd_ctrl_write16(host, CTL_SD_XFER_LEN, data->blksz);
703-
sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks);
707+
if (host->mmc->max_blk_count >= SZ_64K)
708+
sd_ctrl_write32(host, CTL_XFER_BLK_COUNT, data->blocks);
709+
else
710+
sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks);
704711

705712
tmio_mmc_start_dma(host, data);
706713

0 commit comments

Comments
 (0)