From patchwork Tue Jan 20 23:43:21 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1710 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=1768952663; bh=0N73GxSB6ua3S69NdhOZwyJaHTZyZvQFLUTKuzA0iVU=; 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=JPS+UURm2Qqj1Z6D6rpRibRM4HZRFnIFwSTcGjRDBchAG93ZcXi/J4VZeapVcT/qm 8lYMnQP8FLpJ3kxGQRX2xPcXDpDjudrP/sNdQHuEZvtB0CHsD+nBYJpum2rYgKT/NJ XaeySa92TV6i0MZ8XQdqQKlXMroNOORwoAJv8CohyTi3ateAU6kCrQZGr5iLPDQY7u oN1v0tx6XaJPGtpcwtx85mb3Lt+yI3jdm8zyUS4rpO0SpvZubtE6w8NW0hE5pNwY75 nNaxhkQ0wdRrwNOjjao9bFmO5s/JldhXKf9nN1eDp5D5VQFq3dK8WH5xL2FXRDpJpo ehZPl44B/umEA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EA0AA695A6 for ; Tue, 20 Jan 2026 16:44:23 -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 UhQvCMbfeqjn for ; Tue, 20 Jan 2026 16:44:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952663; bh=0N73GxSB6ua3S69NdhOZwyJaHTZyZvQFLUTKuzA0iVU=; 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=JPS+UURm2Qqj1Z6D6rpRibRM4HZRFnIFwSTcGjRDBchAG93ZcXi/J4VZeapVcT/qm 8lYMnQP8FLpJ3kxGQRX2xPcXDpDjudrP/sNdQHuEZvtB0CHsD+nBYJpum2rYgKT/NJ XaeySa92TV6i0MZ8XQdqQKlXMroNOORwoAJv8CohyTi3ateAU6kCrQZGr5iLPDQY7u oN1v0tx6XaJPGtpcwtx85mb3Lt+yI3jdm8zyUS4rpO0SpvZubtE6w8NW0hE5pNwY75 nNaxhkQ0wdRrwNOjjao9bFmO5s/JldhXKf9nN1eDp5D5VQFq3dK8WH5xL2FXRDpJpo ehZPl44B/umEA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D8FCA69597 for ; Tue, 20 Jan 2026 16:44:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952662; bh=kq9o2HMBfMmSFpQEuRXDe3oEdVTaOMvTnnd4LQRjQsU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qsDleTX2abTkrUYYljvnn1RwtS2aXx8Ecg9IXIVZVSVLOwGiqVRrNAchta72+WPNe fM5eTetYSAVx+NZwqcwGuyvw9G2HuLYuqx+8Vm0uWlzsqvLILJoVfrCmdEV/WUV1yg W1efZT3efFQnktz30ouckxTBC+i8NaVzwLgpJiz6KNVuinJ5ozEdf2QK1a4pu6qipx +jORSqiW7dVb6kjZCTnlIop4y6lY0jZHrCwVTlbZCXARjXl5hpT6ufezqzhFBREG3i XLZ5OUbd/x7coz97uMhNZJ/Mq7HwkWtg5lG+2sHp2/QXf1rKpkUTsswrUz9IWGMq6j yUj8tr8CM20mw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5F2BD69590; Tue, 20 Jan 2026 16:44:22 -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 a6uX44edhXEK; Tue, 20 Jan 2026 16:44:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768952658; bh=14cgxHswjIz4R/IHWOY/+niW/vWYS4QW/thq0MrK5Ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RK8UYjRQM6UQWex+U5mzBasOE+1RJL8AJ7mFbxZmdU3wy3UIrO1v5eFzwJPePw/fp xYB+aZ39x/+RdMhu1CoXA4QeOF4EiHCNnAu7pX7v7n+5j8kqhOPK1plvH4sWcAitie 71BwGQSeSDFt8GpeE8XE3K0n1fz8QmqqU6T5n6mreYIcSD7gAjWx0CUTg+cRgCKfVn mbTD4sqIFyqos5hA97beOL9JqAwHyAKrhASw7imu99lp20RR6iTKdtOZxeVykEptY4 0MIfvWAEfgqDzwzrGfVVn8rdv1M0fcq1wA6nT1PZuq8jczcSKRL61IWWxVhmbSVjp6 y5+ylDIdEJW7g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0EEED69555; Tue, 20 Jan 2026 16:44:18 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:43:21 -0700 Message-ID: <20260120234344.495605-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260120234344.495605-1-sjg@u-boot.org> References: <20260120234344.495605-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: IHSDG7QW5ATZKS4HT4JEHNH5M6Y4O4R5 X-Message-ID-Hash: IHSDG7QW5ATZKS4HT4JEHNH5M6Y4O4R5 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 , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 01/17] ext4l: Move cache alignment and pointer macros to headers 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 Move several compatibility macros to their proper Linux headers: - Create linux/cache.h with ____cacheline_aligned_in_smp stub - Move ZERO_OR_NULL_PTR to linux/slab.h - Add __counted_by stub to linux/compiler_attributes.h This reduces ext4_uboot.h by moving these definitions to their canonical locations in the Linux header hierarchy. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 10 ++++------ include/linux/cache.h | 22 ++++++++++++++++++++++ include/linux/compiler_attributes.h | 10 ++++++++++ include/linux/slab.h | 9 +++++++++ 4 files changed, 45 insertions(+), 6 deletions(-) create mode 100644 include/linux/cache.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index eadff92aecb..2255458a46d 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -118,11 +118,10 @@ /* completion - use Linux header */ #include -/* Cache alignment - stub */ -#define ____cacheline_aligned_in_smp +/* Cache alignment - use linux/cache.h */ +#include -/* Pointer check macros */ -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= PAGE_SIZE) +/* ZERO_OR_NULL_PTR is in linux/slab.h */ /* data_race is in linux/compiler.h */ /* REQ_META, REQ_PRIO, REQ_RAHEAD are in linux/blk_types.h */ @@ -154,8 +153,7 @@ /* kiocb, iov_iter - use linux/uio.h */ #include -/* __counted_by attribute - not available in U-Boot */ -#define __counted_by(x) +/* __counted_by is in linux/compiler_attributes.h */ /* dir_context, filldir_t are in linux/fs.h */ diff --git a/include/linux/cache.h b/include/linux/cache.h new file mode 100644 index 00000000000..2fb4e00faa7 --- /dev/null +++ b/include/linux/cache.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Cache alignment definitions for U-Boot + * + * Based on Linux include/linux/cache.h + */ +#ifndef _LINUX_CACHE_H +#define _LINUX_CACHE_H + +/* + * U-Boot is single-threaded, so cache line alignment for SMP is not needed. + * These are provided for compatibility with Linux code. + */ +#ifndef ____cacheline_aligned_in_smp +#define ____cacheline_aligned_in_smp +#endif + +#ifndef __cacheline_aligned_in_smp +#define __cacheline_aligned_in_smp +#endif + +#endif /* _LINUX_CACHE_H */ diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h index 44c9a08d734..097fce857c5 100644 --- a/include/linux/compiler_attributes.h +++ b/include/linux/compiler_attributes.h @@ -270,4 +270,14 @@ */ #define __weak __attribute__((__weak__)) +/* + * __counted_by(member) - flexible array bounds annotation + * + * Used to annotate flexible array members with the struct member that + * holds the count. Not available in all compilers, so stub it out. + */ +#ifndef __counted_by +#define __counted_by(member) +#endif + #endif /* __LINUX_COMPILER_ATTRIBUTES_H */ diff --git a/include/linux/slab.h b/include/linux/slab.h index 15d561f0527..628126e0a3b 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -56,6 +56,15 @@ #define SLAB_RECLAIM_ACCOUNT 0x00020000UL /* Track pages reclaimed */ #define SLAB_ACCOUNT 0x00000000UL /* Account to memcg (no-op) */ +/* + * Check if pointer is zero or in the zero page (used by SLUB allocator). + * PAGE_SIZE fallback for when this header is included standalone. + */ +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= PAGE_SIZE) + void *kmalloc(size_t size, gfp_t flags); static inline void *kzalloc(size_t size, gfp_t flags)