[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240117082514.42967-1-cuiyunhui@bytedance.com>
Date: Wed, 17 Jan 2024 16:25:14 +0800
From: Yunhui Cui <cuiyunhui@...edance.com>
To: shuah@...nel.org,
paul.walmsley@...ive.com,
palmer@...belt.com,
aou@...s.berkeley.edu,
cuiyunhui@...edance.com,
ajones@...tanamicro.com,
xiao.w.wang@...el.com,
linux-kselftest@...r.kernel.org,
linux-riscv@...ts.infradead.org,
linux-kernel@...r.kernel.org,
xuzhipeng.1973@...edance.com
Subject: [PATCH] RISC-V: selftests: fix cbo.c compilation error
When compiling with -O0, the following error will occur:
cbo.c: In function 'cbo_insn':
cbo.c:43:9: warning: 'asm' operand 1 probably does not match constraints
43 | asm volatile(
| ^~~
cbo.c:43:9: warning: 'asm' operand 2 probably does not match constraints
cbo.c:43:9: error: impossible constraint in 'asm'
Add __attribute__((optimize("O"))) to fix.
Fixes: a29e2a48afe3 ("RISC-V: selftests: Add CBO tests")
Signed-off-by: Yunhui Cui <cuiyunhui@...edance.com>
Suggested-by: Zhipeng Xu <xuzhipeng.1973@...edance.com>
---
tools/testing/selftests/riscv/hwprobe/cbo.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/riscv/hwprobe/cbo.c b/tools/testing/selftests/riscv/hwprobe/cbo.c
index 50a2cc8aef38..ff1d8e843d70 100644
--- a/tools/testing/selftests/riscv/hwprobe/cbo.c
+++ b/tools/testing/selftests/riscv/hwprobe/cbo.c
@@ -36,7 +36,7 @@ static void sigill_handler(int sig, siginfo_t *info, void *context)
regs[0] += 4;
}
-static void cbo_insn(char *base, int fn)
+static __always_inline void cbo_insn(char *base, int fn)
{
uint32_t insn = MK_CBO(fn);
@@ -47,10 +47,11 @@ static void cbo_insn(char *base, int fn)
: : "r" (base), "i" (fn), "i" (insn) : "a0", "a1", "memory");
}
-static void cbo_inval(char *base) { cbo_insn(base, 0); }
-static void cbo_clean(char *base) { cbo_insn(base, 1); }
-static void cbo_flush(char *base) { cbo_insn(base, 2); }
-static void cbo_zero(char *base) { cbo_insn(base, 4); }
+#define OPTIMIZE __attribute__((optimize("O")))
+OPTIMIZE static void cbo_inval(char *base) { cbo_insn(base, 0); }
+OPTIMIZE static void cbo_clean(char *base) { cbo_insn(base, 1); }
+OPTIMIZE static void cbo_flush(char *base) { cbo_insn(base, 2); }
+OPTIMIZE static void cbo_zero(char *base) { cbo_insn(base, 4); }
static void test_no_zicbom(void *arg)
{
--
2.20.1
Powered by blists - more mailing lists