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

mmc: remove multiwrite capability

Relax requirements on host controllers and only require that they do not
report a transfer count than is larger than the actual one (i.e. a lower
value is okay). This is how many other parts of the kernel behaves so
upper layers should already be prepared to handle that scenario. This
gives us a performance boost on MMC cards.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>

+29 -43
+18 -27
drivers/mmc/card/block.c
··· 237 237 if (brq.data.blocks > card->host->max_blk_count) 238 238 brq.data.blocks = card->host->max_blk_count; 239 239 240 - /* 241 - * If the host doesn't support multiple block writes, force 242 - * block writes to single block. SD cards are excepted from 243 - * this rule as they support querying the number of 244 - * successfully written sectors. 245 - */ 246 - if (rq_data_dir(req) != READ && 247 - !(card->host->caps & MMC_CAP_MULTIWRITE) && 248 - !mmc_card_sd(card)) 249 - brq.data.blocks = 1; 250 - 251 240 if (brq.data.blocks > 1) { 252 241 /* SPI multiblock writes terminate using a special 253 242 * token, not a STOP_TRANSMISSION request. ··· 356 367 * mark the known good sectors as ok. 357 368 * 358 369 * If the card is not SD, we can still ok written sectors 359 - * if the controller can do proper error reporting. 370 + * as reported by the controller (which might be less than 371 + * the real number of written sectors, but never more). 360 372 * 361 373 * For reads we just fail the entire chunk as that should 362 374 * be safe in all cases. 363 375 */ 364 - if (rq_data_dir(req) != READ && mmc_card_sd(card)) { 365 - u32 blocks; 366 - unsigned int bytes; 376 + if (rq_data_dir(req) != READ) { 377 + if (mmc_card_sd(card)) { 378 + u32 blocks; 379 + unsigned int bytes; 367 380 368 - blocks = mmc_sd_num_wr_blocks(card); 369 - if (blocks != (u32)-1) { 370 - if (card->csd.write_partial) 371 - bytes = blocks << md->block_bits; 372 - else 373 - bytes = blocks << 9; 381 + blocks = mmc_sd_num_wr_blocks(card); 382 + if (blocks != (u32)-1) { 383 + if (card->csd.write_partial) 384 + bytes = blocks << md->block_bits; 385 + else 386 + bytes = blocks << 9; 387 + spin_lock_irq(&md->lock); 388 + ret = __blk_end_request(req, 0, bytes); 389 + spin_unlock_irq(&md->lock); 390 + } 391 + } else { 374 392 spin_lock_irq(&md->lock); 375 - ret = __blk_end_request(req, 0, bytes); 393 + ret = __blk_end_request(req, 0, brq.data.bytes_xfered); 376 394 spin_unlock_irq(&md->lock); 377 395 } 378 - } else if (rq_data_dir(req) != READ && 379 - (card->host->caps & MMC_CAP_MULTIWRITE)) { 380 - spin_lock_irq(&md->lock); 381 - ret = __blk_end_request(req, 0, brq.data.bytes_xfered); 382 - spin_unlock_irq(&md->lock); 383 396 } 384 397 385 398 mmc_release_host(card->host);
+1 -1
drivers/mmc/host/at91_mci.c
··· 995 995 mmc->f_min = 375000; 996 996 mmc->f_max = 25000000; 997 997 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; 998 - mmc->caps = MMC_CAP_MULTIWRITE | MMC_CAP_SDIO_IRQ; 998 + mmc->caps = MMC_CAP_SDIO_IRQ; 999 999 1000 1000 mmc->max_blk_size = 4095; 1001 1001 mmc->max_blk_count = mmc->max_req_size;
+1 -1
drivers/mmc/host/atmel-mci.c
··· 849 849 mmc->f_min = (host->bus_hz + 511) / 512; 850 850 mmc->f_max = host->bus_hz / 2; 851 851 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; 852 - mmc->caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_MULTIWRITE; 852 + mmc->caps |= MMC_CAP_4_BIT_DATA; 853 853 854 854 mmc->max_hw_segs = 64; 855 855 mmc->max_phys_segs = 64;
+1 -4
drivers/mmc/host/mmc_spi.c
··· 1252 1252 mmc->ops = &mmc_spi_ops; 1253 1253 mmc->max_blk_size = MMC_SPI_BLOCKSIZE; 1254 1254 1255 - /* As long as we keep track of the number of successfully 1256 - * transmitted blocks, we're good for multiwrite. 1257 - */ 1258 - mmc->caps = MMC_CAP_SPI | MMC_CAP_MULTIWRITE; 1255 + mmc->caps = MMC_CAP_SPI; 1259 1256 1260 1257 /* SPI doesn't need the lowspeed device identification thing for 1261 1258 * MMC or SD cards, since it never comes up in open drain mode.
-1
drivers/mmc/host/mmci.c
··· 535 535 mmc->f_min = (host->mclk + 511) / 512; 536 536 mmc->f_max = min(host->mclk, fmax); 537 537 mmc->ocr_avail = plat->ocr_mask; 538 - mmc->caps = MMC_CAP_MULTIWRITE; 539 538 540 539 /* 541 540 * We can do SGIO
+1 -1
drivers/mmc/host/omap.c
··· 1317 1317 1318 1318 host->slots[id] = slot; 1319 1319 1320 - mmc->caps = MMC_CAP_MULTIWRITE; 1320 + mmc->caps = 0; 1321 1321 if (host->pdata->conf.wire4) 1322 1322 mmc->caps |= MMC_CAP_4_BIT_DATA; 1323 1323
+1 -1
drivers/mmc/host/tifm_sd.c
··· 973 973 974 974 mmc->ops = &tifm_sd_ops; 975 975 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; 976 - mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_MULTIWRITE; 976 + mmc->caps = MMC_CAP_4_BIT_DATA; 977 977 mmc->f_min = 20000000 / 60; 978 978 mmc->f_max = 24000000; 979 979
+1 -1
drivers/mmc/host/wbsd.c
··· 1219 1219 mmc->f_min = 375000; 1220 1220 mmc->f_max = 24000000; 1221 1221 mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; 1222 - mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_MULTIWRITE; 1222 + mmc->caps = MMC_CAP_4_BIT_DATA; 1223 1223 1224 1224 spin_lock_init(&host->lock); 1225 1225
+5 -6
include/linux/mmc/host.h
··· 111 111 unsigned long caps; /* Host capabilities */ 112 112 113 113 #define MMC_CAP_4_BIT_DATA (1 << 0) /* Can the host do 4 bit transfers */ 114 - #define MMC_CAP_MULTIWRITE (1 << 1) /* Can accurately report bytes sent to card on error */ 115 - #define MMC_CAP_MMC_HIGHSPEED (1 << 2) /* Can do MMC high-speed timing */ 116 - #define MMC_CAP_SD_HIGHSPEED (1 << 3) /* Can do SD high-speed timing */ 117 - #define MMC_CAP_SDIO_IRQ (1 << 4) /* Can signal pending SDIO IRQs */ 118 - #define MMC_CAP_SPI (1 << 5) /* Talks only SPI protocols */ 119 - #define MMC_CAP_NEEDS_POLL (1 << 6) /* Needs polling for card-detection */ 114 + #define MMC_CAP_MMC_HIGHSPEED (1 << 1) /* Can do MMC high-speed timing */ 115 + #define MMC_CAP_SD_HIGHSPEED (1 << 2) /* Can do SD high-speed timing */ 116 + #define MMC_CAP_SDIO_IRQ (1 << 3) /* Can signal pending SDIO IRQs */ 117 + #define MMC_CAP_SPI (1 << 4) /* Talks only SPI protocols */ 118 + #define MMC_CAP_NEEDS_POLL (1 << 5) /* Needs polling for card-detection */ 120 119 121 120 /* host specific block data */ 122 121 unsigned int max_seg_size; /* see blk_queue_max_segment_size */