Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'acpi-6.18-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull more ACPI updates from Rafael Wysocki:
"These fix a driver bug, clean up two pieces of code and improve the
fwnode API consistency:

- Add missing synchronization between interface updates in the ACPI
battery driver (Rafael Wysocki)

- Remove open coded check for cpu_feature_enabled() from
acpi_processor_power_init_bm_check() (Mario Limonciello)

- 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)"

* tag 'acpi-6.18-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
ACPI: property: Return present device nodes only on fwnode interface
ACPI: APEI: Remove redundant rcu_read_lock/unlock() under spinlock
ACPI: battery: Add synchronization between interface updates
x86/acpi/cstate: Remove open coded check for cpu_feature_enabled()

+53 -18
+1 -1
arch/x86/kernel/acpi/cstate.c
··· 89 89 */ 90 90 flags->bm_control = 0; 91 91 } 92 - if (c->x86_vendor == X86_VENDOR_AMD && c->x86 >= 0x17) { 92 + if (cpu_feature_enabled(X86_FEATURE_ZEN)) { 93 93 /* 94 94 * For all AMD Zen or newer CPUs that support C3, caches 95 95 * should not be flushed by software while entering C3
-2
drivers/acpi/apei/ghes.c
··· 1207 1207 int ret = NOTIFY_DONE; 1208 1208 1209 1209 spin_lock_irqsave(&ghes_notify_lock_irq, flags); 1210 - rcu_read_lock(); 1211 1210 list_for_each_entry_rcu(ghes, &ghes_hed, list) { 1212 1211 if (!ghes_proc(ghes)) 1213 1212 ret = NOTIFY_OK; 1214 1213 } 1215 - rcu_read_unlock(); 1216 1214 spin_unlock_irqrestore(&ghes_notify_lock_irq, flags); 1217 1215 1218 1216 return ret;
+29 -14
drivers/acpi/battery.c
··· 92 92 93 93 struct acpi_battery { 94 94 struct mutex lock; 95 - struct mutex sysfs_lock; 95 + struct mutex update_lock; 96 96 struct power_supply *bat; 97 97 struct power_supply_desc bat_desc; 98 98 struct acpi_device *device; ··· 904 904 905 905 static void sysfs_remove_battery(struct acpi_battery *battery) 906 906 { 907 - mutex_lock(&battery->sysfs_lock); 908 - if (!battery->bat) { 909 - mutex_unlock(&battery->sysfs_lock); 907 + if (!battery->bat) 910 908 return; 911 - } 909 + 912 910 battery_hook_remove_battery(battery); 913 911 power_supply_unregister(battery->bat); 914 912 battery->bat = NULL; 915 - mutex_unlock(&battery->sysfs_lock); 916 913 } 917 914 918 915 static void find_battery(const struct dmi_header *dm, void *private) ··· 1069 1072 1070 1073 if (!battery) 1071 1074 return; 1075 + 1076 + guard(mutex)(&battery->update_lock); 1077 + 1072 1078 old = battery->bat; 1073 1079 /* 1074 1080 * On Acer Aspire V5-573G notifications are sometimes triggered too ··· 1094 1094 } 1095 1095 1096 1096 static int battery_notify(struct notifier_block *nb, 1097 - unsigned long mode, void *_unused) 1097 + unsigned long mode, void *_unused) 1098 1098 { 1099 1099 struct acpi_battery *battery = container_of(nb, struct acpi_battery, 1100 1100 pm_nb); 1101 - int result; 1102 1101 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 + 1106 1105 if (!acpi_battery_present(battery)) 1107 1106 return 0; 1108 1107 1109 1108 if (battery->bat) { 1110 1109 acpi_battery_refresh(battery); 1111 1110 } else { 1111 + int result; 1112 + 1112 1113 result = acpi_battery_get_info(battery); 1113 1114 if (result) 1114 1115 return result; ··· 1121 1120 1122 1121 acpi_battery_init_alarm(battery); 1123 1122 acpi_battery_get_state(battery); 1124 - break; 1125 1123 } 1126 1124 1127 1125 return 0; ··· 1198 1198 { 1199 1199 int retry, ret; 1200 1200 1201 + guard(mutex)(&battery->update_lock); 1202 + 1201 1203 for (retry = 5; retry; retry--) { 1202 1204 ret = acpi_battery_update(battery, false); 1203 1205 if (!ret) ··· 1208 1206 msleep(20); 1209 1207 } 1210 1208 return ret; 1209 + } 1210 + 1211 + static void sysfs_battery_cleanup(struct acpi_battery *battery) 1212 + { 1213 + guard(mutex)(&battery->update_lock); 1214 + 1215 + sysfs_remove_battery(battery); 1211 1216 } 1212 1217 1213 1218 static int acpi_battery_add(struct acpi_device *device) ··· 1239 1230 if (result) 1240 1231 return result; 1241 1232 1242 - result = devm_mutex_init(&device->dev, &battery->sysfs_lock); 1233 + result = devm_mutex_init(&device->dev, &battery->update_lock); 1243 1234 if (result) 1244 1235 return result; 1245 1236 ··· 1271 1262 device_init_wakeup(&device->dev, 0); 1272 1263 unregister_pm_notifier(&battery->pm_nb); 1273 1264 fail: 1274 - sysfs_remove_battery(battery); 1265 + sysfs_battery_cleanup(battery); 1275 1266 1276 1267 return result; 1277 1268 } ··· 1290 1281 1291 1282 device_init_wakeup(&device->dev, 0); 1292 1283 unregister_pm_notifier(&battery->pm_nb); 1284 + 1285 + guard(mutex)(&battery->update_lock); 1286 + 1293 1287 sysfs_remove_battery(battery); 1294 1288 } 1295 1289 ··· 1309 1297 return -EINVAL; 1310 1298 1311 1299 battery->update_time = 0; 1300 + 1301 + guard(mutex)(&battery->update_lock); 1302 + 1312 1303 acpi_battery_update(battery, true); 1313 1304 return 0; 1314 1305 }
+23 -1
drivers/acpi/property.c
··· 1388 1388 return NULL; 1389 1389 } 1390 1390 1391 + /* 1392 + * acpi_get_next_present_subnode - Return the next present child node handle 1393 + * @fwnode: Firmware node to find the next child node for. 1394 + * @child: Handle to one of the device's child nodes or a null handle. 1395 + * 1396 + * Like acpi_get_next_subnode(), but the device nodes returned by 1397 + * acpi_get_next_present_subnode() are guaranteed to be present. 1398 + * 1399 + * Returns: The fwnode handle of the next present sub-node. 1400 + */ 1401 + static struct fwnode_handle * 1402 + acpi_get_next_present_subnode(const struct fwnode_handle *fwnode, 1403 + struct fwnode_handle *child) 1404 + { 1405 + do { 1406 + child = acpi_get_next_subnode(fwnode, child); 1407 + } while (is_acpi_device_node(child) && 1408 + !acpi_device_is_present(to_acpi_device_node(child))); 1409 + 1410 + return child; 1411 + } 1412 + 1391 1413 /** 1392 1414 * acpi_node_get_parent - Return parent fwnode of this fwnode 1393 1415 * @fwnode: Firmware node whose parent to get ··· 1744 1722 .property_read_string_array = \ 1745 1723 acpi_fwnode_property_read_string_array, \ 1746 1724 .get_parent = acpi_node_get_parent, \ 1747 - .get_next_child_node = acpi_get_next_subnode, \ 1725 + .get_next_child_node = acpi_get_next_present_subnode, \ 1748 1726 .get_named_child_node = acpi_fwnode_get_named_child_node, \ 1749 1727 .get_name = acpi_fwnode_get_name, \ 1750 1728 .get_name_prefix = acpi_fwnode_get_name_prefix, \