diff mbox

[U-Boot] mmc: fix ERASE_GRP_DEF handling

Message ID OF1DCACC94.2F2894EE-ONC1257D2E.002ACA34-C1257D2E.002ACA36@br-automation.com
State Accepted
Delegated to: Pantelis Antoniou
Headers show

Commit Message

Hannes Schmelzer Aug. 8, 2014, 7:47 a.m. UTC
if we set manually this bit on the eMMC card using mmc_switch(...),
we also have to set it within our (before read) internal structure
'ext_csd'.

Otherwise following checks on this will fail.

Signed-off-by: Hannes Petermaier <oe5hpm@oevsv.at>
---
 drivers/mmc/mmc.c |    2 ++
 1 file changed, 2 insertions(+)

Comments

Jaehoon Chung Aug. 12, 2014, 4:24 a.m. UTC | #1
Hi, Hannes.

On 08/08/2014 04:47 PM, Hannes Petermaier wrote:
> if we set manually this bit on the eMMC card using mmc_switch(...),
> we also have to set it within our (before read) internal structure
> 'ext_csd'.
> 
> Otherwise following checks on this will fail.
> 
> Signed-off-by: Hannes Petermaier <oe5hpm@oevsv.at>
> ---
>  drivers/mmc/mmc.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index a26f3ce..52a8e36 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -1010,6 +1010,8 @@ static int mmc_startup(struct mmc *mmc)
>  
>  			if (err)
>  				return err;
> +			else
> +				ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1;
When is this value read?
If i'm right, you means that it has to set before comparing with test_csd, right?
It's reasonable, but i'm not sure that hard-coding is right.

Best Regards,
Jaehoon Chung

>  
>  			/* Read out group size from ext_csd */
>  			mmc->erase_grp_size =
>
Hannes Schmelzer Aug. 12, 2014, 5:47 a.m. UTC | #2
> Hi, Hannes.
Hi Jaehoon,

> > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> > index a26f3ce..52a8e36 100644
> > --- a/drivers/mmc/mmc.c
> > +++ b/drivers/mmc/mmc.c
> > @@ -1010,6 +1010,8 @@ static int mmc_startup(struct mmc *mmc)
> > 
> >           if (err)
> >              return err;
> > +         else
> > +            ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1;
> When is this value read?

a few lines above, have a look at line 967:
/* check  ext_csd version and capacity */
err = mmc_send_ext_csd(mmc, ext_csd);

> If i'm right, you means that it has to set before comparing with 
test_csd, right?
yes, exactly thats what i mean.

> It's reasonable, but i'm not sure that hard-coding is right.
why not ? we set the bit using mmc_switch, and only after success we alter 
our internal structure.

> 
> Best Regards,
> Jaehoon Chung

best regards,
Hannes
Pantelis Antoniou Oct. 2, 2014, 10:49 a.m. UTC | #3
Hi Hannes,

On Aug 12, 2014, at 8:47 AM, Hannes Petermaier <Hannes.Petermaier@br-automation.com> wrote:

>> Hi, Hannes.
> Hi Jaehoon,
> 
>>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>>> index a26f3ce..52a8e36 100644
>>> --- a/drivers/mmc/mmc.c
>>> +++ b/drivers/mmc/mmc.c
>>> @@ -1010,6 +1010,8 @@ static int mmc_startup(struct mmc *mmc)
>>> 
>>>          if (err)
>>>             return err;
>>> +         else
>>> +            ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1;
>> When is this value read?
> 
> a few lines above, have a look at line 967:
> /* check  ext_csd version and capacity */
> err = mmc_send_ext_csd(mmc, ext_csd);
> 
>> If i'm right, you means that it has to set before comparing with 
> test_csd, right?
> yes, exactly thats what i mean.
> 
>> It's reasonable, but i'm not sure that hard-coding is right.
> why not ? we set the bit using mmc_switch, and only after success we alter 
> our internal structure.
> 

It is reasonable in this context, but I’m wary of cases where a read would be
required in case the write didn’t ‘take’.

I’ll apply this for now.

>> 
>> Best Regards,
>> Jaehoon Chung
> 
> best regards,
> Hannes
> 
> 
> 

Regards

— Pantelis
diff mbox

Patch

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index a26f3ce..52a8e36 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -1010,6 +1010,8 @@  static int mmc_startup(struct mmc *mmc)
 
 			if (err)
 				return err;
+			else
+				ext_csd[EXT_CSD_ERASE_GROUP_DEF] = 1;
 
 			/* Read out group size from ext_csd */
 			mmc->erase_grp_size =