From patchwork Mon Oct 14 11:11:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Wildt X-Patchwork-Id: 1176222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=blueri.se Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 46sG900lw4z9sPc for ; Mon, 14 Oct 2019 22:11:48 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id B3EE3C21DD3; Mon, 14 Oct 2019 11:11:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 32327C21D4A; Mon, 14 Oct 2019 11:11:44 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A82FFC21D4A; Mon, 14 Oct 2019 11:11:42 +0000 (UTC) Received: from pwildt.genua.de (pwildt.genua.de [80.154.94.49]) by lists.denx.de (Postfix) with ESMTPS id 78E8AC21C51 for ; Mon, 14 Oct 2019 11:11:42 +0000 (UTC) Received: from nox.fritz.box (p200300C1C72B82000C26F91CC66B79A6.dip0.t-ipconnect.de [2003:c1:c72b:8200:c26:f91c:c66b:79a6]) by pwildt.genua.de (OpenSMTPD) with ESMTPSA id 1807349d (TLSv1.2:ECDHE-RSA-CHACHA20-POLY1305:256:NO); Mon, 14 Oct 2019 13:11:41 +0200 (CEST) Date: Mon, 14 Oct 2019 13:11:40 +0200 From: Patrick Wildt To: u-boot@lists.denx.de Message-ID: <20191014111140.GB22994@nox.fritz.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.12.2 (2019-09-21) Subject: [U-Boot] [PATCH] nvme: add more cache flushes X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 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" On an i.MX8MQ our nvme driver doesn't completely work since we are missing a few cache flushes. One is the prp list, which is an extra buffer that we need to flush before handing it to the hardware. Also the block read/write operations needs more cache flushes on this SoC. Signed-off-by: Patrick Wildt --- drivers/nvme/nvme.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c index 2444e0270f..69d5e3eedc 100644 --- a/drivers/nvme/nvme.c +++ b/drivers/nvme/nvme.c @@ -123,6 +123,9 @@ static int nvme_setup_prps(struct nvme_dev *dev, u64 *prp2, } *prp2 = (ulong)dev->prp_pool; + flush_dcache_range((ulong)dev->prp_pool, (ulong)dev->prp_pool + + dev->prp_entry_num * sizeof(u64)); + return 0; } @@ -717,9 +720,10 @@ static ulong nvme_blk_rw(struct udevice *udev, lbaint_t blknr, u16 lbas = 1 << (dev->max_transfer_shift - ns->lba_shift); u64 total_lbas = blkcnt; - if (!read) - flush_dcache_range((unsigned long)buffer, - (unsigned long)buffer + total_len); + flush_dcache_range((unsigned long)buffer, + (unsigned long)buffer + total_len); + invalidate_dcache_range((unsigned long)buffer, + (unsigned long)buffer + total_len); c.rw.opcode = read ? nvme_cmd_read : nvme_cmd_write; c.rw.flags = 0; @@ -755,9 +759,8 @@ static ulong nvme_blk_rw(struct udevice *udev, lbaint_t blknr, buffer += lbas << ns->lba_shift; } - if (read) - invalidate_dcache_range((unsigned long)buffer, - (unsigned long)buffer + total_len); + invalidate_dcache_range((unsigned long)buffer, + (unsigned long)buffer + total_len); return (total_len - temp_len) >> desc->log2blksz; }