Skip to content

Commit dd68fd7

Browse files
committed
Merge branches 'acpi-x86', 'acpi-battery', 'acpi-apei' and 'acpi-property'
Merge an x86 cleanup related to ACPI, an ACPI battery driver fix, an ACPI APEI cleanup, and an ACPI device properties handling update for 6.18-rc1: - Remove open coded check for cpu_feature_enabled() from acpi_processor_power_init_bm_check() (Mario Limonciello) - Add missing synchronization between interface updates in the ACPI battery driver (Rafael Wysocki) - Remove redundant rcu_read_lock/unlock() under spinlock from ghes_notify_hed() in the ACPI APEI support code (pengdonglin) - Make the .get_next_child_node() callback in the ACPI fwnode backend skip ACPI devices that are not present for consistency with the analogous callback in the OF fwnode backend (Sakari Ailus) * acpi-x86: x86/acpi/cstate: Remove open coded check for cpu_feature_enabled() * acpi-battery: ACPI: battery: Add synchronization between interface updates * acpi-apei: ACPI: APEI: Remove redundant rcu_read_lock/unlock() under spinlock * acpi-property: ACPI: property: Return present device nodes only on fwnode interface
5 parents 679a163 + 5b87014 + 399dbca + c7bc7e9 + d9f866b commit dd68fd7

4 files changed

Lines changed: 53 additions & 18 deletions

File tree

