From nobody Thu Dec 18 18:03:53 2025 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 791E519D8AA for ; Thu, 27 Jun 2024 17:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719508980; cv=none; b=Z4fWZ3dmlPPDr2uFVpFxR/sLJ/nAV9PY00YPNp1i/ORdAnRzWSeShw0mG52Bj+7T/aXDB+kt6ZMc3UmoWEQSOkTq4xqb1JG5poB1N7koEX/oh8B5isaCRC81bn4470Uf7kGG48WqRPYvR08IGkrFKzgoe6cng+9NJxFZvG58pdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719508980; c=relaxed/simple; bh=i4ZaFghgO+Lt6ofSiczvE8yLB1Ot2zvxfE6Ayg/1ZT8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=giXuPXHoOE3v0gNl2oZWG5dtz/maviWl65aMHKVnDNFNQAKKFnNr7oCsvSc6vzcb9yBwzvFehFd7U3q/9NC8ShX3R9TaZaqW9LnomUrYbfQn6PhA9ZgJmVFVBFosuv7Bod5ygXb5f78yEl/QxX9T1JmwwKjNESuOWFv5MRtzZ6Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=IvHRAUbz; arc=none smtp.client-ip=209.85.210.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="IvHRAUbz" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-706683e5249so4501285b3a.2 for ; Thu, 27 Jun 2024 10:22:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1719508977; x=1720113777; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=WP7jtD8GMMYgLKsWgQuz0MWj++7gT6SNnVpQZDX9lDo=; b=IvHRAUbzS1Bb9upUW8x7px7S9DPNPt8K3TayLLmDa+UCJ22cTKgXvNFFULQLddkWVs nf3YkB3Ws49aUIx9pkvUIowlt/TKxH/iWy0nWsuVko7X4El7a9wG4ZghLgetZ8cdgxJo za+gMDTFvnQ0S77NoC63AFFI3hC256s0oIvZHdNEvelkap8T7PIQ7e6SYaQK+U2l2YiS IdSWalRH/PH1YapBk4AkLnlUrduqh/cktZouDk6x25NI6sgNxB4QelyGg0KdMHhR2aVm CSorUQHxC0aBI6mB+VU31Zhsv2Tu7rZfVu3Efcu5q0dY1nzF4N3EjBts3SjUITsfv0/S Zwfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508977; x=1720113777; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=WP7jtD8GMMYgLKsWgQuz0MWj++7gT6SNnVpQZDX9lDo=; b=TzdDusglmXC+jX0gMtfZkuoPzHjmmaAGAEjn+Hkf6kEXR+nTtzgogyHJhbXyIH16tW grMdyMHUIV1oot7Cfm7uMt8LzBDpU4F1E+JrubZa/JVAlhWpV+13dtd+2i7lPEbB5Laz 8QJcDDABIV9RHZqtan2viFWAuHOEqlHykn1nGlklmJNuRZ7vayQA86QKjDnr/eTpkFVJ UUQiKzQHte3H04O2Juj3awDY4coDo3QqY7AHNuekJIXsDiR/4dDp47TDyHVFARHcf7Bx qB0iZNG9FAC4DyELy3BgAT2Gve6YIY8VXRidlqSzSsKkwFcKXjbv5OPWue5acWoZuvyq 75Bw== X-Forwarded-Encrypted: i=1; AJvYcCV+67ltWCITZIEFwBEIGbcM1T9B0lxbq0H15HnMFOAbag9I6Rp3DLOwsd2C6wv8yS1kybsWVg+S5sgW+nxhSBlsz0WdfQJzN4O7v1/U X-Gm-Message-State: AOJu0Yx3YMRaPaf06jcEDBS3G8eTk9ay4y6CF41TI/c9+4fey8CzjZyt pro9iJ+DASOTa0fTQjrrqvJCMeB8GeDOVGRM5hoaSTqGh2vdbnw9BiRzW4qvg60= X-Google-Smtp-Source: AGHT+IHWlzW7b9dIzeFM1UaPGPNDnj9mj0+synWhNkTAZT9w3SowrsNm8Dr6wgU1vaHYW9dDDvMM4Q== X-Received: by 2002:a05:6a00:bf0:b0:705:9aac:ffb8 with SMTP id d2e1a72fcca58-70674582b1bmr13224247b3a.9.1719508976537; Thu, 27 Jun 2024 10:22:56 -0700 (PDT) Received: from evan.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a58847sm1617843b3a.186.2024.06.27.10.22.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 10:22:55 -0700 (PDT) From: Evan Green To: Palmer Dabbelt Cc: Yangyu Chen , Evan Green , Charlie Jenkins , Andrew Jones , Albert Ou , Andy Chiu , =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Conor Dooley , Costa Shulyupin , Jonathan Corbet , Paul Walmsley , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v3 1/2] RISC-V: hwprobe: Add MISALIGNED_PERF key Date: Thu, 27 Jun 2024 10:22:37 -0700 Message-Id: <20240627172238.2460840-2-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627172238.2460840-1-evan@rivosinc.com> References: <20240627172238.2460840-1-evan@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" RISCV_HWPROBE_KEY_CPUPERF_0 was mistakenly flagged as a bitmask in hwprobe_key_is_bitmask(), when in reality it was an enum value. This causes problems when used in conjunction with RISCV_HWPROBE_WHICH_CPUS, since SLOW, FAST, and EMULATED have values whose bits overlap with each other. If the caller asked for the set of CPUs that was SLOW or EMULATED, the returned set would also include CPUs that were FAST. Introduce a new hwprobe key, RISCV_HWPROBE_KEY_MISALIGNED_PERF, which returns the same values in response to a direct query (with no flags), but is properly handled as an enumerated value. As a result, SLOW, FAST, and EMULATED are all correctly treated as distinct values under the new key when queried with the WHICH_CPUS flag. Leave the old key in place to avoid disturbing applications which may have already come to rely on the key, with or without its broken behavior with respect to the WHICH_CPUS flag. Fixes: e178bf146e4b ("RISC-V: hwprobe: Introduce which-cpus flag") Signed-off-by: Evan Green Reviewed-by: Charlie Jenkins Reviewed-by: Andrew Jones --- Changes in v3: - Further documentation wordsmithing (Conor) Changes in v2: - Clarified the distinction of slow and fast refers to misaligned word accesses. Previously it just said misaligned accesses, leaving it ambiguous as to which type of access was measured. - Removed shifts in values (Andrew) - Renamed key to RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF (Palmer) Documentation/arch/riscv/hwprobe.rst | 20 +++++++++++++------- arch/riscv/include/asm/hwprobe.h | 2 +- arch/riscv/include/uapi/asm/hwprobe.h | 1 + arch/riscv/kernel/sys_hwprobe.c | 1 + 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Documentation/arch/riscv/hwprobe.rst b/Documentation/arch/risc= v/hwprobe.rst index 25d783be2878..7121a00a8464 100644 --- a/Documentation/arch/riscv/hwprobe.rst +++ b/Documentation/arch/riscv/hwprobe.rst @@ -235,8 +235,13 @@ The following keys are defined: supported as defined in the RISC-V ISA manual starting from commit c732a4f39a4 ("Zcmop is ratified/1.0"). =20 -* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performa= nce - information about the selected set of processors. +* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: Deprecated. Returns similar val= ues to + :c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`, but the key was + mistakenly classified as a bitmask rather than a value. + +* :c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`: An enum value descr= ibing + the performance of misaligned scalar native word accesses on the selecte= d set + of processors. =20 * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNKNOWN`: The performance of misali= gned accesses is unknown. @@ -245,12 +250,13 @@ The following keys are defined: emulated via software, either in or below the kernel. These accesses = are always extremely slow. =20 - * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned accesses are slow= er - than equivalent byte accesses. Misaligned accesses may be supported - directly in hardware, or trapped and emulated by software. + * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned native word + sized accesses are slower than the equivalent quantity of byte accesse= s. + Misaligned accesses may be supported directly in hardware, or trapped = and + emulated by software. =20 - * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned accesses are fast= er - than equivalent byte accesses. + * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned native word + sized accesses are faster than the equivalent quantity of byte accesse= s. =20 * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned accesses a= re not supported at all and will generate a misaligned address fault. diff --git a/arch/riscv/include/asm/hwprobe.h b/arch/riscv/include/asm/hwpr= obe.h index 630507dff5ea..150a9877b0af 100644 --- a/arch/riscv/include/asm/hwprobe.h +++ b/arch/riscv/include/asm/hwprobe.h @@ -8,7 +8,7 @@ =20 #include =20 -#define RISCV_HWPROBE_MAX_KEY 6 +#define RISCV_HWPROBE_MAX_KEY 7 =20 static inline bool riscv_hwprobe_key_is_valid(__s64 key) { diff --git a/arch/riscv/include/uapi/asm/hwprobe.h b/arch/riscv/include/uap= i/asm/hwprobe.h index 920fc6a586c9..7ebb2f2cc4cf 100644 --- a/arch/riscv/include/uapi/asm/hwprobe.h +++ b/arch/riscv/include/uapi/asm/hwprobe.h @@ -79,6 +79,7 @@ struct riscv_hwprobe { #define RISCV_HWPROBE_MISALIGNED_UNSUPPORTED (4 << 0) #define RISCV_HWPROBE_MISALIGNED_MASK (7 << 0) #define RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE 6 +#define RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF 7 /* Increase RISCV_HWPROBE_MAX_KEY when adding items. */ =20 /* Flags */ diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprob= e.c index 3d1aa13a0bb2..b18639020c61 100644 --- a/arch/riscv/kernel/sys_hwprobe.c +++ b/arch/riscv/kernel/sys_hwprobe.c @@ -223,6 +223,7 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair, break; =20 case RISCV_HWPROBE_KEY_CPUPERF_0: + case RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF: pair->value =3D hwprobe_misaligned(cpus); break; =20 --=20 2.34.1 From nobody Thu Dec 18 18:03:53 2025 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 604A019E810 for ; Thu, 27 Jun 2024 17:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719508985; cv=none; b=VD6bcJQ3lpehsFRWBvdShlF69KwAJNbchNOx1GBBIA+uYyQovfTnGVcnpTefZ+6J+Ne7dy3Cs81tttOlw+P8DljIxZ2tTHmg3yR9s4rt87SoBxGy/G9Ax5IoA93WE/QwU6RWhErLw8yL5pu8N8z5nYelbEU4Slm+0K6kjJCmfrQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719508985; c=relaxed/simple; bh=JXXlPXccbyhFcGcATRCSAgEZbpc1SuYgHVtnO5FsXLI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ejVgm/zEy2ubNEJu0vbC+XVfnly3Cs2D0DfhHSSBU4XYxyPRss9JW90Ip9usnKr1fKdgC0B+UcCDNQAoli7YDW4IYGL3p0avW6EZRCoIhvnJ3cpZSOW/aAzWSCo7G+x5Y3NVfBIJH82iOvGhIwnzoN24jBgdoiPADDfc1mGNrq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com; spf=pass smtp.mailfrom=rivosinc.com; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b=mFAFCgGt; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rivosinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.b="mFAFCgGt" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-706683e5249so4501375b3a.2 for ; Thu, 27 Jun 2024 10:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1719508983; x=1720113783; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MBy/I5g30Afg6Ip53Uvr05h0yboT8uG6AlPNhdgJavA=; b=mFAFCgGtjaj6xVdG2+9CdLwMKf4C7PHRt6WS5l6Uor7mYQSAikozRYC2Q4RFsFUyRA f+1wjBrtxEwcqxYcZT0FdjrKRuPj+7usaBdTZ8pYEVVZb3+uWUhgnGyVdrzNocnKp/ar /slQATET1tVkBPd5KmjwDpQtLU56XgZWp3O3EkRIP0NtRmFYdngYqzJYfdTIXt3g4/ca 4zlxTs4Tj43a8YZrlk7kwq1i1tb2MY1chI1ANUyS65tdUeG9p3h1CbujchKaxkrYbwcj LS1Qp1eJcXc0+VjtTpkn5y/J0uPtoH3DdyV+FKIsHPTsFuVNy02XpdTCFpszCU+/9RyA MaDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719508983; x=1720113783; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MBy/I5g30Afg6Ip53Uvr05h0yboT8uG6AlPNhdgJavA=; b=QQOZB0/GkBa0loRLzfjsorZ02n9eIdj7jEtiIa86e4mJ6yCQ0gDvA+fIjesLdwBbcf F9B+DTOInKeqUXyYCFf46gIuhwV8w2tUhQJecGqWX9zOc2J9boIJUo8SpcZncMD4R5uz 03hnt0429d5+N47A3FHv1hajoXbGS5CVXtiKPK2yRQQfBIQSKHkIblsT/HzNJM28xiX5 6rLRwSDzCt2sBOmoVtzhm6cd8s6OjsBkwHDaffh8HfQldRxkPH8idovr88J8A76zquZT EPyOIhMWu+wnAHCP+Qp3T//5JJI/iWGGPHf+PDU33/V3HoE0DCg8fEMAUKkbRuQ3nNae ctVA== X-Forwarded-Encrypted: i=1; AJvYcCUKZQ0OG3RgtZ5FwSReCZ8gdRkUP24f3Z6pFphVdkO6kHCDKVMpfLkUucXAXHAcU23CcPHPCzQIyuNvlaKFKn9Yywz6jUlu4QdyiNf9 X-Gm-Message-State: AOJu0YxxU62Vo8/Ma1NaTBlgc7pQh6uum3RolSvVYWDM3ZNEfQj5d/Vt UjVohrrzrcWt+DtEnn8BISkwJ+H6mX7yEx0oc8hml1WXFgrGQWWxZPF7zivqQP0= X-Google-Smtp-Source: AGHT+IHNzwD75G4DCcfJ5H0IAezjiX7N7H3o7hyu24co/DPv8hD7Ygm2LVOFxEE4oALKKKYJb0dY1A== X-Received: by 2002:a05:6a00:1d1d:b0:706:61cc:577f with SMTP id d2e1a72fcca58-70674548227mr16032428b3a.3.1719508982671; Thu, 27 Jun 2024 10:23:02 -0700 (PDT) Received: from evan.ba.rivosinc.com ([64.71.180.162]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-706b4a58847sm1617843b3a.186.2024.06.27.10.23.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jun 2024 10:23:02 -0700 (PDT) From: Evan Green To: Palmer Dabbelt Cc: Yangyu Chen , Evan Green , Charlie Jenkins , Albert Ou , Alexandre Ghiti , Andrew Jones , Andy Chiu , Ben Dooks , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , Conor Dooley , Costa Shulyupin , Erick Archer , Jonathan Corbet , Paul Walmsley , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org Subject: [PATCH v3 2/2] RISC-V: hwprobe: Add SCALAR to misaligned perf defines Date: Thu, 27 Jun 2024 10:22:38 -0700 Message-Id: <20240627172238.2460840-3-evan@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240627172238.2460840-1-evan@rivosinc.com> References: <20240627172238.2460840-1-evan@rivosinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In preparation for misaligned vector performance hwprobe keys, rename the hwprobe key values associated with misaligned scalar accesses to include the term SCALAR. Leave the old defines in place to maintain source compatibility. This change is intended to be a functional no-op. Signed-off-by: Evan Green Reviewed-by: Charlie Jenkins --- Changes in v3: - Leave the old defines in place (Conor, Palmer) Changes in v2: - Added patch to rename misaligned perf key values (Palmer) Documentation/arch/riscv/hwprobe.rst | 14 +++++++------- arch/riscv/include/uapi/asm/hwprobe.h | 5 +++++ arch/riscv/kernel/sys_hwprobe.c | 10 +++++----- arch/riscv/kernel/traps_misaligned.c | 6 +++--- arch/riscv/kernel/unaligned_access_speed.c | 12 ++++++------ 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/Documentation/arch/riscv/hwprobe.rst b/Documentation/arch/risc= v/hwprobe.rst index 7121a00a8464..0d14e9d83a78 100644 --- a/Documentation/arch/riscv/hwprobe.rst +++ b/Documentation/arch/riscv/hwprobe.rst @@ -243,23 +243,23 @@ The following keys are defined: the performance of misaligned scalar native word accesses on the selecte= d set of processors. =20 - * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNKNOWN`: The performance of misali= gned - accesses is unknown. + * :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN`: The performance of + misaligned accesses is unknown. =20 - * :c:macro:`RISCV_HWPROBE_MISALIGNED_EMULATED`: Misaligned accesses are + * :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED`: Misaligned access= es are emulated via software, either in or below the kernel. These accesses = are always extremely slow. =20 - * :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned native word + * :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_SLOW`: Misaligned native word sized accesses are slower than the equivalent quantity of byte accesse= s. Misaligned accesses may be supported directly in hardware, or trapped = and emulated by software. =20 - * :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned native word + * :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_FAST`: Misaligned native word sized accesses are faster than the equivalent quantity of byte accesse= s. =20 - * :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned accesses a= re - not supported at all and will generate a misaligned address fault. + * :c:macro:`RISCV_HWPROBE_MISALIGNED_SCALAR_UNSUPPORTED`: Misaligned acc= esses + are not supported at all and will generate a misaligned address fault. =20 * :c:macro:`RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE`: An unsigned int which represents the size of the Zicboz block in bytes. diff --git a/arch/riscv/include/uapi/asm/hwprobe.h b/arch/riscv/include/uap= i/asm/hwprobe.h index 7ebb2f2cc4cf..bcb2d91241d5 100644 --- a/arch/riscv/include/uapi/asm/hwprobe.h +++ b/arch/riscv/include/uapi/asm/hwprobe.h @@ -80,6 +80,11 @@ struct riscv_hwprobe { #define RISCV_HWPROBE_MISALIGNED_MASK (7 << 0) #define RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE 6 #define RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF 7 +#define RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN 0 +#define RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED 1 +#define RISCV_HWPROBE_MISALIGNED_SCALAR_SLOW 2 +#define RISCV_HWPROBE_MISALIGNED_SCALAR_FAST 3 +#define RISCV_HWPROBE_MISALIGNED_SCALAR_UNSUPPORTED 4 /* Increase RISCV_HWPROBE_MAX_KEY when adding items. */ =20 /* Flags */ diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprob= e.c index b18639020c61..d5541f6c843e 100644 --- a/arch/riscv/kernel/sys_hwprobe.c +++ b/arch/riscv/kernel/sys_hwprobe.c @@ -176,13 +176,13 @@ static u64 hwprobe_misaligned(const struct cpumask *c= pus) perf =3D this_perf; =20 if (perf !=3D this_perf) { - perf =3D RISCV_HWPROBE_MISALIGNED_UNKNOWN; + perf =3D RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN; break; } } =20 if (perf =3D=3D -1ULL) - return RISCV_HWPROBE_MISALIGNED_UNKNOWN; + return RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN; =20 return perf; } @@ -190,12 +190,12 @@ static u64 hwprobe_misaligned(const struct cpumask *c= pus) static u64 hwprobe_misaligned(const struct cpumask *cpus) { if (IS_ENABLED(CONFIG_RISCV_EFFICIENT_UNALIGNED_ACCESS)) - return RISCV_HWPROBE_MISALIGNED_FAST; + return RISCV_HWPROBE_MISALIGNED_SCALAR_FAST; =20 if (IS_ENABLED(CONFIG_RISCV_EMULATED_UNALIGNED_ACCESS) && unaligned_ctl_a= vailable()) - return RISCV_HWPROBE_MISALIGNED_EMULATED; + return RISCV_HWPROBE_MISALIGNED_SCALAR_EMULATED; =20 - return RISCV_HWPROBE_MISALIGNED_SLOW; + return RISCV_HWPROBE_MISALIGNED_SCALAR_SLOW; } #endif =20 diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps= _misaligned.c index b62d5a2f4541..192cd5603e95 100644 --- a/arch/riscv/kernel/traps_misaligned.c +++ b/arch/riscv/kernel/traps_misaligned.c @@ -338,7 +338,7 @@ int handle_misaligned_load(struct pt_regs *regs) perf_sw_event(PERF_COUNT_SW_ALIGNMENT_FAULTS, 1, regs, addr); =20 #ifdef CONFIG_RISCV_PROBE_UNALIGNED_ACCESS - *this_cpu_ptr(&misaligned_access_speed) =3D RISCV_HWPROBE_MISALIGNED_EMUL= ATED; + *this_cpu_ptr(&misaligned_access_speed) =3D RISCV_HWPROBE_MISALIGNED_SCAL= AR_EMULATED; #endif =20 if (!unaligned_enabled) @@ -532,13 +532,13 @@ static bool check_unaligned_access_emulated(int cpu) unsigned long tmp_var, tmp_val; bool misaligned_emu_detected; =20 - *mas_ptr =3D RISCV_HWPROBE_MISALIGNED_UNKNOWN; + *mas_ptr =3D RISCV_HWPROBE_MISALIGNED_SCALAR_UNKNOWN; =20 __asm__ __volatile__ ( " "REG_L" %[tmp], 1(%[ptr])\n" : [tmp] "=3Dr" (tmp_val) : [ptr] "r" (&tmp_var) : "memory"); =20 - misaligned_emu_detected =3D (*mas_ptr =3D=3D RISCV_HWPROBE_MISALIGNED_EMU= LATED); + misaligned_emu_detected =3D (*mas_ptr =3D=3D RISCV_HWPROBE_MISALIGNED_SCA= LAR_EMULATED); /* * If unaligned_ctl is already set, this means that we detected that all * CPUS uses emulated misaligned access at boot time. If that changed diff --git a/arch/riscv/kernel/unaligned_access_speed.c b/arch/riscv/kernel= /unaligned_access_speed.c index a9a6bcb02acf..160628a2116d 100644 --- a/arch/riscv/kernel/unaligned_access_speed.c +++ b/arch/riscv/kernel/unaligned_access_speed.c @@ -34,9 +34,9 @@ static int check_unaligned_access(void *param) struct page *page =3D param; void *dst; void *src; - long speed =3D RISCV_HWPROBE_MISALIGNED_SLOW; + long speed =3D RISCV_HWPROBE_MISALIGNED_SCALAR_SLOW; =20 - if (per_cpu(misaligned_access_speed, cpu) !=3D RISCV_HWPROBE_MISALIGNED_U= NKNOWN) + if (per_cpu(misaligned_access_speed, cpu) !=3D RISCV_HWPROBE_MISALIGNED_S= CALAR_UNKNOWN) return 0; =20 /* Make an unaligned destination buffer. */ @@ -95,14 +95,14 @@ static int check_unaligned_access(void *param) } =20 if (word_cycles < byte_cycles) - speed =3D RISCV_HWPROBE_MISALIGNED_FAST; + speed =3D RISCV_HWPROBE_MISALIGNED_SCALAR_FAST; =20 ratio =3D div_u64((byte_cycles * 100), word_cycles); pr_info("cpu%d: Ratio of byte access time to unaligned word access is %d.= %02d, unaligned accesses are %s\n", cpu, ratio / 100, ratio % 100, - (speed =3D=3D RISCV_HWPROBE_MISALIGNED_FAST) ? "fast" : "slow"); + (speed =3D=3D RISCV_HWPROBE_MISALIGNED_SCALAR_FAST) ? "fast" : "slow"); =20 per_cpu(misaligned_access_speed, cpu) =3D speed; =20 @@ -110,7 +110,7 @@ static int check_unaligned_access(void *param) * Set the value of fast_misaligned_access of a CPU. These operations * are atomic to avoid race conditions. */ - if (speed =3D=3D RISCV_HWPROBE_MISALIGNED_FAST) + if (speed =3D=3D RISCV_HWPROBE_MISALIGNED_SCALAR_FAST) cpumask_set_cpu(cpu, &fast_misaligned_access); else cpumask_clear_cpu(cpu, &fast_misaligned_access); @@ -188,7 +188,7 @@ static int riscv_online_cpu(unsigned int cpu) static struct page *buf; =20 /* We are already set since the last check */ - if (per_cpu(misaligned_access_speed, cpu) !=3D RISCV_HWPROBE_MISALIGNED_U= NKNOWN) + if (per_cpu(misaligned_access_speed, cpu) !=3D RISCV_HWPROBE_MISALIGNED_S= CALAR_UNKNOWN) goto exit; =20 buf =3D alloc_pages(GFP_KERNEL, MISALIGNED_BUFFER_ORDER); --=20 2.34.1