Skip to content

Commit 959bfe4

Browse files
committed
Merge tag 'acpi-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI updates from Rafael Wysocki: "These add Microsoft fan extensions support to the ACPI fan driver, fix a bug in ACPICA, update other ACPI drivers (processor, time and alarm device), update ACPI power management code and ACPI device properties management, and fix an ACPI utility: - Avoid walking the ACPI namespace in the AML interpreter if the starting node cannot be determined (Cryolitia PukNgae) - Use min() instead of min_t() in the ACPI device properties handling code to avoid discarding significant bits (David Laight) - Fix potential fwnode refcount leak in acpi_fwnode_graph_parse_endpoint() that may prevent the parent fwnode from being released (Haotian Zhang) - Rework acpi_graph_get_next_endpoint() to use ACPI functions only, remove unnecessary conditionals from it to make it easier to follow, and make acpi_get_next_subnode() static (Sakari Ailus) - Drop unused function acpi_get_lps0_constraint(), make some Low-Power S0 callback functions for suspend-to-idle static, and rearrange the code retrieving Low-Power S0 constraints so it only runs when the constraints are actually used (Rafael Wysocki) - Drop redundant locking from the ACPI battery driver (Rafael Wysocki) - Improve runtime PM in the ACPI time and alarm device (TAD) driver using guard macros and rearrange code related to runtime PM in acpi_tad_remove() (Rafael Wysocki) - Add support for Microsoft fan extensions to the ACPI fan driver along with notification support and work around a 64-bit firmware bug in that driver (Armin Wolf) - Use ACPI_FREE() to free ACPI buffer in the ACPI DPTF code (Kaushlendra Kumar) - Fix a memory leak and a resource leak in the ACPI pfrut utility (Malaya Kumar Rout) - Replace `core::mem::zeroed` with `pin_init::zeroed` in the ACPI Rust code (Siyuan Huang) - Update the ACPI code to use the new style of allocating workqueues and new global workqueues (Marco Crivellari) - Fix two spelling mistakes in the ACPI code (Chu Guangqing) - Fix ISAPNP to generate uevents to auto-load modules (René Rebe) - Relocate the state flags initialization in the ACPI processor idle driver and drop redundant C-state count checks from it (Huisong Li) - Fix map_x2apic_id() in the ACPI processor core driver for amd-pstate on am4 (René Rebe)" * tag 'acpi-6.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (30 commits) ACPI: PM: Fix a spelling mistake ACPI: LPSS: Fix a spelling mistake ACPI: processor_core: fix map_x2apic_id for amd-pstate on am4 ACPICA: Avoid walking the Namespace if start_node is NULL ACPI: tools: pfrut: fix memory leak and resource leak in pfrut.c ACPI: property: use min() instead of min_t() PNP: Fix ISAPNP to generate uevents to auto-load modules ACPI: property: Fix fwnode refcount leak in acpi_fwnode_graph_parse_endpoint() ACPI: DPTF: Use ACPI_FREE() for ACPI buffer deallocation ACPI: processor: idle: Drop redundant C-state count checks ACPI: thermal: Add WQ_PERCPU to alloc_workqueue() users ACPI: OSL: Add WQ_PERCPU to alloc_workqueue() users ACPI: EC: Add WQ_PERCPU to alloc_workqueue() users ACPI: OSL: replace use of system_wq with system_percpu_wq ACPI: scan: replace use of system_unbound_wq with system_dfl_wq ACPI: fan: Add support for Microsoft fan extensions ACPI: fan: Add hwmon notification support ACPI: fan: Add basic notification support ACPI: TAD: Improve runtime PM using guard macros ACPI: TAD: Rearrange runtime PM operations in acpi_tad_remove() ...
2 parents 44fc843 + af47d98 commit 959bfe4

22 files changed

Lines changed: 420 additions & 168 deletions

File tree

drivers/acpi/acpi_tad.c

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,18 @@ static int acpi_tad_set_real_time(struct device *dev, struct acpi_tad_rt *rt)
9090
args[0].buffer.pointer = (u8 *)rt;
9191
args[0].buffer.length = sizeof(*rt);
9292

93-
pm_runtime_get_sync(dev);
93+
ACQUIRE(pm_runtime_active_try, pm)(dev);
94+
if (ACQUIRE_ERR(pm_runtime_active_try, &pm))
95+
return -ENXIO;
9496

