Skip to content

Commit

Permalink
mips: Extract HWREna configuration and call from APs
Browse files Browse the repository at this point in the history
The intent of mips_get_identity is to perform any feature detection and
corresponding global system configuration, but currently it is also
abused to set HWREna.UL on the BSP when available, with APs being left
unconfigured. Extract that part out into its own function that gets
called after mips_get_identity on the BSP, and call it on the APs from
smp_init_secondary.

This is a direct commit to stable/13 as mips no longer exists in main.

Reviewed by:	jhibbits
Differential Revision:	https://reviews.freebsd.org/D48064
  • Loading branch information
jrtc27 committed Dec 13, 2024
1 parent 05150ed commit 8176157
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions sys/mips/include/md_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void mips_wait(void);

void mips_vector_init(void);
void mips_cpu_init(void);
void mips_hwrena_init(void);
void mips_pcpu0_init(void);
void mips_proc0_init(void);
void mips_postboot_fixup(void);
Expand Down
21 changes: 18 additions & 3 deletions sys/mips/mips/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,11 @@ mips_get_identity(struct mips_cpuinfo *cpuinfo)

/* Check to see if UserLocal register is implemented. */
if (cfg3 & MIPS_CONFIG3_ULR) {
/* UserLocal register is implemented, enable it. */
/*
* UserLocal register is implemented, enable it later in
* mips_hwrena_init.
*/
cpuinfo->userlocal_reg = true;
tmp = mips_rd_hwrena();
mips_wr_hwrena(tmp | MIPS_HWRENA_UL);
} else {
/*
* UserLocal register is not implemented. Patch
Expand Down Expand Up @@ -275,11 +276,25 @@ mips_get_identity(struct mips_cpuinfo *cpuinfo)
#endif
}

void
mips_hwrena_init(void)
{
uint32_t reg;

reg = mips_rd_hwrena();

if (cpuinfo.userlocal_reg)
reg |= MIPS_HWRENA_UL;

mips_wr_hwrena(reg);
}

void
mips_cpu_init(void)
{
platform_cpu_init();
mips_get_identity(&cpuinfo);
mips_hwrena_init();
num_tlbentries = cpuinfo.tlb_nentries;
mips_wr_wired(0);
tlb_invalidate_all();
Expand Down
3 changes: 3 additions & 0 deletions sys/mips/mips/mp_machdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
#include <machine/intr_machdep.h>
#include <machine/cache.h>
#include <machine/tlb.h>
#include <machine/md_var.h>

struct pcb stoppcbs[MAXCPU];

Expand Down Expand Up @@ -276,6 +277,8 @@ void
smp_init_secondary(u_int32_t cpuid)
{

mips_hwrena_init();

/* TLB */
mips_wr_wired(0);
tlb_invalidate_all();
Expand Down

0 comments on commit 8176157

Please sign in to comment.