merge of 425cf1b391611c169a1c3b78f1fe86df088902b9
[vuplus_openembedded] / packages / linux / linux-rp-2.6.16 / rmk-mmc1.patch
1
2 The CSD contains a "read2write factor" which determines the multiplier to
3 be applied to the read timeout to obtain the write timeout.  We were
4 ignoring this parameter, resulting in the possibility for writes being
5 timed out too early.
6
7 Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
8
9 diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
10 --- a/drivers/mmc/mmc.c
11 +++ b/drivers/mmc/mmc.c
12 @@ -549,6 +549,7 @@ static void mmc_decode_csd(struct mmc_ca
13                 csd->read_partial = UNSTUFF_BITS(resp, 79, 1);
14                 csd->write_misalign = UNSTUFF_BITS(resp, 78, 1);
15                 csd->read_misalign = UNSTUFF_BITS(resp, 77, 1);
16 +               csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3);
17                 csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4);
18                 csd->write_partial = UNSTUFF_BITS(resp, 21, 1);
19         } else {
20 @@ -583,6 +584,7 @@ static void mmc_decode_csd(struct mmc_ca
21                 csd->read_partial = UNSTUFF_BITS(resp, 79, 1);
22                 csd->write_misalign = UNSTUFF_BITS(resp, 78, 1);
23                 csd->read_misalign = UNSTUFF_BITS(resp, 77, 1);
24 +               csd->r2w_factor = UNSTUFF_BITS(resp, 26, 3);
25                 csd->write_blkbits = UNSTUFF_BITS(resp, 22, 4);
26                 csd->write_partial = UNSTUFF_BITS(resp, 21, 1);
27         }
28 diff --git a/drivers/mmc/mmc_block.c b/drivers/mmc/mmc_block.c
29 --- a/drivers/mmc/mmc_block.c
30 +++ b/drivers/mmc/mmc_block.c
31 @@ -187,6 +187,12 @@ static int mmc_blk_issue_rq(struct mmc_q
32                         brq.cmd.opcode = MMC_WRITE_BLOCK;
33                         brq.data.flags |= MMC_DATA_WRITE;
34                         brq.data.blocks = 1;
35 +
36 +                       /*
37 +                        * Scale up the timeout by the r2w factor
38 +                        */
39 +                       brq.data.timeout_ns <<= card->csd.r2w_factor;
40 +                       brq.data.timeout_clks <<= card->csd.r2w_factor;
41                 }
42  
43                 if (brq.data.blocks > 1) {
44 diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
45 --- a/include/linux/mmc/card.h
46 +++ b/include/linux/mmc/card.h
47 @@ -28,6 +28,7 @@ struct mmc_csd {
48         unsigned short          cmdclass;
49         unsigned short          tacc_clks;
50         unsigned int            tacc_ns;
51 +       unsigned int            r2w_factor;
52         unsigned int            max_dtr;
53         unsigned int            read_blkbits;
54         unsigned int            write_blkbits;
55
56
57 -------------------------------------------------------------------
58 List admin: http://lists.arm.linux.org.uk/mailman/listinfo/linux-arm-kernel
59 FAQ:        http://www.arm.linux.org.uk/mailinglists/faq.php
60 Etiquette:  http://www.arm.linux.org.uk/mailinglists/etiquette.php
61