Skip to content

Commit bb19180

Browse files
committed
Merge branches 'acpi-battery', 'acpi-pmic', 'acpi-cppc' and 'acpi-processor'
Merge ACPI battery driver, ACPI PMIC driver, ACPI processor driver and ACPI CPPC library updates for 6.12-rc1: - Use the driver core for the async probing management in the ACPI battery driver (Thomas Weißschuh). - Remove redundant initalizations of a local variable to NULL from the ACPI battery driver (Ilpo Järvinen). - Use strscpy() instead of strcpy() in the ACPI battery driver (Muhammad Qasim Abdul Majeed). - Remove unneeded check in tps68470_pmic_opregion_probe() (Aleksandr Mishin). - Add support for setting the EPP register through the ACPI CPPC sysfs interface if it is in FFH (Mario Limonciello). - Fix MASK_VAL() usage in the ACPI CPPC library (Clément Léger). - Reduce the log level of a per-CPU message about idle states in the ACPI processor driver (Li RongQing). * acpi-battery: ACPI: battery: use driver core managed async probing ACPI: battery: Remove redundant NULL initalizations ACPI: battery: Use strscpy() instead of strcpy() * acpi-pmic: ACPI: PMIC: Remove unneeded check in tps68470_pmic_opregion_probe() * acpi-cppc: ACPI: CPPC: Add support for setting EPP register in FFH ACPI: CPPC: Fix MASK_VAL() usage * acpi-processor: ACPI: processor: Reduce the log level of a per-CPU message about idle states
5 parents 4ed63b3 + eea3d53 + 07442c4 + aaf21ac + 5ac5f3f commit bb19180

File tree

5 files changed

+64
-38
lines changed

5 files changed

+64
-38
lines changed

drivers/acpi/acpi_processor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
985985
memcpy(&info->states[++last_index], &cx, sizeof(cx));
986986
}
987987

988-
acpi_handle_info(handle, "Found %d idle states\n", last_index);
988+
acpi_handle_debug(handle, "Found %d idle states\n", last_index);
989989

990990
info->count = last_index;
991991

drivers/acpi/battery.c

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
#define pr_fmt(fmt) "ACPI: battery: " fmt
1212

13-
#include <linux/async.h>
1413
#include <linux/delay.h>
1514
#include <linux/dmi.h>
1615
#include <linux/jiffies.h>
@@ -50,8 +49,6 @@ MODULE_AUTHOR("Alexey Starikovskiy <[email protected]>");
5049
MODULE_DESCRIPTION("ACPI Battery Driver");
5150
MODULE_LICENSE("GPL");
5251

