From: Steve Rae <srae@broadcom.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 4/5] fastboot: sparse: implement reserve()
Date: Tue, 7 Jun 2016 11:19:38 -0700 [thread overview]
Message-ID: <1465323579-18928-5-git-send-email-srae@broadcom.com> (raw)
In-Reply-To: <1465323579-18928-1-git-send-email-srae@broadcom.com>
In order to process the CHUNK_TYPE_DONT_CARE properly, there is
a requirement to be able to 'reserve' a specified number of blocks
in the storage media. Because of the special handling of "bad blocks"
in NAND devices, this is implemented in a storage abstraction function.
Signed-off-by: Steve Rae <srae@broadcom.com>
---
Changes in v2: None
common/fb_mmc.c | 7 +++++++
common/fb_nand.c | 20 ++++++++++++++++++++
common/image-sparse.c | 5 ++---
include/image-sparse.h | 4 ++++
4 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/common/fb_mmc.c b/common/fb_mmc.c
index 6bafbc6..c739651 100644
--- a/common/fb_mmc.c
+++ b/common/fb_mmc.c
@@ -53,6 +53,12 @@ static lbaint_t fb_mmc_sparse_write(struct sparse_storage *info,
return blk_dwrite(dev_desc, blk, blkcnt, buffer);
}
+static lbaint_t fb_mmc_sparse_reserve(struct sparse_storage *info,
+ lbaint_t blk, lbaint_t blkcnt)
+{
+ return blkcnt;
+}
+
static void write_raw_image(struct blk_desc *dev_desc, disk_partition_t *info,
const char *part_name, void *buffer,
unsigned int download_bytes)
@@ -131,6 +137,7 @@ void fb_mmc_flash_write(const char *cmd, void *download_buffer,
sparse.start = info.start;
sparse.size = info.size;
sparse.write = fb_mmc_sparse_write;
+ sparse.reserve = fb_mmc_sparse_reserve;
printf("Flashing sparse image at offset " LBAFU "\n",
sparse.start);
diff --git a/common/fb_nand.c b/common/fb_nand.c
index 77ca55d..c8c79e9 100644
--- a/common/fb_nand.c
+++ b/common/fb_nand.c
@@ -126,6 +126,25 @@ static lbaint_t fb_nand_sparse_write(struct sparse_storage *info,
return written / info->blksz;
}
+static lbaint_t fb_nand_sparse_reserve(struct sparse_storage *info,
+ lbaint_t blk, lbaint_t blkcnt)
+{
+ int bad_blocks = 0;
+
+/*
+ * TODO - implement a function to determine the total number
+ * of blocks which must be used in order to reserve the specified
+ * number ("blkcnt") of "good-blocks", starting at "blk"...
+ * ( possibly something like the "check_skip_len()" function )
+ */
+
+ /*
+ * the return value must be 'blkcnt' ("good-blocks") plus the
+ * number of "bad-blocks" encountered within this space...
+ */
+ return blkcnt + bad_blocks;
+}
+
void fb_nand_flash_write(const char *cmd, void *download_buffer,
unsigned int download_bytes)
{
@@ -155,6 +174,7 @@ void fb_nand_flash_write(const char *cmd, void *download_buffer,
sparse.start = part->offset / sparse.blksz;
sparse.size = part->size / sparse.blksz;
sparse.write = fb_nand_sparse_write;
+ sparse.reserve = fb_nand_sparse_reserve;
printf("Flashing sparse image at offset " LBAFU "\n",
sparse.start);
diff --git a/common/image-sparse.c b/common/image-sparse.c
index b36703b..9632c6f 100644
--- a/common/image-sparse.c
+++ b/common/image-sparse.c
@@ -1,3 +1,4 @@
+
/*
* Copyright (c) 2009, Google Inc.
* All rights reserved.
@@ -210,10 +211,8 @@ void write_sparse_image(
break;
case CHUNK_TYPE_DONT_CARE:
-#ifdef CONFIG_FASTBOOT_FLASH_MMC_DEV
- blk += blkcnt;
+ blk += info->reserve(info, blk, blkcnt);
total_blocks += chunk_header->chunk_sz;
-#endif
break;
case CHUNK_TYPE_CRC32:
diff --git a/include/image-sparse.h b/include/image-sparse.h
index f6869d6..b0cc500 100644
--- a/include/image-sparse.h
+++ b/include/image-sparse.h
@@ -19,6 +19,10 @@ struct sparse_storage {
lbaint_t blk,
lbaint_t blkcnt,
const void *buffer);
+
+ lbaint_t (*reserve)(struct sparse_storage *info,
+ lbaint_t blk,
+ lbaint_t blkcnt);
};
static inline int is_sparse_image(void *buf)
--
1.8.5
next prev parent reply other threads:[~2016-06-07 18:19 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-07 18:19 [U-Boot] [PATCH v2 0/5] Update fastboot sparse image handling Steve Rae
2016-06-07 18:19 ` [U-Boot] [PATCH v2 1/5] fastboot: sparse: remove session-id logic Steve Rae
2016-06-28 1:12 ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-06-07 18:19 ` [U-Boot] [PATCH v2 2/5] fastboot: sparse: resync common/image-sparse.c (part 1) Steve Rae
2016-06-15 8:18 ` Maxime Ripard
2016-06-16 17:29 ` Steve Rae
2016-06-22 19:36 ` Maxime Ripard
2016-06-22 21:44 ` Tom Rini
2016-06-28 1:12 ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-06-07 18:19 ` [U-Boot] [PATCH v2 3/5] fastboot: sparse: resync common/image-sparse.c (part 2) Steve Rae
2016-06-28 1:12 ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-06-07 18:19 ` Steve Rae [this message]
2016-06-15 8:31 ` [U-Boot] [PATCH v2 4/5] fastboot: sparse: implement reserve() Maxime Ripard
2016-06-28 1:12 ` [U-Boot] [U-Boot,v2,4/5] " Tom Rini
2016-06-07 18:19 ` [U-Boot] [PATCH v2 5/5] fastboot: sparse: improve CHUNK_TYPE_FILL write performance Steve Rae
2016-06-15 8:36 ` Maxime Ripard
2016-06-16 17:34 ` Steve Rae
2016-06-16 17:47 ` Steve Rae
2016-06-22 19:39 ` Maxime Ripard
2016-06-28 1:12 ` [U-Boot] [U-Boot, v2, " Tom Rini
2016-06-07 18:36 ` [U-Boot] [PATCH v2 0/5] Update fastboot sparse image handling Sergey Kubushyn
2016-06-07 18:38 ` Steve Rae
2016-06-07 20:20 ` Steve Rae
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=1465323579-18928-5-git-send-email-srae@broadcom.com \
--to=srae@broadcom.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox