Skip to content

Commit 2b35d5b

Browse files
geertupalmer-dabbelt
authored andcommitted
RISC-V: Fix handling of empty cpu masks
The cpumask rework slightly changed the behavior of the code. Fix this by treating an empty cpumask as meaning all online CPUs. Extracted from a patch by Atish Patra <atishp@rivosinc.com>. Reported-by: Jessica Clarke <jrtc27@jrtc27.com> Fixes: 26fb751 ("RISC-V: Do not use cpumask data structure for hartid bitmap") Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org> Reviewed-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 12f4a66 commit 2b35d5b

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

arch/riscv/kernel/sbi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ static int __sbi_send_ipi_v01(const struct cpumask *cpu_mask)
161161
{
162162
unsigned long hart_mask;
163163

164-
if (!cpu_mask)
164+
if (!cpu_mask || cpumask_empty(cpu_mask))
165165
cpu_mask = cpu_online_mask;
166166
hart_mask = __sbi_v01_cpumask_to_hartmask(cpu_mask);
167167

@@ -177,7 +177,7 @@ static int __sbi_rfence_v01(int fid, const struct cpumask *cpu_mask,
177177
int result = 0;
178178
unsigned long hart_mask;
179179

180-
if (!cpu_mask)
180+
if (!cpu_mask || cpumask_empty(cpu_mask))
181181
cpu_mask = cpu_online_mask;
182182
hart_mask = __sbi_v01_cpumask_to_hartmask(cpu_mask);
183183

@@ -254,7 +254,7 @@ static int __sbi_send_ipi_v02(const struct cpumask *cpu_mask)
254254
struct sbiret ret = {0};
255255
int result;
256256

257-
if (!cpu_mask)
257+
if (!cpu_mask || cpumask_empty(cpu_mask))
258258
cpu_mask = cpu_online_mask;
259259

260260
for_each_cpu(cpuid, cpu_mask) {
@@ -348,7 +348,7 @@ static int __sbi_rfence_v02(int fid, const struct cpumask *cpu_mask,
348348
unsigned long hartid, cpuid, hmask = 0, hbase = 0;
349349
int result;
350350

351-
if (!cpu_mask)
351+
if (!cpu_mask || cpumask_empty(cpu_mask))
352352
cpu_mask = cpu_online_mask;
353353

354354
for_each_cpu(cpuid, cpu_mask) {

0 commit comments

Comments
 (0)