diff mbox

mmc: core: eMMC4.5 Add the timeout for switch

Message ID 1314699770-17120-1-git-send-email-girish.shivananjappa@linaro.org
State New
Headers show

Commit Message

Girish K S Aug. 30, 2011, 10:22 a.m. UTC
This patch adds the code to handle the default timeout
for switch command.
For eMMC 4.5 devices if timeout is not specified for the switch
command while accessing a specific field,then the default timeout
shall be used to timeout. Specification says there is no timeout
defined while accessing BKOPS_START, SANITIZE_START, FLUSH_CACHE
field(so these fields are excluded).

Signed-off-by: Girish K S <girish.shivananjappa@linaro.org>
---
 drivers/mmc/core/mmc.c     |    5 +++++
 drivers/mmc/core/mmc_ops.c |    8 ++++++++
 include/linux/mmc/card.h   |    1 +
 include/linux/mmc/mmc.h    |    4 ++++
 4 files changed, 18 insertions(+), 0 deletions(-)

Comments

Girish K S Aug. 30, 2011, 4:07 p.m. UTC | #1
hi all,
the datatype of u8 cmd6_timeout in struct mmc_ext_csd in
lnclude/linux/mmc/card.h should be modified to u16, as its value can go upto
255x10.
will send the modified v2 patch for this soon.


