From patchwork Sun Jun 7 11:22:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 241867 List-Id: U-Boot discussion From: jagan at amarulasolutions.com (Jagan Teki) Date: Sun, 7 Jun 2020 16:52:26 +0530 Subject: [PATCH] nvme: Invalidate dcache before submitting admin cmd Message-ID: <20200607112226.76561-1-jagan@amarulasolutions.com> Some architecture like ARM Cortex A53, A72 would need to invalidate dcache to sync the cache with the memory contents before flushing the cache to memory. The NVME here submitting the admin command using dma_addr to the memory without prior cache invalidation. This causing dma_addr is pointing to an invalid location in the memory and found the sane nvme_ctrl result. Below example shows the nvme disk scan result improper result => 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 makes the dma_addr points to a valid location in the memory. Cc: Andre Przywara Reported-by: Suniel Mahesh Signed-off-by: Michael Trimarchi Signed-off-by: Jagan Teki Tested-by: Suniel Mahesh Reviewed-by: Bin Meng --- drivers/nvme/nvme.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index 0357aba7f1..fc64d93ab8 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -466,6 +466,9 @@ int nvme_identify(struct nvme_dev *dev, unsigned nsid, c.identify.cns = cpu_to_le32(cns); + invalidate_dcache_range(dma_addr, + dma_addr + sizeof(struct nvme_id_ctrl)); + ret = nvme_submit_admin_cmd(dev, &c, NULL); if (!ret) invalidate_dcache_range(dma_addr,