From patchwork Wed Mar 16 21:40:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Nelson X-Patchwork-Id: 598857 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 3qQSgt6mmRz9ssM for ; Thu, 17 Mar 2016 10:42:02 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 210A1B37E8; Thu, 17 Mar 2016 00:41:56 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CD4pg9cyEODI; Thu, 17 Mar 2016 00:41:56 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F0EB3B37EA; Thu, 17 Mar 2016 00:41:50 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 073B3B37E1 for ; Thu, 17 Mar 2016 00:41:43 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h93q7yBImLJM for ; Thu, 17 Mar 2016 00:41:42 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from fed1rmfepi207.cox.net (fed1rmfepi207.cox.net [68.230.241.152]) by theia.denx.de (Postfix) with ESMTP id D2A7EB37E3 for ; Thu, 17 Mar 2016 00:41:40 +0100 (CET) Received: from fed1rmimpo109.cox.net ([68.230.241.158]) by fed1rmfepo202.cox.net (InterMail vM.8.01.05.15 201-2260-151-145-20131218) with ESMTP id <20160316214039.GJFG22785.fed1rmfepo202.cox.net@fed1rmimpo109.cox.net> for ; Wed, 16 Mar 2016 17:40:39 -0400 Received: from localhost.localdomain ([98.165.107.234]) by fed1rmimpo109.cox.net with cox id Wlgd1s00253Tyga01lgeNS; Wed, 16 Mar 2016 17:40:39 -0400 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020206.56E9D2D7.0080, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=2.1 cv=Jb4c1R+V c=1 sm=1 tr=0 a=mmedTQiI2PtWY+RDxZIZmw==:117 a=mmedTQiI2PtWY+RDxZIZmw==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=9_1hYV8uAAAA:8 a=1HhlcP8gorDA6OzFQeMA:9 a=cGOfGqp1oD4NTooz:21 a=m2ofOafGfaJV9S8z:21 X-CM-Score: 0.00 Authentication-Results: cox.net; auth=pass (CRAM-MD5) smtp.auth=eric.a.nelson@cox.net From: Eric Nelson To: u-boot@lists.denx.de, panto@antoniou-consulting.com Date: Wed, 16 Mar 2016 14:40:24 -0700 Message-Id: <1458164424-15363-3-git-send-email-eric@nelint.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1458164424-15363-1-git-send-email-eric@nelint.com> References: <56E9A92F.5000205@nelint.com> <1458164424-15363-1-git-send-email-eric@nelint.com> Cc: swarren@nvidia.com, ioan.nicu.ext@nsn.com, tor@excito.com, patrick.delaunay73@gmail.com, sr@denx.de Subject: [U-Boot] [RFC PATCH 2/2] mmc: add support for block device cache X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Signed-off-by: Eric Nelson --- drivers/mmc/mmc.c | 10 +++++++++- drivers/mmc/mmc_write.c | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 8b2e606..956f4e1 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -6,7 +6,6 @@ * * SPDX-License-Identifier: GPL-2.0+ */ - #include #include #include @@ -240,6 +239,8 @@ static ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, int dev_num = block_dev->devnum; int err; lbaint_t cur, blocks_todo = blkcnt; + void *outbuf = dst; + lbaint_t outblk = start; if (blkcnt == 0) return 0; @@ -260,6 +261,10 @@ static ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, return 0; } + if (cache_block_read(IF_TYPE_MMC, dev_num, start, blkcnt, + mmc->read_bl_len, dst)) + return blkcnt; + if (mmc_set_blocklen(mmc, mmc->read_bl_len)) { debug("%s: Failed to set blocklen\n", __func__); return 0; @@ -277,6 +282,9 @@ static ulong mmc_bread(struct blk_desc *block_dev, lbaint_t start, dst += cur * mmc->read_bl_len; } while (blocks_todo > 0); + cache_block_fill(IF_TYPE_MMC, dev_num, outblk, blkcnt, + mmc->read_bl_len, outbuf); + return blkcnt; } diff --git a/drivers/mmc/mmc_write.c b/drivers/mmc/mmc_write.c index 7b186f8..a877c78 100644 --- a/drivers/mmc/mmc_write.c +++ b/drivers/mmc/mmc_write.c @@ -12,6 +12,7 @@ #include #include #include +#include #include "mmc_private.h" static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt) @@ -20,6 +21,8 @@ static ulong mmc_erase_t(struct mmc *mmc, ulong start, lbaint_t blkcnt) ulong end; int err, start_cmd, end_cmd; + cache_block_invalidate(IF_TYPE_MMC, mmc->block_dev.dev); + if (mmc->high_capacity) { end = start + blkcnt - 1; } else { @@ -82,6 +85,8 @@ unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start, if (err < 0) return -1; + cache_block_invalidate(IF_TYPE_MMC, dev_num); + /* * We want to see if the requested start or total block count are * unaligned. We discard the whole numbers and only care about the @@ -186,6 +191,8 @@ ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start, lbaint_t blkcnt, if (err < 0) return 0; + cache_block_invalidate(IF_TYPE_MMC, dev_num); + if (mmc_set_blocklen(mmc, mmc->write_bl_len)) return 0;