Documentation/power/opp.rst

Source file repositories/reference/linux-study-clean/Documentation/power/opp.rst

File Facts

System
Linux kernel
Corpus path
Documentation/power/opp.rst
Extension
.rst
Size
13990 bytes
Lines
382
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

if (!r) {
			pr_err("%s: unable to register mpu opp(%d)\n", r);
			goto no_cpufreq;
		}
		/* Do cpufreq things */
	 no_cpufreq:
		/* Do remaining things */
	 }

3. OPP Search Functions
=======================
High level framework such as cpufreq operates on frequencies. To map the
frequency back to the corresponding OPP, OPP library provides handy functions
to search the OPP list that OPP library internally manages. These search
functions return the matching pointer representing the opp if a match is
found, else returns error. These errors are expected to be handled by standard
error checks such as IS_ERR() and appropriate actions taken by the caller.

Callers of these functions shall call dev_pm_opp_put() after they have used the
OPP. Otherwise the memory for the OPP will never get freed and result in
memleak.

dev_pm_opp_find_freq_exact
	Search for an OPP based on an *exact* frequency and
	availability. This function is especially useful to enable an OPP which
	is not available by default.
	Example: In a case when SoC framework detects a situation where a
	higher frequency could be made available, it can use this function to
	find the OPP prior to call the dev_pm_opp_enable to actually make
	it available::

	 opp = dev_pm_opp_find_freq_exact(dev, 1000000000, false);
	 dev_pm_opp_put(opp);
	 /* dont operate on the pointer.. just do a sanity check.. */
	 if (IS_ERR(opp)) {
		pr_err("frequency not disabled!\n");
		/* trigger appropriate actions.. */
	 } else {
		dev_pm_opp_enable(dev,1000000000);
	 }

	NOTE:
	  This is the only search function that operates on OPPs which are
	  not available.

dev_pm_opp_find_freq_floor
	Search for an available OPP which is *at most* the
	provided frequency. This function is useful while searching for a lesser
	match OR operating on OPP information in the order of decreasing
	frequency.
	Example: To find the highest opp for a device::

	 freq = ULONG_MAX;
	 opp = dev_pm_opp_find_freq_floor(dev, &freq);
	 dev_pm_opp_put(opp);

dev_pm_opp_find_freq_ceil
	Search for an available OPP which is *at least* the
	provided frequency. This function is useful while searching for a
	higher match OR operating on OPP information in the order of increasing
	frequency.
	Example 1: To find the lowest opp for a device::

	 freq = 0;
	 opp = dev_pm_opp_find_freq_ceil(dev, &freq);
	 dev_pm_opp_put(opp);

	Example 2: A simplified implementation of a SoC cpufreq_driver->target::

	 soc_cpufreq_target(..)

Annotation

Implementation Notes