Skip to content

Commit 31c350f

Browse files
grigorigDom Cobley
authored andcommitted
sdhci-bcm2708: use multiblock-type transfers for single blocks
There are issues with both single block reads (missed completion) and writes (data loss in some cases!). Just don't do single block transfers anymore, and treat them like multiblock transfers. This adds a quirk for this and uses it.
1 parent 3a47543 commit 31c350f

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

‎drivers/mmc/card/block.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
10751075
brq->data.blocks = 1;
10761076
}
10771077

1078-
if (brq->data.blocks > 1 || do_rel_wr) {
1078+
if (brq->data.blocks > 1 || do_rel_wr || card->host->caps2 & MMC_CAP2_FORCE_MULTIBLOCK) {
10791079
/* SPI multiblock writes terminate using a special
10801080
* token, not a STOP_TRANSMISSION request.
10811081
*/

‎drivers/mmc/host/sdhci-bcm2708.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,6 +1392,9 @@ static int __devinit sdhci_bcm2708_probe(struct platform_device *pdev)
13921392

13931393
if (allow_highspeed)
13941394
host->mmc->caps |= MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED;
1395+
1396+
/* single block writes cause data loss with some SD cards! */
1397+
host->mmc->caps2 |= MMC_CAP2_FORCE_MULTIBLOCK;
13951398
#endif
13961399

13971400
ret = sdhci_add_host(host);

‎include/linux/mmc/host.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ struct mmc_host {
242242
#define MMC_CAP2_CACHE_CTRL (1 << 1) /* Allow cache control */
243243
#define MMC_CAP2_POWEROFF_NOTIFY (1 << 2) /* Notify poweroff supported */
244244
#define MMC_CAP2_NO_MULTI_READ (1 << 3) /* Multiblock reads don't work */
245+
#define MMC_CAP2_FORCE_MULTIBLOCK (1 << 4) /* Always use multiblock transfers */
245246

246247
mmc_pm_flag_t pm_caps; /* supported pm features */
247248
unsigned int power_notify_type;

0 commit comments

Comments
 (0)