All of lore.kernel.org
 help / color / mirror / Atom feed
From: haojian.zhuang@linaro.org (Haojian Zhuang)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 07/12] ARM: hisi: add hip04 SoC support
Date: Tue, 15 Apr 2014 15:35:59 +0800	[thread overview]
Message-ID: <CAD6h2NRcQg2Gy+4rDR188r8VERqTo_YbCFZdXo-Baqcz9N+JSw@mail.gmail.com> (raw)
In-Reply-To: <20140410085052.GC22639@e106331-lin.cambridge.arm.com>

On 10 April 2014 16:50, Mark Rutland <mark.rutland@arm.com> wrote:
> On Tue, Apr 08, 2014 at 09:00:47AM +0100, Haojian Zhuang wrote:
>> Hisilicon Hi3xxx is based on Cortex A9 Core. Now HiP04 SoC is based on
>> Cortex A15 Core. Since multiple clusters is used in HiP04 SoC, it could
>> be based on MCPM.
>>
>>
>> +config ARCH_HIP04
>> +       bool "Hisilicon HiP04 Cortex A15 family" if ARCH_MULTI_V7_LPAE
>> +       select HAVE_ARM_ARCH_TIMER
>> +       select MCPM if SMP
>> +       help
>> +         Support for Hisilicon HiP04 processor family
>
> Nit: Surely this is an SoC family? The processor is Cortex-A15, as you
> state above.
>
Yes, it's SoC, not processor. I'll fix it.

>> +
>>  endmenu
>>
>>  endif
>> diff --git a/arch/arm/mach-hisi/core.h b/arch/arm/mach-hisi/core.h
>> index af23ec2..e008c7a 100644
>> --- a/arch/arm/mach-hisi/core.h
>> +++ b/arch/arm/mach-hisi/core.h
>> @@ -12,4 +12,10 @@ extern void hi3xxx_cpu_die(unsigned int cpu);
>>  extern int hi3xxx_cpu_kill(unsigned int cpu);
>>  extern void hi3xxx_set_cpu(int cpu, bool enable);
>>
>> +#define HIP04_BOOTWRAPPER_PHYS         0x10c00000
>> +#define HIP04_BOOTWRAPPER_MAGIC                0xa5a5a5a5
>> +#define HIP04_BOOTWRAPPER_SIZE         0x00010000
>
> The address and size should come from DT.
>
> What is the magic, exactly? How is it used by the kernel and
> bootwrapper?
>
Of course, I can move it into DT.

>
>> +static void __init hip04_reserve(void)
>> +{
>> +       memblock_reserve(HIP04_BOOTWRAPPER_PHYS, HIP04_BOOTWRAPPER_SIZE);
>> +}
>
> As Arnd said, do this in your DT. This is not a hardware property the
> kernel needs to statically know, but rather a system-specific property
> that needs to be in the DT such that it can vary.
>
Sure. I'll update it.

