Re: [U-Boot] [v2, 2/5] mmc: send STOP command when the READ/WRITE commands fail

2016-11-14 Thread york sun
On 09/23/2016 12:38 AM, Y.B. Lu wrote:
>> ditto.
>
> [Lu Yangbo-B47093] Ok, I will check the return. Thanks :)
>>

Yangbo,

Do you have an update?

York

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [v2, 2/5] mmc: send STOP command when the READ/WRITE commands fail

2016-09-23 Thread Y.B. Lu
> -Original Message-
> From: Jaehoon Chung [mailto:jh80.ch...@samsung.com]
> Sent: Monday, September 19, 2016 8:09 AM
> To: Y.B. Lu; u-boot@lists.denx.de
> Cc: york sun
> Subject: Re: [v2, 2/5] mmc: send STOP command when the READ/WRITE
> commands fail
> 
> Hi Yangbo,
> 
> On 08/02/2016 06:20 PM, Yangbo Lu wrote:
> > The STOP command should be sent to stop data transfer when the
> > READ/WRITE commands fail. Otherwise, any subsequent command will fail
> > to be sent.
> >
> > Signed-off-by: Yangbo Lu 
> > ---
> > Changes for v2:
> > - None
> > ---
> >  drivers/mmc/mmc.c | 28 +++-
> >  drivers/mmc/mmc_private.h |  1 +
> >  drivers/mmc/mmc_write.c   |  8 ++--
> >  3 files changed, 22 insertions(+), 15 deletions(-)
> >
> > diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index
> > f8e5f7a..85d1e18 100644
> > --- a/drivers/mmc/mmc.c
> > +++ b/drivers/mmc/mmc.c
> > @@ -188,6 +188,21 @@ int mmc_set_blocklen(struct mmc *mmc, int len)
> > return mmc_send_cmd(mmc, &cmd, NULL);  }
> >
> > +int mmc_send_stop(struct mmc *mmc)
> > +{
> > +   struct mmc_cmd cmd;
> > +   int err;
> > +
> > +   cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
> > +   cmd.cmdarg = 0;
> > +   cmd.resp_type = MMC_RSP_R1b;
> > +
> > +   err = mmc_send_cmd(mmc, &cmd, NULL);
> > +   if (err)
> > +   printf("mmc fail to send stop cmd\n");
> > +   return err;
> > +}
> > +
> >  static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
> >lbaint_t blkcnt)
> >  {
> > @@ -211,19 +226,14 @@ static int mmc_read_blocks(struct mmc *mmc, void
> *dst, lbaint_t start,
> > data.blocksize = mmc->read_bl_len;
> > data.flags = MMC_DATA_READ;
> >
> > -   if (mmc_send_cmd(mmc, &cmd, &data))
> > +   if (mmc_send_cmd(mmc, &cmd, &data)) {
> > +   mmc_send_stop(mmc);
> 
> If mmc_send_stop() is also failed, is it doesn't need to return error
> number?
> 

[Lu Yangbo-B47093] You're right. I need to check the return. Thanks :)

> > return 0;
> > +   }
> >
> > if (blkcnt > 1) {
> > -   cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
> > -   cmd.cmdarg = 0;
> > -   cmd.resp_type = MMC_RSP_R1b;
> > -   if (mmc_send_cmd(mmc, &cmd, NULL)) {
> > -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
> > -   printf("mmc fail to send stop cmd\n");
> > -#endif
> > +   if (mmc_send_stop(mmc))
> > return 0;
> > -   }
> > }
> >
> > return blkcnt;
> > diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
> > index 49ec022..2791125 100644
> > --- a/drivers/mmc/mmc_private.h
> > +++ b/drivers/mmc/mmc_private.h
> > @@ -16,6 +16,7 @@ extern int mmc_send_cmd(struct mmc *mmc, struct
> mmc_cmd *cmd,
> > struct mmc_data *data);
> >  extern int mmc_send_status(struct mmc *mmc, int timeout);  extern int
> > mmc_set_blocklen(struct mmc *mmc, int len);
> > +int mmc_send_stop(struct mmc *mmc);
> >  #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT  void
> > mmc_adapter_card_type_ident(void);
> >  #endif
> > diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c index
> > 0f8b5c7..fb8488c 100644
> > --- a/drivers/mmc/mmc_write.c
> > +++ b/drivers/mmc/mmc_write.c
> > @@ -150,6 +150,7 @@ static ulong mmc_write_blocks(struct mmc *mmc,
> > lbaint_t start,
> >
> > if (mmc_send_cmd(mmc, &cmd, &data)) {
> > printf("mmc write failed\n");
> > +   mmc_send_stop(mmc);
> 
> ditto.

[Lu Yangbo-B47093] Ok, I will check the return. Thanks :)
> 
> Best Regards,
> Jaehoon Chung
> 
> > return 0;
> > }
> >
> > @@ -157,13 +158,8 @@ static ulong mmc_write_blocks(struct mmc *mmc,
> lbaint_t start,
> >  * token, not a STOP_TRANSMISSION request.
> >  */
> > if (!mmc_host_is_spi(mmc) && blkcnt > 1) {
> > -   cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
> > -   cmd.cmdarg = 0;
> > -   cmd.resp_type = MMC_RSP_R1b;
> > -   if (mmc_send_cmd(mmc, &cmd, NULL)) {
> > -   printf("mmc fail to send stop cmd\n");
> > +   if (mmc_send_stop(mmc))
> > return 0;
> > -   }
> > }
> >
> > /* Waiting for the ready status */
> >

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [v2, 2/5] mmc: send STOP command when the READ/WRITE commands fail

2016-09-18 Thread Jaehoon Chung
Hi Yangbo,

On 08/02/2016 06:20 PM, Yangbo Lu wrote:
> The STOP command should be sent to stop data transfer when the
> READ/WRITE commands fail. Otherwise, any subsequent command will
> fail to be sent.
> 
> Signed-off-by: Yangbo Lu 
> ---
> Changes for v2:
>   - None
> ---
>  drivers/mmc/mmc.c | 28 +++-
>  drivers/mmc/mmc_private.h |  1 +
>  drivers/mmc/mmc_write.c   |  8 ++--
>  3 files changed, 22 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
> index f8e5f7a..85d1e18 100644
> --- a/drivers/mmc/mmc.c
> +++ b/drivers/mmc/mmc.c
> @@ -188,6 +188,21 @@ int mmc_set_blocklen(struct mmc *mmc, int len)
>   return mmc_send_cmd(mmc, &cmd, NULL);
>  }
>  
> +int mmc_send_stop(struct mmc *mmc)
> +{
> + struct mmc_cmd cmd;
> + int err;
> +
> + cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
> + cmd.cmdarg = 0;
> + cmd.resp_type = MMC_RSP_R1b;
> +
> + err = mmc_send_cmd(mmc, &cmd, NULL);
> + if (err)
> + printf("mmc fail to send stop cmd\n");
> + return err;
> +}
> +
>  static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start,
>  lbaint_t blkcnt)
>  {
> @@ -211,19 +226,14 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, 
> lbaint_t start,
>   data.blocksize = mmc->read_bl_len;
>   data.flags = MMC_DATA_READ;
>  
> - if (mmc_send_cmd(mmc, &cmd, &data))
> + if (mmc_send_cmd(mmc, &cmd, &data)) {
> + mmc_send_stop(mmc);

If mmc_send_stop() is also failed, is it doesn't need to return error number?

>   return 0;
> + }
>  
>   if (blkcnt > 1) {
> - cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
> - cmd.cmdarg = 0;
> - cmd.resp_type = MMC_RSP_R1b;
> - if (mmc_send_cmd(mmc, &cmd, NULL)) {
> -#if !defined(CONFIG_SPL_BUILD) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT)
> - printf("mmc fail to send stop cmd\n");
> -#endif
> + if (mmc_send_stop(mmc))
>   return 0;
> - }
>   }
>  
>   return blkcnt;
> diff --git a/drivers/mmc/mmc_private.h b/drivers/mmc/mmc_private.h
> index 49ec022..2791125 100644
> --- a/drivers/mmc/mmc_private.h
> +++ b/drivers/mmc/mmc_private.h
> @@ -16,6 +16,7 @@ extern int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd 
> *cmd,
>   struct mmc_data *data);
>  extern int mmc_send_status(struct mmc *mmc, int timeout);
>  extern int mmc_set_blocklen(struct mmc *mmc, int len);
> +int mmc_send_stop(struct mmc *mmc);
>  #ifdef CONFIG_FSL_ESDHC_ADAPTER_IDENT
>  void mmc_adapter_card_type_ident(void);
>  #endif
> diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c
> index 0f8b5c7..fb8488c 100644
> --- a/drivers/mmc/mmc_write.c
> +++ b/drivers/mmc/mmc_write.c
> @@ -150,6 +150,7 @@ static ulong mmc_write_blocks(struct mmc *mmc, lbaint_t 
> start,
>  
>   if (mmc_send_cmd(mmc, &cmd, &data)) {
>   printf("mmc write failed\n");
> + mmc_send_stop(mmc);

ditto.

Best Regards,
Jaehoon Chung

>   return 0;
>   }
>  
> @@ -157,13 +158,8 @@ static ulong mmc_write_blocks(struct mmc *mmc, lbaint_t 
> start,
>* token, not a STOP_TRANSMISSION request.
>*/
>   if (!mmc_host_is_spi(mmc) && blkcnt > 1) {
> - cmd.cmdidx = MMC_CMD_STOP_TRANSMISSION;
> - cmd.cmdarg = 0;
> - cmd.resp_type = MMC_RSP_R1b;
> - if (mmc_send_cmd(mmc, &cmd, NULL)) {
> - printf("mmc fail to send stop cmd\n");
> + if (mmc_send_stop(mmc))
>   return 0;
> - }
>   }
>  
>   /* Waiting for the ready status */
> 

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot