Commit 24d268ad authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge branches 'acpica', 'acpi-property', 'acpi-pm' and 'acpi-battery'

Merge an ACPICA change, device ACPI properties handling update, ACPI
power management updates, and an ACPI battery driver update for
6.19-rc1:

 - 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 contitionals 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 constraits so it only runs when the
   constraits are actually used (Rafael Wysocki)

 - Drop redundant locking from the ACPI battery driver (Rafael Wysocki)

* acpica:
  ACPICA: Avoid walking the Namespace if start_node is NULL

* acpi-property:
  ACPI: property: use min() instead of min_t()
  ACPI: property: Fix fwnode refcount leak in acpi_fwnode_graph_parse_endpoint()
  ACPI: property: Rework acpi_graph_get_next_endpoint()
  ACPI: property: Use ACPI functions in acpi_graph_get_next_endpoint() only
  ACPI: property: Make acpi_get_next_subnode() static

* acpi-pm:
  ACPI: PM: s2idle: Only retrieve constraints when needed
  ACPI: PM: s2idle: Staticise LPS0 callback functions
  ACPI: PM: s2idle: Drop acpi_get_lps0_constraint()

* acpi-battery:
  ACPI: battery: Drop redundant locking
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -169,10 +169,13 @@ acpi_ns_walk_namespace(acpi_object_type type,

	if (start_node == ACPI_ROOT_OBJECT) {
		start_node = acpi_gbl_root_node;
	}

	/* Avoid walking the namespace if the StartNode is NULL */

	if (!start_node) {
		return_ACPI_STATUS(AE_NO_NAMESPACE);
	}
	}

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

