Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

Merge branch 'acpi-processor'

* acpi-processor:
  ACPI / processor: fixed a brace coding style issue
  ACPI / processor: Remove outdated comments
  ACPI / processor: remove unnecessary if (!pr) check
  ACPI / processor: remove some dead code in acpi_processor_get_info()
  x86 / ACPI: simplify _acpi_map_lsapic()
  ACPI / processor: use apic_id and remove duplicated _MAT evaluation
  ACPI / processor: Introduce apic_id in struct processor to save parsed APIC id
parents 8e32e47d 764d0221
Loading
Loading
Loading
Loading
+4 −34
Original line number Diff line number Diff line
@@ -882,40 +882,10 @@ __init void prefill_possible_map(void)
		set_cpu_possible(i, true);
}

static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
{
	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
	union acpi_object *obj;
	struct acpi_madt_local_sapic *lsapic;
	cpumask_t tmp_map;
	int cpu, physid;

	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
		return -EINVAL;

	if (!buffer.length || !buffer.pointer)
		return -EINVAL;

	obj = buffer.pointer;
	if (obj->type != ACPI_TYPE_BUFFER)
	{
		kfree(buffer.pointer);
		return -EINVAL;
	}

	lsapic = (struct acpi_madt_local_sapic *)obj->buffer.pointer;

	if ((lsapic->header.type != ACPI_MADT_TYPE_LOCAL_SAPIC) ||
	    (!(lsapic->lapic_flags & ACPI_MADT_ENABLED))) {
		kfree(buffer.pointer);
		return -EINVAL;
	}

	physid = ((lsapic->id << 8) | (lsapic->eid));

	kfree(buffer.pointer);
	buffer.length = ACPI_ALLOCATE_BUFFER;
	buffer.pointer = NULL;
	int cpu;

	cpumask_complement(&tmp_map, cpu_present_mask);
	cpu = cpumask_first(&tmp_map);
@@ -934,9 +904,9 @@ static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
}

/* wrapper to silence section mismatch warning */
int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
{
	return _acpi_map_lsapic(handle, pcpu);
	return _acpi_map_lsapic(handle, physid, pcpu);
}
EXPORT_SYMBOL(acpi_map_lsapic);

+1 −1
Original line number Diff line number Diff line
@@ -94,7 +94,7 @@ static inline void early_reserve_e820_mpc_new(void) { }
#define default_get_smp_config x86_init_uint_noop
#endif

void generic_processor_info(int apicid, int version);
int generic_processor_info(int apicid, int version);
#ifdef CONFIG_ACPI
extern void mp_register_ioapic(int id, u32 address, u32 gsi_base);
extern void mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger,
+19 −69
Original line number Diff line number Diff line
@@ -189,24 +189,31 @@ static int __init acpi_parse_madt(struct acpi_table_header *table)
	return 0;
}

static void acpi_register_lapic(int id, u8 enabled)
/**
 * acpi_register_lapic - register a local apic and generates a logic cpu number
 * @id: local apic id to register
 * @enabled: this cpu is enabled or not
 *
 * Returns the logic cpu number which maps to the local apic
 */
static int acpi_register_lapic(int id, u8 enabled)
{
	unsigned int ver = 0;

	if (id >= MAX_LOCAL_APIC) {
		printk(KERN_INFO PREFIX "skipped apicid that is too big\n");
		return;
		return -EINVAL;
	}

	if (!enabled) {
		++disabled_cpus;
		return;
		return -EINVAL;
	}

	if (boot_cpu_physical_apicid != -1U)
		ver = apic_version[boot_cpu_physical_apicid];

	generic_processor_info(id, ver);
	return generic_processor_info(id, ver);
}

static int __init
@@ -614,84 +621,27 @@ static void acpi_map_cpu2node(acpi_handle handle, int cpu, int physid)
#endif
}

