Unified Linux/Windows MSR log messages.
This commit is contained in:
parent
1ad6b5504c
commit
5d0fd2dc8e
3 changed files with 141 additions and 63 deletions
|
@ -28,12 +28,13 @@
|
|||
|
||||
|
||||
#include "crypto/rx/Rx.h"
|
||||
#include "backend/common/Tags.h"
|
||||
#include "backend/cpu/Cpu.h"
|
||||
#include "base/io/log/Log.h"
|
||||
#include "base/tools/Chrono.h"
|
||||
#include "crypto/rx/RxConfig.h"
|
||||
|
||||
|
||||
#include <array>
|
||||
#include <cctype>
|
||||
#include <cinttypes>
|
||||
#include <cstdio>
|
||||
|
@ -47,6 +48,18 @@
|
|||
namespace xmrig {
|
||||
|
||||
|
||||
enum MsrMod : uint32_t {
|
||||
MSR_MOD_NONE,
|
||||
MSR_MOD_RYZEN,
|
||||
MSR_MOD_INTEL,
|
||||
MSR_MOD_MAX
|
||||
};
|
||||
|
||||
|
||||
static const char *tag = YELLOW_BG_BOLD(WHITE_BOLD_S " msr ") " ";
|
||||
static const std::array<const char *, MSR_MOD_MAX> modNames = { nullptr, "Ryzen", "Intel" };
|
||||
|
||||
|
||||
static inline int dir_filter(const struct dirent *dirp)
|
||||
{
|
||||
return isdigit(dirp->d_name[0]) ? 1 : 0;
|
||||
|
@ -88,7 +101,7 @@ static bool wrmsr_on_all_cpus(uint32_t reg, uint64_t value)
|
|||
free(namelist);
|
||||
|
||||
if (errors) {
|
||||
LOG_WARN(CLEAR "%s" YELLOW_BOLD_S "cannot set MSR 0x%08" PRIx32 " to 0x%08" PRIx64, rx_tag(), reg, value);
|
||||
LOG_WARN(CLEAR "%s" YELLOW_BOLD_S "cannot set MSR 0x%08" PRIx32 " to 0x%08" PRIx64, tag, reg, value);
|
||||
}
|
||||
|
||||
return errors == 0;
|
||||
|
@ -98,7 +111,7 @@ static bool wrmsr_on_all_cpus(uint32_t reg, uint64_t value)
|
|||
static bool wrmsr_modprobe()
|
||||
{
|
||||
if (system("/sbin/modprobe msr > /dev/null 2>&1") != 0) {
|
||||
LOG_WARN(CLEAR "%s" YELLOW_BOLD_S "msr kernel module is not available", rx_tag());
|
||||
LOG_WARN(CLEAR "%s" YELLOW_BOLD_S "msr kernel module is not available", tag);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -116,16 +129,33 @@ void xmrig::Rx::osInit(const RxConfig &config)
|
|||
return;
|
||||
}
|
||||
|
||||
if (Cpu::info()->assembly() == Assembly::RYZEN && wrmsr_modprobe()) {
|
||||
wrmsr_on_all_cpus(0xC0011022, 0x510000);
|
||||
wrmsr_on_all_cpus(0xC001102b, 0x1808cc16);
|
||||
wrmsr_on_all_cpus(0xC0011020, 0);
|
||||
wrmsr_on_all_cpus(0xC0011021, 0x40);
|
||||
MsrMod mod = MSR_MOD_NONE;
|
||||
if (Cpu::info()->assembly() == Assembly::RYZEN) {
|
||||
mod = MSR_MOD_RYZEN;
|
||||
}
|
||||
else if (Cpu::info()->vendor() == ICpuInfo::VENDOR_INTEL) {
|
||||
mod = MSR_MOD_INTEL;
|
||||
}
|
||||
|
||||
if (mod == MSR_MOD_NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cpu::info()->vendor() == ICpuInfo::VENDOR_INTEL && wrmsr_modprobe()) {
|
||||
const uint64_t ts = Chrono::steadyMSecs();
|
||||
|
||||
if (!wrmsr_modprobe()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mod == MSR_MOD_RYZEN) {
|
||||
wrmsr_on_all_cpus(0xC0011020, 0);
|
||||
wrmsr_on_all_cpus(0xC0011021, 0x40);
|
||||
wrmsr_on_all_cpus(0xC0011022, 0x510000);
|
||||
wrmsr_on_all_cpus(0xC001102b, 0x1808cc16);
|
||||
}
|
||||
else if (mod == MSR_MOD_INTEL) {
|
||||
wrmsr_on_all_cpus(0x1a4, config.wrmsr());
|
||||
}
|
||||
|
||||
LOG_NOTICE(CLEAR "%s" GREEN_BOLD_S "register values for %s has been set successfully" BLACK_BOLD(" (%" PRIu64 " ms)"), tag, modNames[mod], Chrono::steadyMSecs() - ts);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue