Compare commits

...

2 commits

8 changed files with 89 additions and 22 deletions

View file

@ -51,7 +51,9 @@ pub struct GeneralLimits {}
#[derive(Serialize, Deserialize)]
pub struct GpuLimits {
pub fast_ppt_limits: Option<RangeLimit<u64>>,
pub fast_ppt_default: u64,
pub slow_ppt_limits: Option<RangeLimit<u64>>,
pub slow_ppt_default: u64,
pub ppt_step: u64,
pub tdp_limits: Option<RangeLimit<u64>>,
pub tdp_boost_limits: Option<RangeLimit<u64>>,

View file

@ -99,15 +99,27 @@ impl TGpu for Gpu {
log::debug!("dev_mode_Gpu::limits(self) -> {{...}}");
let ppt_divisor = self.limits.ppt_divisor.unwrap_or(1_000_000);
let tdp_divisor = self.limits.tdp_divisor.unwrap_or(1_000_000);
crate::api::GpuLimits {
let limit_struct = crate::api::GpuLimits {
fast_ppt_limits: self.limits.fast_ppt.map(|lim| crate::api::RangeLimit {
min: lim.min.unwrap_or(11_000_000) / ppt_divisor,
max: lim.max.unwrap_or(42_000_000) / ppt_divisor,
}),
fast_ppt_default: self
.limits
.fast_ppt_default
.or_else(|| self.limits.fast_ppt.and_then(|x| x.max))
.unwrap_or(2_000_000)
/ ppt_divisor,
slow_ppt_limits: self.limits.slow_ppt.map(|lim| crate::api::RangeLimit {
min: lim.min.unwrap_or(7_000_000) / ppt_divisor,
max: lim.max.unwrap_or(69_000_000) / ppt_divisor,
}),
slow_ppt_default: self
.limits
.slow_ppt_default
.or_else(|| self.limits.slow_ppt.and_then(|x| x.max))
.unwrap_or(3_000_000)
/ ppt_divisor,
ppt_step: self.limits.ppt_step.unwrap_or(1),
tdp_limits: self.limits.tdp.map(|lim| crate::api::RangeLimit {
min: lim.min.unwrap_or(11_000_000) / tdp_divisor,
@ -132,7 +144,12 @@ impl TGpu for Gpu {
max: lim.max.unwrap_or(1100),
}),
memory_step: self.limits.memory_clock_step.unwrap_or(400),
}
};
log::debug!(
"dev_mode_Gpu::limits(self) -> {}",
serde_json::to_string_pretty(&limit_struct).unwrap()
);
limit_struct
}
fn json(&self) -> crate::persist::GpuJson {

View file

@ -167,6 +167,18 @@ impl TGpu for Gpu {
x
}
}),
fast_ppt_default: {
let def = self
.limits
.fast_ppt_default
.or_else(|| self.limits.fast_ppt.and_then(|x| x.max))
.unwrap_or(15);
if let Some(ppt_divisor) = self.limits.ppt_divisor {
def / ppt_divisor
} else {
def
}
},
slow_ppt_limits: self
.limits
.slow_ppt
@ -181,6 +193,18 @@ impl TGpu for Gpu {
x
}
}),
slow_ppt_default: {
let def = self
.limits
.slow_ppt_default
.or_else(|| self.limits.slow_ppt.and_then(|x| x.max))
.unwrap_or(15);
if let Some(ppt_divisor) = self.limits.ppt_divisor {
def / ppt_divisor
} else {
def
}
},
ppt_step: self.limits.ppt_step.unwrap_or(1),
tdp_limits: self
.limits

View file

