remove 2.6.37 patches and config
[openwrt/openwrt.git] / target / linux / ep93xx / patches-2.6.37 / 002-mmc_spi_fix_sdhc.patch
1 This patch makes SDHC cards work with the mmc_spi driver.
2
3 The problem is that they fail when reading the last block of the card using
4 a multi-block read. This is because on SDHC the multiple block read has to be
5 stopped with an explicit STOP command, which needs to be sent to the card
6 while the incoming transfer is in progress.
7 The 2.6.3[45] mmc-spi driver sends it after the last block transfer, so the
8 SDHC card continues reading past the end of the card.
9 This patch works around this by using single-block reads if we're reading the
10 last blocks of the card.
11 -martinwguy, 14 May 2010
12
13 Date: Thu, 29 Apr 2010 21:30:36 +0300
14 From: Mika Westerberg <mika.westerberg@iki.fi>
15 To: Martin Guy <martinwguy@gmail.com>
16
17 On 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
24 I bought today a new 4GB SDHC card and with that I get similar
25 errors that you are getting. I hacked around quick fix which seems
26 to work in my case. I'm wondering whether you could check if it
27 helps with your SDHC card as well?
28
29 This problem is easy to reproduce, just read last sector of the
30 card (I wrote simple C program but running fdisk -l does the same).
31
32 Patch is below.
33
34 Thanks,
35 MW
36
37 From: Mika Westerberg <mika.westerberg@iki.fi>
38 Date: Thu, 29 Apr 2010 21:14:32 +0300
39 Subject: [PATCH] mmc_block: use single block reads for last block on SPI
40
41 Some SD-cards fail when doing multiblock read for last block with SPI host. Real
42 reason is not known but as workaround we can perform this last read using
43 multiple single block reads.
44
45 Signed-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