Page MenuHomeFreeBSD

D60072.id187833.diff
No OneTemporary

D60072.id187833.diff

diff --git a/sys/riscv/include/smp.h b/sys/riscv/include/smp.h
--- a/sys/riscv/include/smp.h
+++ b/sys/riscv/include/smp.h
@@ -50,5 +50,5 @@
void ipi_all_but_self(u_int ipi);
void ipi_cpu(int cpu, u_int ipi);
void ipi_selected(cpuset_t cpus, u_int ipi);
-
+cpuset_t hartmask_to_cpumask(const cpuset_t);
#endif /* !_MACHINE_SMP_H_ */
diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c
--- a/sys/riscv/riscv/mp_machdep.c
+++ b/sys/riscv/riscv/mp_machdep.c
@@ -110,6 +110,19 @@
/* Temporary variables for init_secondary() */
void *dpcpu[MAXCPU - 1];
+static u_int
+hartid_to_cpuid(u_int hart)
+{
+ u_int cpuid;
+
+ cpuid = hart;
+ if (cpuid < boot_hart)
+ cpuid += mp_maxid + 1;
+ cpuid -= boot_hart;
+
+ return cpuid;
+}
+
static void
release_aps(void *dummy __unused)
{
@@ -154,10 +167,7 @@
u_int cpuid;
/* Renumber this cpu */
- cpuid = hart;
- if (cpuid < boot_hart)
- cpuid += mp_maxid + 1;
- cpuid -= boot_hart;
+ cpuid = hartid_to_cpuid(hart);
/* Setup the pcpu pointer */
pcpup = &__pcpu[cpuid];
@@ -366,10 +376,7 @@
* Rotate the CPU IDs to put the boot CPU as CPU 0.
* We keep the other CPUs ordered.
*/
- cpuid = hart;
- if (cpuid < boot_hart)
- cpuid += mp_maxid + 1;
- cpuid -= boot_hart;
+ cpuid = hartid_to_cpuid(hart);
/* Check if we are able to start this cpu */
if (cpuid > mp_maxid)
@@ -525,3 +532,19 @@
CTR1(KTR_SMP, "ipi_selected: ipi: %x", ipi);
intr_ipi_send(cpus, ipi);
}
+
+cpuset_t
+hartmask_to_cpumask(const cpuset_t harts)
+{
+ u_int hart;
+ u_int cpu;
+ cpuset_t cpumask;
+
+ CPU_ZERO(&cpumask);
+ CPU_FOREACH_ISSET(hart, &harts) {
+ cpu = hartid_to_cpuid(hart);
+ CPU_SET(cpu, &cpumask);
+ }
+
+ return (cpumask);
+}
diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -162,6 +162,7 @@
#include <machine/ifunc.h>
#include <machine/pcb.h>
#include <machine/sbi.h>
+#include <machine/smp.h>
#include <machine/thead.h>
/*
@@ -1166,11 +1167,11 @@
args.sva = sva;
args.eva = eva;
fence();
- if (smp_started)
- smp_rendezvous_cpus(pmap->pm_active, smp_no_rendezvous_barrier,
- pmap_invalidate_range_svinval_cb,
+ if (smp_started) {
+ smp_rendezvous_cpus(hartmask_to_cpumask(pmap->pm_active),
+ smp_no_rendezvous_barrier, pmap_invalidate_range_svinval_cb,
smp_no_rendezvous_barrier, &args);
- else
+ } else
pmap_invalidate_range_svinval_cb(&args);
sched_unpin();
}
@@ -5340,7 +5341,7 @@
void
pmap_active_cpus(pmap_t pmap, cpuset_t *res)
{
- *res = pmap->pm_active;
+ *res = hartmask_to_cpumask(pmap->pm_active);
}
void

File Metadata

Mime Type
text/plain
Expires
Mon, Sep 28, 10:46 PM (19 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39839687
Default Alt Text
D60072.id187833.diff (2 KB)

Event Timeline