<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/cpufreq/cppc_cpufreq.c, branch linux-5.12.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.12.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.12.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2021-07-20T14:02:28Z</updated>
<entry>
<title>cpufreq: CPPC: Fix potential memleak in cppc_cpufreq_cpu_init</title>
<updated>2021-07-20T14:02:28Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2021-06-18T08:01:27Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b775383355755885b19d2acef977f1ca132e80a3'/>
<id>urn:sha1:b775383355755885b19d2acef977f1ca132e80a3</id>
<content type='text'>
[ Upstream commit fe2535a44904a77615a3af8e8fd7dafb98fb0e1b ]

It's a classic example of memleak, we allocate something, we fail and
never free the resources.

Make sure we free all resources on policy -&gt;init() failures.

Fixes: a28b2bfc099c ("cppc_cpufreq: replace per-cpu data array with a list")
Tested-by: Vincent Guittot &lt;vincent.guittot@linaro.org&gt;
Reviewed-by: Ionela Voinescu &lt;ionela.voinescu@arm.com&gt;
Tested-by: Qian Cai &lt;quic_qiancai@quicinc.com&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>cppc_cpufreq: replace per-cpu data array with a list</title>
<updated>2020-12-15T18:19:32Z</updated>
<author>
<name>Ionela Voinescu</name>
</author>
<published>2020-12-14T12:38:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=a28b2bfc099c6b9caa6ef697660408e076a32019'/>
<id>urn:sha1:a28b2bfc099c6b9caa6ef697660408e076a32019</id>
<content type='text'>
The cppc_cpudata per-cpu storage was inefficient (1) additional to causing
functional issues (2) when CPUs are hotplugged out, due to per-cpu data
being improperly initialised.

(1) The amount of information needed for CPPC performance control in its
    cpufreq driver depends on the domain (PSD) coordination type:

    ANY:    One set of CPPC control and capability data (e.g desired
            performance, highest/lowest performance, etc) applies to all
            CPUs in the domain.

    ALL:    Same as ANY. To be noted that this type is not currently
            supported. When supported, information about which CPUs
            belong to a domain is needed in order for frequency change
            requests to be sent to each of them.

    HW:     It's necessary to store CPPC control and capability
            information for all the CPUs. HW will then coordinate the
            performance state based on their limitations and requests.

    NONE:   Same as HW. No HW coordination is expected.

    Despite this, the previous initialisation code would indiscriminately
    allocate memory for all CPUs (all_cpu_data) and unnecessarily
    duplicate performance capabilities and the domain sharing mask and type
    for each possible CPU.

(2) With the current per-cpu structure, when having ANY coordination,
    the cppc_cpudata cpu information is not initialised (will remain 0)
    for all CPUs in a policy, other than policy-&gt;cpu. When policy-&gt;cpu is
    hotplugged out, the driver will incorrectly use the uninitialised (0)
    value of the other CPUs when making frequency changes. Additionally,
    the previous values stored in the perf_ctrls.desired_perf will be
    lost when policy-&gt;cpu changes.

Therefore replace the array of per cpu data with a list. The memory for
each structure is allocated at policy init, where a single structure
can be allocated per policy, not per cpu. In order to accommodate the
struct list_head node in the cppc_cpudata structure, the now unused cpu
and cur_policy variables are removed.

For example, on a arm64 Juno platform with 6 CPUs: (0, 1, 2, 3) in PSD1,
(4, 5) in PSD2 - ANY coordination, the memory allocation comparison shows:

Before patch:

 - ANY coordination:
   total    slack      req alloc/free  caller
       0        0        0     0/1     _kernel_size_le_hi32+0x0xffff800008ff7810
       0        0        0     0/6     _kernel_size_le_hi32+0x0xffff800008ff7808
     128       80       48     1/0     _kernel_size_le_hi32+0x0xffff800008ffc070
     768        0      768     6/0     _kernel_size_le_hi32+0x0xffff800008ffc0e4