static int _acpi_map_lsapic(acpi_handle handle, int *pcpu)
static int _acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
{
	struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
	union acpi_object *obj;
	struct acpi_madt_local_apic *lapic;
	cpumask_var_t tmp_map, new_map;
	u8 physid;
	int cpu;
	int retval = -ENOMEM;

	if (ACPI_FAILURE(acpi_evaluate_object(handle, "_MAT", NULL, &buffer)))
		return -EINVAL;

	if (!buffer.length || !buffer.pointer)
		return -EINVAL;

	obj = buffer.pointer;
	if (obj->type != ACPI_TYPE_BUFFER ||
	    obj->buffer.length < sizeof(*lapic)) {
		kfree(buffer.pointer);
		return -EINVAL;
	}

	lapic = (struct acpi_madt_local_apic *)obj->buffer.pointer;

	if (lapic->header.type != ACPI_MADT_TYPE_LOCAL_APIC ||
	    !(lapic->lapic_flags & ACPI_MADT_ENABLED)) {
		kfree(buffer.pointer);
		return -EINVAL;
	}

	physid = lapic->id;

	kfree(buffer.pointer);
	buffer.length = ACPI_ALLOCATE_BUFFER;
	buffer.pointer = NULL;
	lapic = NULL;

	if (!alloc_cpumask_var(&tmp_map, GFP_KERNEL))
		goto out;

	if (!alloc_cpumask_var(&new_map, GFP_KERNEL))
		goto free_tmp_map;

	cpumask_copy(tmp_map, cpu_present_mask);
	acpi_register_lapic(physid, ACPI_MADT_ENABLED);

	/*
	 * If acpi_register_lapic successfully generates a new logical cpu
	 * number, then the following will get us exactly what was mapped
	 */
	cpumask_andnot(new_map, cpu_present_mask, tmp_map);
	if (cpumask_empty(new_map)) {
		printk ("Unable to map lapic to logical cpu number\n");
		retval = -EINVAL;
		goto free_new_map;
	cpu = acpi_register_lapic(physid, ACPI_MADT_ENABLED);
	if (cpu < 0) {
		pr_info(PREFIX "Unable to map lapic to logical cpu number\n");
		return cpu;
	}

	acpi_processor_set_pdc(handle);

	cpu = cpumask_first(new_map);
	acpi_map_cpu2node(handle, cpu, physid);

	*pcpu = cpu;
	retval = 0;

free_new_map:
	free_cpumask_var(new_map);
free_tmp_map:
	free_cpumask_var(tmp_map);
out:
	return retval;
	return 0;
}

/* wrapper to silence section mismatch warning */
int __ref acpi_map_lsapic(acpi_handle handle, int *pcpu)
int __ref acpi_map_lsapic(acpi_handle handle, int physid, int *pcpu)
{
	return _acpi_map_lsapic(handle, pcpu);
	return _acpi_map_lsapic(handle, physid, pcpu);
}
EXPORT_SYMBOL(acpi_map_lsapic);

+5 −3
Original line number Diff line number Diff line
@@ -2107,7 +2107,7 @@ void disconnect_bsp_APIC(int virt_wire_setup)
	apic_write(APIC_LVT1, value);
}

void generic_processor_info(int apicid, int version)
int generic_processor_info(int apicid, int version)
{
	int cpu, max = nr_cpu_ids;
	bool boot_cpu_detected = physid_isset(boot_cpu_physical_apicid,
@@ -2127,7 +2127,7 @@ void generic_processor_info(int apicid, int version)
			"  Processor %d/0x%x ignored.\n", max, thiscpu, apicid);

		disabled_cpus++;
		return;
		return -ENODEV;
	}

	if (num_processors >= nr_cpu_ids) {
@@ -2138,7 +2138,7 @@ void generic_processor_info(int apicid, int version)
			"  Processor %d/0x%x ignored.\n", max, thiscpu, apicid);

		disabled_cpus++;
		return;
		return -EINVAL;
	}

	num_processors++;
@@ -2183,6 +2183,8 @@ void generic_processor_info(int apicid, int version)
#endif
	set_cpu_possible(cpu, true);
	set_cpu_present(cpu, true);

	return cpu;
}

int hard_smp_processor_id(void)
+6 −16
Original line number Diff line number Diff line
@@ -140,15 +140,11 @@ static int acpi_processor_errata_piix4(struct pci_dev *dev)
	return 0;
}

static int acpi_processor_errata(struct acpi_processor *pr)
static int acpi_processor_errata(void)
{
	int result = 0;
	struct pci_dev *dev = NULL;


	if (!pr)
		return -EINVAL;

	/*
	 * PIIX4
	 */
@@ -181,7 +177,7 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
	cpu_maps_update_begin();
	cpu_hotplug_begin();

	ret = acpi_map_lsapic(pr->handle, &pr->id);
	ret = acpi_map_lsapic(pr->handle, pr->apic_id, &pr->id);
	if (ret)
		goto out;

@@ -221,10 +217,7 @@ static int acpi_processor_get_info(struct acpi_device *device)
	static int cpu0_initialized;
	unsigned long long value;

	if (num_online_cpus() > 1)
		errata.smp = TRUE;

	acpi_processor_errata(pr);
	acpi_processor_errata();

	/*
	 * Check to see if we have bus mastering arbitration control.  This
@@ -248,11 +241,6 @@ static int acpi_processor_get_info(struct acpi_device *device)
			return -ENODEV;
		}

		/*
		 * TBD: Synch processor ID (via LAPIC/LSAPIC structures) on SMP.
		 *      >>> 'acpi_get_processor_id(acpi_id, &id)' in
		 *      arch/xxx/acpi.c
		 */
		pr->acpi_id = object.processor.proc_id;
	} else {
		/*
@@ -270,7 +258,9 @@ static int acpi_processor_get_info(struct acpi_device *device)
		device_declaration = 1;
		pr->acpi_id = value;
	}
	cpu_index = acpi_get_cpuid(pr->handle, device_declaration, pr->acpi_id);
	pr->apic_id = acpi_get_apicid(pr->handle, device_declaration,
					pr->acpi_id);
	cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);

	/* Handle UP system running SMP kernel, with no LAPIC in MADT */
	if (!cpu0_initialized && (cpu_index == -1) &&
Loading