linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: catalin.marinas@arm.com (Catalin Marinas)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 06/18] ARM64 / ACPI: Parse MADT to map logical cpu to MPIDR and get cpu_possible/present_map
Date: Mon, 18 Aug 2014 15:27:28 +0100	[thread overview]
Message-ID: <20140818142728.GS20043@localhost> (raw)
In-Reply-To: <1407166105-17675-7-git-send-email-hanjun.guo@linaro.org>

On Mon, Aug 04, 2014 at 04:28:13PM +0100, Hanjun Guo wrote:
> diff --git a/arch/arm64/include/asm/acpi.h b/arch/arm64/include/asm/acpi.h
> index 6e04868..e877967 100644
> --- a/arch/arm64/include/asm/acpi.h
> +++ b/arch/arm64/include/asm/acpi.h
> @@ -64,6 +64,8 @@ static inline void arch_fix_phys_package_id(int num, u32 slot) { }
>  extern int (*acpi_suspend_lowlevel)(void);
>  #define acpi_wakeup_address 0
>  
> +#define MAX_GIC_CPU_INTERFACE 65535

Does this need to be more than NR_CPUS?

> +/**
> + * acpi_register_gic_cpu_interface - register a gic cpu interface and
> + * generates a logical cpu number
> + * @mpidr: CPU's hardware id to register, MPIDR represented in MADT
> + * @enabled: this cpu is enabled or not
> + *
> + * Returns the logical cpu number which maps to the gic cpu interface
> + */
> +static int acpi_register_gic_cpu_interface(u64 mpidr, u8 enabled)
> +{
> +	int cpu;
> +
> +	if (mpidr == INVALID_HWID) {
> +		pr_info("Skip invalid cpu hardware ID\n");
> +		return -EINVAL;
> +	}
> +
> +	total_cpus++;
> +	if (!enabled)
> +		return -EINVAL;
> +
> +	if (enabled_cpus >=  NR_CPUS) {
> +		pr_warn("NR_CPUS limit of %d reached, Processor %d/0x%llx ignored.\n",
> +			NR_CPUS, total_cpus, mpidr);
> +		return -EINVAL;
> +	}
> +
> +	/* If it is the first CPU, no need to check duplicate MPIDRs */
> +	if (!enabled_cpus)
> +		goto skip_mpidr_check;
> +
> +	/*
> +	 * Duplicate MPIDRs are a recipe for disaster. Scan
> +	 * all initialized entries and check for
> +	 * duplicates. If any is found just ignore the CPU.
> +	 */
> +	for_each_present_cpu(cpu) {
> +		if (cpu_logical_map(cpu) == mpidr) {
> +			pr_err("Firmware bug, duplicate CPU MPIDR: 0x%llx in MADT\n",
> +			       mpidr);
> +			return -EINVAL;
> +		}
> +	}
> +
> +skip_mpidr_check:
> +	enabled_cpus++;
> +
> +	/* allocate a logical cpu id for the new comer */
> +	if (cpu_logical_map(0) == mpidr) {
> +		/*
> +		 * boot_cpu_init() already hold bit 0 in cpu_present_mask
> +		 * for BSP, no need to allocate again.
> +		 */
> +		cpu = 0;
> +	} else {
> +		cpu = cpumask_next_zero(-1, cpu_present_mask);
> +	}
> +
> +	/* map the logical cpu id to cpu MPIDR */
> +	cpu_logical_map(cpu) = mpidr;
> +
> +	set_cpu_possible(cpu, true);
> +	set_cpu_present(cpu, true);
> +
> +	return cpu;
> +}

Why not only set the cpu possible here (with the additional mpidr
validity checks changed to for_each_possible_cpu)...

> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index 40f38f4..8f1d37c 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -36,6 +36,7 @@
>  #include <linux/completion.h>
>  #include <linux/of.h>
>  #include <linux/irq_work.h>
> +#include <linux/acpi.h>
>  
>  #include <asm/atomic.h>
>  #include <asm/cacheflush.h>
> @@ -458,7 +459,14 @@ void __init smp_prepare_cpus(unsigned int max_cpus)
>  		if (err)
>  			continue;
>  
> -		set_cpu_present(cpu, true);
> +		/*
> +		 * In ACPI mode, cpu_present_map was initialised when
> +		 * MADT table was parsed which before this function
> +		 * is called.
> +		 */
> +		if (acpi_disabled)
> +			set_cpu_present(cpu, true);
> +
>  		max_cpus--;

... and don't touch this at all.

-- 
Catalin

  reply	other threads:[~2014-08-18 14:27 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-04 15:28 [PATCH v2 00/18] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 01/18] ARM64: Move the init of cpu_logical_map(0) before unflatten_device_tree() Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 02/18] ARM64 / ACPI: Get RSDP and ACPI boot-time tables Hanjun Guo
