linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Sudeep Holla <sudeep.holla@arm.com>
To: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: anshuman.khandual@arm.com, catalin.marinas@arm.com,
	mperttunen@nvidia.com, hch@infradead.org,
	Hulk Robot <hulkci@huawei.com>,
	viresh.kumar@linaro.org, sumitg@nvidia.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH -next v2] arm64: Fix __cpu_logical_map undefined issue
Date: Mon, 27 Jul 2020 18:27:44 +0100	[thread overview]
Message-ID: <20200727172744.GD8003@bogus> (raw)
In-Reply-To: <20200727152938.28664-1-wangkefeng.wang@huawei.com>

(+ ALKML)

On Mon, Jul 27, 2020 at 11:29:38PM +0800, Kefeng Wang wrote:
> The __cpu_logical_map undefined issue occued when the new
> tegra194-cpufreq drvier building as a module.
>
> ERROR: modpost: "__cpu_logical_map" [drivers/cpufreq/tegra194-cpufreq.ko] undefined!
>
> The driver using cpu_logical_map() macro which will expand to
> __cpu_logical_map, we can't access it in a drvier. Let's turn
> cpu_logical_map() into a C wrapper and export it to fix the
> build issue.
>
> Also create a function set_cpu_logical_map(cpu, hwid) when assign
> a value to cpu_logical_map(cpu).

While I don't have any objection to this in principle, I want to avoid
exporting this if possible. I have responded to Sumit's response.

--
Regards,
Sudeep
>
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Kefeng Wang <wangkefeng.wang@huawei.com>
> ---
>  arch/arm64/include/asm/smp.h | 7 ++++++-
>  arch/arm64/kernel/setup.c    | 8 +++++++-
>  arch/arm64/kernel/smp.c      | 6 +++---
>  3 files changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm64/include/asm/smp.h b/arch/arm64/include/asm/smp.h
> index ea268d88b6f7e..f362dddd09c47 100644
> --- a/arch/arm64/include/asm/smp.h
> +++ b/arch/arm64/include/asm/smp.h
> @@ -47,7 +47,12 @@ DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
>   * Logical CPU mapping.
>   */
>  extern u64 __cpu_logical_map[NR_CPUS];
> -#define cpu_logical_map(cpu)    __cpu_logical_map[cpu]
> +extern u64 cpu_logical_map(int cpu);
> +
> +static inline void set_cpu_logical_map(int cpu, u64 hwid)
> +{
> +	__cpu_logical_map[cpu] = hwid;
> +}
>
>  struct seq_file;
>
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index c793276ec7ad9..457652de9df40 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -85,7 +85,7 @@ u64 __cacheline_aligned boot_args[4];
>  void __init smp_setup_processor_id(void)
>  {
>  	u64 mpidr = read_cpuid_mpidr() & MPIDR_HWID_BITMASK;
> -	cpu_logical_map(0) = mpidr;
> +	set_cpu_logical_map(0, mpidr);
>
>  	/*
>  	 * clear __my_cpu_offset on boot CPU to avoid hang caused by
> @@ -276,6 +276,12 @@ arch_initcall(reserve_memblock_reserved_regions);
>
>  u64 __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = INVALID_HWID };
>
> +u64 cpu_logical_map(int cpu)
> +{
> +	return __cpu_logical_map[cpu];
> +}
> +EXPORT_SYMBOL_GPL(cpu_logical_map);
> +
>  void __init setup_arch(char **cmdline_p)
>  {
>  	init_mm.start_code = (unsigned long) _text;
> diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c
> index 8059d50bc8cbc..03957a1ae6c0c 100644
> --- a/arch/arm64/kernel/smp.c
> +++ b/arch/arm64/kernel/smp.c
> @@ -566,7 +566,7 @@ acpi_map_gic_cpu_interface(struct acpi_madt_generic_interrupt *processor)
>  		return;
>
>  	/* map the logical cpu id to cpu MPIDR */
> -	cpu_logical_map(cpu_count) = hwid;
> +	set_cpu_logical_map(cpu_count, hwid);
>
>  	cpu_madt_gicc[cpu_count] = *processor;
>
> @@ -680,7 +680,7 @@ static void __init of_parse_and_init_cpus(void)
>  			goto next;
>
>  		pr_debug("cpu logical map 0x%llx\n", hwid);
> -		cpu_logical_map(cpu_count) = hwid;
> +		set_cpu_logical_map(cpu_count, hwid);
>
>  		early_map_cpu_to_node(cpu_count, of_node_to_nid(dn));
>  next:
> @@ -721,7 +721,7 @@ void __init smp_init_cpus(void)
>  	for (i = 1; i < nr_cpu_ids; i++) {
>  		if (cpu_logical_map(i) != INVALID_HWID) {
>  			if (smp_cpu_setup(i))
> -				cpu_logical_map(i) = INVALID_HWID;
> +				set_cpu_logical_map(i, INVALID_HWID);
>  		}
>  	}
>  }
> --
> 2.26.2
>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

           reply	other threads:[~2020-07-27 17:29 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20200727152938.28664-1-wangkefeng.wang@huawei.com>]

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=20200727172744.GD8003@bogus \
    --to=sudeep.holla@arm.com \
    --cc=anshuman.khandual@arm.com \
    --cc=catalin.marinas@arm.com \
    --cc=hch@infradead.org \
    --cc=hulkci@huawei.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mperttunen@nvidia.com \
    --cc=sumitg@nvidia.com \
    --cc=viresh.kumar@linaro.org \
    --cc=wangkefeng.wang@huawei.com \
    /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).