From: Andrew Jones <ajones@ventanamicro.com>
To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Cc: paul.walmsley@sifive.com, palmer@dabbelt.com,
charlie@rivosinc.com, cleger@rivosinc.com, alex@ghiti.fr,
Anup Patel <apatel@ventanamicro.com>,
corbet@lwn.net, Alexandre Ghiti <alexghiti@rivosinc.com>
Subject: [PATCH v2 3/8] riscv: Fix check_unaligned_access_all_cpus
Date: Fri, 21 Feb 2025 15:57:22 +0100 [thread overview]
Message-ID: <20250221145718.115076-13-ajones@ventanamicro.com> (raw)
In-Reply-To: <20250221145718.115076-10-ajones@ventanamicro.com>
check_vector_unaligned_access_emulated_all_cpus(), like its name
suggests, will return true when all cpus emulate unaligned vector
accesses. If the function returned false it may have been because
vector isn't supported at all (!has_vector()) or because at least
one cpu doesn't emulate unaligned vector accesses. Since false may
be returned for two cases, checking for it isn't sufficient when
attempting to determine if we should proceed with the vector speed
check. Move the !has_vector() functionality to
check_unaligned_access_all_cpus() in order for
check_vector_unaligned_access_emulated_all_cpus() to return false
for a single case.
Fixes: e7c9d66e313b ("RISC-V: Report vector unaligned access speed hwprobe")
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
---
arch/riscv/kernel/traps_misaligned.c | 6 ------
arch/riscv/kernel/unaligned_access_speed.c | 11 +++++++----
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/arch/riscv/kernel/traps_misaligned.c b/arch/riscv/kernel/traps_misaligned.c
index aacbd9d7196e..4354c87c0376 100644
--- a/arch/riscv/kernel/traps_misaligned.c
+++ b/arch/riscv/kernel/traps_misaligned.c
@@ -609,12 +609,6 @@ bool __init check_vector_unaligned_access_emulated_all_cpus(void)
{
int cpu;
- if (!has_vector()) {
- for_each_online_cpu(cpu)
- per_cpu(vector_misaligned_access, cpu) = RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED;
- return false;
- }
-
schedule_on_each_cpu(check_vector_unaligned_access_emulated);
for_each_online_cpu(cpu)
diff --git a/arch/riscv/kernel/unaligned_access_speed.c b/arch/riscv/kernel/unaligned_access_speed.c
index 161964cf2abc..02b485dc4bc4 100644
--- a/arch/riscv/kernel/unaligned_access_speed.c
+++ b/arch/riscv/kernel/unaligned_access_speed.c
@@ -403,13 +403,16 @@ static int __init vec_check_unaligned_access_speed_all_cpus(void *unused __alway
static int __init check_unaligned_access_all_cpus(void)
{
- bool all_cpus_emulated, all_cpus_vec_unsupported;
+ bool all_cpus_emulated;
+ int cpu;
all_cpus_emulated = check_unaligned_access_emulated_all_cpus();
- all_cpus_vec_unsupported = check_vector_unaligned_access_emulated_all_cpus();
- if (!all_cpus_vec_unsupported &&
- IS_ENABLED(CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS)) {
+ if (!has_vector()) {
+ for_each_online_cpu(cpu)
+ per_cpu(vector_misaligned_access, cpu) = RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED;
+ } else if (!check_vector_unaligned_access_emulated_all_cpus() &&
+ IS_ENABLED(CONFIG_RISCV_PROBE_VECTOR_UNALIGNED_ACCESS)) {
kthread_run(vec_check_unaligned_access_speed_all_cpus,
NULL, "vec_check_unaligned_access_speed_all_cpus");
}
--
2.48.1
next prev parent reply other threads:[~2025-02-21 14:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 14:57 [PATCH v2 0/8] riscv: Unaligned access speed probing fixes and skipping Andrew Jones
2025-02-21 14:57 ` [PATCH v2 1/8] riscv: Annotate unaligned access init functions Andrew Jones
2025-02-21 14:57 ` [PATCH v2 2/8] riscv: Fix riscv_online_cpu_vec Andrew Jones
2025-02-21 14:57 ` Andrew Jones [this message]
2025-02-21 14:57 ` [PATCH v2 4/8] riscv: Change check_unaligned_access_speed_all_cpus to void Andrew Jones
2025-02-21 14:57 ` [PATCH v2 5/8] riscv: Fix set up of cpu hotplug callbacks Andrew Jones
2025-02-21 14:57 ` [PATCH v2 6/8] riscv: Fix set up of vector cpu hotplug callback Andrew Jones
2025-02-21 14:57 ` [PATCH v2 7/8] riscv: Add parameter for skipping access speed tests Andrew Jones
2025-02-21 14:57 ` [PATCH v2 8/8] Documentation/kernel-parameters: Add riscv unaligned speed parameters Andrew Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250221145718.115076-13-ajones@ventanamicro.com \
--to=ajones@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=alexghiti@rivosinc.com \
--cc=apatel@ventanamicro.com \
--cc=charlie@rivosinc.com \
--cc=cleger@rivosinc.com \
--cc=corbet@lwn.net \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).