After patch:

 - ANY coordination:
    total    slack      req alloc/free  caller
     256        0      256     2/0     _kernel_size_le_hi32+0x0xffff800008fed410
       0        0        0     0/2     _kernel_size_le_hi32+0x0xffff800008fed274

Additional notes:
 - A pointer to the policy's cppc_cpudata is stored in policy-&gt;driver_data
 - Driver registration is skipped if _CPC entries are not present.

Signed-off-by: Ionela Voinescu &lt;ionela.voinescu@arm.com&gt;
Tested-by: Mian Yousaf Kaukab &lt;ykaukab@suse.de&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cppc_cpufreq: expose information on frequency domains</title>
<updated>2020-12-15T18:19:32Z</updated>
<author>
<name>Ionela Voinescu</name>
</author>
<published>2020-12-14T12:38:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=cfdc589f4b5f94bf1a975b4a67d8163d533f6e9b'/>
<id>urn:sha1:cfdc589f4b5f94bf1a975b4a67d8163d533f6e9b</id>
<content type='text'>
Use the existing sysfs attribute "freqdomain_cpus" to expose
information to userspace about CPUs in the same frequency domain.

Signed-off-by: Ionela Voinescu &lt;ionela.voinescu@arm.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Tested-by: Mian Yousaf Kaukab &lt;ykaukab@suse.de&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cppc_cpufreq: clarify support for coordination types</title>
<updated>2020-12-15T18:19:32Z</updated>
<author>
<name>Ionela Voinescu</name>
</author>
<published>2020-12-14T12:38:21Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bf76bb208f2b653306f2fc8f9c2a22f9890702bd'/>
<id>urn:sha1:bf76bb208f2b653306f2fc8f9c2a22f9890702bd</id>
<content type='text'>
The previous coordination type handling in the cppc_cpufreq init code
created some confusion: the comment mentioned "Support only SW_ANY for
now" while only the SW_ALL/ALL case resulted in a failure. The other
coordination types (HW_ALL/HW, NONE) were silently supported.

Clarify support for coordination types while describing in comments the
intended behavior.

Signed-off-by: Ionela Voinescu &lt;ionela.voinescu@arm.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Tested-by: Mian Yousaf Kaukab &lt;ykaukab@suse.de&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cppc_cpufreq: use policy-&gt;cpu as driver of frequency setting</title>
<updated>2020-12-15T18:19:31Z</updated>
<author>
<name>Ionela Voinescu</name>
</author>
<published>2020-12-14T12:38:20Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d2641a5c3d5ecaa1078225e493c7fed821715a04'/>
<id>urn:sha1:d2641a5c3d5ecaa1078225e493c7fed821715a04</id>
<content type='text'>
Considering only the currently supported coordination types (ANY, HW,
NONE), this change only makes a difference for the ANY type, when
policy-&gt;cpu is hotplugged out. In that case the new policy-&gt;cpu will
be different from ((struct cppc_cpudata *)policy-&gt;driver_data)-&gt;cpu.

While in this case the controls of *ANY* CPU could be used to drive
frequency changes, it's more consistent to use policy-&gt;cpu as the
leading CPU, as used in all other cppc_cpufreq functions. Additionally,
the debug prints in cppc_set_perf() would no longer create confusion
when referring to a CPU that is hotplugged out.

Signed-off-by: Ionela Voinescu &lt;ionela.voinescu@arm.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Tested-by: Mian Yousaf Kaukab &lt;ykaukab@suse.de&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cppc_cpufreq: simplify use of performance capabilities</title>
<updated>2020-11-17T14:57:09Z</updated>
<author>
<name>Ionela Voinescu</name>
</author>
<published>2020-11-05T12:55:19Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bb025fb6c276ac874b718b9d884b7ee1099b2c22'/>
<id>urn:sha1:bb025fb6c276ac874b718b9d884b7ee1099b2c22</id>
<content type='text'>
The CPPC performance capabilities are used significantly throughout
the driver.

