From patchwork Mon Dec 22 11:56:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1052 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404674; bh=3Eok8OAaMmmU8uojCXYdKMYxbR2SOggyOkfvrsEojnY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=D6kAVwKTYPoPlLfzovZ2BBeOn5Ov72RZQa+W3cOoLDzixGNdBPgSm8BsEegq8V7Ce mTk2rwmdyctgWB4ILdvYyTM+vofphC6p3kcgfadjyHONMozw7/mCnC23vdK9sbBTkT T6azV9XQNaRxk15xdtWMWy7YAQN/WV+yJvHupxGx3bxsSPiQ4ocv7pr8hw8sOWVQvn QgYZ2i1WQmGsGpK39/cnP+s5QGVcmTP6MNVut03HphmXegmY+XXZwgjf4XkAKgyjSQ PsJPD/vjNFGdH9jsrkblHs7e2VjgVIIhWz+r27TKXqzskI4ArMgqN8asIoCeH39Yds z2ONO5dSwvu2w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B32B964D79 for ; Mon, 22 Dec 2025 04:57:54 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id aSD4ap3KQKIE for ; Mon, 22 Dec 2025 04:57:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404674; bh=3Eok8OAaMmmU8uojCXYdKMYxbR2SOggyOkfvrsEojnY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=D6kAVwKTYPoPlLfzovZ2BBeOn5Ov72RZQa+W3cOoLDzixGNdBPgSm8BsEegq8V7Ce mTk2rwmdyctgWB4ILdvYyTM+vofphC6p3kcgfadjyHONMozw7/mCnC23vdK9sbBTkT T6azV9XQNaRxk15xdtWMWy7YAQN/WV+yJvHupxGx3bxsSPiQ4ocv7pr8hw8sOWVQvn QgYZ2i1WQmGsGpK39/cnP+s5QGVcmTP6MNVut03HphmXegmY+XXZwgjf4XkAKgyjSQ PsJPD/vjNFGdH9jsrkblHs7e2VjgVIIhWz+r27TKXqzskI4ArMgqN8asIoCeH39Yds z2ONO5dSwvu2w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A161864D62 for ; Mon, 22 Dec 2025 04:57:54 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404672; bh=osHBIVqI00K/9tWH2KqyqCb4hsURfxkTjLZofHE6StA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jPtXAMcpdHS2P4h/vwgmOM/DbCjQ6RPNTjFrSkgzzda3EVjpY+eHa3Qe4Zu+FbSY0 3+4YkF/byUmdh73Eytt1cwS6SBUbzK4P3bUZOLonha03O9/bD10xeoFARMF57jAv6B 2oc3y57w6+bf/p3Boz3c9MzK5j9Mp6SXq6XFlnhTwxr/85t4GmOECCf8uEnuEf+5FO 87YhDZlOc8Twj7g0bTVQuThzCw57AraIuR7MiUsAQdUQ3PuuZc2EqH+P5KLkjzGyEk V0MyUKzNNboruUpOBrFpcA9ZDXlxWcvStDiXG9ZEBgyutkqYdLXT6I3C2LL49RmY/+ /mUSJ9btTKfgQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 807EE64D62; Mon, 22 Dec 2025 04:57:52 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id VdgLm-8qP38j; Mon, 22 Dec 2025 04:57:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1766404667; bh=EwHc3GP1hAZnDsuPpoEHS9jGCsarZ0Fa2BPb+b7oj9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TBqTQiFTIfjU69z+s3SmRuMRFswIZLEMr8XIKsbPN/nyre+HWKNigOBrGUV9htnsE I9p+avZncYsIYqdv/6cvL4N2vMoMy+2PXbVqbSBiJH4Yqgm7rs1hJM1GuyFIx3FH80 918sQNZow657EgXdGOeYAj3i9IhLWAvOEHE13P4wNT+aHlnrYJ1C7nm5MYdWcaKyek Xbl3wZJAsnN3EA8oRomQKQNXhJPedddvMCOA3Z7PWorSUBKl+CTqai5LxVjaMUt2gL o4geL98W7pPyL5dUWoluHstQa2HifuXRRT08+n8I0e3rNIcBsMlerUSqyvcYNlmKL/ ocrqzVHHmBBtQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8393264C31; Mon, 22 Dec 2025 04:57:47 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Mon, 22 Dec 2025 04:56:26 -0700 Message-ID: <20251222115639.700578-23-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251222115639.700578-1-sjg@u-boot.org> References: <20251222115639.700578-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: W5MBGW3OZ5XIVLXOPAKSKCW6IL46YGC3 X-Message-ID-Hash: W5MBGW3OZ5XIVLXOPAKSKCW6IL46YGC3 X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 22/26] fs: ext4l: Add CRC32C implementation List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add ext4l_crc32c() which uses the Castagnoli polynomial (0x82F63B78) required for ext4 checksums. The table is initialised on first mount. Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 2 ++ fs/ext4l/interface.c | 2 ++ fs/ext4l/support.c | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index 96b1c06a05b..8b70bbcb75c 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -35,6 +35,7 @@ #include #include #include /* Real rbtree implementation */ +#include /* For crc32() used by crc32_be */ /* * Override no_printk to avoid format warnings in disabled debug prints. @@ -2818,6 +2819,7 @@ struct wait_bit_entry { void free_buffer_head(struct buffer_head *bh); /* ext4l support functions (support.c) */ +void ext4l_crc32c_init(void); void bh_cache_clear(void); int ext4l_read_block(sector_t block, size_t size, void *buffer); diff --git a/fs/ext4l/interface.c b/fs/ext4l/interface.c index e1458ea6bfe..141afc42c17 100644 --- a/fs/ext4l/interface.c +++ b/fs/ext4l/interface.c @@ -92,6 +92,8 @@ int ext4l_probe(struct blk_desc *fs_dev_desc, /* Set up block device for buffer I/O */ ext4l_set_blk_dev(fs_dev_desc, fs_partition); + ext4l_crc32c_init(); + /* Initialise journal subsystem if enabled */ if (IS_ENABLED(CONFIG_EXT4_JOURNAL)) { ret = jbd2_journal_init_global(); diff --git a/fs/ext4l/support.c b/fs/ext4l/support.c index 0765065a99f..2040ad5f480 100644 --- a/fs/ext4l/support.c +++ b/fs/ext4l/support.c @@ -12,12 +12,33 @@ #include #include #include +#include #include #include #include "ext4_uboot.h" #include "ext4.h" +/* + * CRC32C support - uses Castagnoli polynomial 0x82F63B78 + * Table is initialised on first mount + */ +static u32 ext4l_crc32c_table[256]; +static bool ext4l_crc32c_inited; + +void ext4l_crc32c_init(void) +{ + if (!ext4l_crc32c_inited) { + crc32c_init(ext4l_crc32c_table, 0x82F63B78); + ext4l_crc32c_inited = true; + } +} + +u32 ext4l_crc32c(u32 crc, const void *address, unsigned int length) +{ + return crc32c_cal(crc, address, length, ext4l_crc32c_table); +} + /* * Buffer cache implementation *