53-
static async_cookie_t async_cookie;
54-
static bool battery_driver_registered;
5552
static int battery_bix_broken_package;
5653
static int battery_notification_delay_ms;
5754
static int battery_ac_is_broken;
@@ -1207,7 +1204,7 @@ static int acpi_battery_update_retry(struct acpi_battery *battery)
12071204
static int acpi_battery_add(struct acpi_device *device)
12081205
{
12091206
int result = 0;
1210-
struct acpi_battery *battery = NULL;
1207+
struct acpi_battery *battery;
12111208

12121209
if (!device)
12131210
return -EINVAL;
@@ -1219,8 +1216,8 @@ static int acpi_battery_add(struct acpi_device *device)
12191216
if (!battery)
12201217
return -ENOMEM;
12211218
battery->device = device;
1222-
strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
1223-
strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
1219+
strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
1220+
strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
12241221
device->driver_data = battery;
12251222
mutex_init(&battery->lock);
12261223
mutex_init(&battery->sysfs_lock);
@@ -1260,7 +1257,7 @@ static int acpi_battery_add(struct acpi_device *device)
12601257

12611258
static void acpi_battery_remove(struct acpi_device *device)
12621259
{
1263-
struct acpi_battery *battery = NULL;
1260+
struct acpi_battery *battery;
12641261

12651262
if (!device || !acpi_driver_data(device))
12661263
return;
@@ -1311,37 +1308,23 @@ static struct acpi_driver acpi_battery_driver = {
13111308
.remove = acpi_battery_remove,
13121309
},
13131310
.drv.pm = &acpi_battery_pm,
1311+
.drv.probe_type = PROBE_PREFER_ASYNCHRONOUS,
13141312
};
13151313

1316-
static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
1317-
{
1318-
int result;
1319-
1320-
if (acpi_quirk_skip_acpi_ac_and_battery())
1321-
return;
1322-
1323-
dmi_check_system(bat_dmi_table);
1324-
1325-
result = acpi_bus_register_driver(&acpi_battery_driver);
1326-
battery_driver_registered = (result == 0);
1327-
}
1328-
13291314
static int __init acpi_battery_init(void)
13301315
{
1331-
if (acpi_disabled)
1316+
if (acpi_disabled || acpi_quirk_skip_acpi_ac_and_battery())
13321317
return -ENODEV;
13331318

1334-
async_cookie = async_schedule(acpi_battery_init_async, NULL);
1335-
return 0;
1319+
dmi_check_system(bat_dmi_table);
1320+
1321+
return acpi_bus_register_driver(&acpi_battery_driver);
13361322
}
13371323

13381324
static void __exit acpi_battery_exit(void)
13391325
{
1340-
async_synchronize_cookie(async_cookie + 1);
1341-
if (battery_driver_registered) {
1342-
acpi_bus_unregister_driver(&acpi_battery_driver);
1343-
battery_hook_exit();
1344-
}
1326+
acpi_bus_unregister_driver(&acpi_battery_driver);
1327+
battery_hook_exit();
13451328
}
13461329

13471330
module_init(acpi_battery_init);

drivers/acpi/cppc_acpi.c

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
103103
(cpc)->cpc_entry.reg.space_id == \
104104
ACPI_ADR_SPACE_PLATFORM_COMM)
105105

106+
/* Check if a CPC register is in FFH */
107+
#define CPC_IN_FFH(cpc) ((cpc)->type == ACPI_TYPE_BUFFER && \
108+
(cpc)->cpc_entry.reg.space_id == \
109+
ACPI_ADR_SPACE_FIXED_HARDWARE)
110+
106111
/* Check if a CPC register is in SystemMemory */
107112
#define CPC_IN_SYSTEM_MEMORY(cpc) ((cpc)->type == ACPI_TYPE_BUFFER && \
108113
(cpc)->cpc_entry.reg.space_id == \
@@ -171,8 +176,11 @@ show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, wraparound_time);
171176
#define GET_BIT_WIDTH(reg) ((reg)->access_width ? (8 << ((reg)->access_width - 1)) : (reg)->bit_width)
172177

173178
/* Shift and apply the mask for CPC reads/writes */
174-
#define MASK_VAL(reg, val) (((val) >> (reg)->bit_offset) & \
179+
#define MASK_VAL_READ(reg, val) (((val) >> (reg)->bit_offset) & \
175180
GENMASK(((reg)->bit_width) - 1, 0))
181+
#define MASK_VAL_WRITE(reg, prev_val, val) \
182+
((((val) & GENMASK(((reg)->bit_width) - 1, 0)) << (reg)->bit_offset) | \
183+
((prev_val) & ~(GENMASK(((reg)->bit_width) - 1, 0) << (reg)->bit_offset))) \
176184

177185
static ssize_t show_feedback_ctrs(struct kobject *kobj,
178186
struct kobj_attribute *attr, char *buf)
@@ -859,6 +867,7 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
859867

860868
/* Store CPU Logical ID */
861869
cpc_ptr->cpu_id = pr->id;
870+
spin_lock_init(&cpc_ptr->rmw_lock);
862871

863872
/* Parse PSD data for this CPU */
864873
ret = acpi_get_psd(cpc_ptr, handle);
@@ -1064,7 +1073,7 @@ static int cpc_read(int cpu, struct cpc_register_resource *reg_res, u64 *val)
10641073
}
10651074

