[PATCH V2] nvme: Invalidate dcache before submitting admin cmd

Bin Meng bmeng.cn at gmail.com
Thu Jun 11 02:46:50 CEST 2020


On Thu, Jun 11, 2020 at 3:18 AM Michael Trimarchi
<michael at amarulasolutions.com> wrote:
>
> From: Jagan Teki <jagan at amarulasolutions.com>
>
> This patch try to avoids eviction of dirty lines during DMA
> transfer. The code right now execute the following step:
>
> - allocate the buffer
> - start a dma operation using the non-coherent dma buffer
> - invalidate cache lines associated with the buffer
> - read the buffer
>
> This can lead to reading back not valid information, because the cache
> controller could evict dirty cache lines belonging to the buffer *after*
> the DMA operation has started to fill the DRAM.
> In order to avoid this, a new invalidation is required *before* starting
> the DMA operation. The patch just adds an invalidation before submitting
> the DMA command.
>
> Example below shows the nvme disk scan result without the following
> patch
>
> => nvme scan
> nvme_get_info_from_identify: nn = 544502629, vwc = 100,
> sn = dev_0T, mn = `�\�, fr = t_part, mdts = 105
>
> So, invalidating the cache before submitting the admin command,
> fix the cpu read.
>
> Cc: André Przywara <andre.przywara at arm.com>
> Reported-by: Suniel Mahesh <sunil at amarulasolutions.com>
> Signed-off-by: Michael Trimarchi <michael at amarulasolutions.com>
> Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
> Tested-by: Suniel Mahesh <sunil at amarulasolutions.com>
> ---
> V1 -> V2:
>         Get feedback from André Przywara and
>         Bin Meng. They help me not only to write a proper commit
>         message but even make in some English form.
> ---
>  drivers/nvme/nvme.c | 3 +++
>  1 file changed, 3 insertions(+)
>

Reviewed-by: Bin Meng <bmeng.cn at gmail.com>


More information about the U-Boot mailing list