linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bean Huo <jackyard88@gmail.com>
To: richard@nod.at, dedekind1@gmail.com, adrian.hunter@intel.com,
	computersforpeace@gmail.com, boris.brezillon@free-electrons.com
Cc: beanhuo@micron.com, linux-mtd@lists.infradead.org,
	linux-kernel@vger.kernel.org, zszubbocsev@micron.com,
	peterpandong@micron.com
Subject: [PATCH v2 05/17] drivers:mtd:ubi:add bakvol on-flash and RAM data structures
Date: Tue,  2 Feb 2016 02:30:40 +0000	[thread overview]
Message-ID: <1454380252-16170-6-git-send-email-jackyard88@gmail.com> (raw)
In-Reply-To: <1454380252-16170-1-git-send-email-jackyard88@gmail.com>

From: Bean Huo <beanhuo@micron.com>

This file is to add bakvol default configure and on-flash data structures.
Here add three key structures:
        ubi_bkblk_info: for backup block programming info.
        bakvol_oob_info: for user oob area bakvol data structure.
        ubi_bkblk_tbl: for bakvol module info.

Signed-off-by: BeanHuo <beanhuo@micron.com>
---
 drivers/mtd/ubi/ubi-media.h | 64 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/drivers/mtd/ubi/ubi-media.h b/drivers/mtd/ubi/ubi-media.h
index d0d072e..8981a39 100644
--- a/drivers/mtd/ubi/ubi-media.h
+++ b/drivers/mtd/ubi/ubi-media.h
@@ -31,6 +31,7 @@
 #define __UBI_MEDIA_H__
 
 #include <asm/byteorder.h>
+#include <linux/list.h>
 
 /* The version of UBI images supported by this implementation */
 #define UBI_VERSION 1
@@ -295,7 +296,11 @@ struct ubi_vid_hdr {
 } __packed;
 
 /* Internal UBI volumes count */
+#ifdef CONFIG_MTD_UBI_MLC_NAND_BAKVOL
+#define UBI_INT_VOL_COUNT 2
+#else
 #define UBI_INT_VOL_COUNT 1
+#endif
 
 /*
  * Starting ID of internal volumes: 0x7fffefff.
@@ -312,6 +317,15 @@ struct ubi_vid_hdr {
 #define UBI_LAYOUT_VOLUME_NAME   "layout volume"
 #define UBI_LAYOUT_VOLUME_COMPAT UBI_COMPAT_REJECT
 
+/* The backup log volume */
+
+#define UBI_BACKUP_VOLUME_ID     (UBI_INTERNAL_VOL_START + 1)
+#define UBI_BACKUP_VOLUME_TYPE   UBI_VID_DYNAMIC
+#define UBI_BACKUP_VOLUME_ALIGN  1
+#define UBI_BACKUP_VOLUME_EBS    20
+#define UBI_BACKUP_VOLUME_NAME   "bakvol"
+#define UBI_BACKUP_VOLUME_COMPAT UBI_COMPAT_REJECT
+
 /* The maximum number of volumes per one UBI device */
 #define UBI_MAX_VOLUMES 128
 
