All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] workaround of 1-bit mmc card in case cmd19 & cmd 14 not supported
@ 2010-12-17  3:21 zhangfei gao
  2010-12-20  4:52 ` Philip Rakity
  0 siblings, 1 reply; 4+ messages in thread
From: zhangfei gao @ 2010-12-17  3:21 UTC (permalink / raw)
  To: linux-mmc; +Cc: Chris Ball

If controller does not support cmd19 & cmd14, here is workaround we using.
Send just in case somebody require.

>From b95c5e8d1c5b42a149a521c4992dfd8fc8d61143 Mon Sep 17 00:00:00 2001
From: Zhangfei Gao <zhangfei.gao@marvell.com>
Date: Thu, 16 Dec 2010 22:28:40 -0500
Subject: [PATCH] mmc: workaround of 1-bit mmc card

	In case controller does not support cmd19 & cmd14.
	Use workaround to decrease bus width when error happen via reading
partition table

Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
---
 drivers/mmc/card/block.c |   28 ++++++++++++++++++++++++++++
 include/linux/mmc/host.h |    2 ++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 217f820..c0d2b73 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -432,6 +432,34 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue
*mq, struct request *req)
 		 * programming mode even when things go wrong.
 		 */
 		if (brq.cmd.error || brq.data.error || brq.stop.error) {
+			if (mmc_card_mmc(card)) {
+				u8 width = card->host->ios.bus_width;
+
+				if (width == MMC_BUS_WIDTH_4) {
+					printk(KERN_WARNING "%s: "
+						"retrying using 1 BIT WIDTH \n",
+						req->rq_disk->disk_name);
+					mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+							EXT_CSD_BUS_WIDTH,
+							EXT_CSD_BUS_WIDTH_1);
+
+					mmc_set_bus_width(card->host,
+							MMC_BUS_WIDTH_1);
+					continue;
+				}
+				if (width == MMC_BUS_WIDTH_8) {
+					printk(KERN_WARNING "%s: "
+						"retrying using 4 BIT WIDTH \n",
+						req->rq_disk->disk_name);
+					mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
+						EXT_CSD_BUS_WIDTH,
+						EXT_CSD_BUS_WIDTH_4);
+
+					mmc_set_bus_width(card->host,
+						MMC_BUS_WIDTH_4);
+					continue;
+				}
+			}
 			if (brq.data.blocks > 1 && rq_data_dir(req) == READ) {
 				/* Redo read one sector at a time */
 				printk(KERN_WARNING "%s: retrying using single "
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 4a9d9d2..2a2c1ab 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -249,6 +249,8 @@ extern struct mmc_host *mmc_alloc_host(int extra,
struct device *);
 extern int mmc_add_host(struct mmc_host *);
 extern void mmc_remove_host(struct mmc_host *);
 extern void mmc_free_host(struct mmc_host *);
+extern int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value);
+extern void mmc_set_bus_width(struct mmc_host *host, unsigned int width);

 static inline void *mmc_priv(struct mmc_host *host)
 {
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] workaround of 1-bit mmc card in case cmd19 & cmd 14 not supported
  2010-12-17  3:21 [patch] workaround of 1-bit mmc card in case cmd19 & cmd 14 not supported zhangfei gao
@ 2010-12-20  4:52 ` Philip Rakity
  2010-12-20  8:24   ` zhangfei gao
  0 siblings, 1 reply; 4+ messages in thread
From: Philip Rakity @ 2010-12-20  4:52 UTC (permalink / raw)
  To: zhangfei gao; +Cc: linux-mmc, Chris Ball


On Dec 16, 2010, at 7:21 PM, zhangfei gao wrote:

> If controller does not support cmd19 & cmd14, here is workaround we using.
> Send just in case somebody require.
> 
> From b95c5e8d1c5b42a149a521c4992dfd8fc8d61143 Mon Sep 17 00:00:00 2001
> From: Zhangfei Gao <zhangfei.gao@marvell.com>
> Date: Thu, 16 Dec 2010 22:28:40 -0500
> Subject: [PATCH] mmc: workaround of 1-bit mmc card
> 
> 	In case controller does not support cmd19 & cmd14.
> 	Use workaround to decrease bus width when error happen via reading
> partition table
> 
> Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
> ---
> drivers/mmc/card/block.c |   28 ++++++++++++++++++++++++++++
> include/linux/mmc/host.h |    2 ++
> 2 files changed, 30 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 217f820..c0d2b73 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -432,6 +432,34 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue
> *mq, struct request *req)
> 		 * programming mode even when things go wrong.
> 		 */
> 		if (brq.cmd.error || brq.data.error || brq.stop.error) {
> +			if (mmc_card_mmc(card)) {
> +				u8 width = card->host->ios.bus_width;
> +
> +				if (width == MMC_BUS_WIDTH_4) {
> +					printk(KERN_WARNING "%s: "
> +						"retrying using 1 BIT WIDTH \n",
> +						req->rq_disk->disk_name);
> +					mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
> +							EXT_CSD_BUS_WIDTH,
> +							EXT_CSD_BUS_WIDTH_1);
> +
> +					mmc_set_bus_width(card->host,
> +							MMC_BUS_WIDTH_1);
> +					continue;
> +				}
> +				if (width == MMC_BUS_WIDTH_8) {
> +					printk(KERN_WARNING "%s: "
> +						"retrying using 4 BIT WIDTH \n",
> +						req->rq_disk->disk_name);
> +					mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
> +						EXT_CSD_BUS_WIDTH,
> +						EXT_CSD_BUS_WIDTH_4);
> +
> +					mmc_set_bus_width(card->host,
> +						MMC_BUS_WIDTH_4);
> +					continue;
> +				}
> +			}
> 			if (brq.data.blocks > 1 && rq_data_dir(req) == READ) {
> 				/* Redo read one sector at a time */
> 				printk(KERN_WARNING "%s: retrying using single "
> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
> index 4a9d9d2..2a2c1ab 100644
> --- a/include/linux/mmc/host.h
> +++ b/include/linux/mmc/host.h
> @@ -249,6 +249,8 @@ extern struct mmc_host *mmc_alloc_host(int extra,
> struct device *);
> extern int mmc_add_host(struct mmc_host *);
> extern void mmc_remove_host(struct mmc_host *);
> extern void mmc_free_host(struct mmc_host *);
> +extern int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value);
> +extern void mmc_set_bus_width(struct mmc_host *host, unsigned int width);
> 
> static inline void *mmc_priv(struct mmc_host *host)
> {
> -- 
> 1.7.0.4

Curious, 
What cards fail without this patch ?  and on what system ?
PXA168/PXA910 and MMP2 all support bus width testing for mmc cards.

> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] workaround of 1-bit mmc card in case cmd19 & cmd 14 not supported
  2010-12-20  4:52 ` Philip Rakity
