From patchwork Tue Feb 14 20:06:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Weinberger X-Patchwork-Id: 141189 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (unknown [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 75F601007D1 for ; Wed, 15 Feb 2012 07:56:32 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RxPPK-0002Ip-S6; Tue, 14 Feb 2012 20:55:26 +0000 Received: from galois.linutronix.de ([2001:470:1f0b:1c35:abcd:42:0:1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RxPOu-0002CF-Bu for linux-mtd@lists.infradead.org; Tue, 14 Feb 2012 20:55:04 +0000 Received: from custos.ou.linutronix.de ([212.62.202.73] helo=localhost.localdomain) by Galois.linutronix.de with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from ) id 1RxPOr-0007rV-GU; Tue, 14 Feb 2012 21:54:57 +0100 From: Richard Weinberger To: linux-mtd@lists.infradead.org Subject: [RFC][PATCH 1/7] MTD: UBI: Add checkpoint on-chip layout Date: Tue, 14 Feb 2012 21:06:40 +0100 Message-Id: <1329250006-22944-2-git-send-email-rw@linutronix.de> X-Mailer: git-send-email 1.7.7 In-Reply-To: <1329250006-22944-1-git-send-email-rw@linutronix.de> References: <1329250006-22944-1-git-send-email-rw@linutronix.de> X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1, SHORTCIRCUIT=-0.0001 X-Spam-Note: CRM114 invocation failed X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: tglx@linutronix.de, dedekind1@gmail.com, linux-kernel@vger.kernel.org, Richard Weinberger , tim.bird@am.sony.com X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Specify the on-chip checkpoint layout. The checkpoint consists of two major parts. A super block (identified via UBI_CP_SB_VOLUME_ID) and zero or more data blocks (identified via UBI_CP_DATA_VOLUME_ID). Data blocks are only used if whole checkpoint information does not fit into the super block. Currently UBI_CP_MAX_START, UBI_CP_MAX_BLOCKS and UBI_CP_MAX_POOL_SIZE are hard-coded. In future this values may be configurable via Kconfig or sysfs. All three checkpointing pools have the same size for now, this my also change. An automatic calibration would be also nice to have. Signed-off-by: Richard Weinberger --- drivers/mtd/ubi/ubi-media.h | 81 +++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 81 insertions(+), 0 deletions(-) diff --git a/drivers/mtd/ubi/ubi-media.h b/drivers/mtd/ubi/ubi-media.h index 6fb8ec2..45f2b7b 100644 --- a/drivers/mtd/ubi/ubi-media.h +++ b/drivers/mtd/ubi/ubi-media.h @@ -375,4 +375,85 @@ struct ubi_vtbl_record { __be32 crc; } __packed; +#ifdef CONFIG_MTD_UBI_CHECKPOINT +#define UBI_CP_SB_VOLUME_ID (UBI_LAYOUT_VOLUME_ID + 1) +#define UBI_CP_DATA_VOLUME_ID (UBI_CP_SB_VOLUME_ID + 1) + +/* Checkoint format version */ +#define UBI_CP_FMT_VERSION 1 + +#define UBI_CP_MAX_START 64 +#define UBI_CP_MAX_BLOCKS 32 +#define UBI_CP_MAX_POOL_SIZE 128 +#define UBI_CP_SB_MAGIC 0x7B11D69F +#define UBI_CP_HDR_MAGIC 0xD4B82EF7 +#define UBI_CP_VHDR_MAGIC 0xFA370ED1 +#define UBI_CP_LPOOL_MAGIC 0x67AF4D08 +#define UBI_CP_SPOOL_MAGIC 0x67AF4D09 +#define UBI_CP_UPOOL_MAGIC 0x67AF4D0A + +struct ubi_cp_sb { + __be32 magic; + __u8 version; + __be32 data_crc; + __be32 nblocks; + __be32 block_loc[UBI_CP_MAX_BLOCKS]; + __be32 block_ec[UBI_CP_MAX_BLOCKS]; + __be64 sqnum; +} __packed; + +/* first entry in the checkpoint (cp) data set */ +struct ubi_cp_hdr { + __be32 magic; + __be32 nfree; + __be32 nused; + __be32 nvol; +} __packed; + +/* struct ubi_cp_hdr is followed by exactly three struct ub_cp_pool_* records + * long, short and unknown pool */ + +struct ubi_cp_long_pool { + __be32 magic; + __be32 size; + __be32 pebs[UBI_CP_MAX_POOL_SIZE]; +} __packed; + +struct ubi_cp_short_pool { + __be32 magic; + __be32 size; + __be32 pebs[UBI_CP_MAX_POOL_SIZE]; +} __packed; + +struct ubi_cp_unk_pool { + __be32 magic; + __be32 size; + __be32 pebs[UBI_CP_MAX_POOL_SIZE]; +} __packed; + +/* struct ub_cp_pool is followed by nfree+nused struct ubi_cp_ec records */ + +/* erase counter per peb */ +struct ubi_cp_ec { + __be32 pnum; + __be32 ec; +} __packed; + +/* identifies the start of a eba table */ +struct ubi_cp_volhdr { + __be32 magic; + __be32 vol_id; + __u8 vol_type; + __be32 data_pad; + __be32 used_ebs; + __be32 last_eb_bytes; +} __packed; + +/* struct ubi_cp_volhdr is followed by nused struct ubi_cp_eba records */ + +struct ubi_cp_eba { + __be32 lnum; + __be32 pnum; +} __packed; +#endif /* CONFIG_MTD_UBI_CHECKPOINT */ #endif /* !__UBI_MEDIA_H__ */