From patchwork Sun Jun 7 11:22:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 1304675 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.a=rsa-sha256 header.s=google header.b=XDGGoCdk; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49fvBm0xQWz9sRh for ; Sun, 7 Jun 2020 21:23:11 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 1B546801CA; Sun, 7 Jun 2020 13:22:59 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=amarulasolutions.com header.i=@amarulasolutions.com header.b="XDGGoCdk"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C1A5780476; Sun, 7 Jun 2020 13:22:57 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pf1-x443.google.com (mail-pf1-x443.google.com [IPv6:2607:f8b0:4864:20::443]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 960CE80199 for ; Sun, 7 Jun 2020 13:22:54 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=amarulasolutions.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jagan@amarulasolutions.com Received: by mail-pf1-x443.google.com with SMTP id x207so7219843pfc.5 for ; Sun, 07 Jun 2020 04:22:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pcdFKPIKO05+Bn9+8r0KYSTp/3aZo60TmESmNZnv3Sk=; b=XDGGoCdk3kRg2o2+WNNIsFiw8hSNiqdBkvcaepVFDVcjOwZ9niZn8nl1ZDSdkxsMpi 0aeRKzxZP08+vedN3hg3oLuJG9k6LU3EQogtO7E/637cHf0wNKC/dEuhPCYkCUMG7hzK f+aJr9usg2pZ8L/SUHIeXLH0S+zuXs0tQvrYE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=pcdFKPIKO05+Bn9+8r0KYSTp/3aZo60TmESmNZnv3Sk=; b=R7KpJs4YlmO3tILxvOLzo/7uEZnbfFj4MQr9fTrDlyNvZSdWFjt4SKIg703Ch2GtUw rdmPKgA3YagwYOOKgOYQevbmrBiESSarv8uP6NG/rqFrW5J10IZ2wolaPZHPP8IY6LZ0 OOjsK19rb3yi3zd0J4ECtR5FJ2DXGbtGt4RYyCgNKELntz5wQ3pz2sZQgrHGRg1H/C1I ggT481HrwpL1xDnejADtq2ZiHec3rghaq9e+qUwgqN4u25dFMNtaJqcvuUxAzegWjzx1 33S68yvdnClXF+Fx2g9Fa/TSQniAtBSzYd+pGV0U48/A60mPNqluhiJn7sEBe4bg4Cm7 BFyw== X-Gm-Message-State: AOAM530zIs/1lvSwl6C1luS4sw1tjxcfdcM9mLmi+UwIEX4LIpjHCeBX ElOxWlLzD1R5puXe5cYQIJsoCGUj7o1u0Q== X-Google-Smtp-Source: ABdhPJxLG5gDFBrqASDtuf496okbAerpkrwvddE0mb2vQDRqQx8ODP/qCriz3Ph13yWGWlWt6SntHA== X-Received: by 2002:a63:7a12:: with SMTP id v18mr16713330pgc.131.1591528972063; Sun, 07 Jun 2020 04:22:52 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c809:c7d5:d4bb:2f04:c633:ed51]) by smtp.gmail.com with ESMTPSA id t4sm4280174pfh.5.2020.06.07.04.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Jun 2020 04:22:51 -0700 (PDT) From: Jagan Teki To: u-boot@lists.denx.de Cc: Simon Glass , Bin Meng , Patrick Wildt , Jagan Teki , Andre Przywara , Suniel Mahesh , Michael Trimarchi Subject: [PATCH] nvme: Invalidate dcache before submitting admin cmd Date: Sun, 7 Jun 2020 16:52:26 +0530 Message-Id: <20200607112226.76561-1-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean 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,