@ 2010-12-20  8:24   ` zhangfei gao
  2010-12-20 15:43     ` Philip Rakity
  0 siblings, 1 reply; 4+ messages in thread
From: zhangfei gao @ 2010-12-20  8:24 UTC (permalink / raw)
  To: Philip Rakity; +Cc: linux-mmc, Chris Ball

On Sun, Dec 19, 2010 at 11:52 PM, Philip Rakity <prakity@marvell.com> wrote:
>
> On Dec 16, 2010, at 7:21 PM, zhangfei gao wrote:
>
>> If controller does not support cmd19 & cmd14, here is workaround we using.
>> Send just in case somebody require.
>>
>> From b95c5e8d1c5b42a149a521c4992dfd8fc8d61143 Mon Sep 17 00:00:00 2001
>> From: Zhangfei Gao <zhangfei.gao@marvell.com>
>> Date: Thu, 16 Dec 2010 22:28:40 -0500
>> Subject: [PATCH] mmc: workaround of 1-bit mmc card
>>
>>       In case controller does not support cmd19 & cmd14.
>>       Use workaround to decrease bus width when error happen via reading
>> partition table
>>
>> Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
>> ---
>> drivers/mmc/card/block.c |   28 ++++++++++++++++++++++++++++
>> include/linux/mmc/host.h |    2 ++
>> 2 files changed, 30 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> index 217f820..c0d2b73 100644
>> --- a/drivers/mmc/card/block.c
>> +++ b/drivers/mmc/card/block.c
>> @@ -432,6 +432,34 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue
>> *mq, struct request *req)
>>                * programming mode even when things go wrong.
>>                */
>>               if (brq.cmd.error || brq.data.error || brq.stop.error) {
>> +                     if (mmc_card_mmc(card)) {
>> +                             u8 width = card->host->ios.bus_width;
>> +
>> +                             if (width == MMC_BUS_WIDTH_4) {
>> +                                     printk(KERN_WARNING "%s: "
>> +                                             "retrying using 1 BIT WIDTH \n",
>> +                                             req->rq_disk->disk_name);
>> +                                     mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
>> +                                                     EXT_CSD_BUS_WIDTH,
>> +                                                     EXT_CSD_BUS_WIDTH_1);
>> +
>> +                                     mmc_set_bus_width(card->host,
>> +                                                     MMC_BUS_WIDTH_1);
>> +                                     continue;
>> +                             }
>> +                             if (width == MMC_BUS_WIDTH_8) {
>> +                                     printk(KERN_WARNING "%s: "
>> +                                             "retrying using 4 BIT WIDTH \n",
>> +                                             req->rq_disk->disk_name);
>> +                                     mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
>> +                                             EXT_CSD_BUS_WIDTH,
>> +                                             EXT_CSD_BUS_WIDTH_4);
>> +
>> +                                     mmc_set_bus_width(card->host,
>> +                                             MMC_BUS_WIDTH_4);
>> +                                     continue;
>> +                             }
>> +                     }
>>                       if (brq.data.blocks > 1 && rq_data_dir(req) == READ) {
>>                               /* Redo read one sector at a time */
>>                               printk(KERN_WARNING "%s: retrying using single "
>> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
>> index 4a9d9d2..2a2c1ab 100644
>> --- a/include/linux/mmc/host.h
>> +++ b/include/linux/mmc/host.h
>> @@ -249,6 +249,8 @@ extern struct mmc_host *mmc_alloc_host(int extra,
>> struct device *);
>> extern int mmc_add_host(struct mmc_host *);
>> extern void mmc_remove_host(struct mmc_host *);
>> extern void mmc_free_host(struct mmc_host *);
>> +extern int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value);
>> +extern void mmc_set_bus_width(struct mmc_host *host, unsigned int width);
>>
>> static inline void *mmc_priv(struct mmc_host *host)
>> {
>> --
>> 1.7.0.4
>
> Curious,
> What cards fail without this patch ?  and on what system ?
> PXA168/PXA910 and MMP2 all support bus width testing for mmc cards.
>
We found some controller can not support cmd19 & cmd14 well, such as
pxa955, also mmp2 will support these two cmd after A2.
Here just send as reference in case still other controller has the same issue.

>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] workaround of 1-bit mmc card in case cmd19 & cmd 14 not supported
  2010-12-20  8:24   ` zhangfei gao
@ 2010-12-20 15:43     ` Philip Rakity
  0 siblings, 0 replies; 4+ messages in thread
From: Philip Rakity @ 2010-12-20 15:43 UTC (permalink / raw)
  To: zhangfei gao; +Cc: linux-mmc, Chris Ball


On Dec 20, 2010, at 12:24 AM, zhangfei gao wrote:

> On Sun, Dec 19, 2010 at 11:52 PM, Philip Rakity <prakity@marvell.com> wrote:
>> 
>> On Dec 16, 2010, at 7:21 PM, zhangfei gao wrote:
>> 
>>> If controller does not support cmd19 & cmd14, here is workaround we using.
>>> Send just in case somebody require.
>>> 
>>> From b95c5e8d1c5b42a149a521c4992dfd8fc8d61143 Mon Sep 17 00:00:00 2001
>>> From: Zhangfei Gao <zhangfei.gao@marvell.com>
>>> Date: Thu, 16 Dec 2010 22:28:40 -0500
>>> Subject: [PATCH] mmc: workaround of 1-bit mmc card
>>> 
>>>       In case controller does not support cmd19 & cmd14.
>>>       Use workaround to decrease bus width when error happen via reading
>>> partition table
>>> 
>>> Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
>>> ---
>>> drivers/mmc/card/block.c |   28 ++++++++++++++++++++++++++++
>>> include/linux/mmc/host.h |    2 ++
>>> 2 files changed, 30 insertions(+), 0 deletions(-)
>>> 
>>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>>> index 217f820..c0d2b73 100644
>>> --- a/drivers/mmc/card/block.c
>>> +++ b/drivers/mmc/card/block.c
>>> @@ -432,6 +432,34 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue
>>> *mq, struct request *req)
>>>                * programming mode even when things go wrong.
>>>                */
>>>               if (brq.cmd.error || brq.data.error || brq.stop.error) {
>>> +                     if (mmc_card_mmc(card)) {
>>> +                             u8 width = card->host->ios.bus_width;
>>> +
>>> +                             if (width == MMC_BUS_WIDTH_4) {
>>> +                                     printk(KERN_WARNING "%s: "
>>> +                                             "retrying using 1 BIT WIDTH \n",
>>> +                                             req->rq_disk->disk_name);
>>> +                                     mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
>>> +                                                     EXT_CSD_BUS_WIDTH,
>>> +                                                     EXT_CSD_BUS_WIDTH_1);
>>> +
>>> +                                     mmc_set_bus_width(card->host,
>>> +                                                     MMC_BUS_WIDTH_1);
>>> +                                     continue;
>>> +                             }
>>> +                             if (width == MMC_BUS_WIDTH_8) {
>>> +                                     printk(KERN_WARNING "%s: "
>>> +                                             "retrying using 4 BIT WIDTH \n",
>>> +                                             req->rq_disk->disk_name);
>>> +                                     mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
>>> +                                             EXT_CSD_BUS_WIDTH,
>>> +                                             EXT_CSD_BUS_WIDTH_4);
>>> +
>>> +                                     mmc_set_bus_width(card->host,
>>> +                                             MMC_BUS_WIDTH_4);
>>> +                                     continue;
>>> +                             }
>>> +                     }
>>>                       if (brq.data.blocks > 1 && rq_data_dir(req) == READ) {
>>>                               /* Redo read one sector at a time */
>>>                               printk(KERN_WARNING "%s: retrying using single "
>>> diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
>>> index 4a9d9d2..2a2c1ab 100644
>>> --- a/include/linux/mmc/host.h
>>> +++ b/include/linux/mmc/host.h
>>> @@ -249,6 +249,8 @@ extern struct mmc_host *mmc_alloc_host(int extra,
>>> struct device *);
>>> extern int mmc_add_host(struct mmc_host *);
>>> extern void mmc_remove_host(struct mmc_host *);
>>> extern void mmc_free_host(struct mmc_host *);
>>> +extern int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value);
>>> +extern void mmc_set_bus_width(struct mmc_host *host, unsigned int width);
>>> 
>>> static inline void *mmc_priv(struct mmc_host *host)
>>> {
>>> --
>>> 1.7.0.4
>> 
>> Curious,
>> What cards fail without this patch ?  and on what system ?
>> PXA168/PXA910 and MMP2 all support bus width testing for mmc cards.
>> 
> We found some controller can not support cmd19 & cmd14 well, such as
> pxa955, also mmp2 will support these two cmd after A2.

mmp2 supports cmd19 and cmd14 today. My testing shows bit width testing
works.  The time taken for the cmd19/cmd14 exchange will improve in future.

> Here just send as reference in case still other controller has the same issue.
> 
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> 
>> 


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-12-20 15:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-17  3:21 [patch] workaround of 1-bit mmc card in case cmd19 & cmd 14 not supported zhangfei gao
2010-12-20  4:52 ` Philip Rakity
2010-12-20  8:24   ` zhangfei gao
2010-12-20 15:43     ` Philip Rakity

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.