9597
status = acpi_evaluate_integer(handle, "_SRT", &arg_list, &retval);
96-
97-
pm_runtime_put_sync(dev);
98-
9998
if (ACPI_FAILURE(status) || retval)
10099
return -EIO;
101100

102101
return 0;
103102
}
104103

105-
static int acpi_tad_get_real_time(struct device *dev, struct acpi_tad_rt *rt)
104+
static int acpi_tad_evaluate_grt(struct device *dev, struct acpi_tad_rt *rt)
106105
{
107106
acpi_handle handle = ACPI_HANDLE(dev);
108107
struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER };
@@ -111,12 +110,7 @@ static int acpi_tad_get_real_time(struct device *dev, struct acpi_tad_rt *rt)
111110
acpi_status status;
112111
int ret = -EIO;
113112

114-
pm_runtime_get_sync(dev);
115-
116113
status = acpi_evaluate_object(handle, "_GRT", NULL, &output);
117-
118-
pm_runtime_put_sync(dev);
119-
120114
if (ACPI_FAILURE(status))
121115
goto out_free;
122116

@@ -139,6 +133,21 @@ static int acpi_tad_get_real_time(struct device *dev, struct acpi_tad_rt *rt)
139133
return ret;
140134
}
141135

136+
static int acpi_tad_get_real_time(struct device *dev, struct acpi_tad_rt *rt)
137+
{
138+
int ret;
139+
140+
ACQUIRE(pm_runtime_active_try, pm)(dev);
141+
if (ACQUIRE_ERR(pm_runtime_active_try, &pm))
142+
return -ENXIO;
143+
144+
ret = acpi_tad_evaluate_grt(dev, rt);
145+
if (ret)
146+
return ret;
147+
148+
return 0;
149+
}
150+
142151
static char *acpi_tad_rt_next_field(char *s, int *val)
143152
{
144153
char *p;
@@ -266,12 +275,11 @@ static int acpi_tad_wake_set(struct device *dev, char *method, u32 timer_id,
266275
args[0].integer.value = timer_id;
267276
args[1].integer.value = value;
268277

269-
pm_runtime_get_sync(dev);
278+
ACQUIRE(pm_runtime_active_try, pm)(dev);
279+
if (ACQUIRE_ERR(pm_runtime_active_try, &pm))
280+
return -ENXIO;
270281

271282
status = acpi_evaluate_integer(handle, method, &arg_list, &retval);
272-
273-
pm_runtime_put_sync(dev);
274-
275283
if (ACPI_FAILURE(status) || retval)
276284
return -EIO;
277285

@@ -314,12 +322,11 @@ static ssize_t acpi_tad_wake_read(struct device *dev, char *buf, char *method,
314322

315323
args[0].integer.value = timer_id;
316324

317-
pm_runtime_get_sync(dev);
325+
ACQUIRE(pm_runtime_active_try, pm)(dev);
326+
if (ACQUIRE_ERR(pm_runtime_active_try, &pm))
327+
return -ENXIO;
318328

319329
status = acpi_evaluate_integer(handle, method, &arg_list, &retval);
320-
321-
pm_runtime_put_sync(dev);
322-
323330
if (ACPI_FAILURE(status))
324331
return -EIO;
325332

@@ -370,12 +377,11 @@ static int acpi_tad_clear_status(struct device *dev, u32 timer_id)
370377

371378
args[0].integer.value = timer_id;
372379

373-
pm_runtime_get_sync(dev);
380+
ACQUIRE(pm_runtime_active_try, pm)(dev);
381+
if (ACQUIRE_ERR(pm_runtime_active_try, &pm))
382+
return -ENXIO;
374383

375384
status = acpi_evaluate_integer(handle, "_CWS", &arg_list, &retval);
376-
377-
pm_runtime_put_sync(dev);
378-
379385
if (ACPI_FAILURE(status) || retval)
380386
return -EIO;
381387

@@ -411,12 +417,11 @@ static ssize_t acpi_tad_status_read(struct device *dev, char *buf, u32 timer_id)
411417

412418
args[0].integer.value = timer_id;
413419

414-
pm_runtime_get_sync(dev);
420+
ACQUIRE(pm_runtime_active_try, pm)(dev);
421+
if (ACQUIRE_ERR(pm_runtime_active_try, &pm))
422+
return -ENXIO;
415423

416424
status = acpi_evaluate_integer(handle, "_GWS", &arg_list, &retval);
417-
418-
pm_runtime_put_sync(dev);
419-
420425
if (ACPI_FAILURE(status))
421426
return -EIO;
422427

@@ -563,8 +568,6 @@ static void acpi_tad_remove(struct platform_device *pdev)
563568

564569
device_init_wakeup(dev, false);
565570

566-
pm_runtime_get_sync(dev);
567-
568571
if (dd->capabilities & ACPI_TAD_RT)
569572
sysfs_remove_group(&dev->kobj, &acpi_tad_time_attr_group);
570573

@@ -573,14 +576,16 @@ static void acpi_tad_remove(struct platform_device *pdev)
573576

574577
sysfs_remove_group(&dev->kobj, &acpi_tad_attr_group);
575578

576-
acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER);
577-
acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER);
578-
if (dd->capabilities & ACPI_TAD_DC_WAKE) {
579-
acpi_tad_disable_timer(dev, ACPI_TAD_DC_TIMER);
580-
acpi_tad_clear_status(dev, ACPI_TAD_DC_TIMER);
579+
scoped_guard(pm_runtime_noresume, dev) {
580+
acpi_tad_disable_timer(dev, ACPI_TAD_AC_TIMER);
581+
acpi_tad_clear_status(dev, ACPI_TAD_AC_TIMER);
582+
if (dd->capabilities & ACPI_TAD_DC_WAKE) {
583+
acpi_tad_disable_timer(dev, ACPI_TAD_DC_TIMER);
584+
acpi_tad_clear_status(dev, ACPI_TAD_DC_TIMER);
585+
}
581586
}
582587

583-
pm_runtime_put_sync(dev);
588+
pm_runtime_suspend(dev);
584589
pm_runtime_disable(dev);
585590
acpi_remove_cmos_rtc_space_handler(handle);
586591
}

drivers/acpi/acpica/nswalk.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,12 @@ acpi_ns_walk_namespace(acpi_object_type type,
169169

170170
if (start_node == ACPI_ROOT_OBJECT) {
171171
start_node = acpi_gbl_root_node;
172-
if (!start_node) {
173-
return_ACPI_STATUS(AE_NO_NAMESPACE);
174-
}
172+
}
173+
174+
/* Avoid walking the namespace if the StartNode is NULL */
175+
176+
if (!start_node) {
177+
return_ACPI_STATUS(AE_NO_NAMESPACE);
175178
}
176179

177180
/* Null child means "get first node" */

drivers/acpi/battery.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ enum {
9191
};
9292

9393
struct acpi_battery {
94-
struct mutex lock;
9594
struct mutex update_lock;
9695
struct power_supply *bat;
9796
struct power_supply_desc bat_desc;
@@ -535,11 +534,9 @@ static int acpi_battery_get_info(struct acpi_battery *battery)
535534
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
536535
acpi_status status = AE_ERROR;
537536

538-
mutex_lock(&battery->lock);
539537
status = acpi_evaluate_object(battery->device->handle,
540538
use_bix ? "_BIX":"_BIF",
541539
NULL, &buffer);
542-
mutex_unlock(&battery->lock);
543540

544541
if (ACPI_FAILURE(status)) {
545542
acpi_handle_info(battery->device->handle,
@@ -576,11 +573,8 @@ static int acpi_battery_get_state(struct acpi_battery *battery)
576573
msecs_to_jiffies(cache_time)))
577574
return 0;
578575

579-
mutex_lock(&battery->lock);
580576
status = acpi_evaluate_object(battery->device->handle, "_BST",
581577
NULL, &buffer);
582-
mutex_unlock(&battery->lock);
583-
584578
if (ACPI_FAILURE(status)) {
585579
acpi_handle_info(battery->device->handle,
586580
"_BST evaluation failed: %s",
@@ -628,11 +622,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery)
628622
!test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags))
629623
return -ENODEV;
630624

631-
mutex_lock(&battery->lock);
632625
status = acpi_execute_simple_method(battery->device->handle, "_BTP",
633626
battery->alarm);
634-
mutex_unlock(&battery->lock);
635-
636627
if (ACPI_FAILURE(status))
637628
return -ENODEV;
638629

@@ -1235,9 +1226,6 @@ static int acpi_battery_add(struct acpi_device *device)
12351226
strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
12361227
strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
12371228
device->driver_data = battery;
1238-
result = devm_mutex_init(&device->dev, &battery->lock);
1239-
if (result)
1240-
return result;
12411229

12421230
result = devm_mutex_init(&device->dev, &battery->update_lock);
12431231
if (result)

drivers/acpi/dptf/dptf_pch_fivr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static int pch_fivr_read(acpi_handle handle, char *method, struct pch_fivr_resp
4141
ret = 0;
4242

4343
release_buffer:
44-
kfree(buffer.pointer);
44+
ACPI_FREE(buffer.pointer);
4545
return ret;
4646
}
4747

drivers/acpi/ec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2294,7 +2294,8 @@ static int acpi_ec_init_workqueues(void)
22942294
ec_wq = alloc_ordered_workqueue("kec", 0);
22952295

22962296
if (!ec_query_wq)
2297-
ec_query_wq = alloc_workqueue("kec_query", 0, ec_max_queries);
2297+
ec_query_wq = alloc_workqueue("kec_query", WQ_PERCPU,
2298+
ec_max_queries);
22982299

22992300
if (!ec_wq || !ec_query_wq) {
23002301
acpi_ec_destroy_workqueues();

drivers/acpi/fan.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#define _ACPI_FAN_H_
1212

1313
#include <linux/kconfig.h>
14+
#include <linux/limits.h>
1415

1516
#define ACPI_FAN_DEVICE_IDS \
1617
{"INT3404", }, /* Fan */ \
@@ -55,19 +56,58 @@ struct acpi_fan {
5556
struct acpi_fan_fif fif;
5657
struct acpi_fan_fps *fps;
5758
int fps_count;
59+
/* A value of 0 means that trippoint-related functions are not supported */
60+
u32 fan_trip_granularity;
61+
#if IS_REACHABLE(CONFIG_HWMON)
62+
struct device *hdev;
63+
#endif
5864
struct thermal_cooling_device *cdev;
5965
struct device_attribute fst_speed;
6066
struct device_attribute fine_grain_control;
6167
};
6268

69+
/**
70+
* acpi_fan_speed_valid - Check if fan speed value is valid
71+
* @speeed: Speed value returned by the ACPI firmware
72+
*
73+
* Check if the fan speed value returned by the ACPI firmware is valid. This function is
74+
* necessary as ACPI firmware implementations can return 0xFFFFFFFF to signal that the
75+
* ACPI fan does not support speed reporting. Additionally, some buggy ACPI firmware
76+
* implementations return a value larger than the 32-bit integer value defined by
77+
* the ACPI specification when using placeholder values. Such invalid values are also
78+
* detected by this function.
79+
*
80+
* Returns: True if the fan speed value is valid, false otherwise.
81+
*/
82+
static inline bool acpi_fan_speed_valid(u64 speed)
83+
{
84+
return speed < U32_MAX;
85+
}
86+
87+
/**
88+
* acpi_fan_power_valid - Check if fan power value is valid
89+
* @power: Power value returned by the ACPI firmware
90+
*
91+
* Check if the fan power value returned by the ACPI firmware is valid.
92+
* See acpi_fan_speed_valid() for details.
93+
*
94+
* Returns: True if the fan power value is valid, false otherwise.
95+
*/
96+
static inline bool acpi_fan_power_valid(u64 power)
97+
{
98+
return power < U32_MAX;
99+
}
100+
63101
int acpi_fan_get_fst(acpi_handle handle, struct acpi_fan_fst *fst);
64102
int acpi_fan_create_attributes(struct acpi_device *device);
65103
void acpi_fan_delete_attributes(struct acpi_device *device);
66104

67105
#if IS_REACHABLE(CONFIG_HWMON)
68106
int devm_acpi_fan_create_hwmon(struct device *dev);
107+
void acpi_fan_notify_hwmon(struct device *dev);
69108
#else
70109
static inline int devm_acpi_fan_create_hwmon(struct device *dev) { return 0; };
110+
static inline void acpi_fan_notify_hwmon(struct device *dev) { };
71111
#endif
72112

73113
#endif

0 commit comments

Comments
 (0)