[U-Boot] [RFC V2 PATCH 3/3] mmc: add support for block device cache
Eric Nelson
eric at nelint.com
Mon Mar 21 02:45:27 CET 2016
Signed-off-by: Eric Nelson <eric at 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
More information about the U-Boot
mailing list