mirror of
https://github.com/torvalds/linux.git
synced 2026-04-21 08:13:56 -04:00
selftests/powerpc: Move Hash MMU check to utilities
This moves a function to test if the MMU is in Hash mode under the generic test utilities. Signed-off-by: Sandipan Das <sandipan@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20200604125610.649668-3-sandipan@linux.ibm.com
This commit is contained in:
committed by
Michael Ellerman
parent
828ca4320d
commit
c405b738da
@@ -293,3 +293,31 @@ void set_dscr(unsigned long val)
|
||||
|
||||
asm volatile("mtspr %1,%0" : : "r" (val), "i" (SPRN_DSCR));
|
||||
}
|
||||
|
||||
int using_hash_mmu(bool *using_hash)
|
||||
{
|
||||
char line[128];
|
||||
FILE *f;
|
||||
int rc;
|
||||
|
||||
f = fopen("/proc/cpuinfo", "r");
|
||||
FAIL_IF(!f);
|
||||
|
||||
rc = 0;
|
||||
while (fgets(line, sizeof(line), f) != NULL) {
|
||||
if (strcmp(line, "MMU : Hash\n") == 0) {
|
||||
*using_hash = true;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strcmp(line, "MMU : Radix\n") == 0) {
|
||||
*using_hash = false;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
rc = -1;
|
||||
out:
|
||||
fclose(f);
|
||||
return rc;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user