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

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

+44 -19
-6
drivers/mmc/core/block.c
··· 2380 2380 snprintf(md->disk->disk_name, sizeof(md->disk->disk_name), 2381 2381 "mmcblk%u%s", card->host->index, subname ? subname : ""); 2382 2382 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 - 2389 2383 set_capacity(md->disk, size); 2390 2384 2391 2385 if (mmc_host_cmd23(card->host)) {
+1 -1
drivers/mmc/core/core.c
··· 95 95 if (!data) 96 96 return; 97 97 98 - if (cmd->error || data->error || 98 + if ((cmd && cmd->error) || data->error || 99 99 !should_fail(&host->fail_mmc_request, data->blksz * data->blocks)) 100 100 return; 101 101
+8 -1
drivers/mmc/core/queue.c
··· 355 355 { 356 356 struct mmc_host *host = card->host; 357 357 u64 limit = BLK_BOUNCE_HIGH; 358 + unsigned block_size = 512; 358 359 359 360 if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask) 360 361 limit = (u64)dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT; ··· 369 368 blk_queue_max_hw_sectors(mq->queue, 370 369 min(host->max_blk_count, host->max_req_size / 512)); 371 370 blk_queue_max_segments(mq->queue, host->max_segs); 372 - blk_queue_max_segment_size(mq->queue, host->max_seg_size); 371 + 372 + if (mmc_card_mmc(card)) 373 + block_size = card->ext_csd.data_sector_size; 374 + 375 + blk_queue_logical_block_size(mq->queue, block_size); 376 + blk_queue_max_segment_size(mq->queue, 377 + round_down(host->max_seg_size, block_size)); 373 378 374 379 INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler); 375 380 INIT_WORK(&mq->complete_work, mmc_blk_mq_complete_work);
+11 -2
drivers/mmc/host/cqhci.c
··· 201 201 cq_host->desc_size = cq_host->slot_sz * cq_host->num_slots; 202 202 203 203 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; 205 205 206 206 pr_debug("%s: cqhci: desc_size: %zu data_sz: %zu slot-sz: %d\n", 207 207 mmc_hostname(cq_host->mmc), cq_host->desc_size, cq_host->data_size, ··· 217 217 cq_host->desc_size, 218 218 &cq_host->desc_dma_base, 219 219 GFP_KERNEL); 220 + if (!cq_host->desc_base) 221 + return -ENOMEM; 222 + 220 223 cq_host->trans_desc_base = dmam_alloc_coherent(mmc_dev(cq_host->mmc), 221 224 cq_host->data_size, 222 225 &cq_host->trans_desc_dma_base, 223 226 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; 225 233 return -ENOMEM; 234 + } 226 235 227 236 pr_debug("%s: cqhci: desc-base: 0x%p trans-base: 0x%p\n desc_dma 0x%llx trans_dma: 0x%llx\n", 228 237 mmc_hostname(cq_host->mmc), cq_host->desc_base, cq_host->trans_desc_base,
+1
drivers/mmc/host/mmc_spi.c
··· 1450 1450 mmc->caps &= ~MMC_CAP_NEEDS_POLL; 1451 1451 mmc_gpiod_request_cd_irq(mmc); 1452 1452 } 1453 + mmc_detect_change(mmc, 0); 1453 1454 1454 1455 /* Index 1 is write protect/read only */ 1455 1456 status = mmc_gpiod_request_ro(mmc, NULL, 1, false, 0, NULL);
+1
drivers/mmc/host/renesas_sdhi_sys_dmac.c
··· 65 65 .scc_offset = 0x0300, 66 66 .taps = rcar_gen2_scc_taps, 67 67 .taps_num = ARRAY_SIZE(rcar_gen2_scc_taps), 68 + .max_blk_count = 0xffffffff, 68 69 }; 69 70 70 71 /* Definitions for sampling clocks */
+5 -4
drivers/mmc/host/sdhci-esdhc-imx.c
··· 1095 1095 writel(readl(host->ioaddr + SDHCI_HOST_CONTROL) 1096 1096 | ESDHC_BURST_LEN_EN_INCR, 1097 1097 host->ioaddr + SDHCI_HOST_CONTROL); 1098 + 1098 1099 /* 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), 1103 1104 host->ioaddr + 0x6c); 1104 1105 1105 1106 /* disable DLL_CTRL delay line settings */
+5
drivers/mmc/host/tmio_mmc.h
··· 277 277 iowrite16(val >> 16, host->ctl + ((addr + 2) << host->bus_shift)); 278 278 } 279 279 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 + 280 285 static inline void sd_ctrl_write32_rep(struct tmio_mmc_host *host, int addr, 281 286 const u32 *buf, int count) 282 287 {
+12 -5
drivers/mmc/host/tmio_mmc_core.c
··· 43 43 #include <linux/regulator/consumer.h> 44 44 #include <linux/mmc/sdio.h> 45 45 #include <linux/scatterlist.h> 46 + #include <linux/sizes.h> 46 47 #include <linux/spinlock.h> 47 48 #include <linux/swiotlb.h> 48 49 #include <linux/workqueue.h> ··· 630 629 return false; 631 630 } 632 631 633 - static void __tmio_mmc_sdio_irq(struct tmio_mmc_host *host) 632 + static bool __tmio_mmc_sdio_irq(struct tmio_mmc_host *host) 634 633 { 635 634 struct mmc_host *mmc = host->mmc; 636 635 struct tmio_mmc_data *pdata = host->pdata; ··· 638 637 unsigned int sdio_status; 639 638 640 639 if (!(pdata->flags & TMIO_MMC_SDIO_IRQ)) 641 - return; 640 + return false; 642 641 643 642 status = sd_ctrl_read16(host, CTL_SDIO_STATUS); 644 643 ireg = status & TMIO_SDIO_MASK_ALL & ~host->sdio_irq_mask; ··· 651 650 652 651 if (mmc->caps & MMC_CAP_SDIO_IRQ && ireg & TMIO_SDIO_STAT_IOIRQ) 653 652 mmc_signal_sdio_irq(mmc); 653 + 654 + return ireg; 654 655 } 655 656 656 657 irqreturn_t tmio_mmc_irq(int irq, void *devid) ··· 671 668 if (__tmio_mmc_sdcard_irq(host, ireg, status)) 672 669 return IRQ_HANDLED; 673 670 674 - __tmio_mmc_sdio_irq(host); 671 + if (__tmio_mmc_sdio_irq(host)) 672 + return IRQ_HANDLED; 675 673 676 - return IRQ_HANDLED; 674 + return IRQ_NONE; 677 675 } 678 676 EXPORT_SYMBOL_GPL(tmio_mmc_irq); 679 677 ··· 704 700 705 701 /* Set transfer length / blocksize */ 706 702 sd_ctrl_write16(host, CTL_SD_XFER_LEN, data->blksz); 707 - sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks); 703 + if (host->mmc->max_blk_count >= SZ_64K) 704 + sd_ctrl_write32(host, CTL_XFER_BLK_COUNT, data->blocks); 705 + else 706 + sd_ctrl_write16(host, CTL_XFER_BLK_COUNT, data->blocks); 708 707 709 708 tmio_mmc_start_dma(host, data); 710 709