diff mbox

[U-Boot,1/2,v2] SDHC/MMC: fix the wrong infomation after change SD card

Message ID 1337335022-18501-1-git-send-email-Chang-Ming.Huang@freescale.com
State Rejected, archived
Delegated to: Andy Fleming
Headers show

Commit Message

Jerry Huang May 18, 2012, 9:57 a.m. UTC
From: Jerry Huang <Chang-Ming.Huang@freescale.com>

When first inserting the SD card to slot, the command "mmcinfo" can
display the card information correctly.
But, then removing the SD card or inserting another SD card to slot,
the command "mmcinfo" can't display the information correctly.

when we use command "mmcinfo" every time, the driver must initialize the
SD card again, instead of assuming the card has been initialized.

Therefore remove the detect codes from mmc_init function.
And add the codes to check the mmc_init, only when mmc_init return
the right value, driver will print the information.

Below is the error log (SD card removed):
=> mmcinfo
MMC: no card present
Device: FSL_SDHC
Manufacturer ID: 3
OEM: 5344
Name: SD02G
Tran Speed: 25000000
Rd Block Len: 512
SD version 2.0
High Capacity: No
Capacity: 1.8 GiB
Bus Width: 4-bit

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
CC: Andy Fleming <afleming@gmail.com>
CC: Marek Vasut <marex@denx.de>
---
changes for v2:
	- keep the member has_init
	- only remove the detect code

 common/cmd_mmc.c  |    5 ++---
 drivers/mmc/mmc.c |    3 ---
 2 files changed, 2 insertions(+), 6 deletions(-)

Comments

Changming Huang July 11, 2012, 9:29 a.m. UTC | #1
Hi, Andy,
There is not any feedback for very long time,
Could it be applied to the u-boot?

Best Regards
Jerry Huang


> -----Original Message-----
> From: Huang Changming-R66093
> Sent: Friday, May 18, 2012 5:57 PM
> To: u-boot@lists.denx.de
> Cc: Huang Changming-R66093; Andy Fleming; Marek Vasut
> Subject: [PATCH 1/2 v2] SDHC/MMC: fix the wrong infomation after change
> SD card
> 
> From: Jerry Huang <Chang-Ming.Huang@freescale.com>
> 
> When first inserting the SD card to slot, the command "mmcinfo" can
> display the card information correctly.
> But, then removing the SD card or inserting another SD card to slot,
> the command "mmcinfo" can't display the information correctly.
> 
> when we use command "mmcinfo" every time, the driver must initialize the
> SD card again, instead of assuming the card has been initialized.
> 
> Therefore remove the detect codes from mmc_init function.
> And add the codes to check the mmc_init, only when mmc_init return
> the right value, driver will print the information.
> 
> Below is the error log (SD card removed):
> => mmcinfo
> MMC: no card present
> Device: FSL_SDHC
> Manufacturer ID: 3
> OEM: 5344
> Name: SD02G
> Tran Speed: 25000000
> Rd Block Len: 512
> SD version 2.0
> High Capacity: No
> Capacity: 1.8 GiB
> Bus Width: 4-bit
> 
> Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>
> CC: Andy Fleming <afleming@gmail.com>
> CC: Marek Vasut <marex@denx.de>
> ---
> changes for v2:
> 	- keep the member has_init
> 	- only remove the detect code
> 
>  common/cmd_mmc.c  |    5 ++---
>  drivers/mmc/mmc.c |    3 ---
>  2 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
> index 750509d..e73ce03 100644
> --- a/common/cmd_mmc.c
> +++ b/common/cmd_mmc.c
> @@ -131,9 +131,8 @@ int do_mmcinfo (cmd_tbl_t *cmdtp, int flag, int argc,
> char * const argv[])
>  	mmc = find_mmc_device(curr_device);
> 
>  	if (mmc) {
> -		mmc_init(mmc);
> -
> -		print_mmcinfo(mmc);
> +		if (!mmc_init(mmc))
> +			print_mmcinfo(mmc);
>  		return 0;
>  	} else {
>  		printf("no mmc device at slot %x\n", curr_device);
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index f92b662..af644bb 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1323,9 +1323,6 @@ int mmc_init(struct mmc *mmc)
>  		return NO_CARD_ERR;
>  	}
> 
> -	if (mmc->has_init)
> -		return 0;
> -
>  	err = mmc->init(mmc);
> 
>  	if (err)
> --
> 1.7.5.4
Andy Fleming July 13, 2012, 9:32 p.m. UTC | #2
On Wed, Jul 11, 2012 at 4:29 AM, Huang Changming-R66093
<r66093@freescale.com> wrote:
> Hi, Andy,
> There is not any feedback for very long time,
> Could it be applied to the u-boot?


