[U-Boot] [PATCH RFC] fsl_esdhc: flush cache after non-read operation

Fabio Estevam festevam at gmail.com
Fri Mar 28 14:49:46 CET 2014


On Fri, Mar 28, 2014 at 7:15 AM, Hector Palacios
<hector.palacios at digi.com> wrote:
> Cache was invalidated on the read operation, but it should
> also be flushed otherwise.
>
> Signed-off-by: Hector Palacios <hector.palacios at digi.com>

Thanks, Hector.

Adding Marek on Cc as well.


> ---
>
> Notes:
>     After enabling L2 cache on i.MX6 I found out that many times
>     when running the 'gpt' command to partition a uSD card, the
>     data was not written at all, or was badly written to the media.
>
>     This patch seems to solve it but I'm not sure if that's the
>     right place to flush the cache. Could someone please comment?
>
>     Thank you.
>
>  drivers/mmc/fsl_esdhc.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
>
> diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
> index e945c0a470ca..5ef575eb0272 100644
> --- a/drivers/mmc/fsl_esdhc.c
> +++ b/drivers/mmc/fsl_esdhc.c
> @@ -253,6 +253,16 @@ static int esdhc_setup_data(struct mmc *mmc, struct mmc_data *data)
>         return 0;
>  }
>
> +static void check_and_flush_dcache_range
> +       (struct mmc_cmd *cmd,
> +        struct mmc_data *data) {
> +       unsigned start = (unsigned)data->dest ;
> +       unsigned size = roundup(ARCH_DMA_MINALIGN,
> +                               data->blocks*data->blocksize);
> +       unsigned end = start+size ;
> +       flush_dcache_range(start, end);
> +}
> +
>  static void check_and_invalidate_dcache_range
>         (struct mmc_cmd *cmd,
>          struct mmc_data *data) {
> @@ -401,6 +411,8 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
>  #endif
>                 if (data->flags & MMC_DATA_READ)
>                         check_and_invalidate_dcache_range(cmd, data);
> +               else
> +                       check_and_flush_dcache_range(cmd, data);
>         }
>
>         esdhc_write32(&regs->irqstat, -1);
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot


More information about the U-Boot mailing list