Root/target/linux/ep93xx/patches-2.6.39/002-mmc_spi_fix_sdhc.patch

1This patch makes SDHC cards work with the mmc_spi driver.
2
3The problem is that they fail when reading the last block of the card using
4a multi-block read. This is because on SDHC the multiple block read has to be
5stopped with an explicit STOP command, which needs to be sent to the card
6while the incoming transfer is in progress.
7The 2.6.3[45] mmc-spi driver sends it after the last block transfer, so the
8SDHC card continues reading past the end of the card.
9This patch works around this by using single-block reads if we're reading the
10last blocks of the card.
11  -martinwguy, 14 May 2010
12
13Date: Thu, 29 Apr 2010 21:30:36 +0300
14From: Mika Westerberg <mika.westerberg@iki.fi>
15To: Martin Guy <martinwguy@gmail.com>
16
17On Wed, Apr 21, 2010 at 02:10:08AM +0100, Martin Guy wrote:
18>
19> the SDHC cards I have don't work at all, spewing tons of:
20> mmcblk0: error -38 sending status comand
21> mmcblk0: error -38 sending read/write command, response 0x4, card status 0xff04
22> end_request: I/O error, dev mmcblk0, sector 7744509
23
24I bought today a new 4GB SDHC card and with that I get similar
25errors that you are getting. I hacked around quick fix which seems
26to work in my case. I'm wondering whether you could check if it
27helps with your SDHC card as well?
28
29This problem is easy to reproduce, just read last sector of the
30card (I wrote simple C program but running fdisk -l does the same).
31
32Patch is below.
33
34Thanks,
35MW
36
37From: Mika Westerberg <mika.westerberg@iki.fi>
38Date: Thu, 29 Apr 2010 21:14:32 +0300
39Subject: [PATCH] mmc_block: use single block reads for last block on SPI
40
41Some SD-cards fail when doing multiblock read for last block with SPI host. Real
42reason is not known but as workaround we can perform this last read using
43multiple single block reads.
44
45Signed-off-by: Mika Westerberg <mika.westerberg@iki.fi>
46---
47 drivers/mmc/card/block.c | 19 +++++++++++++++++++
48 1 files changed, 19 insertions(+), 0 deletions(-)
49
50--- a/drivers/mmc/card/block.c
51+++ b/drivers/mmc/card/block.c
52@@ -366,6 +366,22 @@ static int mmc_blk_issue_rw_rq(struct mm
53         if (brq.data.blocks > card->host->max_blk_count)
54             brq.data.blocks = card->host->max_blk_count;
55 
56+ if (mmc_host_is_spi(card->host)) {
57+ /*
58+ * Some SD-cards fail when we are reading last block
59+ * with multiblock read. In these cases we automatically
60+ * use single block reads. This only happens on SPI
61+ * hosts.
62+ */
63+ if (rq_data_dir(req) == READ && brq.data.blocks > 1) {
64+ sector_t s = blk_rq_pos(req) + brq.data.blocks;
65+
66+ if (s >= get_capacity(md->disk)) {
67+ disable_multi = 1;
68+ }
69+ }
70+ }
71+
72         /*
73          * After a read error, we redo the request one sector at a time
74          * in order to accurately determine which sectors can be read
75

Archive Download this file



interactive