/// Finds exact supply name from the OF node. fn find_supply_name_exact(dev: &Device, name: &str) -> Option<CString> { let prop_name = CString::try_from_fmt(fmt!("{name}-supply")).ok()?;
dev.fwnode()?
.property_present(&prop_name)
.then(|| CString::try_from_fmt(fmt!("{name}")).ok())
.flatten()
}
/// Finds supply name for the CPU from DT. fn find_supply_names(dev: &Device, cpu: cpu::CpuId) -> Option<KVec<CString>> { // Try "cpu0" for older DTs, fallback to "cpu". let name = (cpu.as_u32() == 0)
.then(|| find_supply_name_exact(dev, "cpu0"))
.flatten()
.or_else(|| find_supply_name_exact(dev, "cpu"))?;
letmut list = KVec::with_capacity(1, GFP_KERNEL).ok()?;
list.push(name, GFP_KERNEL).ok()?;
fn init(policy: &mut cpufreq::Policy) -> Result<Self::PData> { let cpu = policy.cpu(); // SAFETY: The CPU device is only used during init; it won't get hot-unplugged. The cpufreq // core registers with CPU notifiers and the cpufreq core/driver won't use the CPU device, // once the CPU is hot-unplugged. let dev = unsafe { cpu::from_cpu(cpu)? }; letmut mask = CpumaskVar::new_zero(GFP_KERNEL)?;
// Get OPP-sharing information from "operating-points-v2" bindings. let fallback = match opp::Table::of_sharing_cpus(dev, &mut mask) {
Ok(()) => false,
Err(e) if e == ENOENT => { // "operating-points-v2" not supported. If the platform hasn't // set sharing CPUs, fallback to all CPUs share the `Policy` // for backward compatibility.
opp::Table::sharing_cpus(dev, &mut mask).is_err()
}
Err(e) => return Err(e),
};
// Initialize OPP tables for all policy cpus. // // For platforms not using "operating-points-v2" bindings, we do this // before updating policy cpus. Otherwise, we will end up creating // duplicate OPPs for the CPUs. // // OPPs might be populated at runtime, don't fail for error here unless // it is -EPROBE_DEFER. letmut opp_table = match opp::Table::from_of_cpumask(dev, &mut mask) {
Ok(table) => table,
Err(e) => { if e == EPROBE_DEFER { return Err(e);
}
// The table is added dynamically ?
opp::Table::from_dev(dev)?
}
};
// The OPP table must be initialized, statically or dynamically, by this point.
opp_table.opp_count()?;
// Set sharing cpus for fallback scenario. if fallback {
mask.setall();
opp_table.set_sharing_cpus(&mut mask)?;
}
letmut transition_latency = opp_table.max_transition_latency_ns() as u32; if transition_latency == 0 {
transition_latency = cpufreq::DEFAULT_TRANSITION_LATENCY_NS;
}
let freq_table = opp_table.cpufreq_table()?; // SAFETY: The `freq_table` is not dropped while it is getting used by the C code. unsafe { policy.set_freq_table(&freq_table) };
// SAFETY: The returned `clk` is not dropped while it is getting used by the C code. let clk = unsafe { policy.set_clk(dev, None)? };
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.