Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp1794281lqz; Mon, 1 Apr 2024 18:48:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWDBNBnZm5zRPY7EcUDFLYKZfl2c047Vs3HWNxQRv3RlZj7tmZimUMiAORls5ARLSQuHVP9t3DRgoKnu793lPMkcCtW4hzgpzF8jZWNhw== X-Google-Smtp-Source: AGHT+IFYc41NQCnApkhreuFIfdN0Y2QmioGxlc3UO6xW8irrbGKRzccp45e3NZESmvcOg9H/TYlp X-Received: by 2002:a9d:5e83:0:b0:6e6:b209:b24c with SMTP id f3-20020a9d5e83000000b006e6b209b24cmr11814152otl.17.1712022489108; Mon, 01 Apr 2024 18:48:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712022489; cv=pass; d=google.com; s=arc-20160816; b=0nuM1LmFLWeQsV22FTDTTTjUrDhk7BoZVvEj4osuGzbQQF0IxDz9yS0Rmr4euy0Zmj eNGC/13hIYwm4VYMLDG/vpjGGLY8fPLtbJaAMhoC7JePO6/TvsL0c5Ik761HLpZ/Sr2G X7Kd2+htIuCmmE+mgCTX1ZDEKcPl/V21s1F/ap7VD4XZwJSIxaH5qbAuulompL9ScncA 8c5gt5NXVEZ3HwhhwEkyMeXt2eueJyuL3mw/zME6odl2gK8lo8e1cWASrV84pBrbzeVA +CYoApBNSSkVoLQCWsk7b5gOmkVIS+VUacmbWNMcBXi++J6H8U3isq1m1JoJFwtlxOTw WEUw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=i4X7K8R3U0XvMmPyqS+IPCIp/zMWFiuyylPYoGweXMQ=; fh=lxNDTY3uaWBv0b9Is4kVBaMzf1trKYOpxBHrw1u+ptI=; b=yW1OeF/iHzqzfgWujO0tI0rNAtT4OBB4FNSSWBrtOX5rRL9uWpnlDikOjN4puW46Jz Q5XIu7vZcPQSBO+OFgZGS1D69h1l9Nq+8KvK16h7/kXjMjaPQ2Z8hUbdLrXKJhKqv2PG lTBlDw+ois4BIcXU6syRHI3WncLoml377tfkE/MwZtQe5539RcWuct4unxm3YnrUXoMy 3ZsN1V/JQtcTq29DuKgiORTYyHUxjJ3dg7jVqmd9O+KAD4yf+MhXc2EZYvsUbIA/mSSH /peZYO98OYkJlwn+dj6R3PQZ4xDV41LWaDcbGesaq+TIjxKbrtuNpw7IYZ1e5mcRNwFE +8Ow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=B3iyhwRp; arc=pass (i=1 spf=pass spfdomain=amazon.com dkim=pass dkdomain=amazon.com dmarc=pass fromdomain=amazon.com); spf=pass (google.com: domain of linux-kernel+bounces-127264-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id s70-20020a637749000000b005dc8372021bsi10639322pgc.464.2024.04.01.18.48.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Apr 2024 18:48:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-127264-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=B3iyhwRp; arc=pass (i=1 spf=pass spfdomain=amazon.com dkim=pass dkdomain=amazon.com dmarc=pass fromdomain=amazon.com); spf=pass (google.com: domain of linux-kernel+bounces-127264-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-127264-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B173B283CDA for ; Tue, 2 Apr 2024 01:48:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB923F9FE; Tue, 2 Apr 2024 01:47:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="B3iyhwRp" Received: from smtp-fw-2101.amazon.com (smtp-fw-2101.amazon.com [72.21.196.25]) (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 2F2CCD52A; Tue, 2 Apr 2024 01:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=72.21.196.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712022468; cv=none; b=vEYqKGDSkbFVcAa/orhlU0nC29kJyTJOd5EVnrygmF4zko31hHc5fc7nFTi1ZrLd47aBP/bTSf+TtfUARk6Kh5fS3VvQM0eGacqPOXLAMqZHnye6nEQjoCNWFK+4kvCPCO0jMPY80QvBlYKCGajvHCgyxJa+5ndG9hzjcODFwYk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712022468; c=relaxed/simple; bh=byrp57rZFpFTLThv1cyX8/wDPU8rPp83GIPgcwu5g3o=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PeSvi11st6fJJbBHVs7PyP0TajgINEgS2oOatHAgi7lXaeAL+1MiYSxlKuNS1LIKsGS+ymTuZDNzwG/2DpClyL0KWgm4fWBBElcsiRFTtyMLm0esopDkFghRhQW6F+PuGmxJE3Gk+Wqy9RwIfSpRo2otzYrgJVcz97pb3y1jjqA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com; spf=pass smtp.mailfrom=amazon.com; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b=B3iyhwRp; arc=none smtp.client-ip=72.21.196.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1712022468; x=1743558468; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=i4X7K8R3U0XvMmPyqS+IPCIp/zMWFiuyylPYoGweXMQ=; b=B3iyhwRpMxrOSqY0qbrSL9K5AvQwNvmOdzRt72NRhQp0Bqw/w/Yd3wGz BL22kHTonboLlUTwYGd3RTbtd9PneUS9X4BaLhXug3dWVnnCX6Ksqki6D pqRa/664hc5NQBcKVPCpqkTzZMCOBcpzjHzidxqpkdiu2Oq7RugRgEgAA 8=; X-IronPort-AV: E=Sophos;i="6.07,173,1708387200"; d="scan'208";a="391962966" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO smtpout.prod.us-west-2.prod.farcaster.email.amazon.dev) ([10.43.8.6]) by smtp-border-fw-2101.iad2.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Apr 2024 01:47:47 +0000 Received: from EX19MTAUWB002.ant.amazon.com [10.0.38.20:22255] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.7.132:2525] with esmtp (Farcaster) id 6f55626c-399e-4a5c-a1dc-3175624daa6b; Tue, 2 Apr 2024 01:47:45 +0000 (UTC) X-Farcaster-Flow-ID: 6f55626c-399e-4a5c-a1dc-3175624daa6b Received: from EX19D001UWA003.ant.amazon.com (10.13.138.211) by EX19MTAUWB002.ant.amazon.com (10.250.64.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.28; Tue, 2 Apr 2024 01:47:44 +0000 Received: from u34cccd802f2d52.ant.amazon.com (10.252.141.8) by EX19D001UWA003.ant.amazon.com (10.13.138.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.1258.28; Tue, 2 Apr 2024 01:47:43 +0000 From: Haris Okanovic To: , , CC: , Haris Okanovic Subject: [PATCH 2/3] arm64: add __READ_ONCE_EX() Date: Mon, 1 Apr 2024 20:47:05 -0500 Message-ID: <20240402014706.3969151-2-harisokn@amazon.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402014706.3969151-1-harisokn@amazon.com> References: <20240402014706.3969151-1-harisokn@amazon.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: EX19D035UWB001.ant.amazon.com (10.13.138.33) To EX19D001UWA003.ant.amazon.com (10.13.138.211) Perform an exclusive load, which atomically loads a word and arms the execusive monitor to enable wfe() polling of an address. Adding this macro in preparation for an arm64 cpuidle driver which supports a wfe() based polling state. https://developer.arm.com/documentation/dht0008/a/arm-synchronization-primitives/exclusive-accesses/exclusive-monitors Signed-off-by: Haris Okanovic --- arch/arm64/include/asm/readex.h | 46 +++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 arch/arm64/include/asm/readex.h diff --git a/arch/arm64/include/asm/readex.h b/arch/arm64/include/asm/readex.h new file mode 100644 index 000000000000..51963c3107e1 --- /dev/null +++ b/arch/arm64/include/asm/readex.h @@ -0,0 +1,46 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * Based on arch/arm64/include/asm/rwonce.h + * + * Copyright (C) 2020 Google LLC. + * Copyright (C) 2024 Amazon.com, Inc. or its affiliates. + */ + +#ifndef __ASM_READEX_H +#define __ASM_READEX_H + +#define __LOAD_EX(sfx, regs...) "ldaxr" #sfx "\t" #regs + +#define __READ_ONCE_EX(x) \ +({ \ + typeof(&(x)) __x = &(x); \ + int atomic = 1; \ + union { __unqual_scalar_typeof(*__x) __val; char __c[1]; } __u; \ + switch (sizeof(x)) { \ + case 1: \ + asm volatile(__LOAD_EX(b, %w0, %1) \ + : "=r" (*(__u8 *)__u.__c) \ + : "Q" (*__x) : "memory"); \ + break; \ + case 2: \ + asm volatile(__LOAD_EX(h, %w0, %1) \ + : "=r" (*(__u16 *)__u.__c) \ + : "Q" (*__x) : "memory"); \ + break; \ + case 4: \ + asm volatile(__LOAD_EX(, %w0, %1) \ + : "=r" (*(__u32 *)__u.__c) \ + : "Q" (*__x) : "memory"); \ + break; \ + case 8: \ + asm volatile(__LOAD_EX(, %0, %1) \ + : "=r" (*(__u64 *)__u.__c) \ + : "Q" (*__x) : "memory"); \ + break; \ + default: \ + atomic = 0; \ + } \ + atomic ? (typeof(*__x))__u.__val : (*(volatile typeof(__x))__x);\ +}) + +#endif -- 2.34.1