All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eric Nelson <eric@nelint.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC V2 PATCH 3/3] mmc: add support for block device cache
Date: Sun, 20 Mar 2016 18:45:27 -0700	[thread overview]
Message-ID: <1458524727-4643-4-git-send-email-eric@nelint.com> (raw)
In-Reply-To: <1458524727-4643-1-git-send-email-eric@nelint.com>

Signed-off-by: Eric Nelson <eric@nelint.com>
---
 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 <config.h>
 #include <common.h>
 #include <command.h>
@@ -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..1c96d29 100644
--- a/drivers/mmc/mmc_write.c
+++ b/drivers/mmc/mmc_write.c
@@ -12,6 +12,7 @@
 #include <part.h>
 #include <div64.h>
 #include <linux/math64.h>
+#include <part.h>
 #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.devnum);
+
 	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;
 
-- 
2.6.2

  parent reply	other threads:[~2016-03-21  1:45 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-21  1:45 [U-Boot] [RFC V2 PATCH 0/3] Add cache for block devices Eric Nelson
2016-03-21  1:45 ` [U-Boot] [RFC V2 PATCH 1/3] drivers: block: add block device cache Eric Nelson
2016-03-21 17:59   ` Eric Nelson
2016-03-23 17:22   ` Stephen Warren
2016-03-23 17:43     ` Eric Nelson
2016-03-21  1:45 ` [U-Boot] [RFC V2 PATCH 2/3] block: add Kconfig options for [CMD_]BLOCK_CACHE Eric Nelson
2016-03-23 17:24   ` Stephen Warren
2016-03-23 17:45     ` Eric Nelson
2016-03-21  1:45 ` Eric Nelson [this message]
2016-03-23 17:27   ` [U-Boot] [RFC V2 PATCH 3/3] mmc: add support for block device cache Stephen Warren
2016-03-23 17:46     ` Eric Nelson
2016-03-21  1:59 ` [U-Boot] [RFC V2 PATCH 0/3] Add cache for block devices Marek Vasut
2016-03-21 13:48   ` Eric Nelson
2016-03-21 16:49     ` Marek Vasut
2016-03-21 17:56       ` Eric Nelson
2016-03-21 18:54         ` Marek Vasut
2016-03-27 19:00 ` [U-Boot] [PATCH " Eric Nelson
2016-03-27 19:00   ` [U-Boot] [PATCH 1/3] drivers: block: add block device cache Eric Nelson
2016-03-28 14:16     ` Tom Rini
2016-03-28 14:33       ` Eric Nelson
2016-03-28 16:24         ` [U-Boot] [PATCH V2 " Eric Nelson
2016-03-28 17:05           ` [U-Boot] [PATCH V3 " Eric Nelson
2016-03-30 14:36             ` Stephen Warren
2016-03-30 15:19               ` Tom Rini
2016-03-30 15:21                 ` Stephen Warren
2016-03-30 17:37                 ` Eric Nelson
2016-03-30 17:34               ` Eric Nelson
2016-03-30 21:57                 ` Stephen Warren
2016-03-31 20:24                   ` Eric Nelson
2016-04-01 22:57                     ` Stephen Warren
2016-04-01 23:16                       ` Eric Nelson
2016-04-01 23:41                         ` Tom Rini
2016-04-02 14:17                           ` Eric Nelson
2016-04-02  2:07                         ` Stephen Warren
2016-04-02 14:24                           ` Eric Nelson
2016-04-02  1:59             ` [U-Boot] [U-Boot, V3, " Tom Rini
2016-04-02 14:19               ` Eric Nelson
2016-04-02 14:37                 ` [U-Boot] [PATCH 0/3] minor blkcache updates Eric Nelson
2016-04-02 14:37                   ` [U-Boot] [PATCH 1/3] cmd: blkcache: remove indentation from output of 'show' Eric Nelson
2016-04-12  2:28                     ` [U-Boot] [U-Boot, " Tom Rini
2016-04-02 14:37                   ` [U-Boot] [PATCH 2/3] cmd: blkcache: simplify sub-command handling Eric Nelson
2016-04-04 17:39                     ` Stephen Warren
2016-04-12  2:28                     ` [U-Boot] [U-Boot, " Tom Rini
2016-04-02 14:37                   ` [U-Boot] [PATCH 3/3] drivers: block: fix placement of parameters Eric Nelson
2016-04-12  2:29                     ` [U-Boot] [U-Boot, " Tom Rini
2016-03-27 19:00   ` [U-Boot] [PATCH 2/3] mmc: use block layer in mmc command Eric Nelson
2016-03-28 14:16     ` Tom Rini
2016-04-02  1:58     ` [U-Boot] [U-Boot,2/3] " Tom Rini
2016-03-27 19:00   ` [U-Boot] [PATCH 3/3] sata: use block layer for sata command Eric Nelson
2016-03-28 14:16     ` Tom Rini
2016-04-02  1:59     ` [U-Boot] [U-Boot,3/3] " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1458524727-4643-4-git-send-email-eric@nelint.com \
    --to=eric@nelint.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.