>
>> +static int hip04_mcpm_power_up(unsigned int cpu, unsigned int cluster)
>> +{
>> +       unsigned long data, mask;
>> +
>> +       if (!relocation || !sysctrl)
>> +               return -ENODEV;
>> +       if (cluster >= HIP04_MAX_CLUSTERS || cpu >= HIP04_MAX_CPUS_PER_CLUSTER)
>> +               return -EINVAL;
>> +
>> +       spin_lock(&boot_lock);
>> +       writel_relaxed(HIP04_BOOTWRAPPER_PHYS, relocation);
>> +       writel_relaxed(HIP04_BOOTWRAPPER_MAGIC, relocation + 4);
>> +       writel_relaxed(virt_to_phys(mcpm_entry_point), relocation + 8);
>
> So the kernel is poking the hardware directly to throw CPUs into a
> bootwrapper that it pokes to throw the CPUs into the kernel? That does
> not strike me as fantastic.
>
> It's a shame we have to manage coherency here at all and don't have a
> PSCI implementation to abstract this. That would mean you wouldn't need
> a machine descriptor at all, could reuse existing infrastructure, and
> you'd be able to use Hyp.
>

Do we need a firmware to support PSCI first? Up to now, I don't have
this kind of firmware.

>
>> +static void hip04_mcpm_power_down(void)
>> +{
>> +       unsigned int mpidr, cpu, cluster;
>> +       unsigned int v;
>> +
>> +       spin_lock(&boot_lock);
>> +       spin_unlock(&boot_lock);
>
> Huh? What's this for?

Actually it could be removed. Since secondary CPU is always booted up
one by one.
>
>> +       asm volatile(
>> +       "       mrc     p15, 0, %0, c1, c0, 0\n"
>> +       "       bic     %0, %0, %1\n"
>> +       "       mcr     p15, 0, %0, c1, c0, 0\n"
>> +         : "=&r" (v)
>> +         : "Ir" (CR_C)
>> +         : "cc");
>
> I don't think that cc clobber is necessary, none of these instructions
> set the flags.

Yes, I'll remove it.
>
>> +       asm volatile(
>> +       /*
>> +       * Turn off coherency
>> +       */
>> +       "       mrc     p15, 0, %0, c1, c0, 1\n"
>> +       "       bic     %0, %0, %1\n"
>> +       "       mcr     p15, 0, %0, c1, c0, 1\n"
>> +       : "=&r" (v)
>> +       : "Ir" (0x40)
>
> 0x40?

Disable SMP bit in ACTLR register.

>
>> +       : "cc");
>
> Likewise I don't think this clobber is necessary.

Yes, I'll remove it.
>
>> +static int __init hip04_mcpm_init(void)
>> +{
>> +       struct device_node *np;
>> +       int ret = -ENODEV;
>> +
>> +       np = of_find_compatible_node(NULL, NULL, "hisilicon,hip04-mcpm");
>> +       if (!np) {
>> +               pr_err("failed to find hisilicon,hip04-mcpm node\n");
>> +               goto err;
>> +       }
>
> MCPM is a Linux-specific software construct. It is not a piece of
> hardware, and not a generic interface name. Please come up with a better
> name for this that makes it clear exactly what you are describing.
>

OK. I'll use "hisilicon,core-power-control" instead.

>> +       relocation = of_iomap(np, 0);
>> +       if (!relocation) {
>> +               pr_err("failed to get relocation space\n");
>> +               ret = -ENOMEM;
>> +               goto err;
>> +       }
>> +       sysctrl = of_iomap(np, 1);
>> +       if (!sysctrl) {
>> +               pr_err("failed to get sysctrl base\n");
>> +               ret = -ENOMEM;
>> +               goto err_sysctrl;
>> +       }
>> +       fabric = of_iomap(np, 2);
>> +       if (!fabric) {
>> +               pr_err("failed to get fabric base\n");
>> +               ret = -ENOMEM;
>> +               goto err_fabric;
>> +       }
>
> These sounds like they would be better described by separate nodes.
>
OK

  reply	other threads:[~2014-04-15  7:35 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-08  8:00 [PATCH v2 00/12] Add Hisilicon HiP04 SoC Haojian Zhuang
2014-04-08  8:00 ` [PATCH v2 01/12] ARM: debug: add HiP04 debug uart Haojian Zhuang
2014-04-08  8:00 ` [PATCH v2 02/12] ARM: append ARCH_MULTI_V7_LPAE Haojian Zhuang
2014-04-08 10:59   ` Arnd Bergmann
2014-04-14  6:26     ` Haojian Zhuang
2014-04-08  8:00 ` [PATCH v2 03/12] ARM: hisi: add ARCH_HISI Haojian Zhuang
2014-04-08 11:02   ` Arnd Bergmann
2014-04-08 11:13   ` Arnd Bergmann
2014-04-14  7:57     ` Haojian Zhuang
2014-04-14  9:10       ` Arnd Bergmann
2014-04-08  8:00 ` [PATCH v2 04/12] irq: gic: use mask field in GICC_IAR Haojian Zhuang
2014-04-08  8:00 ` [PATCH v2 05/12] irq: gic: extends the cpu interface to 16 Haojian Zhuang
2014-04-10  8:12   ` Marc Zyngier
2014-04-08  8:00 ` [PATCH v2 06/12] ARM: mcpm: change max clusters to 4 Haojian Zhuang
2014-04-10  9:56   ` Dave Martin
2014-04-11  2:39     ` Nicolas Pitre
2014-04-11 14:57       ` Dave Martin
2014-04-15  6:45       ` Haojian Zhuang
2014-04-15  8:15         ` Dave Martin
2014-04-15 14:48         ` Nicolas Pitre
2014-04-08  8:00 ` [PATCH v2 07/12] ARM: hisi: add hip04 SoC support Haojian Zhuang
2014-04-08 11:10   ` Arnd Bergmann
2014-04-15  7:02     ` Haojian Zhuang
2014-04-15  7:50       ` Arnd Bergmann
2014-04-10  8:50   ` Mark Rutland
2014-04-15  7:35     ` Haojian Zhuang [this message]
2014-04-10 11:21   ` Dave Martin
2014-04-08  8:00 ` [PATCH v2 08/12] ARM: dts: add hip04-d01 dts file Haojian Zhuang
2014-04-10  9:09   ` Mark Rutland
2014-04-10 10:25   ` Dave Martin
2014-04-08  8:00 ` [PATCH v2 09/12] ARM: config: append hip04_defconfig Haojian Zhuang
2014-04-08 11:18   ` Arnd Bergmann
2014-04-08  8:00 ` [PATCH v2 10/12] ARM: config: select ARCH_HISI in hi3xxx_defconfig Haojian Zhuang
2014-04-08  8:00 ` [PATCH v2 11/12] ARM: hisi: enable erratum 798181 of A15 on HiP04 Haojian Zhuang
2014-04-08  8:00 ` [PATCH v2 12/12] ARM: dts: Add PMU support in HiP04 Haojian Zhuang

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=CAD6h2NRcQg2Gy+4rDR188r8VERqTo_YbCFZdXo-Baqcz9N+JSw@mail.gmail.com \
    --to=haojian.zhuang@linaro.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.