@ -327,7 +327,9 @@ impl crate::settings::OnUnload for Gpu {
fn bad_gpu_limits() -> crate::api::GpuLimits {
crate::api::GpuLimits {
fast_ppt_limits: None,
fast_ppt_default: 1,
slow_ppt_limits: None,
slow_ppt_default: 1,
ppt_step: 1,
tdp_limits: None,
tdp_boost_limits: None,

View file

@ -340,6 +340,7 @@ impl Gpu {
}
fn set_memory_speed(&self, clock: u64) -> Result<(), SettingError> {
if POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.needs_manual() {
let path = GPU_MEMORY_DOWNCLOCK_ATTRIBUTE.path(&self.sysfs_card);
let payload = self.build_memory_clock_payload(clock);
log::debug!(
@ -353,6 +354,9 @@ impl Gpu {
msg: format!("Failed to write to `{}`: {}", path.display(), e),
setting: crate::settings::SettingVariant::Gpu,
})
} else {
Ok(())
}
}
fn set_force_performance_related(&mut self) -> Result<(), Vec<SettingError>> {
@ -362,7 +366,7 @@ impl Gpu {
POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT
.enforce_level(&self.sysfs_card)
.unwrap_or_else(|mut e| errors.append(&mut e));
// enable/disable downclock of GPU memory (to 400Mhz?)
// enable/disable downclock of GPU memory
self.set_memory_speed(
self.memory_clock
.or_else(|| {
@ -631,6 +635,7 @@ impl crate::settings::OnLoad for Gpu {
impl crate::settings::OnUnload for Gpu {
fn on_unload(&mut self) -> Result<(), Vec<SettingError>> {
POWER_DPM_FORCE_PERFORMANCE_LEVEL_MGMT.set_gpu(false);
Ok(())
}
}
@ -638,19 +643,32 @@ impl crate::settings::OnUnload for Gpu {
impl TGpu for Gpu {
fn limits(&self) -> crate::api::GpuLimits {
let max_gpu_clock = self.read_max_gpu_clock();
let ppt_divisor = self.limits.ppt_divisor.unwrap_or(PPT_DIVISOR);
crate::api::GpuLimits {
fast_ppt_limits: Some(RangeLimit {
min: super::util::range_min_or_fallback(&self.limits.fast_ppt, MIN_FAST_PPT)
/ self.limits.ppt_divisor.unwrap_or(PPT_DIVISOR),
/ ppt_divisor,
max: super::util::range_max_or_fallback(&self.limits.fast_ppt, MAX_FAST_PPT)
/ self.limits.ppt_divisor.unwrap_or(PPT_DIVISOR),
/ ppt_divisor,
}),
fast_ppt_default: self
.limits
.fast_ppt_default
.or_else(|| self.limits.fast_ppt.and_then(|x| x.max))
.unwrap_or(MAX_FAST_PPT)
/ ppt_divisor,
slow_ppt_limits: Some(RangeLimit {
min: super::util::range_min_or_fallback(&self.limits.slow_ppt, MIN_SLOW_PPT)
/ self.limits.ppt_divisor.unwrap_or(PPT_DIVISOR),
/ ppt_divisor,
max: super::util::range_max_or_fallback(&self.limits.slow_ppt, MIN_SLOW_PPT)
/ self.limits.ppt_divisor.unwrap_or(PPT_DIVISOR),
/ ppt_divisor,
}),
slow_ppt_default: self
.limits
.slow_ppt_default
.or_else(|| self.limits.slow_ppt.and_then(|x| x.max))
.unwrap_or(MAX_SLOW_PPT)
/ ppt_divisor,
ppt_step: self.limits.ppt_step.unwrap_or(1),
tdp_limits: None,
tdp_boost_limits: None,

View file

@ -71,7 +71,9 @@ impl TGpu for Gpu {
fn limits(&self) -> crate::api::GpuLimits {
crate::api::GpuLimits {
fast_ppt_limits: None,
fast_ppt_default: 1_000_000,
slow_ppt_limits: None,
slow_ppt_default: 1_000_000,
ppt_step: 1_000_000,
tdp_limits: None,
tdp_boost_limits: None,

View file

@ -85,7 +85,9 @@ export type GeneralLimits = {};
export type GpuLimits = {
fast_ppt_limits: RangeLimit | null;
fast_ppt_default: number;
slow_ppt_limits: RangeLimit | null;
slow_ppt_default: number;
ppt_step: number;
clock_min_limits: RangeLimit | null;
clock_max_limits: RangeLimit | null;

View file

@ -41,11 +41,11 @@ export class Gpu extends Component<backend.IdcProps> {
onChange={(value: boolean) => {
if (value) {
if ((get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_limits != null) {
set_value(SLOW_PPT_GPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_limits!.max);
set_value(SLOW_PPT_GPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.slow_ppt_default);
}
if ((get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_limits != null) {
set_value(FAST_PPT_GPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_limits!.max);
set_value(FAST_PPT_GPU, (get_value(LIMITS_INFO) as backend.SettingsLimits).gpu.fast_ppt_default);
}
reloadGUI("GPUPPTToggle");
} else {