I'm afraid I have to reject this patch. We need to find a better
solution to the two problems:

1) We want to change cards and still have mmc commands work
2) We don't want eMMC devices to be slowed down by constantly
re-initializing their cards.

Normally, I would err on the side of #1, but there's a simple
workaround. If you replace the card, execute "mmc rescan", and the
card will be reinitialized. Please let me know if that workaround
doesn't work. I hope, in the future, we'll have some code which makes
both possible, by being able to detect that a card has been changed,
but for now I think the current system is reasonably satisfactory to
both cases #1 and #2.

Andy
Marek Vasut July 14, 2012, 5 a.m. UTC | #3
Dear Andy Fleming,

> On Wed, Jul 11, 2012 at 4:29 AM, Huang Changming-R66093
> 
> <r66093@freescale.com> wrote:
> > Hi, Andy,
> > There is not any feedback for very long time,
> > Could it be applied to the u-boot?
> 
> I'm afraid I have to reject this patch. We need to find a better
> solution to the two problems:
> 
> 1) We want to change cards and still have mmc commands work
> 2) We don't want eMMC devices to be slowed down by constantly
> re-initializing their cards.
> 
> Normally, I would err on the side of #1, but there's a simple
> workaround. If you replace the card, execute "mmc rescan", and the
> card will be reinitialized. Please let me know if that workaround
> doesn't work. I hope, in the future, we'll have some code which makes
> both possible, by being able to detect that a card has been changed,
> but for now I think the current system is reasonably satisfactory to
> both cases #1 and #2.

Andy, I don't want to be a bastard, but do you happen to be overloaded? Or what 
is the exact reason your replies to patches are so slow?

Best regards,
Marek Vasut
Changming Huang July 30, 2012, 7 a.m. UTC | #4
Hi, Andy
Could you give some reason why eMMC device will be so slowed down by re-initialization?
I think eMMC device is initialized only once, except it invoke 'mmc_init' many times.

The workaround "mmc rescan" works when replace the card.
But if one card is removed, then use "mmcfinfo": there is no card present, while the previous card information is displayed, I don't' think it make sense.
=> mmc rescan
MMC: no card present
=> mmcinfo
MMC: no card present
Device: FSL_SDHC
Manufacturer ID: 2
OEM: 544d
Name: SD04G
Tran Speed: 50000000
Rd Block Len: 512
SD version 2.0
High Capacity: Yes
Capacity: 3.7 GiB
Bus Width: 4-bit

Best Regards
Jerry Huang


> -----Original Message-----
> From: Andy Fleming [mailto:afleming@gmail.com]
> Sent: Saturday, July 14, 2012 5:33 AM
> To: Huang Changming-R66093
> Cc: u-boot@lists.denx.de; Marek Vasut
> Subject: Re: [PATCH 1/2 v2] SDHC/MMC: fix the wrong infomation after
> change SD card
> 
> On Wed, Jul 11, 2012 at 4:29 AM, Huang Changming-R66093
> <r66093@freescale.com> wrote:
> > Hi, Andy,
> > There is not any feedback for very long time,
> > Could it be applied to the u-boot?
> 
> 
> I'm afraid I have to reject this patch. We need to find a better
> solution to the two problems:
> 
> 1) We want to change cards and still have mmc commands work
> 2) We don't want eMMC devices to be slowed down by constantly
> re-initializing their cards.
> 
> Normally, I would err on the side of #1, but there's a simple
> workaround. If you replace the card, execute "mmc rescan", and the
> card will be reinitialized. Please let me know if that workaround
> doesn't work. I hope, in the future, we'll have some code which makes
> both possible, by being able to detect that a card has been changed,
> but for now I think the current system is reasonably satisfactory to
> both cases #1 and #2.
> 
> Andy
diff mbox

Patch

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index 750509d..e73ce03 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -131,9 +131,8 @@  int do_mmcinfo (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	mmc = find_mmc_device(curr_device);
 
 	if (mmc) {
-		mmc_init(mmc);
-
-		print_mmcinfo(mmc);
+		if (!mmc_init(mmc))
+			print_mmcinfo(mmc);
 		return 0;
 	} else {
 		printf("no mmc device at slot %x\n", curr_device);
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index f92b662..af644bb 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1323,9 +1323,6 @@  int mmc_init(struct mmc *mmc)
 		return NO_CARD_ERR;
 	}
 
-	if (mmc->has_init)
-		return 0;
-
 	err = mmc->init(mmc);
 
 	if (err)