Simplify the use of them by introducing a local pointer "caps" to
point to cpu_data-&gt;perf_caps, in functions that access performance
capabilities often.

Signed-off-by: Ionela Voinescu &lt;ionela.voinescu@arm.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cppc_cpufreq: clean up cpu, cpu_num and cpunum variable use</title>
<updated>2020-11-17T14:57:09Z</updated>
<author>
<name>Ionela Voinescu</name>
</author>
<published>2020-11-05T12:55:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=48ad8dc94032ab43f0655190d9687f6d65b98f7f'/>
<id>urn:sha1:48ad8dc94032ab43f0655190d9687f6d65b98f7f</id>
<content type='text'>
In order to maintain the typical naming convention in the cpufreq
framework:

 - replace the use of "cpu" variable name for cppc_cpudata pointers
   with "cpu_data"
 - replace variable names "cpu_num" and "cpunum" with "cpu"
 - make cpu variables unsigned int

Where pertinent, also move the initialisation of cpu_data variable to
its declaration and make consistent use of the local "cpu" variable.

Signed-off-by: Ionela Voinescu &lt;ionela.voinescu@arm.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cppc_cpufreq: fix misspelling, code style and readability issues</title>
<updated>2020-11-17T14:57:09Z</updated>
<author>
<name>Ionela Voinescu</name>
</author>
<published>2020-11-05T12:55:17Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=63087265c288dc2d0f198ffba964c9fb383a61ed'/>
<id>urn:sha1:63087265c288dc2d0f198ffba964c9fb383a61ed</id>
<content type='text'>
Fix a few trivial issues in the cppc_cpufreq driver:

 - indentation of function arguments
 - consistent use of tabs (vs space) in defines
 - spelling: s/Offest/Offset, s/trasition/transition
 - order of local variables, from long pointers to structures to
   short ret and i (index) variables, to improve readability

Signed-off-by: Ionela Voinescu &lt;ionela.voinescu@arm.com&gt;
Acked-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>cpufreq: CPPC: Reuse caps variable in few routines</title>
<updated>2020-07-30T05:27:47Z</updated>
<author>
<name>Xin Hao</name>
</author>
<published>2020-07-01T03:26:10Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=4264e02d3e1865549952abe2b6d7c61a1e07ca62'/>
<id>urn:sha1:4264e02d3e1865549952abe2b6d7c61a1e07ca62</id>
<content type='text'>
The 'caps' variable has been defined in cppc_cpufreq_khz_to_perf() and
cppc_cpufreq_perf_to_khz() routines, so there is no need to get
'highest_perf' value through 'cpu-&gt;caps.highest_perf', we can use
'caps-&gt;highest_perf' instead.

Signed-off-by: Xin Hao &lt;xhao@linux.alibaba.com&gt;
[ Viresh: Updated commit log ]
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
</content>
</entry>
<entry>
<title>cpufreq: cppc: Reorder code and remove apply_hisi_workaround variable</title>
<updated>2020-07-30T05:27:46Z</updated>
<author>
<name>Viresh Kumar</name>
</author>
<published>2020-06-23T05:08:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=d88b0f0edb9041be6feff98e83cd6002e4ab534e'/>
<id>urn:sha1:d88b0f0edb9041be6feff98e83cd6002e4ab534e</id>
<content type='text'>
With the current approach we have an extra check in the
cppc_cpufreq_get_rate() callback, which checks if hisilicon's get rate
implementation should be used instead. While it works fine, the approach
isn't very straight forward, over that we have an extra check in the
routine.

Rearrange code and update the cpufreq driver's get() callback pointer
directly for the hisilicon case. This gets the extra variable is removed
and the extra check isn't required anymore as well.

Tested-by: Xiongfeng Wang &lt;wangxiongfeng2@huawei.com&gt;
Signed-off-by: Viresh Kumar &lt;viresh.kumar@linaro.org&gt;
</content>
</entry>
</feed>