On Tuesday, 30 August 2011, Girish K S <girish.shivananjappa@linaro.org>
wrote:
> This patch adds the code to handle the default timeout
> for switch command.
> For eMMC 4.5 devices if timeout is not specified for the switch
> command while accessing a specific field,then the default timeout
> shall be used to timeout. Specification says there is no timeout
> defined while accessing BKOPS_START, SANITIZE_START, FLUSH_CACHE
> field(so these fields are excluded).
>
> Signed-off-by: Girish K S <girish.shivananjappa@linaro.org>
> ---
>  drivers/mmc/core/mmc.c     |    5 +++++
>  drivers/mmc/core/mmc_ops.c |    8 ++++++++
>  include/linux/mmc/card.h   |    1 +
>  include/linux/mmc/mmc.h    |    4 ++++
>  4 files changed, 18 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 5700b1c..5b9fb6a 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -405,6 +405,11 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8
*ext_csd)
>        if (card->ext_csd.rev >= 5)
>                card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM];
>
> +       if (card->ext_csd.rev > 5) {
> +               /* (eMMC 4.5)timeout is expressed in units of 10 ms*/
> +               card->ext_csd.cmd6_timeout =
ext_csd[EXT_CSD_CMD6_TIME]*10;
> +       }
> +
>        if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
>                card->erased_byte = 0xFF;
>        else
> diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
> index 770c3d0..c4d82f4 100644
> --- a/drivers/mmc/core/mmc_ops.c
> +++ b/drivers/mmc/core/mmc_ops.c
> @@ -394,6 +394,14 @@ int mmc_switch(struct mmc_card *card, u8 set, u8
index, u8 value,
>        cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
>        cmd.cmd_timeout_ms = timeout_ms;
>
> +       /* timeout is not defined for below command indexes (eMMC 4.5) */
> +       if ((timeout_ms == 0)                                   &&
> +               (card->ext_csd->rev > 5)                        &&
> +               (index != EXT_CSD_BKOPS_START)          &&
> +               (index != EXT_CSD_SANITIZE_START)       &&
> +               (index != EXT_CSD_FLUSH_CACHE))
> +                       cmd.cmd_timeout_ms = card->ext_csd->cmd6_timeout;
> +
>        err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
>        if (err)
>                return err;
> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> index b460fc2..ef88412 100644
> --- a/include/linux/mmc/card.h
> +++ b/include/linux/mmc/card.h
> @@ -50,6 +50,7 @@ struct mmc_ext_csd {
>        u8                      rel_sectors;
>        u8                      rel_param;
>        u8                      part_config;
> +       u8                      cmd6_timeout;   /* timeout in ms */
>        unsigned int            part_time;              /* Units: ms */
>        unsigned int            sa_timeout;             /* Units: 100ns */
>        unsigned int            hs_max_dtr;
> diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
> index 5a794cb..a23f836 100644
> --- a/include/linux/mmc/mmc.h
> +++ b/include/linux/mmc/mmc.h
> @@ -270,8 +270,11 @@ struct _mmc_csd {
>  * EXT_CSD fields
>  */
>
> +#define EXT_CSD_FLUSH_CACHE            32      /* R/W */
>  #define EXT_CSD_PARTITION_ATTRIBUTE    156     /* R/W */
>  #define EXT_CSD_PARTITION_SUPPORT      160     /* RO */
> +#define EXT_CSD_BKOPS_START            164     /* R/W */
> +#define EXT_CSD_SANITIZE_START         165     /* R/W */
>  #define EXT_CSD_WR_REL_PARAM           166     /* RO */
>  #define EXT_CSD_ERASE_GROUP_DEF                175     /* R/W */
>  #define EXT_CSD_PART_CONFIG            179     /* R/W */
> @@ -293,6 +296,7 @@ struct _mmc_csd {
>  #define EXT_CSD_SEC_ERASE_MULT         230     /* RO */
>  #define EXT_CSD_SEC_FEATURE_SUPPORT    231     /* RO */
>  #define EXT_CSD_TRIM_MULT              232     /* RO */
> +#define EXT_CSD_CMD6_TIME              248     /* RO */
>
>  /*
>  * EXT_CSD field definitions
> --
> 1.7.1
>
>
Kukjin Kim Sept. 1, 2011, 2:13 a.m. UTC | #2
Girish K S wrote:
> 
> This patch adds the code to handle the default timeout
> for switch command.
> For eMMC 4.5 devices if timeout is not specified for the switch
> command while accessing a specific field,then the default timeout
> shall be used to timeout. Specification says there is no timeout
> defined while accessing BKOPS_START, SANITIZE_START, FLUSH_CACHE
> field(so these fields are excluded).
> 
> Signed-off-by: Girish K S <girish.shivananjappa@linaro.org>
> ---
>  drivers/mmc/core/mmc.c     |    5 +++++
>  drivers/mmc/core/mmc_ops.c |    8 ++++++++
>  include/linux/mmc/card.h   |    1 +
>  include/linux/mmc/mmc.h    |    4 ++++
>  4 files changed, 18 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> index 5700b1c..5b9fb6a 100644
> --- a/drivers/mmc/core/mmc.c
> +++ b/drivers/mmc/core/mmc.c
> @@ -405,6 +405,11 @@ static int mmc_read_ext_csd(struct mmc_card *card, u8
> *ext_csd)
>  	if (card->ext_csd.rev >= 5)
>  		card->ext_csd.rel_param =
> ext_csd[EXT_CSD_WR_REL_PARAM];
> 
> +	if (card->ext_csd.rev > 5) {
> +		/* (eMMC 4.5)timeout is expressed in units of 10 ms*/
> +		card->ext_csd.cmd6_timeout =
> ext_csd[EXT_CSD_CMD6_TIME]*10;
> +	}
> +
>  	if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
>  		card->erased_byte = 0xFF;
>  	else
> diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
> index 770c3d0..c4d82f4 100644
> --- a/drivers/mmc/core/mmc_ops.c
> +++ b/drivers/mmc/core/mmc_ops.c
> @@ -394,6 +394,14 @@ int mmc_switch(struct mmc_card *card, u8 set, u8
index,
> u8 value,
>  	cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
>  	cmd.cmd_timeout_ms = timeout_ms;
> 
> +	/* timeout is not defined for below command indexes (eMMC 4.5) */
> +	if ((timeout_ms == 0)					&&
> +		(card->ext_csd->rev > 5)			&&
> +		(index != EXT_CSD_BKOPS_START)		&&
> +		(index != EXT_CSD_SANITIZE_START)	&&
> +		(index != EXT_CSD_FLUSH_CACHE))
> +			cmd.cmd_timeout_ms = card->ext_csd->cmd6_timeout;
> +
>  	err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
>  	if (err)
>  		return err;
> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> index b460fc2..ef88412 100644
> --- a/include/linux/mmc/card.h
> +++ b/include/linux/mmc/card.h
> @@ -50,6 +50,7 @@ struct mmc_ext_csd {
>  	u8			rel_sectors;
>  	u8			rel_param;
>  	u8			part_config;
> +	u8			cmd6_timeout;	/* timeout in ms */
>  	unsigned int		part_time;		/* Units: ms */
>  	unsigned int		sa_timeout;		/* Units: 100ns */
>  	unsigned int		hs_max_dtr;
> diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
> index 5a794cb..a23f836 100644
> --- a/include/linux/mmc/mmc.h
> +++ b/include/linux/mmc/mmc.h
> @@ -270,8 +270,11 @@ struct _mmc_csd {
>   * EXT_CSD fields
>   */
> 
> +#define EXT_CSD_FLUSH_CACHE		32	/* R/W */
>  #define EXT_CSD_PARTITION_ATTRIBUTE	156	/* R/W */
>  #define EXT_CSD_PARTITION_SUPPORT	160	/* RO */
> +#define EXT_CSD_BKOPS_START		164	/* R/W */
> +#define EXT_CSD_SANITIZE_START		165	/* R/W */
>  #define EXT_CSD_WR_REL_PARAM		166	/* RO */
>  #define EXT_CSD_ERASE_GROUP_DEF		175	/* R/W */
>  #define EXT_CSD_PART_CONFIG		179	/* R/W */
> @@ -293,6 +296,7 @@ struct _mmc_csd {
>  #define EXT_CSD_SEC_ERASE_MULT		230	/* RO */
>  #define EXT_CSD_SEC_FEATURE_SUPPORT	231	/* RO */
>  #define EXT_CSD_TRIM_MULT		232	/* RO */
> +#define EXT_CSD_CMD6_TIME		248	/* RO */
> 
>  /*
>   * EXT_CSD field definitions
> --
> 1.7.1

Hi Girish,

(Cc'ed Seungwon Jeon)

As I know, Seungwon Jeon has been submitted same/similar patch before this.
http://www.spinics.net/lists/linux-mmc/msg09770.html

Chris,
I cannot find your review on that...

Thanks.

Best regards,
Kgene.
--
Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
SW Solution Development Team, Samsung Electronics Co., Ltd.
Girish K S Sept. 1, 2011, 3:50 a.m. UTC | #3
hi kukjin,
but I cannot see its handling in the mmc_ops.c file which also updates the
switch function.
regards
girish

On Thursday, 1 September 2011, Kukjin Kim <kgene.kim@samsung.com> wrote:
> Girish K S wrote:
>>
>> This patch adds the code to handle the default timeout
>> for switch command.
>> For eMMC 4.5 devices if timeout is not specified for the switch
>> command while accessing a specific field,then the default timeout
>> shall be used to timeout. Specification says there is no timeout
>> defined while accessing BKOPS_START, SANITIZE_START, FLUSH_CACHE
>> field(so these fields are excluded).
>>
>> Signed-off-by: Girish K S <girish.shivananjappa@linaro.org>
>> ---
>>  drivers/mmc/core/mmc.c     |    5 +++++
>>  drivers/mmc/core/mmc_ops.c |    8 ++++++++
>>  include/linux/mmc/card.h   |    1 +
>>  include/linux/mmc/mmc.h    |    4 ++++
>>  4 files changed, 18 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>> index 5700b1c..5b9fb6a 100644
>> --- a/drivers/mmc/core/mmc.c
>> +++ b/drivers/mmc/core/mmc.c
>> @@ -405,6 +405,11 @@ static int mmc_read_ext_csd(struct mmc_card *card,
u8
>> *ext_csd)
>>       if (card->ext_csd.rev >= 5)
>>               card->ext_csd.rel_param =
>> ext_csd[EXT_CSD_WR_REL_PARAM];
>>
>> +     if (card->ext_csd.rev > 5) {
>> +             /* (eMMC 4.5)timeout is expressed in units of 10 ms*/
>> +             card->ext_csd.cmd6_timeout =
>> ext_csd[EXT_CSD_CMD6_TIME]*10;
>> +     }
>> +
>>       if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
>>               card->erased_byte = 0xFF;
>>       else
>> diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
>> index 770c3d0..c4d82f4 100644
>> --- a/drivers/mmc/core/mmc_ops.c
>> +++ b/drivers/mmc/core/mmc_ops.c
>> @@ -394,6 +394,14 @@ int mmc_switch(struct mmc_card *card, u8 set, u8
> index,
>> u8 value,
>>       cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
>>       cmd.cmd_timeout_ms = timeout_ms;
>>
>> +     /* timeout is not defined for below command indexes (eMMC 4.5) */
>> +     if ((timeout_ms == 0)                                   &&
>> +             (card->ext_csd->rev > 5)                        &&
>> +             (index != EXT_CSD_BKOPS_START)          &&
>> +             (index != EXT_CSD_SANITIZE_START)       &&
>> +             (index != EXT_CSD_FLUSH_CACHE))
>> +                     cmd.cmd_timeout_ms = card->ext_csd->cmd6_timeout;
>> +
>>       err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
>>       if (err)
>>               return err;
>> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
>> index b460fc2..ef88412 100644
>> --- a/include/linux/mmc/card.h
>> +++ b/include/linux/mmc/card.h
>> @@ -50,6 +50,7 @@ struct mmc_ext_csd {
>>       u8                      rel_sectors;
>>       u8                      rel_param;
>>       u8                      part_config;
>> +     u8                      cmd6_timeout;   /* timeout in ms */
>>       unsigned int            part_time;              /* Units: ms */
>>       unsigned int            sa_timeout;             /* Units: 100ns */
>>       unsigned int            hs_max_dtr;
>> diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
>> index 5a794cb..a23f836 100644
>> --- a/include/linux/mmc/mmc.h
>> +++ b/include/linux/mmc/mmc.hHi Girish,
>
> (Cc'ed Seungwon Jeon)
>
> As I know, Seungwon Jeon has been submitted same/similar patch before
this.
> http://www.spinics.net/lists/linux-mmc/msg09770.html
>
> Chris,
> I cannot find your review on that...
>
> Thanks.
>
> Best regards,
> Kgene.
> --
> Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
> SW Solution Development Team, Samsung Electronics Co., Ltd.
>
>
Girish K S Sept. 1, 2011, 5:09 a.m. UTC | #4
Hello Mr Kukjin,
           I checked this link "
http://www.spinics.net/lists/linux-mmc/msg09770.html" given by you,
but this link has the patch only to extract the timeout value from the
extended CSD register of the eMMC 4.5 device.
Whereas if you review my patch you can actually see the implementation of
the timeout handling in the mmc_switch
function in the mmc_ops.c

Thanks and regards
Girish K S

On 1 September 2011 07:43, Kukjin Kim <kgene.kim@samsung.com> wrote:

> Girish K S wrote:
> >
> > This patch adds the code to handle the default timeout
> > for switch command.
> > For eMMC 4.5 devices if timeout is not specified for the switch
> > command while accessing a specific field,then the default timeout
> > shall be used to timeout. Specification says there is no timeout
> > defined while accessing BKOPS_START, SANITIZE_START, FLUSH_CACHE
> > field(so these fields are excluded).
> >
> > Signed-off-by: Girish K S <girish.shivananjappa@linaro.org>
> > ---
> >  drivers/mmc/core/mmc.c     |    5 +++++
> >  drivers/mmc/core/mmc_ops.c |    8 ++++++++
> >  include/linux/mmc/card.h   |    1 +
> >  include/linux/mmc/mmc.h    |    4 ++++
> >  4 files changed, 18 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
> > index 5700b1c..5b9fb6a 100644
> > --- a/drivers/mmc/core/mmc.c
> > +++ b/drivers/mmc/core/mmc.c
> > @@ -405,6 +405,11 @@ static int mmc_read_ext_csd(struct mmc_card *card,
> u8
> > *ext_csd)
> >       if (card->ext_csd.rev >= 5)
> >               card->ext_csd.rel_param =
> > ext_csd[EXT_CSD_WR_REL_PARAM];
> >
> > +     if (card->ext_csd.rev > 5) {
> > +             /* (eMMC 4.5)timeout is expressed in units of 10 ms*/
> > +             card->ext_csd.cmd6_timeout =
> > ext_csd[EXT_CSD_CMD6_TIME]*10;
> > +     }
> > +
> >       if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
> >               card->erased_byte = 0xFF;
> >       else
> > diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
> > index 770c3d0..c4d82f4 100644
> > --- a/drivers/mmc/core/mmc_ops.c
> > +++ b/drivers/mmc/core/mmc_ops.c
> > @@ -394,6 +394,14 @@ int mmc_switch(struct mmc_card *card, u8 set, u8
> index,
> > u8 value,
> >       cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
> >       cmd.cmd_timeout_ms = timeout_ms;
> >
> > +     /* timeout is not defined for below command indexes (eMMC 4.5) */
> > +     if ((timeout_ms == 0)                                   &&
> > +             (card->ext_csd->rev > 5)                        &&
> > +             (index != EXT_CSD_BKOPS_START)          &&
> > +             (index != EXT_CSD_SANITIZE_START)       &&
> > +             (index != EXT_CSD_FLUSH_CACHE))
> > +                     cmd.cmd_timeout_ms = card->ext_csd->cmd6_timeout;
> > +
> >       err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
> >       if (err)
> >               return err;
> > diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
> > index b460fc2..ef88412 100644
> > --- a/include/linux/mmc/card.h
> > +++ b/include/linux/mmc/card.h
> > @@ -50,6 +50,7 @@ struct mmc_ext_csd {
> >       u8                      rel_sectors;
> >       u8                      rel_param;
> >       u8                      part_config;
> > +     u8                      cmd6_timeout;   /* timeout in ms */
> >       unsigned int            part_time;              /* Units: ms */
> >       unsigned int            sa_timeout;             /* Units: 100ns */
> >       unsigned int            hs_max_dtr;
> > diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
> > index 5a794cb..a23f836 100644
> > --- a/include/linux/mmc/mmc.h
> > +++ b/include/linux/mmc/mmc.h
> > @@ -270,8 +270,11 @@ struct _mmc_csd {
> >   * EXT_CSD fields
> >   */
> >
> > +#define EXT_CSD_FLUSH_CACHE          32      /* R/W */
> >  #define EXT_CSD_PARTITION_ATTRIBUTE  156     /* R/W */
> >  #define EXT_CSD_PARTITION_SUPPORT    160     /* RO */
> > +#define EXT_CSD_BKOPS_START          164     /* R/W */
> > +#define EXT_CSD_SANITIZE_START               165     /* R/W */
> >  #define EXT_CSD_WR_REL_PARAM         166     /* RO */
> >  #define EXT_CSD_ERASE_GROUP_DEF              175     /* R/W */
> >  #define EXT_CSD_PART_CONFIG          179     /* R/W */
> > @@ -293,6 +296,7 @@ struct _mmc_csd {
> >  #define EXT_CSD_SEC_ERASE_MULT               230     /* RO */
> >  #define EXT_CSD_SEC_FEATURE_SUPPORT  231     /* RO */
> >  #define EXT_CSD_TRIM_MULT            232     /* RO */
> > +#define EXT_CSD_CMD6_TIME            248     /* RO */
> >
> >  /*
> >   * EXT_CSD field definitions
> > --
> > 1.7.1
>
> Hi Girish,
>
> (Cc'ed Seungwon Jeon)
>
> As I know, Seungwon Jeon has been submitted same/similar patch before this.
> http://www.spinics.net/lists/linux-mmc/msg09770.html
>
> Chris,
> I cannot find your review on that...
>
> Thanks.
>
> Best regards,
> Kgene.
> --
> Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
> SW Solution Development Team, Samsung Electronics Co., Ltd.
>
>
Girish K S Sept. 1, 2011, 5:15 a.m. UTC | #5
Hello Mr Kukjin,
          I checked this link
"http://www.spinics.net/lists/linux-mmc/msg09770.html"
given by you,but this link has the patch only to extract the timeout
value from the
extended CSD register of the eMMC 4.5 device. Whereas if you review my patch
you can actually see the implementation of the timeout handling in the
mmc_switch
function in the mmc_ops.c

Sorry my previous mails were with ricj text enabled.
Thanks and regards
Girish K S


On 1 September 2011 09:20, Girish K S <girish.shivananjappa@linaro.org> wrote:
> hi kukjin,
> but I cannot see its handling in the mmc_ops.c file which also updates the
> switch function.
> regards
> girish
>
> On Thursday, 1 September 2011, Kukjin Kim <kgene.kim@samsung.com> wrote:
>> Girish K S wrote:
>>>
>>> This patch adds the code to handle the default timeout
>>> for switch command.
>>> For eMMC 4.5 devices if timeout is not specified for the switch
>>> command while accessing a specific field,then the default timeout
>>> shall be used to timeout. Specification says there is no timeout
>>> defined while accessing BKOPS_START, SANITIZE_START, FLUSH_CACHE
>>> field(so these fields are excluded).
>>>
>>> Signed-off-by: Girish K S <girish.shivananjappa@linaro.org>
>>> ---
>>>  drivers/mmc/core/mmc.c     |    5 +++++
>>>  drivers/mmc/core/mmc_ops.c |    8 ++++++++
>>>  include/linux/mmc/card.h   |    1 +
>>>  include/linux/mmc/mmc.h    |    4 ++++
>>>  4 files changed, 18 insertions(+), 0 deletions(-)
>>>
>>> diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
>>> index 5700b1c..5b9fb6a 100644
>>> --- a/drivers/mmc/core/mmc.c
>>> +++ b/drivers/mmc/core/mmc.c
>>> @@ -405,6 +405,11 @@ static int mmc_read_ext_csd(struct mmc_card *card,
>>> u8
>>> *ext_csd)
>>>       if (card->ext_csd.rev >= 5)
>>>               card->ext_csd.rel_param =
>>> ext_csd[EXT_CSD_WR_REL_PARAM];
>>>
>>> +     if (card->ext_csd.rev > 5) {
>>> +             /* (eMMC 4.5)timeout is expressed in units of 10 ms*/
>>> +             card->ext_csd.cmd6_timeout =
>>> ext_csd[EXT_CSD_CMD6_TIME]*10;
>>> +     }
>>> +
>>>       if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
>>>               card->erased_byte = 0xFF;
>>>       else
>>> diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
>>> index 770c3d0..c4d82f4 100644
>>> --- a/drivers/mmc/core/mmc_ops.c
>>> +++ b/drivers/mmc/core/mmc_ops.c
>>> @@ -394,6 +394,14 @@ int mmc_switch(struct mmc_card *card, u8 set, u8
>> index,
>>> u8 value,
>>>       cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
>>>       cmd.cmd_timeout_ms = timeout_ms;
>>>
>>> +     /* timeout is not defined for below command indexes (eMMC 4.5) */
>>> +     if ((timeout_ms == 0)                                   &&
>>> +             (card->ext_csd->rev > 5)                        &&
>>> +             (index != EXT_CSD_BKOPS_START)          &&
>>> +             (index != EXT_CSD_SANITIZE_START)       &&
>>> +             (index != EXT_CSD_FLUSH_CACHE))
>>> +                     cmd.cmd_timeout_ms = card->ext_csd->cmd6_timeout;
>>> +
>>>       err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
>>>       if (err)
>>>               return err;
>>> diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
>>> index b460fc2..ef88412 100644
>>> --- a/include/linux/mmc/card.h
>>> +++ b/include/linux/mmc/card.h
>>> @@ -50,6 +50,7 @@ struct mmc_ext_csd {
>>>       u8                      rel_sectors;
>>>       u8                      rel_param;
>>>       u8                      part_config;
>>> +     u8                      cmd6_timeout;   /* timeout in ms */
>>>       unsigned int            part_time;              /* Units: ms */
>>>       unsigned int            sa_timeout;             /* Units: 100ns */
>>>       unsigned int            hs_max_dtr;
>>> diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
>>> index 5a794cb..a23f836 100644
>>> --- a/include/linux/mmc/mmc.h
>>> +++ b/include/linux/mmc/mmc.hHi Girish,
>>
>> (Cc'ed Seungwon Jeon)
>>
>> As I know, Seungwon Jeon has been submitted same/similar patch before
>> this.
>> http://www.spinics.net/lists/linux-mmc/msg09770.html
>>
>> Chris,
>> I cannot find your review on that...
>>
>> Thanks.
>>
>> Best regards,
>> Kgene.
>> --
>> Kukjin Kim <kgene.kim@samsung.com>, Senior Engineer,
>> SW Solution Development Team, Samsung Electronics Co., Ltd.
>>
>>
diff mbox

Patch

diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c
index 5700b1c..5b9fb6a 100644
--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -405,6 +405,11 @@  static int mmc_read_ext_csd(struct mmc_card *card, u8 *ext_csd)
 	if (card->ext_csd.rev >= 5)
 		card->ext_csd.rel_param = ext_csd[EXT_CSD_WR_REL_PARAM];
 
+	if (card->ext_csd.rev > 5) {
+		/* (eMMC 4.5)timeout is expressed in units of 10 ms*/
+		card->ext_csd.cmd6_timeout = ext_csd[EXT_CSD_CMD6_TIME]*10;
+	}
+
 	if (ext_csd[EXT_CSD_ERASED_MEM_CONT])
 		card->erased_byte = 0xFF;
 	else
diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
index 770c3d0..c4d82f4 100644
--- a/drivers/mmc/core/mmc_ops.c
+++ b/drivers/mmc/core/mmc_ops.c
@@ -394,6 +394,14 @@  int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,
 	cmd.flags = MMC_RSP_SPI_R1B | MMC_RSP_R1B | MMC_CMD_AC;
 	cmd.cmd_timeout_ms = timeout_ms;
 
+	/* timeout is not defined for below command indexes (eMMC 4.5) */
+	if ((timeout_ms == 0)					&&
+		(card->ext_csd->rev > 5)			&&
+		(index != EXT_CSD_BKOPS_START)		&&
+		(index != EXT_CSD_SANITIZE_START)	&&
+		(index != EXT_CSD_FLUSH_CACHE))
+			cmd.cmd_timeout_ms = card->ext_csd->cmd6_timeout;
+
 	err = mmc_wait_for_cmd(card->host, &cmd, MMC_CMD_RETRIES);
 	if (err)
 		return err;
diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h
index b460fc2..ef88412 100644
--- a/include/linux/mmc/card.h
+++ b/include/linux/mmc/card.h
@@ -50,6 +50,7 @@  struct mmc_ext_csd {
 	u8			rel_sectors;
 	u8			rel_param;
 	u8			part_config;
+	u8			cmd6_timeout;	/* timeout in ms */
 	unsigned int		part_time;		/* Units: ms */
 	unsigned int		sa_timeout;		/* Units: 100ns */
 	unsigned int		hs_max_dtr;
diff --git a/include/linux/mmc/mmc.h b/include/linux/mmc/mmc.h
index 5a794cb..a23f836 100644
--- a/include/linux/mmc/mmc.h
+++ b/include/linux/mmc/mmc.h
@@ -270,8 +270,11 @@  struct _mmc_csd {
  * EXT_CSD fields
  */
 
+#define EXT_CSD_FLUSH_CACHE		32	/* R/W */
 #define EXT_CSD_PARTITION_ATTRIBUTE	156	/* R/W */
 #define EXT_CSD_PARTITION_SUPPORT	160	/* RO */
+#define EXT_CSD_BKOPS_START		164	/* R/W */
+#define EXT_CSD_SANITIZE_START		165	/* R/W */
 #define EXT_CSD_WR_REL_PARAM		166	/* RO */
 #define EXT_CSD_ERASE_GROUP_DEF		175	/* R/W */
 #define EXT_CSD_PART_CONFIG		179	/* R/W */
@@ -293,6 +296,7 @@  struct _mmc_csd {
 #define EXT_CSD_SEC_ERASE_MULT		230	/* RO */
 #define EXT_CSD_SEC_FEATURE_SUPPORT	231	/* RO */
 #define EXT_CSD_TRIM_MULT		232	/* RO */
+#define EXT_CSD_CMD6_TIME		248	/* RO */
 
 /*
  * EXT_CSD field definitions