2014-08-18 18:30   ` Sudeep Holla
2014-08-19  9:35     ` Hanjun Guo
2014-08-19  9:47       ` Sudeep Holla
2014-08-04 15:28 ` [PATCH v2 03/18] ARM64 / ACPI: Introduce lowlevel suspend function Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 04/18] ARM64 / ACPI: Make PCI optional for ACPI on ARM64 Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 05/18] ARM64 / ACPI: Parse FADT table to get PSCI flags for PSCI init Hanjun Guo
2014-08-18 14:27   ` Catalin Marinas
2014-08-19  3:50     ` Hanjun Guo
2014-08-19 11:10       ` Mark Rutland
2014-08-19 12:13         ` Hanjun Guo
2014-08-19 22:55           ` Moore, Robert
2014-08-20  4:12             ` Hanjun Guo
2014-08-18 18:32   ` Sudeep Holla
2014-08-19 10:39     ` Hanjun Guo
2014-08-19 11:07       ` Sudeep Holla
2014-08-04 15:28 ` [PATCH v2 06/18] ARM64 / ACPI: Parse MADT to map logical cpu to MPIDR and get cpu_possible/present_map Hanjun Guo
2014-08-18 14:27   ` Catalin Marinas [this message]
2014-08-19  7:36     ` Hanjun Guo
2014-08-20 14:38       ` Catalin Marinas
2014-08-21  2:51         ` Hanjun Guo
2014-08-18 18:33   ` Sudeep Holla
2014-08-19 11:00     ` Hanjun Guo
2014-08-19 16:46       ` [Linaro-acpi] " Zi Shen Lim
2014-08-20  3:24         ` Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 07/18] ACPI / table: Print GIC information when MADT is parsed Hanjun Guo
2014-08-07  1:41   ` Zheng, Lv
2014-08-07 10:28     ` Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 08/18] ARM64 / ACPI: Get the enable method for SMP initialization in ACPI way Hanjun Guo
2014-08-18 14:27   ` Catalin Marinas
2014-08-19  8:32     ` Hanjun Guo
2014-08-20 14:52       ` Catalin Marinas
2014-08-21  3:06         ` Hanjun Guo
2014-08-18 18:34   ` Sudeep Holla
2014-08-19 11:26     ` Hanjun Guo
2014-08-18 18:56   ` Geoff Levand
2014-08-19 12:11     ` Hanjun Guo
2014-08-19 19:25       ` Geoff Levand
2014-08-20  3:25         ` Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 09/18] ACPI / processor: Make it possible to get CPU hardware ID via GICC Hanjun Guo
2014-08-18 14:27   ` Catalin Marinas
2014-08-19  8:37     ` Hanjun Guo
2014-08-20 14:56       ` Catalin Marinas
2014-08-21  3:25         ` Hanjun Guo
2014-08-18 18:34   ` Sudeep Holla
2014-08-19 11:29     ` Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 10/18] ARM64 / ACPI: Introduce ACPI_IRQ_MODEL_GIC and register device's gsi Hanjun Guo
2014-08-18 18:34   ` Sudeep Holla
2014-08-19 11:36     ` Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 11/18] ACPI / table: Add new function to get table entries Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 12/18] ARM64 / ACPI: Add GICv2 specific ACPI boot support Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 13/18] ARM64 / ACPI: Parse GTDT to initialize arch timer Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 14/18] ARM64 / ACPI: Select ACPI_REDUCED_HARDWARE_ONLY if ACPI is enabled on ARM64 Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 15/18] ARM64 / ACPI: Introduce early_param for "acpi" and set ACPI default off Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 16/18] ARM64 / ACPI: If we chose to boot from acpi then disable FDT Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 17/18] ARM64 / ACPI: Enable ARM64 in Kconfig Hanjun Guo
2014-08-18 14:27   ` Catalin Marinas
2014-08-19  8:38     ` Hanjun Guo
2014-08-04 15:28 ` [PATCH v2 18/18] Documentation: ACPI for ARM64 Hanjun Guo
2014-08-04 20:48   ` Randy Dunlap
2014-08-05  3:36     ` Hanjun Guo
     [not found] ` <CAJRNFK+UfJhGR65tOecy=X+YdHQHiNPZ4p_p8LUxhRL3GW5gFw@mail.gmail.com>
2014-08-05  3:34   ` [Linaro-acpi] [PATCH v2 00/18] Introduce ACPI for ARM64 based on ACPI 5.1 Hanjun Guo
2014-08-18 17:08     ` Alexander Spyridakis
2014-08-18 18:11       ` Graeme Gregory

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140818142728.GS20043@localhost \
    --to=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).