Skip to content

Commit d91a46d

Browse files
committed
Merge tag 'riscv-for-linus-6.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Paul Walmsley: "The notable changes here are the three RISC-V timer compare register update sequence patches. These only apply to RV32 systems and are related to the 64-bit timer compare value being split across two separate 32-bit registers. We weren't using the appropriate three-write sequence, documented in the RISC-V ISA specifications, to avoid spurious timer interrupts during the update sequence; so, these patches now use the recommended sequence. This doesn't affect 64-bit RISC-V systems, since the timer compare value fits inside a single register and can be updated with a single write. - Fix the RISC-V timer compare register update sequence on RV32 systems to use the recommended sequence in the RISC-V ISA manual This avoids spurious interrupts during updates - Add a dependence on the new CONFIG_CACHEMAINT_FOR_DMA Kconfig symbol for Renesas and StarFive RISC-V SoCs - Add a temporary workaround for a Clang compiler bug caused by using asm_goto_output for get_user() - Clarify our documentation to specifically state a particular ISA specification version for a chapter number reference" * tag 'riscv-for-linus-6.19-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: Add intermediate cast to 'unsigned long' in __get_user_asm riscv: Use 64-bit variable for output in __get_user_asm soc: renesas: Fix missing dependency on new CONFIG_CACHEMAINT_FOR_DMA riscv: ERRATA_STARFIVE_JH7100: Fix missing dependency on new CONFIG_CACHEMAINT_FOR_DMA riscv: suspend: Fix stimecmp update hazard on RV32 riscv: kvm: Fix vstimecmp update hazard on RV32 riscv: clocksource: Fix stimecmp update hazard on RV32 Documentation: riscv: uabi: Clarify ISA spec version for canonical order
2 parents d04ed41 + 841e47d commit d91a46d

File tree

7 files changed

+25
-7
lines changed

7 files changed

+25
-7
lines changed

Documentation/arch/riscv/uabi.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ ISA string ordering in /proc/cpuinfo
77
------------------------------------
88

99
The canonical order of ISA extension names in the ISA string is defined in
10-
chapter 27 of the unprivileged specification.
10+
Chapter 27 of the RISC-V Instruction Set Manual Volume I Unprivileged ISA
11+
(Document Version 20191213).
12+
1113
The specification uses vague wording, such as should, when it comes to ordering,
1214
so for our purposes the following rules apply:
1315

arch/riscv/Kconfig.errata

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ config ERRATA_STARFIVE_JH7100
8484
select DMA_GLOBAL_POOL
8585
select RISCV_DMA_NONCOHERENT
8686
select RISCV_NONSTANDARD_CACHE_OPS
87+
select CACHEMAINT_FOR_DMA
8788
select SIFIVE_CCACHE
8889
default n
8990
help

arch/riscv/include/asm/uaccess.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,23 @@ static inline unsigned long __untagged_addr_remote(struct mm_struct *mm, unsigne
9797
*/
9898

9999
#ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT
100+
/*
101+
* Use a temporary variable for the output of the asm goto to avoid a
102+
* triggering an LLVM assertion due to sign extending the output when
103+
* it is used in later function calls:
104+
* https://github.com/llvm/llvm-project/issues/143795
105+
*/
100106
#define __get_user_asm(insn, x, ptr, label) \
107+
do { \
108+
u64 __tmp; \
101109
asm_goto_output( \
102110
"1:\n" \
103111
" " insn " %0, %1\n" \
104112
_ASM_EXTABLE_UACCESS_ERR(1b, %l2, %0) \
105-
: "=&r" (x) \
106-
: "m" (*(ptr)) : : label)
113+
: "=&r" (__tmp) \
114+
: "m" (*(ptr)) : : label); \
115+
(x) = (__typeof__(x))(unsigned long)__tmp; \
116+
} while (0)
107117
#else /* !CONFIG_CC_HAS_ASM_GOTO_OUTPUT */
108118
#define __get_user_asm(insn, x, ptr, label) \
109119
do { \

arch/riscv/kernel/suspend.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ void suspend_restore_csrs(struct suspend_context *context)
5151

5252
#ifdef CONFIG_MMU
5353
if (riscv_has_extension_unlikely(RISCV_ISA_EXT_SSTC)) {
54-
csr_write(CSR_STIMECMP, context->stimecmp);
5554
#if __riscv_xlen < 64
55+
csr_write(CSR_STIMECMP, ULONG_MAX);
5656
csr_write(CSR_STIMECMPH, context->stimecmph);
5757
#endif
58+
csr_write(CSR_STIMECMP, context->stimecmp);
5859
}
5960

6061
csr_write(CSR_SATP, context->satp);

arch/riscv/kvm/vcpu_timer.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ static int kvm_riscv_vcpu_timer_cancel(struct kvm_vcpu_timer *t)
7272
static int kvm_riscv_vcpu_update_vstimecmp(struct kvm_vcpu *vcpu, u64 ncycles)
7373
{
7474
#if defined(CONFIG_32BIT)
75-
ncsr_write(CSR_VSTIMECMP, ncycles & 0xFFFFFFFF);
75+
ncsr_write(CSR_VSTIMECMP, ULONG_MAX);
7676
ncsr_write(CSR_VSTIMECMPH, ncycles >> 32);
77+
ncsr_write(CSR_VSTIMECMP, (u32)ncycles);
7778
#else
7879
ncsr_write(CSR_VSTIMECMP, ncycles);
7980
#endif
@@ -307,8 +308,9 @@ void kvm_riscv_vcpu_timer_restore(struct kvm_vcpu *vcpu)
307308
return;
308309

309310
#if defined(CONFIG_32BIT)
310-
ncsr_write(CSR_VSTIMECMP, (u32)t->next_cycles);
311+
ncsr_write(CSR_VSTIMECMP, ULONG_MAX);
311312
ncsr_write(CSR_VSTIMECMPH, (u32)(t->next_cycles >> 32));
313+
ncsr_write(CSR_VSTIMECMP, (u32)(t->next_cycles));
312314
#else
313315
ncsr_write(CSR_VSTIMECMP, t->next_cycles);
314316
#endif

drivers/clocksource/timer-riscv.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ static int riscv_clock_next_event(unsigned long delta,
5050

5151
if (static_branch_likely(&riscv_sstc_available)) {
5252
#if defined(CONFIG_32BIT)
53-
csr_write(CSR_STIMECMP, next_tval & 0xFFFFFFFF);
53+
csr_write(CSR_STIMECMP, ULONG_MAX);
5454
csr_write(CSR_STIMECMPH, next_tval >> 32);
55+
csr_write(CSR_STIMECMP, next_tval & 0xFFFFFFFF);
5556
#else
5657
csr_write(CSR_STIMECMP, next_tval);
5758
#endif

drivers/soc/renesas/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ config ARCH_R9A07G043
445445
depends on RISCV_SBI
446446
select ARCH_RZG2L
447447
select AX45MP_L2_CACHE
448+
select CACHEMAINT_FOR_DMA
448449
select DMA_GLOBAL_POOL
449450
select ERRATA_ANDES
450451
select ERRATA_ANDES_CMO

0 commit comments

Comments
 (0)