[<prev] [next>] [day] [month] [year] [list]
Message-ID: <A765B125120D1346A63912DDE6D8B6310BF4CF13@NTXXIAMBX02.xacn.micron.com>
Date: Mon, 28 Sep 2015 07:03:38 +0000
From: Bean Huo 霍斌斌 (beanhuo)
<beanhuo@...ron.com>
To: "dedekind1@...il.com" <dedekind1@...il.com>,
"adrian.hunter@...el.com" <adrian.hunter@...el.com>,
"computersforpeace@...il.com" <computersforpeace@...il.com>,
"baruch@...s.co.il" <baruch@...s.co.il>,
"asierra@...-inc.com" <asierra@...-inc.com>,
"guz.fnst@...fujitsu.com" <guz.fnst@...fujitsu.com>,
"gsi@...x.de" <gsi@...x.de>, "richard@....at" <richard@....at>,
Boris Brezillon <boris.brezillon@...e-electrons.com>
CC: Boris Brezillon <boris.brezillon@...e-electrons.com>,
David Woodhouse <dwmw2@...radead.org>,
"linux-mtd@...ts.infradead.org" <linux-mtd@...ts.infradead.org>,
Artem Bityutskiy <dedekind1@...il.com>,
Richard Weinberger <richard@....at>,
Frank Liu 刘群 (frankliu)
<frankliu@...ron.com>, Andrea Scian <rnd4@...e-tech.it>,
Peter Pan 潘栋 (peterpandong)
<peterpandong@...ron.com>,
Karl Zhang 张双锣 (karlzhang)
<karlzhang@...ron.com>,
Iwo Mergler <Iwo.Mergler@...commwireless.com>,
"Jeff Lauruhn (jlauruhn)" <jlauruhn@...ron.com>,
Stefan Roese <sr@...x.de>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: [PATCH 6/9] drivers:mtd:ubi:add hook for UBI bakvol in ubi_io_write
Add hook for UBI bakvol in ubi_io_write.
Modify ubi_io_write, if program lower page of MLC NAND,
Duplicated it and backup one copy into internal log volume by
Dual plane program method.
Signed-off-by: Bean Huo <beanhuo@...ron.com>
---
drivers/mtd/ubi/io.c | 63 +++++++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 55 insertions(+), 8 deletions(-)
diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c
index 5bbd1f0..912c458 100644
--- a/drivers/mtd/ubi/io.c
+++ b/drivers/mtd/ubi/io.c
@@ -236,8 +236,9 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
int len)
{
int err;
- size_t written;
+ size_t retlen;
loff_t addr;
+ int skip = 0;
dbg_io("write %d bytes to PEB %d:%d", len, pnum, offset);
@@ -281,14 +282,60 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
}
addr = (loff_t)pnum * ubi->peb_size + offset;
- err = mtd_write(ubi->mtd, addr, len, &written, buf);
- if (err) {
- ubi_err(ubi, "error %d while writing %d bytes to PEB %d:%d, written %zd bytes",
- err, len, pnum, offset, written);
- dump_stack();
- ubi_dump_flash(ubi, pnum, offset, len);
+
+#ifdef CONFIG_MTD_UBI_MLC_NAND_BAKVOL
+ if ((offset == 0) && (len == ubi->peb_size))
+ skip = 1;
+
+ if (ubi_check_backup_volume(ubi) && (!skip)) {
+ loff_t addr_temp;
+ unsigned char *buf_temp = (unsigned char *)buf;
+ int len_temp;
+ int writelen = 0;
+
+ addr_temp = addr;
+
+ for (len_temp = len; len_temp > 0; len_temp -= ubi->min_io_size,
+ addr_temp += ubi->min_io_size,
+ buf_temp += ubi->min_io_size) {
+ /* Split data according to min_io_size */
+
+ if (len_temp/ubi->min_io_size)
+ writelen = ubi->min_io_size;
+ else
+ writelen %= ubi->min_io_size;
+
+ if (is_backup_need(ubi, addr_temp)) {
+ err = ubi_backup_data_to_backup_volume(ubi,
+ addr_temp, writelen, &retlen, buf_temp);
+ } else
+ err = mtd_write(ubi->mtd, addr_temp, writelen,
+ &retlen, buf_temp);
+
+ if (err) {
+ ubi_err(ubi, "Writing %d byptes to PEB %d:%d",
+ writelen, pnum, offset);
+ ubi_err(ubi, "Error %d", err);
+ ubi_err(ubi, "Written %zd bytes", retlen);
+ dump_stack();
+ ubi_dump_flash(ubi, pnum, offset, writelen);
+ } else
+ ubi_assert(retlen == writelen);
+ }
} else
- ubi_assert(written == len);
+#endif
+ {
+ err = mtd_write(ubi->mtd, addr, len, &retlen, buf);
+ if (err) {
+ ubi_err(ubi, "Writing %d byptes to PEB %d:%d",
+ len, pnum, offset);
+ ubi_err(ubi, "Error %d", err);
+ ubi_err(ubi, "Written %zd bytes", retlen);
+ dump_stack();
+ ubi_dump_flash(ubi, pnum, offset, len);
+ } else
+ ubi_assert(retlen == len);
+ }
if (!err) {
err = self_check_write(ubi, buf, pnum, offset, len);
--
1.9.1
Powered by blists - more mailing lists