Commit 6a3cc1b7 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull ACPI fixes from Rafael Wysocki:
 "These fix issues in the ACPI CPPC library and in the recently added
  parser for the ACPI MRRM table:

   - Limit some checks in the ACPI CPPC library to online CPUs to avoid
     accessing uninitialized per-CPU variables when some CPUs are
     offline to start with, like during boot with 'nosmt=force' (Gautham
     Shenoy)

   - Rework add_boot_memory_ranges() in the ACPI MRRM table parser to
     fix memory leaks and improve error handling (Kaushlendra Kumar)"

* tag 'acpi-6.18-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  ACPI: MRRM: Fix memory leaks and improve error handling
  ACPI: CPPC: Limit perf ctrs in PCC check only to online CPUs
  ACPI: CPPC: Perform fast check switch only for online CPUs
  ACPI: CPPC: Check _CPC validity for only the online CPUs
  ACPI: CPPC: Detect preferred core availability on online CPUs
parents 9b9e4370 7564f354
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -196,7 +196,7 @@ int amd_detect_prefcore(bool *detected)
		break;
	}

	for_each_present_cpu(cpu) {
	for_each_online_cpu(cpu) {
		u32 tmp;
		int ret;

+33 −10
Original line number Diff line number Diff line
@@ -152,26 +152,49 @@ ATTRIBUTE_GROUPS(memory_range);

static __init int add_boot_memory_ranges(void)
{
	struct kobject *pkobj, *kobj;
	struct kobject *pkobj, *kobj, **kobjs;
	int ret = -EINVAL;
	char *name;
	char name[16];
	int i;

	pkobj = kobject_create_and_add("memory_ranges", acpi_kobj);
	if (!pkobj)
		return -ENOMEM;

	for (int i = 0; i < mrrm_mem_entry_num; i++) {
		name = kasprintf(GFP_KERNEL, "range%d", i);
		if (!name) {
			ret = -ENOMEM;
			break;
	kobjs = kcalloc(mrrm_mem_entry_num, sizeof(*kobjs), GFP_KERNEL);
	if (!kobjs) {
		kobject_put(pkobj);
		return -ENOMEM;
	}

	for (i = 0; i < mrrm_mem_entry_num; i++) {
		scnprintf(name, sizeof(name), "range%d", i);
		kobj = kobject_create_and_add(name, pkobj);
		if (!kobj) {
			ret = -ENOMEM;
			goto cleanup;
		}

		ret = sysfs_create_groups(kobj, memory_range_groups);
		if (ret)
			return ret;
		if (ret) {
			kobject_put(kobj);
			goto cleanup;
		}
		kobjs[i] = kobj;
	}

	kfree(kobjs);
	return 0;

cleanup:
	for (int j = 0; j < i; j++) {
		if (kobjs[j]) {
			sysfs_remove_groups(kobjs[j], memory_range_groups);
			kobject_put(kobjs[j]);
		}
	}
	kfree(kobjs);
	kobject_put(pkobj);
	return ret;
}

+3 −3
Original line number Diff line number Diff line
@@ -460,7 +460,7 @@ bool acpi_cpc_valid(void)
	if (acpi_disabled)
		return false;

	for_each_present_cpu(cpu) {
	for_each_online_cpu(cpu) {
		cpc_ptr = per_cpu(cpc_desc_ptr, cpu);
		if (!cpc_ptr)
			return false;
@@ -476,7 +476,7 @@ bool cppc_allow_fast_switch(void)
	struct cpc_desc *cpc_ptr;
	int cpu;

	for_each_present_cpu(cpu) {
	for_each_online_cpu(cpu) {
		cpc_ptr = per_cpu(cpc_desc_ptr, cpu);
		desired_reg = &cpc_ptr->cpc_regs[DESIRED_PERF];
		if (!CPC_IN_SYSTEM_MEMORY(desired_reg) &&
@@ -1435,7 +1435,7 @@ bool cppc_perf_ctrs_in_pcc(void)
{
	int cpu;

	for_each_present_cpu(cpu) {
	for_each_online_cpu(cpu) {
		struct cpc_register_resource *ref_perf_reg;
		struct cpc_desc *cpc_desc;