@@ -325,6 +339,56 @@ struct ubi_vid_hdr {
 #define UBI_VTBL_RECORD_SIZE_CRC (UBI_VTBL_RECORD_SIZE - sizeof(__be32))
 
 /**
+ * struct ubi_bkblk_info - the information for one backup block .
+ * @peb: physical block number
+ * @leb:  logic block number
+ * @plane: this block belongs to which plane
+ * @pgnum: the page number that already be programmed last time.
+ */
+struct ubi_bkblk_info {
+	__be32  peb;
+	__be32  leb;
+	__u8    plane;
+	__be32  pgnum;
+	struct  list_head node;
+}__packed;
+
+/**
+ * struct bakvol_oob_info - user oob area structure.
+ * @addr: address of source/backup page
+ * @crc: CRC-32 checksum of addr
+ *
+ */
+struct bakvol_oob_info {
+	loff_t addr;
+	__le32 crc;
+} __packed;
+
+/* Sizes of bakvol oob area */
+#define UBI_BAKVOL_OOB_SIZE sizeof(struct bakvol_oob_info)
+
+/* Sizes of bakvol oob area without the ending CRC */
+#define UBI_BAKVOL_OOB_SIZE_CRC (UBI_BAKVOL_OOB_SIZE - sizeof(__be32))
+
+/**
+ * struct ubi_bkblk_tbl - a table for backup blocks.
+ * @bakvol_flag: indicate if backup volume be initted
+ * @bcount_of_plane: block count that has bee applied for corresponding plane
+ * @head: the list of backup blocks.
+ */
+struct ubi_bkblk_tbl {
+	__u8    bakvol_flag;
+#define UBI_BAKVOL_INIT_START 0x01 /* init bakvol module start */
+#define UBI_BAKVOL_REJECT 0x02 /* reject bakvol module operations */
+#define UBI_BAKVOL_INIT_DONE 0x04 /* init bakvol module done */
+#define UBI_BAKVOL_ENABLE 0x08 /* enable bakvol module */
+#define UBI_BAKVOL_DISABLE 0x10 /* disable bakvol module */
+#define UBI_BAKVOL_RECOVERY 0x20 /* bakvol recovery already done */
+	__be32  bcount_of_plane[2];
+	struct  list_head head;
+}__packed;;
+
+/**
  * struct ubi_vtbl_record - a record in the volume table.
  * @reserved_pebs: how many physical eraseblocks are reserved for this volume
  * @alignment: volume alignment
-- 
1.9.1

  parent reply	other threads:[~2016-02-02  2:39 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-02  2:30 [PATCH v2 00/17] Add a bakvol module in UBI layer for MLC paired page power loss issue Bean Huo
2016-02-02  2:30 ` [PATCH v2 01/17] include:mtd:add multi-plane page program command Bean Huo
2016-02-02  2:30 ` [PATCH v2 02/17] include:mtd:add multi-plane program in mtd_info Bean Huo
2016-02-02  2:30 ` [PATCH v2 03/17] drivers:mtd:add dual plane page program support in partition layer Bean Huo
2016-02-02  3:00   ` kbuild test robot
2016-02-02  2:30 ` [PATCH v2 04/17] drivers:mtd:nand:enable dual plane page program function Bean Huo
2016-02-02  3:04   ` kbuild test robot
2016-02-02  2:30 ` Bean Huo [this message]
2016-02-02  2:30 ` [PATCH v2 06/17] drivers:mtd:ubi:add bakvol function define in ubi layer Bean Huo
2016-02-02  3:05   ` kbuild test robot
2016-02-02  3:08   ` kbuild test robot
2016-02-02  2:30 ` [PATCH v2 07/17] fs:ubifs:add bakvol function define in ubifs layer Bean Huo
2016-02-02  2:30 ` [PATCH v2 08/17] drivers:mtd:ubi:disable bakvol function while writing volume table Bean Huo
2016-02-02  2:30 ` [PATCH v2 09/17] drivers:mtd:ubi:get PEB according to specfied plane number Bean Huo
2016-02-02  2:30 ` [PATCH v2 10/17] drivers:mtd:ubi:enable bakvol function for fastmap operation Bean Huo
2016-02-02  2:30 ` [PATCH v2 11/17] drivers:mtd:ubi:add disable/enable bakvol while ubi write Bean Huo
2016-02-02  2:30 ` [PATCH v2 12/17] drivers:mtd:ubi:add disable bakvol while ubi detach Bean Huo
2016-02-02  2:30 ` [PATCH v2 13/17] drivers:mtd:ubi:add bakvol init while attach ubi Bean Huo
2016-02-02  2:30 ` [PATCH v2 14/17] drivers:mtd:ubi:add backup operation in ubi_io_write Bean Huo
2016-02-02  3:22   ` kbuild test robot
2016-02-02  2:30 ` [PATCH v2 15/17] fs:ubifs:enable bakvol module and recover operation Bean Huo
2016-02-02  2:30 ` [PATCH v2 16/17] driver:mtd:ubi:add new bakvol module in ubi layer Bean Huo
2016-02-02  2:30 ` [PATCH v2 17/17] drivers:mtd:ubi: Kconfig Makefile Bean Huo
2016-02-02  3:22   ` kbuild test robot
2016-02-02  3:56   ` kbuild test robot
2016-02-02  3:58   ` kbuild test robot
2016-02-02  4:15     ` Bean Huo 霍斌斌 (beanhuo)
2016-02-03  0:46       ` Brian Norris
2016-02-03  6:14         ` Bean Huo 霍斌斌 (beanhuo)
2016-02-02 23:06 ` [PATCH v2 00/17] Add a bakvol module in UBI layer for MLC paired page power loss issue Richard Weinberger
2016-02-03  6:11   ` Bean Huo 霍斌斌 (beanhuo)

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=1454380252-16170-6-git-send-email-jackyard88@gmail.com \
    --to=jackyard88@gmail.com \
    --cc=adrian.hunter@intel.com \
    --cc=beanhuo@micron.com \
    --cc=boris.brezillon@free-electrons.com \
    --cc=computersforpeace@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=peterpandong@micron.com \
    --cc=richard@nod.at \
    --cc=zszubbocsev@micron.com \
    /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;
as well as URLs for NNTP newsgroup(s).