fam15h_power.c (4b4193256c8d3bc3a5397b5cd9494c2ad386317d) fam15h_power.c (e104d530f3734c7666edf86bbf1b83b1bfafe6ee)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * fam15h_power.c - AMD Family 15h processor power monitoring
4 *
5 * Copyright (c) 2011-2016 Advanced Micro Devices, Inc.
6 * Author: Andreas Herrmann <herrmann.der.user@googlemail.com>
7 */
8

--- 152 unchanged lines hidden (view full) ---

161 int ret, cpu;
162
163 ret = zalloc_cpumask_var(&mask, GFP_KERNEL);
164 if (!ret)
165 return -ENOMEM;
166
167 memset(data->cu_on, 0, sizeof(int) * MAX_CUS);
168
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * fam15h_power.c - AMD Family 15h processor power monitoring
4 *
5 * Copyright (c) 2011-2016 Advanced Micro Devices, Inc.
6 * Author: Andreas Herrmann <herrmann.der.user@googlemail.com>
7 */
8

--- 152 unchanged lines hidden (view full) ---

161 int ret, cpu;
162
163 ret = zalloc_cpumask_var(&mask, GFP_KERNEL);
164 if (!ret)
165 return -ENOMEM;
166
167 memset(data->cu_on, 0, sizeof(int) * MAX_CUS);
168
169 get_online_cpus();
169 cpus_read_lock();
170
171 /*
172 * Choose the first online core of each compute unit, and then
173 * read their MSR value of power and ptsc in a single IPI,
174 * because the MSR value of CPU core represent the compute
175 * unit's.
176 */
177 core = -1;

--- 7 unchanged lines hidden (view full) ---

185 core = this_core;
186
187 /* get any CPU on this compute unit */
188 cpumask_set_cpu(cpumask_any(topology_sibling_cpumask(cpu)), mask);
189 }
190
191 on_each_cpu_mask(mask, do_read_registers_on_cu, data, true);
192
170
171 /*
172 * Choose the first online core of each compute unit, and then
173 * read their MSR value of power and ptsc in a single IPI,
174 * because the MSR value of CPU core represent the compute
175 * unit's.
176 */
177 core = -1;

--- 7 unchanged lines hidden (view full) ---

185 core = this_core;
186
187 /* get any CPU on this compute unit */
188 cpumask_set_cpu(cpumask_any(topology_sibling_cpumask(cpu)), mask);
189 }
190
191 on_each_cpu_mask(mask, do_read_registers_on_cu, data, true);
192
193 put_online_cpus();
193 cpus_read_unlock();
194 free_cpumask_var(mask);
195
196 return 0;
197}
198
199static ssize_t power1_average_show(struct device *dev,
200 struct device_attribute *attr, char *buf)
201{

--- 299 unchanged lines hidden ---
194 free_cpumask_var(mask);
195
196 return 0;
197}
198
199static ssize_t power1_average_show(struct device *dev,
200 struct device_attribute *attr, char *buf)
201{

--- 299 unchanged lines hidden ---