From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from esa3.hc555-34.eu.iphmx.com (esa3.hc555-34.eu.iphmx.com [207.54.77.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9253A438FE0 for ; Tue, 20 Jan 2026 14:27:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=207.54.77.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768919273; cv=none; b=OPSgcIbvCNHHLvIYzT4DdbEiGMYUNGX1LIh+FWCfE3hNNEnuCN9GHjtOTsDY7bEmGzFDPNMRPErVc+9Uj8c5abOUgC+jYNyckQkBmFeMJWYlcSdueTxTMwXZSxpfjfQu/pWaFVKslRgw6EueQX9vb7W+NhKpvd7KLtNaUH/33lw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768919273; c=relaxed/simple; bh=JcK32a/K4Bc5DTjfgo4jpbmZhsGF6/j5Ko6r8eaGKR8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fQ36SqVdfX3ocrALCOENC/9kHZdo7SJkTN3ZtDrjS+fDEIIrPDSpAcPmJHNHbgOx9p1B787wmrgN8l58lbUHDN1iDeocBk1wJUZ4R5233zfE5OWSEaXwpF8bM8AL8vfHPkY6wZjHhQQmQpbrdRcwat25IyYMULH/kYQMY8qGY40= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mobileye.com; spf=pass smtp.mailfrom=mobileye.com; dkim=fail (0-bit key) header.d=mobileye.com header.i=@mobileye.com header.b=bl3dkwUV reason="key not found in DNS"; arc=none smtp.client-ip=207.54.77.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mobileye.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mobileye.com Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="key not found in DNS" (0-bit key) header.d=mobileye.com header.i=@mobileye.com header.b="bl3dkwUV" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mobileye.com; i=@mobileye.com; q=dns/txt; s=MoEyIP; t=1768919268; x=1800455268; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=JcK32a/K4Bc5DTjfgo4jpbmZhsGF6/j5Ko6r8eaGKR8=; b=bl3dkwUVmySS2ZKS/tFs2WVbfPu0pOQisL1YcWek/9V16F4DpUSLKkWT Sky3kKXRf79YIb8QN2Pr8OHyy6KjJYtwrvqkipmlhFnZoax5QXzpen6Q6 T687LY0/6yU8+IPTk6H5VWmgq+UZChKePwHR3lrcgwrufn2+Bsv8bPHXG Upw5EN/nAuxMjdVtaoynRcdnutrNZsvb+R9TcAtD875ZQRYTddFx04GvP FMMkZ515Me85Jc6URQkEKJuKIkB+IQId/9gdRclfEr8UTqfEJaKioA8CR Lzyi15/feyQ3OJpLbFHUbEn5BRQyt+CORBYGIcVMaBsYVVa0xkNV+rt0B A==; X-CSE-ConnectionGUID: 6MoOfPBvSRiGLDUR/p2GsQ== X-CSE-MsgGUID: hrx5QIQ3Q2GGsd+C8pJIDQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from unknown (HELO ces02_data.me-corp.lan) ([146.255.191.134]) by esa3.hc555-34.eu.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jan 2026 16:26:38 +0200 X-CSE-ConnectionGUID: Z7IJKOSBRGaaiEAxrI+bkQ== X-CSE-MsgGUID: /rziLRduQLaA2dxB9YR0yw== Received: from unknown (HELO epgd071.me-corp.lan) ([10.154.54.2]) by ces02_data.me-corp.lan with SMTP; 20 Jan 2026 16:28:38 +0200 Received: by epgd071.me-corp.lan (sSMTP sendmail emulation); Tue, 20 Jan 2026 16:26:39 +0200 From: Vladimir Kondratiev To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Will Deacon , Peter Zijlstra , Boqun Feng , Mark Rutland , Gary Guo , Yury Norov , Rasmus Villemoes , cfu@wavecomp.com, torvalds@linux-foundation.org, olof@lixom.net, aleksa.paunovic@htecgroup.com, arikalo@gmail.com Cc: Vladimir Kondratiev , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Vladimir.Kondratiev@mobileye.com Subject: [PATCH v2 0/2] Support for Risc-V CPUs implementing LR/SC but not AMO Date: Tue, 20 Jan 2026 16:26:22 +0200 Message-ID: <20260120-lrsc-only-v2-0-a522e640d27d@mobileye.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" X-Change-ID: 20260120-lrsc-only-cc06422f5bb1 X-Mailer: b4 0.14.2 Content-Transfer-Encoding: 8bit Primary goal is to support Mobileye eyeq7h automotive platform based on MIPS P8700 CPU [1] having only "zalrsc" ISA extension but not full "a". Such platforms need userspace to be compiled with correct "-march" flags to generate proper instructions for the atomic types so there's not feasible to use universal userspace for it. Thus there's no point to do same binary kernel suitable for both "full A" and "LRSC only" platform types. Do a compile time alternatives and require CONFIG_NONPORTABLE for this [1] https://mips.com/products/hardware/p8700/ Patch 1 do most of work to provide compile-time LR/SC alternatives for the AMO instructions Patch 2 adjust tests for reported CPU extensions compatibility with the code Changes in v2: switch from dynamic atomic flavor resolution to compile-time one. Signed-off-by: Vladimir Kondratiev --- Vladimir Kondratiev (2): riscv: support ISA extensions "zaamo" and "zalrsc" riscv: more accurate check for CPU atomics support arch/riscv/Kconfig | 19 ++++++++++++++ arch/riscv/Makefile | 16 ++++++++---- arch/riscv/include/asm/atomic.h | 56 +++++++++++++++++++++++++++++++++++++++- arch/riscv/include/asm/bitops.h | 48 ++++++++++++++++++++++++++++++++++ arch/riscv/include/asm/cmpxchg.h | 18 +++++++++++++ arch/riscv/include/asm/futex.h | 52 +++++++++++++++++++++++++++++++++++++ arch/riscv/kernel/cpu.c | 22 +++++++++++++--- arch/riscv/kernel/entry.S | 9 +++++++ arch/riscv/kernel/head.S | 18 +++++++++++++ 9 files changed, 248 insertions(+), 10 deletions(-) --- base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449 change-id: 20260120-lrsc-only-cc06422f5bb1 Best regards, -- Vladimir Kondratiev