+0 −12
Original line number Diff line number Diff line
@@ -91,7 +91,6 @@ enum {
};

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

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

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

	mutex_lock(&battery->lock);
	status = acpi_evaluate_object(battery->device->handle, "_BST",
				      NULL, &buffer);
	mutex_unlock(&battery->lock);

	if (ACPI_FAILURE(status)) {
		acpi_handle_info(battery->device->handle,
				 "_BST evaluation failed: %s",
@@ -628,11 +622,8 @@ static int acpi_battery_set_alarm(struct acpi_battery *battery)
	    !test_bit(ACPI_BATTERY_ALARM_PRESENT, &battery->flags))
		return -ENODEV;

	mutex_lock(&battery->lock);
	status = acpi_execute_simple_method(battery->device->handle, "_BTP",
					    battery->alarm);
	mutex_unlock(&battery->lock);

	if (ACPI_FAILURE(status))
		return -ENODEV;

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

	result = devm_mutex_init(&device->dev, &battery->update_lock);
	if (result)
+17 −12
Original line number Diff line number Diff line
@@ -1280,7 +1280,7 @@ static int acpi_data_prop_read(const struct acpi_device_data *data,
		ret = acpi_copy_property_array_uint(items, (u64 *)val, nval);
		break;
	case DEV_PROP_STRING:
		nval = min_t(u32, nval, obj->package.count);
		nval = min(nval, obj->package.count);
		if (nval == 0)
			return -ENODATA;

@@ -1329,12 +1329,13 @@ static int stop_on_next(struct acpi_device *adev, void *data)
	return 0;
}

/**
/*
 * acpi_get_next_subnode - Return the next child node handle for a fwnode
 * @fwnode: Firmware node to find the next child node for.
 * @child: Handle to one of the device's child nodes or a null handle.
 */
struct fwnode_handle *acpi_get_next_subnode(const struct fwnode_handle *fwnode,
static struct fwnode_handle *
acpi_get_next_subnode(const struct fwnode_handle *fwnode,
		      struct fwnode_handle *child)
{
	struct acpi_device *adev = to_acpi_device_node(fwnode);
@@ -1472,7 +1473,7 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint(

	if (!prev) {
		do {
			port = fwnode_get_next_child_node(fwnode, port);
			port = acpi_get_next_subnode(fwnode, port);
			/*
			 * The names of the port nodes begin with "port@"
			 * followed by the number of the port node and they also
@@ -1490,14 +1491,17 @@ static struct fwnode_handle *acpi_graph_get_next_endpoint(
	if (!port)
		return NULL;

	endpoint = fwnode_get_next_child_node(port, prev);
	while (!endpoint) {
		port = fwnode_get_next_child_node(fwnode, port);
		if (!port)
	do {
		endpoint = acpi_get_next_subnode(port, prev);
		if (endpoint)
			break;
		if (is_acpi_graph_node(port, "port"))
			endpoint = fwnode_get_next_child_node(port, NULL);
	}

		prev = NULL;

		do {
			port = acpi_get_next_subnode(fwnode, port);
		} while (port && !is_acpi_graph_node(port, "port"));
	} while (port);

	/*
	 * The names of the endpoint nodes begin with "endpoint@" followed by
@@ -1714,6 +1718,7 @@ static int acpi_fwnode_graph_parse_endpoint(const struct fwnode_handle *fwnode,
	if (fwnode_property_read_u32(fwnode, "reg", &endpoint->id))
		fwnode_property_read_u32(fwnode, "endpoint", &endpoint->id);

	fwnode_handle_put(port_fwnode);
	return 0;
}

+0 −3
Original line number Diff line number Diff line
@@ -17,10 +17,7 @@ static inline acpi_status acpi_set_waking_vector(u32 wakeup_address)

extern int acpi_s2idle_begin(void);
extern int acpi_s2idle_prepare(void);
extern int acpi_s2idle_prepare_late(void);
extern void acpi_s2idle_check(void);
extern bool acpi_s2idle_wake(void);
extern void acpi_s2idle_restore_early(void);
extern void acpi_s2idle_restore(void);
extern void acpi_s2idle_end(void);

+29 −36
Original line number Diff line number Diff line
@@ -299,34 +299,13 @@ static void lpi_device_get_constraints(void)
	ACPI_FREE(out_obj);
}

/**
 * acpi_get_lps0_constraint - Get the LPS0 constraint for a device.
 * @adev: Device to get the constraint for.
 *
 * The LPS0 constraint is the shallowest (minimum) power state in which the
 * device can be so as to allow the platform as a whole to achieve additional
 * energy conservation by utilizing a system-wide low-power state.
 *
 * Returns:
 *  - ACPI power state value of the constraint for @adev on success.
 *  - Otherwise, ACPI_STATE_UNKNOWN.
 */
int acpi_get_lps0_constraint(struct acpi_device *adev)
{
	struct lpi_constraints *entry;

	for_each_lpi_constraint(entry) {
		if (adev->handle == entry->handle)
			return entry->min_dstate;
	}

	return ACPI_STATE_UNKNOWN;
}

static void lpi_check_constraints(void)
{
	struct lpi_constraints *entry;

	if (IS_ERR_OR_NULL(lpi_constraints_table))
		return;

	for_each_lpi_constraint(entry) {
		struct acpi_device *adev = acpi_fetch_acpi_dev(entry->handle);

@@ -508,11 +487,6 @@ static int lps0_device_attach(struct acpi_device *adev,

	lps0_device_handle = adev->handle;

	if (acpi_s2idle_vendor_amd())
		lpi_device_get_constraints_amd();
	else
		lpi_device_get_constraints();

	/*
	 * Use suspend-to-idle by default if ACPI_FADT_LOW_POWER_S0 is set in
	 * the FADT and the default suspend mode was not set from the command
@@ -539,7 +513,26 @@ static struct acpi_scan_handler lps0_handler = {
	.attach = lps0_device_attach,
};

int acpi_s2idle_prepare_late(void)
static int acpi_s2idle_begin_lps0(void)
{
	if (pm_debug_messages_on && !lpi_constraints_table) {
		if (acpi_s2idle_vendor_amd())
			lpi_device_get_constraints_amd();
		else
			lpi_device_get_constraints();

		/*
		 * Try to retrieve the constraints only once because failures
		 * to do so usually are sticky.
		 */
		if (!lpi_constraints_table)
			lpi_constraints_table = ERR_PTR(-ENODATA);
	}

	return acpi_s2idle_begin();
}

static int acpi_s2idle_prepare_late_lps0(void)
{
	struct acpi_s2idle_dev_ops *handler;

@@ -585,7 +578,7 @@ int acpi_s2idle_prepare_late(void)
	return 0;
}

void acpi_s2idle_check(void)
static void acpi_s2idle_check_lps0(void)
{
	struct acpi_s2idle_dev_ops *handler;

@@ -598,7 +591,7 @@ void acpi_s2idle_check(void)
	}
}

void acpi_s2idle_restore_early(void)
static void acpi_s2idle_restore_early_lps0(void)
{
	struct acpi_s2idle_dev_ops *handler;

@@ -636,12 +629,12 @@ void acpi_s2idle_restore_early(void)
}

static const struct platform_s2idle_ops acpi_s2idle_ops_lps0 = {
	.begin = acpi_s2idle_begin,
	.begin = acpi_s2idle_begin_lps0,
	.prepare = acpi_s2idle_prepare,
	.prepare_late = acpi_s2idle_prepare_late,
	.check = acpi_s2idle_check,
	.prepare_late = acpi_s2idle_prepare_late_lps0,
	.check = acpi_s2idle_check_lps0,
	.wake = acpi_s2idle_wake,
	.restore_early = acpi_s2idle_restore_early,
	.restore_early = acpi_s2idle_restore_early_lps0,
	.restore = acpi_s2idle_restore,
	.end = acpi_s2idle_end,
};
Loading