arch/x86/kernel/acpi/cstate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
8989
*/
9090
flags->bm_control = 0;
9191
}
92-
if (c->x86_vendor == X86_VENDOR_AMD && c->x86 >= 0x17) {
92+
if (cpu_feature_enabled(X86_FEATURE_ZEN)) {
9393
/*
9494
* For all AMD Zen or newer CPUs that support C3, caches
9595
* should not be flushed by software while entering C3

drivers/acpi/apei/ghes.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,12 +1207,10 @@ static int ghes_notify_hed(struct notifier_block *this, unsigned long event,
12071207
int ret = NOTIFY_DONE;
12081208

12091209
spin_lock_irqsave(&ghes_notify_lock_irq, flags);
1210-
rcu_read_lock();
12111210
list_for_each_entry_rcu(ghes, &ghes_hed, list) {
12121211
if (!ghes_proc(ghes))
12131212
ret = NOTIFY_OK;
12141213
}
1215-
rcu_read_unlock();
12161214
spin_unlock_irqrestore(&ghes_notify_lock_irq, flags);
12171215

12181216
return ret;

drivers/acpi/battery.c

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ enum {
9292

9393
struct acpi_battery {
9494
struct mutex lock;
95-
struct mutex sysfs_lock;
95+
struct mutex update_lock;
9696
struct power_supply *bat;
9797
struct power_supply_desc bat_desc;
9898
struct acpi_device *device;
@@ -904,15 +904,12 @@ static int sysfs_add_battery(struct acpi_battery *battery)
904904

905905
static void sysfs_remove_battery(struct acpi_battery *battery)
906906
{
907-
mutex_lock(&battery->sysfs_lock);
908-
if (!battery->bat) {
909-
mutex_unlock(&battery->sysfs_lock);
907+
if (!battery->bat)
910908
return;
911-
}
909+
912910
battery_hook_remove_battery(battery);
913911
power_supply_unregister(battery->bat);
914912
battery->bat = NULL;
915-
mutex_unlock(&battery->sysfs_lock);
916913
}
917914

918915
static void find_battery(const struct dmi_header *dm, void *private)
@@ -1072,6 +1069,9 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
10721069

10731070
if (!battery)
10741071
return;
1072+
1073+
guard(mutex)(&battery->update_lock);
1074+
10751075
old = battery->bat;
10761076
/*
10771077
* On Acer Aspire V5-573G notifications are sometimes triggered too
@@ -1094,21 +1094,22 @@ static void acpi_battery_notify(acpi_handle handle, u32 event, void *data)
10941094
}
10951095

10961096
static int battery_notify(struct notifier_block *nb,
1097-
unsigned long mode, void *_unused)
1097+
unsigned long mode, void *_unused)
10981098
{
10991099
struct acpi_battery *battery = container_of(nb, struct acpi_battery,
11001100
pm_nb);
1101-
int result;
11021101

1103-
switch (mode) {
1104-
case PM_POST_HIBERNATION:
1105-
case PM_POST_SUSPEND:
1102+
if (mode == PM_POST_SUSPEND || mode == PM_POST_HIBERNATION) {
1103+
guard(mutex)(&battery->update_lock);
1104+
11061105
if (!acpi_battery_present(battery))
11071106
return 0;
11081107

11091108
if (battery->bat) {
11101109
acpi_battery_refresh(battery);
11111110
} else {
1111+
int result;
1112+
11121113
result = acpi_battery_get_info(battery);
11131114
if (result)
11141115
return result;
@@ -1120,7 +1121,6 @@ static int battery_notify(struct notifier_block *nb,
11201121

11211122
acpi_battery_init_alarm(battery);
11221123
acpi_battery_get_state(battery);
1123-
break;
11241124
}
11251125

11261126
return 0;
@@ -1198,6 +1198,8 @@ static int acpi_battery_update_retry(struct acpi_battery *battery)
11981198
{
11991199
int retry, ret;
12001200

1201+
guard(mutex)(&battery->update_lock);
1202+
12011203
for (retry = 5; retry; retry--) {
12021204
ret = acpi_battery_update(battery, false);
12031205
if (!ret)
@@ -1208,6 +1210,13 @@ static int acpi_battery_update_retry(struct acpi_battery *battery)
12081210
return ret;
12091211
}
12101212

1213+
static void sysfs_battery_cleanup(struct acpi_battery *battery)
1214+
{
1215+
guard(mutex)(&battery->update_lock);
1216+
1217+
sysfs_remove_battery(battery);
1218+
}
1219+
12111220
static int acpi_battery_add(struct acpi_device *device)
12121221
{
12131222
int result = 0;
@@ -1230,7 +1239,7 @@ static int acpi_battery_add(struct acpi_device *device)
12301239
if (result)
12311240
return result;
12321241

1233-
result = devm_mutex_init(&device->dev, &battery->sysfs_lock);
1242+
result = devm_mutex_init(&device->dev, &battery->update_lock);
12341243
if (result)
12351244
return result;
12361245

@@ -1262,7 +1271,7 @@ static int acpi_battery_add(struct acpi_device *device)
12621271
device_init_wakeup(&device->dev, 0);
12631272
unregister_pm_notifier(&battery->pm_nb);
12641273
fail:
1265-
sysfs_remove_battery(battery);
1274+
sysfs_battery_cleanup(battery);
12661275

12671276
return result;
12681277
}
@@ -1281,6 +1290,9 @@ static void acpi_battery_remove(struct acpi_device *device)
12811290

12821291
device_init_wakeup(&device->dev, 0);
12831292
unregister_pm_notifier(&battery->pm_nb);
1293+
1294+
guard(mutex)(&battery->update_lock);
1295+
12841296
sysfs_remove_battery(battery);
12851297
}
12861298

@@ -1297,6 +1309,9 @@ static int acpi_battery_resume(struct device *dev)
12971309
return -EINVAL;
12981310

12991311
battery->update_time = 0;
1312+
1313+
guard(mutex)(&battery->update_lock);
1314+
13001315
acpi_battery_update(battery, true);
13011316
return 0;
13021317
}

drivers/acpi/property.c

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,6 +1358,28 @@ struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
13581358
return NULL;
13591359
}
13601360

1361+
/*
1362+
* acpi_get_next_present_subnode - Return the next present child node handle
1363+
* @fwnode: Firmware node to find the next child node for.
1364+
* @child: Handle to one of the device's child nodes or a null handle.
1365+
*
1366+
* Like acpi_get_next_subnode(), but the device nodes returned by
1367+
* acpi_get_next_present_subnode() are guaranteed to be present.
1368+
*
1369+
* Returns: The fwnode handle of the next present sub-node.
1370+
*/
1371+
static struct fwnode_handle *
1372+
acpi_get_next_present_subnode(const struct fwnode_handle *fwnode,
1373+
struct fwnode_handle *child)
1374+
{
1375+
do {
1376+
child = acpi_get_next_subnode(fwnode, child);
1377+
} while (is_acpi_device_node(child) &&
1378+
!acpi_device_is_present(to_acpi_device_node(child)));
1379+
1380+
return child;
1381+
}
1382+
13611383
/**
13621384
* acpi_node_get_parent - Return parent fwnode of this fwnode
13631385
* @fwnode: Firmware node whose parent to get
@@ -1702,7 +1724,7 @@ static int acpi_fwnode_irq_get(const struct fwnode_handle *fwnode,
17021724
.property_read_string_array = \
17031725
acpi_fwnode_property_read_string_array, \
17041726
.get_parent = acpi_node_get_parent, \
1705-
.get_next_child_node = acpi_get_next_subnode, \
1727+
.get_next_child_node = acpi_get_next_present_subnode, \
17061728
.get_named_child_node = acpi_fwnode_get_named_child_node, \
17071729
.get_name = acpi_fwnode_get_name, \
17081730
.get_name_prefix = acpi_fwnode_get_name_prefix, \

0 commit comments

Comments
 (0)