Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp329998lqp; Wed, 12 Jun 2024 02:54:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUpSm5ju/gB2kourWcxChXqyuigInp854gfiEGSa2b+yKiDFW6fKrIn8CSx3xGfQWHJIi7iSt58f1Ob2ZJJ3uL0ibkM0ev/ym3T2kZ7Mg== X-Google-Smtp-Source: AGHT+IFEyogVdVqJbUFbE6wlvfzsBnnENGyIEWk1F9MLYsaruq+NB+kRErtTbFhosIN4GDCPjVmL X-Received: by 2002:a05:6214:2dc9:b0:6b0:75ad:a61e with SMTP id 6a1803df08f44-6b19196634cmr16665996d6.25.1718186049435; Wed, 12 Jun 2024 02:54:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718186049; cv=pass; d=google.com; s=arc-20160816; b=EM5UpNJ2Hyk2r6ZbRlccdb+w8WSQwY6BcIASdtHJ5b3pobG2nXGAQGQ360TqocbH6N LLhZKe2PfS/JfEyZPumO4xhiVsIWdeeQrXxv7W+PlTzxaSnBwuAJhG+0ymlkvRayDhtM nos2JRHxkPKQ3ZYwGPApcrG/ewDlw1Qqjr6I8N7eJS4kJENDPcCf2Ws+yGZCaWk/eoBo b/8fnZDCIIrtgTxEohSXK3bGHeFtrcxEv3sd9yu5s0F1oI8ZzlsiHpcmfUxhldjFeEzr hFMKDLDOJlBneVY97LbUykZRxnjAs+u3dU6gQ5wwxPiF0KBS3Dg86IdzNb4sKhTQSGQN QrzQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:feedback-id:dkim-signature:dkim-signature; bh=ESHl3L3OxDQSgcJHHY7pIck3NL6/jnLr7SbwhIcuKmI=; fh=mGMdN8CNPnSnCOlUdkXNufr+nOn5LJkQTNTeQ1Iihlw=; b=aWcd9TUpMiVEqifoGvFP8x+wP+OuyjLqJmHj32YhTtdlKZe5/nTH361bN4Sz0BWetn QItDiFvpTCuHvm6yCcacwUz8a7OpVgYyBn1bndKv2u4CEDe36orINLBR27o6dCE1fDVr /QTJ2iEv9B4wzPRa2VR4AX4hNURfRY9HlZnZzN8Bb6uziWml22CY2CY3dTeo6g8gjjhX hWNXcUAAalUFsKbk/kAwLB9ZdugCyIwuzawA1JrpCsdY6lGf9UaIXi9cZoI9TTFo0PVF Fa3h7ThLCpCYnEIK2qeSjoHkNtReYW3jx3aSN+GHWbrcon4+8mbWpfhJOgC7Sm0deYD9 6RyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm2 header.b=fVu1ZxqR; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=WX+kJWVe; arc=pass (i=1 spf=pass spfdomain=flygoat.com dkim=pass dkdomain=flygoat.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=flygoat.com); spf=pass (google.com: domain of linux-kernel+bounces-211300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211300-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id 6a1803df08f44-6b0912bf448si25937716d6.568.2024.06.12.02.54.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 02:54:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-211300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm2 header.b=fVu1ZxqR; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=WX+kJWVe; arc=pass (i=1 spf=pass spfdomain=flygoat.com dkim=pass dkdomain=flygoat.com dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=flygoat.com); spf=pass (google.com: domain of linux-kernel+bounces-211300-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-211300-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6FD2B1C216ED for ; Wed, 12 Jun 2024 09:53:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 791BA16E88B; Wed, 12 Jun 2024 09:53:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b="fVu1ZxqR"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="WX+kJWVe" Received: from fhigh4-smtp.messagingengine.com (fhigh4-smtp.messagingengine.com [103.168.172.155]) (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 B300516DECA; Wed, 12 Jun 2024 09:53:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.155 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718186019; cv=none; b=NLaa3sZ3BrV+GIn5LIPSiUs+dcTV6/pGK+69K16Wz2hfRXZIsRjzt2PIIXz7Ip8IBLa6m1biv04lBzd2LBRzCO/jx7TNXF645zNp0rgDZ0N2dJKFuYHMGxY8asApVR1hxYevm5Sjh8YwHUYd/2I3EJwXv/NYhlqWfBFOwrohJo8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718186019; c=relaxed/simple; bh=dBYBJUV94eWDrUQ36fbRfMft6NGiZT3vPMdQLOfyh3s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j0T4tO3+rP27l5DuXODUIKu9TCHgRWReU/Vwwhlum7ai+Zpj01I+Zjp/QHWEbPSmLtA+kNA+K/ZhQdNqrJExErZuVuHUxri7u9WwG2zQG0+vXJwPR/2ThvTKId3tT2TPlO/rgpmuAgbJ+OhtdWbhpK2ozoeZX+5FIMF/PVGjJRk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com; spf=pass smtp.mailfrom=flygoat.com; dkim=pass (2048-bit key) header.d=flygoat.com header.i=@flygoat.com header.b=fVu1ZxqR; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=WX+kJWVe; arc=none smtp.client-ip=103.168.172.155 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=flygoat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flygoat.com Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id CE5FD11400E2; Wed, 12 Jun 2024 05:53:36 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 12 Jun 2024 05:53:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1718186016; x=1718272416; bh=ESHl3L3OxDQSgcJHHY7pIck3NL6/jnLr7SbwhIcuKmI=; b= fVu1ZxqRvlMRGc2b746PzJ0K+0qXpKdlRQf5FVUCvmuqpbn81piBGsnWh5H0m2/s BCWdhImlCJsD90ssAF+MR0tIcc+zD6MhAZwp4gIIt9+75NW18eO2nSafudzSm0Jb 8uXmlGsFTlPFo/GSh6LPOlmCfSPh5QLqcct2ml015jtaEwmeFSnyY/inLNZ+3lM5 MoqCLoMmrAHpwhSUqWVeFy2ny+rIl6IQjac3/7bCsXUV5ppbtbguu0kuOSJ2fmwl aO0zFeftEhMaIb/scmg5x/g941QlGOyi2kB58HFotPEA3iNebJjOBkALyz7hOJNI iQZyk4TPxLX6VPhO5SL55g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1718186016; x= 1718272416; bh=ESHl3L3OxDQSgcJHHY7pIck3NL6/jnLr7SbwhIcuKmI=; b=W X+kJWVeObf0vh5+s38ilk+JU98RmdkUtOedk3dcEk1o3qxCOjObuYa1NGLZ9QOCZ jOXQNAnUU/YTo1Z5wRrBBeBxe8vMqPM6l5GWFX6ioJh6e9RtaUclBFMDhV1GOEG1 bZP5Yo3pbLI4STA/yCtwUh1My+Urai4T6y8yEGQ3a8NyCK4jr3pPALNseFnReJ7R 6O3fOPRVyAR4v0mYkVdneVzio8pmBIwEmGhEHBL34kWrOKQlXvgFVdXXb/ESc/Zn 8vyckr68Q2+GM4GICbtxdjqvCLnZzqITbXNjLq0KGhvIKYGTh2R8qs2A9f20XonR 9A4JNHAA8Apn4JaH8SX+Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedugedgvddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeflihgr gihunhcujggrnhhguceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomheqne cuggftrfgrthhtvghrnhepvdekiefhfeevkeeuveetfeelffekgedugefhtdduudeghfeu veegffegudekjeelnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilh hfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 12 Jun 2024 05:53:35 -0400 (EDT) From: Jiaxun Yang Date: Wed, 12 Jun 2024 10:53:30 +0100 Subject: [PATCH v2 2/4] MIPS: Introduce config options for LLSC availability 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" Content-Transfer-Encoding: 7bit Message-Id: <20240612-mips-llsc-v2-2-a42bd5562bdb@flygoat.com> References: <20240612-mips-llsc-v2-0-a42bd5562bdb@flygoat.com> In-Reply-To: <20240612-mips-llsc-v2-0-a42bd5562bdb@flygoat.com> To: Thomas Bogendoerfer Cc: Jonas Gorski , "Maciej W. Rozycki" , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Jiaxun Yang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4430; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=dBYBJUV94eWDrUQ36fbRfMft6NGiZT3vPMdQLOfyh3s=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhrTMAlmzSrE/796uPNV07vnHpS420tFOBWfeN9T2Za1dO XnvzEflHaUsDGJcDLJiiiwhAkp9GxovLrj+IOsPzBxWJpAhDFycAjCRHUIM/8vyl+5S6T35LO6E 94LeZ1PdP3hlNphHZ9dVeFSml6pURzD8T8mIqtVpO/c3xGzJtLc3z/CX1UbPNXulmV2+ifnWx+f nWQA= X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Introduce CPU_HAS_LLSC and CPU_MAY_HAVE_LLSC to determine availability of LLSC and Kconfig level. They are both true for almost all supported CPUs besides: R3000: Doesn't have LLSC, so both false. R5000 series: LLSC is unusable for 64bit kernel, so both false. R10000: Some platforms decided to opt-out LLSC due to errata, so only select CPU_MAY_HAVE_LLSC. WAR_4KC_LLSC: LLSC is buggy on certain reversion, which can be detected at cpu-probe or platform override, so only select CPU_MAY_HAVE_LLSC. Signed-off-by: Jiaxun Yang --- v2: Make cpu_has_llsc logic clear --- arch/mips/Kconfig | 20 ++++++++++++++++++++ arch/mips/include/asm/cpu-features.h | 9 ++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 8ac467c1f9c8..50260a7e9b54 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -1548,6 +1548,7 @@ config CPU_R3000 config CPU_R4300 bool "R4300" depends on SYS_HAS_CPU_R4300 + select CPU_HAS_LLSC select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_64BIT_KERNEL help @@ -1556,6 +1557,7 @@ config CPU_R4300 config CPU_R4X00 bool "R4x00" depends on SYS_HAS_CPU_R4X00 + select CPU_HAS_LLSC select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_64BIT_KERNEL select CPU_SUPPORTS_HUGEPAGES @@ -1566,6 +1568,7 @@ config CPU_R4X00 config CPU_TX49XX bool "R49XX" depends on SYS_HAS_CPU_TX49XX + select CPU_HAS_LLSC select CPU_HAS_PREFETCH select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_64BIT_KERNEL @@ -1574,6 +1577,7 @@ config CPU_TX49XX config CPU_R5000 bool "R5000" depends on SYS_HAS_CPU_R5000 + select CPU_HAS_LLSC if !64BIT select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_64BIT_KERNEL select CPU_SUPPORTS_HUGEPAGES @@ -1583,6 +1587,7 @@ config CPU_R5000 config CPU_R5500 bool "R5500" depends on SYS_HAS_CPU_R5500 + select CPU_HAS_LLSC select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_64BIT_KERNEL select CPU_SUPPORTS_HUGEPAGES @@ -1593,6 +1598,7 @@ config CPU_R5500 config CPU_NEVADA bool "RM52xx" depends on SYS_HAS_CPU_NEVADA + select CPU_HAS_LLSC if !64BIT select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_64BIT_KERNEL select CPU_SUPPORTS_HUGEPAGES @@ -1602,6 +1608,8 @@ config CPU_NEVADA config CPU_R10000 bool "R10000" depends on SYS_HAS_CPU_R10000 + select CPU_HAS_LLSC if !WAR_R10000_LLSC + select CPU_MAY_HAVE_LLSC select CPU_HAS_PREFETCH select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_64BIT_KERNEL @@ -1613,6 +1621,7 @@ config CPU_R10000 config CPU_RM7000 bool "RM7000" depends on SYS_HAS_CPU_RM7000 + select CPU_HAS_LLSC select CPU_HAS_PREFETCH select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_64BIT_KERNEL @@ -1622,6 +1631,7 @@ config CPU_RM7000 config CPU_SB1 bool "SB1" depends on SYS_HAS_CPU_SB1 + select CPU_HAS_LLSC select CPU_SUPPORTS_32BIT_KERNEL select CPU_SUPPORTS_64BIT_KERNEL select CPU_SUPPORTS_HIGHMEM @@ -1656,6 +1666,7 @@ config CPU_BMIPS select CPU_BMIPS4350 if SYS_HAS_CPU_BMIPS4350 select CPU_BMIPS4380 if SYS_HAS_CPU_BMIPS4380 select CPU_BMIPS5000 if SYS_HAS_CPU_BMIPS5000 + select CPU_HAS_LLSC select CPU_SUPPORTS_32BIT_KERNEL select DMA_NONCOHERENT select IRQ_MIPS_CPU @@ -2381,6 +2392,15 @@ config CPU_DIEI_BROKEN config CPU_HAS_RIXI bool +# For CPU that must have LLSC +config CPU_HAS_LLSC + def_bool TARGET_ISA_REV > 0 && !WAR_4KC_LLSC + select CPU_MAY_HAVE_LLSC + +# For CPU that LLSC support is optional +config CPU_MAY_HAVE_LLSC + def_bool TARGET_ISA_REV > 0 + config CPU_NO_LOAD_STORE_LR bool help diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h index 404390bb87ea..40f5570de563 100644 --- a/arch/mips/include/asm/cpu-features.h +++ b/arch/mips/include/asm/cpu-features.h @@ -185,8 +185,15 @@ #ifndef cpu_has_ejtag #define cpu_has_ejtag __opt(MIPS_CPU_EJTAG) #endif + #ifndef cpu_has_llsc -#define cpu_has_llsc __isa_ge_or_opt(1, MIPS_CPU_LLSC) +# if defined(CONFIG_CPU_HAS_LLSC) +# define cpu_has_llsc 1 +# elif defined(CONFIG_CPU_MAY_HAVE_LLSC) +# define cpu_has_llsc __opt(MIPS_CPU_LLSC) +# else +# define cpu_has_llsc 0 +# endif #endif #ifndef kernel_uses_llsc #define kernel_uses_llsc cpu_has_llsc -- 2.43.0