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

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
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -985,7 +985,7 @@ int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu,
		memcpy(&info->states[++last_index], &cx, sizeof(cx));
	}

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

	info->count = last_index;

+11 −28
Original line number Diff line number Diff line
@@ -10,7 +10,6 @@

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

#include <linux/async.h>
#include <linux/delay.h>
#include <linux/dmi.h>
#include <linux/jiffies.h>
@@ -50,8 +49,6 @@ MODULE_AUTHOR("Alexey Starikovskiy <astarikovskiy@suse.de>");
MODULE_DESCRIPTION("ACPI Battery Driver");
MODULE_LICENSE("GPL");

static async_cookie_t async_cookie;
static bool battery_driver_registered;
static int battery_bix_broken_package;
static int battery_notification_delay_ms;
static int battery_ac_is_broken;
@@ -1207,7 +1204,7 @@ static int acpi_battery_update_retry(struct acpi_battery *battery)
static int acpi_battery_add(struct acpi_device *device)
{
	int result = 0;
	struct acpi_battery *battery = NULL;
	struct acpi_battery *battery;

	if (!device)
		return -EINVAL;
@@ -1219,8 +1216,8 @@ static int acpi_battery_add(struct acpi_device *device)
	if (!battery)
		return -ENOMEM;
	battery->device = device;
	strcpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
	strcpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
	strscpy(acpi_device_name(device), ACPI_BATTERY_DEVICE_NAME);
	strscpy(acpi_device_class(device), ACPI_BATTERY_CLASS);
	device->driver_data = battery;
	mutex_init(&battery->lock);
	mutex_init(&battery->sysfs_lock);
@@ -1260,7 +1257,7 @@ static int acpi_battery_add(struct acpi_device *device)

static void acpi_battery_remove(struct acpi_device *device)
{
	struct acpi_battery *battery = NULL;
	struct acpi_battery *battery;

	if (!device || !acpi_driver_data(device))
		return;
@@ -1311,38 +1308,24 @@ static struct acpi_driver acpi_battery_driver = {
		.remove = acpi_battery_remove,
		},
	.drv.pm = &acpi_battery_pm,
	.drv.probe_type = PROBE_PREFER_ASYNCHRONOUS,
};

static void __init acpi_battery_init_async(void *unused, async_cookie_t cookie)
{
	int result;

	if (acpi_quirk_skip_acpi_ac_and_battery())
		return;

	dmi_check_system(bat_dmi_table);

	result = acpi_bus_register_driver(&acpi_battery_driver);
	battery_driver_registered = (result == 0);
}

static int __init acpi_battery_init(void)
{
	if (acpi_disabled)
	if (acpi_disabled || acpi_quirk_skip_acpi_ac_and_battery())
		return -ENODEV;

	async_cookie = async_schedule(acpi_battery_init_async, NULL);
	return 0;
	dmi_check_system(bat_dmi_table);

	return acpi_bus_register_driver(&acpi_battery_driver);
}

static void __exit acpi_battery_exit(void)
{
	async_synchronize_cookie(async_cookie + 1);
	if (battery_driver_registered) {
	acpi_bus_unregister_driver(&acpi_battery_driver);
	battery_hook_exit();
}
}

module_init(acpi_battery_init);
module_exit(acpi_battery_exit);
+48 −5
Original line number Diff line number Diff line
@@ -103,6 +103,11 @@ static DEFINE_PER_CPU(struct cpc_desc *, cpc_desc_ptr);
				(cpc)->cpc_entry.reg.space_id ==	\
				ACPI_ADR_SPACE_PLATFORM_COMM)

/* Check if a CPC register is in FFH */
#define CPC_IN_FFH(cpc) ((cpc)->type == ACPI_TYPE_BUFFER &&		\
				(cpc)->cpc_entry.reg.space_id ==	\
				ACPI_ADR_SPACE_FIXED_HARDWARE)

/* Check if a CPC register is in SystemMemory */
#define CPC_IN_SYSTEM_MEMORY(cpc) ((cpc)->type == ACPI_TYPE_BUFFER &&	\
				(cpc)->cpc_entry.reg.space_id ==	\
@@ -171,8 +176,11 @@ show_cppc_data(cppc_get_perf_ctrs, cppc_perf_fb_ctrs, wraparound_time);
#define GET_BIT_WIDTH(reg) ((reg)->access_width ? (8 << ((reg)->access_width - 1)) : (reg)->bit_width)

/* Shift and apply the mask for CPC reads/writes */
#define MASK_VAL(reg, val) (((val) >> (reg)->bit_offset) & 			\
#define MASK_VAL_READ(reg, val) (((val) >> (reg)->bit_offset) &				\
					GENMASK(((reg)->bit_width) - 1, 0))
#define MASK_VAL_WRITE(reg, prev_val, val)						\
	((((val) & GENMASK(((reg)->bit_width) - 1, 0)) << (reg)->bit_offset) |		\
	((prev_val) & ~(GENMASK(((reg)->bit_width) - 1, 0) << (reg)->bit_offset)))	\

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

	/* Store CPU Logical ID */
	cpc_ptr->cpu_id = pr->id;
	spin_lock_init(&cpc_ptr->rmw_lock);

	/* Parse PSD data for this CPU */
	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)
	}

	if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
		*val = MASK_VAL(reg, *val);
		*val = MASK_VAL_READ(reg, *val);

	return 0;
}
@@ -1073,9 +1082,11 @@ static int cpc_write(int cpu, struct cpc_register_resource *reg_res, u64 val)
{
	int ret_val = 0;
	int size;
	u64 prev_val;
	void __iomem *vaddr = NULL;
	int pcc_ss_id = per_cpu(cpu_pcc_subspace_idx, cpu);
	struct cpc_reg *reg = &reg_res->cpc_entry.reg;
	struct cpc_desc *cpc_desc;

	size = GET_BIT_WIDTH(reg);

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

	if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
		val = MASK_VAL(reg, val);
	if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY) {
		cpc_desc = per_cpu(cpc_desc_ptr, cpu);
		if (!cpc_desc) {
			pr_debug("No CPC descriptor for CPU:%d\n", cpu);
			return -ENODEV;
		}

		spin_lock(&cpc_desc->rmw_lock);
		switch (size) {
		case 8:
			prev_val = readb_relaxed(vaddr);
			break;
		case 16:
			prev_val = readw_relaxed(vaddr);
			break;
		case 32:
			prev_val = readl_relaxed(vaddr);
			break;
		case 64:
			prev_val = readq_relaxed(vaddr);
			break;
		default:
			spin_unlock(&cpc_desc->rmw_lock);
			return -EFAULT;
		}
		val = MASK_VAL_WRITE(reg, prev_val, val);
		val |= prev_val;
	}

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

	if (reg->space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY)
		spin_unlock(&cpc_desc->rmw_lock);

	return ret_val;
}

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

	return ret;
+2 −4
Original line number Diff line number Diff line
@@ -376,10 +376,8 @@ static int tps68470_pmic_opregion_probe(struct platform_device *pdev)
	struct tps68470_pmic_opregion *opregion;
	acpi_status status;

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

	if (!handle) {
		dev_warn(dev, "acpi handle is NULL\n");
+2 −0
Original line number Diff line number Diff line
@@ -64,6 +64,8 @@ struct cpc_desc {
	int cpu_id;
	int write_cmd_status;
	int write_cmd_id;
	/* Lock used for RMW operations in cpc_write() */
	spinlock_t rmw_lock;
	struct cpc_register_resource cpc_regs[MAX_CPC_REG_ENT];
	struct acpi_psd_package domain_info;
	struct kobject kobj;