From patchwork Sat Apr 18 00:39:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2218 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=1776472832; bh=nCcmd+mecnICOYl+jYaXJjEAiibWPn6/vdgUL9kXot4=; 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=pb18HB9fN0B3u9I7D3ilmF6/UKaeiGNTviOO5Wv3ux6RgeOSEHI2zF/FvSq7cPmjT rwagroeQMVxncDeSgebzg8JFxTsdXJiOsMFyrhm5jSATihrVtOJLZG77Ky4Y7dgXDw w8KIHErbVkfF6wzAQXePDZW/WkCm/ZJwCzkJ+F+w= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4861E6A516 for ; Fri, 17 Apr 2026 18:40:32 -0600 (MDT) 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 ZC6GqxpFMb95 for ; Fri, 17 Apr 2026 18:40:32 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776472831; bh=nCcmd+mecnICOYl+jYaXJjEAiibWPn6/vdgUL9kXot4=; 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=itrnmNKl/KDVhraR26gJ3Tmwzq/BhYKgd6wOxweFO/N3kpIrWB7d/cXEWSRMTQk9s Fbe13t+B1cAbYAseCy/pNroE+vlI3Dfa0ts4Ewp2rnzeUexJkDCi1foQSVJz3Sd56E O+KbSN3AVHht/WKxeJ7Df9oa2JEaNnkfVwdUrumc= Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 31CFE6A53B for ; Fri, 17 Apr 2026 18:40:31 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776472829; bh=KMsv4uybhZ3mJDrW8tTq3XPLw7B2WhkjP+/cT/piiUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sy4okwtr/Oy1fHEej40G4CN49mKTbvyBNXeR7XoqwlGL9CtlpuJzDEWWWNYA0+sUK 9oXlrpu8wnMSnxlXug43kGWp+hza25mmX1hKhSi7OtK6unpplPwv6dgiWpUh+ZkXAK T+Z2Z2Fa5rU8BzF0A/eVOWCRDCgLENbz1sf9Xpvg= Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AF9646A516; Fri, 17 Apr 2026 18:40:29 -0600 (MDT) 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 8uMAVbZw-Cnv; Fri, 17 Apr 2026 18:40:29 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1776472829; bh=GzbanrGpTw0JfvgM9GFiGpeGz8qArgK+rJjYBM1dh38=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LVmwordZog0BvfaZWMFnC6/ivlYOg537+UVfVrEE7AHIeZ1eZqAV5e/IuzQaTvtz5 P3jZyQ17Zunf81qDI26QfdNiSz8KMixgDmUI2KcANQrixpTss/2YEAZLaO3hj72/SA 8moeQqLpZn8MacErJLmWG0ulY+K1qgGd1YeQlH7g= Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0F4196A414; Fri, 17 Apr 2026 18:40:29 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Fri, 17 Apr 2026 18:39:55 -0600 Message-ID: <20260418004014.1889749-2-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260418004014.1889749-1-sjg@u-boot.org> References: <20260418004014.1889749-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BFWRYJXT2C23CNXGP2H7VYE5GURYRBRG X-Message-ID-Hash: BFWRYJXT2C23CNXGP2H7VYE5GURYRBRG 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 01/10] x86: atomic: Add atomic_dec_and_test() 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 The Linux fs.h port for ext4l and isofs uses atomic_dec_and_test() on buffer_head reference counts. The x86 asm/atomic.h provides atomic_dec() but lacks the dec-and-test variant, so any file that includes linux/fs.h on x86 fails to build once that code path is reached. Add the standard "LOCK decl + sete" implementation, mirroring the Linux kernel x86 atomic primitives, so the per-arch x86 atomic header is complete enough to back linux/fs.h without needing the asm-generic fallback. Signed-off-by: Simon Glass --- arch/x86/include/asm/atomic.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h index 14f811fc367..addbece6c3e 100644 --- a/arch/x86/include/asm/atomic.h +++ b/arch/x86/include/asm/atomic.h @@ -90,6 +90,23 @@ static inline void atomic_dec(atomic_t *v) : "+m" (v->counter)); } +/** + * atomic_dec_and_test - decrement and test + * @v: pointer of type atomic_t + * + * Atomically decrements @v by 1 and returns true if the result is 0, + * or false for all other cases. + */ +static inline int atomic_dec_and_test(atomic_t *v) +{ + unsigned char c; + + asm volatile(LOCK_PREFIX "decl %0; sete %1" + : "+m" (v->counter), "=qm" (c) + : : "memory"); + return c != 0; +} + /** * atomic_inc_short - increment of a short integer * @v: pointer to type int