From patchwork Sat Jan 17 01:14:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1571 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=1768612549; bh=p9xdaekfdNORr6gC8s6PKYPQWxQv7jlxdnYY+kW4Npg=; 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=JBeUvXj51MZvsGytu2iZLZIrGZ4wDCZrw5pYv6/fHeJXKG3viS7U3WdGDisbu5EhD PZiX/+oqKr89lMyNWg6wAKLpfrks6IWyLuHGSdrBKKcLpY4zQi3u7UDLWclfEPsbsy boi/oY8w8y/Xx+ZuWZ0WZwn70ek9C4HQkIE0LRaY1B8E2G+Ov9N5HVROOj/W8Xur9r wsNGon9DpAe+9DXdqjdTCsOVrhPOLIuzVK6HgPmP16+H+y9ULbGXRPRJd7IEtgxlXG KSQnOh464uq541irruHcMOo/5v7tizwHMU/+LYHh3g5tRXjE38GaAPGJXTHs81HK4a 01hV9HT/+YzDA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 91DB66913F for ; Fri, 16 Jan 2026 18:15:49 -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 0_ZcIsdw303Y for ; Fri, 16 Jan 2026 18:15:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768612549; bh=p9xdaekfdNORr6gC8s6PKYPQWxQv7jlxdnYY+kW4Npg=; 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=JBeUvXj51MZvsGytu2iZLZIrGZ4wDCZrw5pYv6/fHeJXKG3viS7U3WdGDisbu5EhD PZiX/+oqKr89lMyNWg6wAKLpfrks6IWyLuHGSdrBKKcLpY4zQi3u7UDLWclfEPsbsy boi/oY8w8y/Xx+ZuWZ0WZwn70ek9C4HQkIE0LRaY1B8E2G+Ov9N5HVROOj/W8Xur9r wsNGon9DpAe+9DXdqjdTCsOVrhPOLIuzVK6HgPmP16+H+y9ULbGXRPRJd7IEtgxlXG KSQnOh464uq541irruHcMOo/5v7tizwHMU/+LYHh3g5tRXjE38GaAPGJXTHs81HK4a 01hV9HT/+YzDA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 81101693F4 for ; Fri, 16 Jan 2026 18:15:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768612548; bh=JL3dLSbE13QbdYtX3SJOLvJyBXEiXEnqH/KxTMdok64=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cvCchtu062kcxfYmoO8YDuz671Ml5e+/ylZaX1CqrQEuQVvNbXTJTyubfm4IbEpPG TB7IJuY/kWXf5CshDRFT9Mi3WMcgRL4vSVTaTL0CTM4PtH6ZyZY9JBrToB9dxxgu6f nxNPYsY6JDOXbGbU/TjiJbiyRFBlZeQZdhEu6aOFXRZ7YZ7oEoTolvrx2cVSDGPWad vedb6pSOSzyE7yJdnsQFxWxjS/FDedR5f2Cv7zQG1x1fmoJNqeQlxsrab5Xgcdo3jw kDXVf82y35kkZ2ePXZAoHEv56knoQtZZ4eDHdSr20eVTGVv2lr/SlRAYBZZqo2fsAe avS/luv3kivHA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2E9FE6913F; Fri, 16 Jan 2026 18:15:48 -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 OLlUanoZLTGd; Fri, 16 Jan 2026 18:15:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768612544; bh=Cv7sZEQygCPXKdqSf2fdYb6Ecan43GBXnIp5BC0ujrA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FGN/I0na+SiIz3ZYyK1PD0TEKSJ0A9FVu0YpNUIF++ZzJZS74ERLiPuUkFq7V7USJ tjo0+qnX7vkSDMraf8u1eRY5oDlDWlTQbQwx3bhcmublaWSdvQWWdIe55nTuckGHRh Om9EKlKrclUnjEty/2Nu6YZuNI+wWSxyVutsWwE6N0j2IwrFMhvJ1N4+lJmGo3GHoX q1F6XbXkckyB6jVIio3ki299b3NNZexffGdvaxL5TPEcRX+fF5Q/94r+V6K0XwRLD5 oYuvrZawY604bmilCnGAFH1F9OqKZ5y2mJQhJxToas+zWUF1fkS07rz3Pefo0xhAfs bLz2Ht2rhcXtw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D7C6D693E0; Fri, 16 Jan 2026 18:15:43 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 16 Jan 2026 18:14:33 -0700 Message-ID: <20260117011448.3007171-12-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260117011448.3007171-1-sjg@u-boot.org> References: <20260117011448.3007171-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TRNTPH6LBC6C4D25VASS42FOUQMROBRZ X-Message-ID-Hash: TRNTPH6LBC6C4D25VASS42FOUQMROBRZ 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 11/19] linux: Add smp.h header with SMP stubs 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 SMP-related stubs to a dedicated header file that mirrors the Linux kernel organisation. smp.h provides: - raw_smp_processor_id() and smp_processor_id() - always return 0 - smp_rmb(), smp_wmb(), smp_mb() - memory barriers (no-ops) - smp_mb__after_atomic() - post-atomic memory barrier (no-op) These are all stubs since U-Boot is single-threaded. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- fs/ext4l/ext4_uboot.h | 13 +++------- include/linux/smp.h | 60 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 9 deletions(-) create mode 100644 include/linux/smp.h diff --git a/fs/ext4l/ext4_uboot.h b/fs/ext4l/ext4_uboot.h index f26006f9291..57d967965da 100644 --- a/fs/ext4l/ext4_uboot.h +++ b/fs/ext4l/ext4_uboot.h @@ -88,13 +88,11 @@ #include #include #include +#include /* atomic_dec_if_positive, atomic_add_unless, etc. are now in asm-generic/atomic.h */ - -/* SMP stubs - U-Boot is single-threaded */ -#define raw_smp_processor_id() 0 - /* cmpxchg is now in asm-generic/atomic.h */ +/* SMP stubs (raw_smp_processor_id, smp_*mb) are now in linux/smp.h */ /* Reference count type */ typedef struct { atomic_t refs; } refcount_t; @@ -255,10 +253,7 @@ struct buffer_head *sb_getblk(struct super_block *sb, sector_t block); /* inode_needs_sync - stub */ #define inode_needs_sync(inode) (0) -/* Memory barriers - stubs for single-threaded */ -#define smp_rmb() do { } while (0) -#define smp_wmb() do { } while (0) -#define smp_mb() do { } while (0) +/* Memory barriers are now in linux/smp.h */ /* * set_bit/clear_bit are declared extern in asm/bitops.h but not implemented. @@ -1897,7 +1892,7 @@ struct wait_bit_entry { /* JBD2 commit.c stubs (folio_trylock is in linux/pagemap.h) */ #define clear_bit_unlock(nr, addr) clear_bit(nr, addr) -#define smp_mb__after_atomic() do { } while (0) +/* smp_mb__after_atomic is now in linux/smp.h */ #define ktime_get_coarse_real_ts64(ts) do { (ts)->tv_sec = 0; (ts)->tv_nsec = 0; } while (0) #define filemap_fdatawait_range_keep_errors(m, s, e) \ ({ (void)(m); (void)(s); (void)(e); 0; }) diff --git a/include/linux/smp.h b/include/linux/smp.h new file mode 100644 index 00000000000..15fb7fa656f --- /dev/null +++ b/include/linux/smp.h @@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * SMP stubs for U-Boot + * + * U-Boot is single-threaded, so all SMP operations are stubs. + */ +#ifndef _LINUX_SMP_H +#define _LINUX_SMP_H + +#include + +/** + * raw_smp_processor_id() - get current processor ID + * + * U-Boot stub - always returns 0 (single CPU). + */ +#define raw_smp_processor_id() 0 + +/** + * smp_processor_id() - get current processor ID + * + * U-Boot stub - always returns 0 (single CPU). + */ +#define smp_processor_id() 0 + +/* Memory barriers - stubs for single-threaded U-Boot */ + +/** + * smp_rmb() - read memory barrier + * + * Ensures that all reads before this point are completed before + * any reads after this point. No-op in single-threaded U-Boot. + */ +#define smp_rmb() do { } while (0) + +/** + * smp_wmb() - write memory barrier + * + * Ensures that all writes before this point are completed before + * any writes after this point. No-op in single-threaded U-Boot. + */ +#define smp_wmb() do { } while (0) + +/** + * smp_mb() - full memory barrier + * + * Ensures that all memory operations before this point are completed + * before any memory operations after this point. No-op in single-threaded + * U-Boot. + */ +#define smp_mb() do { } while (0) + +/** + * smp_mb__after_atomic() - memory barrier after atomic operation + * + * No-op in single-threaded U-Boot. + */ +#define smp_mb__after_atomic() do { } while (0) + +#endif /* _LINUX_SMP_H */