| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * acpi_pad.c ACPI Processor Aggregator Driver |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (c) 2009, Intel Corporation. |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify it |
|---|
| 7 | | - * under the terms and conditions of the GNU General Public License, |
|---|
| 8 | | - * version 2, as published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
|---|
| 11 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 12 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 13 | | - * more details. |
|---|
| 14 | | - * |
|---|
| 15 | 6 | */ |
|---|
| 16 | 7 | |
|---|
| 17 | 8 | #include <linux/kernel.h> |
|---|
| .. | .. |
|---|
| 70 | 61 | |
|---|
| 71 | 62 | #if defined(CONFIG_X86) |
|---|
| 72 | 63 | switch (boot_cpu_data.x86_vendor) { |
|---|
| 64 | + case X86_VENDOR_HYGON: |
|---|
| 73 | 65 | case X86_VENDOR_AMD: |
|---|
| 74 | 66 | case X86_VENDOR_INTEL: |
|---|
| 67 | + case X86_VENDOR_ZHAOXIN: |
|---|
| 75 | 68 | /* |
|---|
| 76 | 69 | * AMD Fam10h TSC will tick in all |
|---|
| 77 | 70 | * C/P/S0/S1 states when this bit is set. |
|---|
| .. | .. |
|---|
| 95 | 88 | cpumask_var_t tmp; |
|---|
| 96 | 89 | int cpu; |
|---|
| 97 | 90 | unsigned long min_weight = -1; |
|---|
| 98 | | - unsigned long uninitialized_var(preferred_cpu); |
|---|
| 91 | + unsigned long preferred_cpu; |
|---|
| 99 | 92 | |
|---|
| 100 | 93 | if (!alloc_cpumask_var(&tmp, GFP_KERNEL)) |
|---|
| 101 | 94 | return; |
|---|
| .. | .. |
|---|
| 143 | 136 | static unsigned int round_robin_time = 1; /* second */ |
|---|
| 144 | 137 | static int power_saving_thread(void *data) |
|---|
| 145 | 138 | { |
|---|
| 146 | | - struct sched_param param = {.sched_priority = 1}; |
|---|
| 147 | 139 | int do_sleep; |
|---|
| 148 | 140 | unsigned int tsk_index = (unsigned long)data; |
|---|
| 149 | 141 | u64 last_jiffies = 0; |
|---|
| 150 | 142 | |
|---|
| 151 | | - sched_setscheduler(current, SCHED_RR, ¶m); |
|---|
| 143 | + sched_set_fifo_low(current); |
|---|
| 152 | 144 | |
|---|
| 153 | 145 | while (!kthread_should_stop()) { |
|---|
| 154 | 146 | unsigned long expire_time; |
|---|
| .. | .. |
|---|
| 269 | 261 | return ps_tsk_num; |
|---|
| 270 | 262 | } |
|---|
| 271 | 263 | |
|---|
| 272 | | -static ssize_t acpi_pad_rrtime_store(struct device *dev, |
|---|
| 264 | +static ssize_t rrtime_store(struct device *dev, |
|---|
| 273 | 265 | struct device_attribute *attr, const char *buf, size_t count) |
|---|
| 274 | 266 | { |
|---|
| 275 | 267 | unsigned long num; |
|---|
| .. | .. |
|---|
| 283 | 275 | return count; |
|---|
| 284 | 276 | } |
|---|
| 285 | 277 | |
|---|
| 286 | | -static ssize_t acpi_pad_rrtime_show(struct device *dev, |
|---|
| 278 | +static ssize_t rrtime_show(struct device *dev, |
|---|
| 287 | 279 | struct device_attribute *attr, char *buf) |
|---|
| 288 | 280 | { |
|---|
| 289 | 281 | return scnprintf(buf, PAGE_SIZE, "%d\n", round_robin_time); |
|---|
| 290 | 282 | } |
|---|
| 291 | | -static DEVICE_ATTR(rrtime, S_IRUGO|S_IWUSR, |
|---|
| 292 | | - acpi_pad_rrtime_show, |
|---|
| 293 | | - acpi_pad_rrtime_store); |
|---|
| 283 | +static DEVICE_ATTR_RW(rrtime); |
|---|
| 294 | 284 | |
|---|
| 295 | | -static ssize_t acpi_pad_idlepct_store(struct device *dev, |
|---|
| 285 | +static ssize_t idlepct_store(struct device *dev, |
|---|
| 296 | 286 | struct device_attribute *attr, const char *buf, size_t count) |
|---|
| 297 | 287 | { |
|---|
| 298 | 288 | unsigned long num; |
|---|
| .. | .. |
|---|
| 306 | 296 | return count; |
|---|
| 307 | 297 | } |
|---|
| 308 | 298 | |
|---|
| 309 | | -static ssize_t acpi_pad_idlepct_show(struct device *dev, |
|---|
| 299 | +static ssize_t idlepct_show(struct device *dev, |
|---|
| 310 | 300 | struct device_attribute *attr, char *buf) |
|---|
| 311 | 301 | { |
|---|
| 312 | 302 | return scnprintf(buf, PAGE_SIZE, "%d\n", idle_pct); |
|---|
| 313 | 303 | } |
|---|
| 314 | | -static DEVICE_ATTR(idlepct, S_IRUGO|S_IWUSR, |
|---|
| 315 | | - acpi_pad_idlepct_show, |
|---|
| 316 | | - acpi_pad_idlepct_store); |
|---|
| 304 | +static DEVICE_ATTR_RW(idlepct); |
|---|
| 317 | 305 | |
|---|
| 318 | | -static ssize_t acpi_pad_idlecpus_store(struct device *dev, |
|---|
| 306 | +static ssize_t idlecpus_store(struct device *dev, |
|---|
| 319 | 307 | struct device_attribute *attr, const char *buf, size_t count) |
|---|
| 320 | 308 | { |
|---|
| 321 | 309 | unsigned long num; |
|---|
| .. | .. |
|---|
| 327 | 315 | return count; |
|---|
| 328 | 316 | } |
|---|
| 329 | 317 | |
|---|
| 330 | | -static ssize_t acpi_pad_idlecpus_show(struct device *dev, |
|---|
| 318 | +static ssize_t idlecpus_show(struct device *dev, |
|---|
| 331 | 319 | struct device_attribute *attr, char *buf) |
|---|
| 332 | 320 | { |
|---|
| 333 | 321 | return cpumap_print_to_pagebuf(false, buf, |
|---|
| 334 | 322 | to_cpumask(pad_busy_cpus_bits)); |
|---|
| 335 | 323 | } |
|---|
| 336 | 324 | |
|---|
| 337 | | -static DEVICE_ATTR(idlecpus, S_IRUGO|S_IWUSR, |
|---|
| 338 | | - acpi_pad_idlecpus_show, |
|---|
| 339 | | - acpi_pad_idlecpus_store); |
|---|
| 325 | +static DEVICE_ATTR_RW(idlecpus); |
|---|
| 340 | 326 | |
|---|
| 341 | 327 | static int acpi_pad_add_sysfs(struct acpi_device *device) |
|---|
| 342 | 328 | { |
|---|