10661075
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
1067-
*val = MASK_VAL(reg, *val);
1076+
*val = MASK_VAL_READ(reg, *val);
10681077

10691078
return 0;
10701079
}
@@ -1073,9 +1082,11 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
10731082
{
10741083
int ret_val = 0;
10751084
int size;
1085+
u64 prev_val;
10761086
void __iomem *vaddr = NULL;
10771087
int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
10781088
struct cpc_reg *reg = &reg_res->cpc_entry.reg;
1089+
struct cpc_desc *cpc_desc;
10791090

10801091
size = GET_BIT_WIDTH(reg);
10811092

@@ -1108,8 +1119,34 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
11081119
return acpi_os_write_memory((acpi_physical_address)reg->address,
11091120
val, size);
11101121

1111-
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
1112-
val = MASK_VAL(reg, val);
1122+
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
1123+
cpc_desc = per_cpu(cpc_desc_ptr, cpu);
1124+
if (!cpc_desc) {
1125+
pr_debug("No CPC descriptor for CPU:%d\n", cpu);
1126+
return -ENODEV;
1127+
}
1128+
1129+
spin_lock(&cpc_desc->rmw_lock);
1130+
switch (size) {
1131+
case 8:
1132+
prev_val = readb_relaxed(vaddr);
1133+
break;
1134+
case 16:
1135+
prev_val = readw_relaxed(vaddr);
1136+
break;
1137+
case 32:
1138+
prev_val = readl_relaxed(vaddr);
1139+
break;
1140+
case 64:
1141+
prev_val = readq_relaxed(vaddr);
1142+
break;
1143+
default:
1144+
spin_unlock(&cpc_desc->rmw_lock);
1145+
return -EFAULT;
1146+
}
1147+
val = MASK_VAL_WRITE(reg, prev_val, val);
1148+
val |= prev_val;
1149+
}
11131150

11141151
switch (size) {
11151152
case 8:
@@ -1136,6 +1173,9 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
11361173
break;
11371174
}
11381175

1176+
if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
1177+
spin_unlock(&cpc_desc->rmw_lock);
1178+
11391179
return ret_val;
11401180
}
11411181

@@ -1486,9 +1526,12 @@ int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable)
14861526
/* after writing CPC, transfer the ownership of PCC to platform */
14871527
ret = send_pcc_cmd(pcc_ss_id, CMD_WRITE);
14881528
up_write(&pcc_ss_data->pcc_lock);
1529+
} else if (osc_cpc_flexible_adr_space_confirmed &&
1530+
CPC_SUPPORTED(epp_set_reg) && CPC_IN_FFH(epp_set_reg)) {
1531+
ret = cpc_write(cpu, epp_set_reg, perf_ctrls->energy_perf);
14891532
} else {
14901533
ret = -ENOTSUPP;
1491-
pr_debug("_CPC in PCC is not supported\n");
1534+
pr_debug("_CPC in PCC and _CPC in FFH are not supported\n");
14921535
}
14931536

14941537
return ret;

drivers/acpi/pmic/tps68470_pmic.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,8 @@ static int tps68470_pmic_opregion_probe(struct platform_device *pdev)
376376
struct tps68470_pmic_opregion *opregion;
377377
acpi_status status;
378378

379-
if (!dev || !tps68470_regmap) {
380-
dev_warn(dev, "dev or regmap is NULL\n");
381-
return -EINVAL;
382-
}
379+
if (!tps68470_regmap)
380+
return dev_err_probe(dev, -EINVAL, "regmap is missing\n");
383381

384382
if (!handle) {
385383
dev_warn(dev, "acpi handle is NULL\n");

include/acpi/cppc_acpi.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ struct cpc_desc {
6464
int cpu_id;
6565
int write_cmd_status;
6666
int write_cmd_id;
67+
/* Lock used for RMW operations in cpc_write() */
68+
spinlock_t rmw_lock;
6769
struct cpc_register_resource cpc_regs[MAX_CPC_REG_ENT];
6870
struct acpi_psd_package domain_info;
6971
struct kobject kobj;

0 commit comments

Comments
 (0)