All of lore.kernel.org
 help / color / mirror / Atom feed
From: sudeep.holla@arm.com (Sudeep Holla)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/9] ARM: MB86S7X: Add MCPM support
Date: Tue, 25 Nov 2014 19:21:38 +0000	[thread overview]
Message-ID: <5474D6C2.7060904@arm.com> (raw)
In-Reply-To: <alpine.LFD.2.11.1411251357230.11690@knanqh.ubzr>



On 25/11/14 18:59, Nicolas Pitre wrote:
> On Tue, 25 Nov 2014, Lorenzo Pieralisi wrote:
>
>> On Tue, Nov 25, 2014 at 05:42:32PM +0000, Nicolas Pitre wrote:
>>> On Thu, 20 Nov 2014, Vincent Yang wrote:
>>>
>>>> The remote firmware(SCB) owns the SMP control. This MCPM driver gets
>>>> CPU/CLUSTER power up/down done by SCB over mailbox.
>>>>
>>>> Signed-off-by: Andy Green <andy.green@linaro.org>
>>>> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
>>>> Signed-off-by: Vincent Yang <Vincent.Yang@tw.fujitsu.com>
>>>> Signed-off-by: Tetsuya Nuriya <nuriya.tetsuya@jp.fujitsu.com>
>>>> ---
>>>>   arch/arm/mach-mb86s7x/Makefile |   2 +-
>>>>   arch/arm/mach-mb86s7x/mcpm.c   | 360 +++++++++++++++++++++++++++++++++++++++++
>>>>   arch/arm/mach-mb86s7x/smc.S    |  27 ++++
>>>>   3 files changed, 388 insertions(+), 1 deletion(-)
>>>>   create mode 100644 arch/arm/mach-mb86s7x/mcpm.c
>>>>   create mode 100644 arch/arm/mach-mb86s7x/smc.S
>>>>
>>>> diff --git a/arch/arm/mach-mb86s7x/Makefile b/arch/arm/mach-mb86s7x/Makefile
>>>> index 97640b6..b0fa34b 100644
>>>> --- a/arch/arm/mach-mb86s7x/Makefile
>>>> +++ b/arch/arm/mach-mb86s7x/Makefile
>>>> @@ -1 +1 @@
>>>> -obj-$(CONFIG_ARCH_MB86S7X)   += board.o
>>>> +obj-$(CONFIG_ARCH_MB86S7X)   += board.o mcpm.o smc.o
>>>> diff --git a/arch/arm/mach-mb86s7x/mcpm.c b/arch/arm/mach-mb86s7x/mcpm.c
>>>> new file mode 100644
>>>> index 0000000..bf1b50a
>>>> --- /dev/null
>>>> +++ b/arch/arm/mach-mb86s7x/mcpm.c
>>>> @@ -0,0 +1,360 @@
>>>> +/*
>>>> + * arch/arm/mach-mb86s7x/mcpm.c
>>>> + * Copyright:        (C) 2013-2014 Fujitsu Semiconductor Limited
>>>> + * Copyright:        (C) 2014 Linaro Ltd.
>>>> + *
>>>> + * This program is free software; you can redistribute it and/or modify
>>>> + * it under the terms of the GNU General Public License version 2 as
>>>> + * published by the Free Software Foundation.
>>>> + */
>>>> +
>>>> +#include <linux/io.h>
>>>> +#include <linux/pm.h>
>>>> +#include <linux/delay.h>
>>>> +#include <linux/cpu_pm.h>
>>>> +#include <linux/kernel.h>
>>>> +#include <linux/module.h>
>>>> +#include <linux/arm-cci.h>
>>>> +#include <linux/spinlock.h>
>>>> +#include <linux/suspend.h>
>>>> +#include <linux/of_device.h>
>>>> +#include <linux/irqchip/arm-gic.h>
>>>> +#include <linux/platform_device.h>
>>>> +
>>>> +#include <soc/mb86s7x/scb_mhu.h>
>>>> +
>>>> +#include <asm/mcpm.h>
>>>> +#include <asm/cp15.h>
>>>> +#include <asm/cputype.h>
>>>> +#include <asm/suspend.h>
>>>> +#include <asm/idmap.h>
>>>> +
>>>> +#define S7X_MAX_CLUSTER      2
>>>> +#define S7X_MAX_CPU  2
>>>> +
>>>> +#define MHU_SHM_OFFSET               0x3800
>>>> +#define WFI_COLOR_OFFSET     0x3f00
>>>> +#define TRAMPOLINE_OFFSET    0x3c00
>>>> +#define RESET_OFFSET         (TRAMPOLINE_OFFSET + 0x3fc)
>>>> +
>>>> +static arch_spinlock_t mb86s7x_pm_lock = __ARCH_SPIN_LOCK_UNLOCKED;
>>>> +static int mb86s7x_pm_use_count[S7X_MAX_CLUSTER][S7X_MAX_CPU];
>>>> +extern void __iomem *mb86s7x_shm_base;
>>>> +
>>>> +#define AT_WFI_DO_NOTHING    0x0
>>>> +#define AT_WFI_DO_SUSPEND    0x1
>>>> +#define AT_WFI_DO_POWEROFF   0x2
>>>> +#define AT_WFI_COLOR_MASK    0x3
>>>> +
>>>> +struct mb86s7x_cpu_gate {
>>>> +     u32 payload_size;
>>>> +     u32 cluster_class;
>>>> +     u32 cluster_id;
>>>> +     u32 cpu_id;
>>>> +#define SCB_CPU_STATE_OFF    0x0
>>>> +#define SCB_CPU_STATE_ON     0x1
>>>> +#define SCB_CPU_STATE_SUSP   0x2
>>>> +     u32 cpu_state;
>>>> +};
>>>> +
>>>> +asmlinkage void mb86s70evb_outer_flush_all(void)
>>>> +{
>>>> +     outer_flush_all();
>>>> +}
>>>> +
>>>> +#define mb86s70evb_exit_coherency_flush(level) { \
>>>> +     asm volatile( \
>>>> +     "stmfd  sp!, {fp, ip}\n\t" \
>>>> +     "mrc    p15, 0, r0, c1, c0, 0   @ get SCTLR\n\t" \
>>>> +     "bic    r0, r0, #"__stringify(CR_C)"\n\t" \
>>>> +     "mcr    p15, 0, r0, c1, c0, 0   @ set SCTLR\n\t" \
>>>> +     "isb\n\t" \
>>>> +     "bl     v7_flush_dcache_"__stringify(level)"\n\t" \
>>>> +     "bl     mb86s70evb_outer_flush_all\n\t" \
>>>
>>> This is wrong.  As mentioned already, this unconditionally flushes L2 in
>>> all cases which shouldn't be necessary in the "louis" case.
>>
>> Is this a bL system with unified and architected L2s ? I think so, so
>> what's the outercache for ?
>>
>>> Furthermore, the safety of this macro is ensured by not having any
>>> memory writes in the middle of the whole sequence.  By calling
>>> mb86s70evb_outer_flush_all() there could be the return address pushed
>>> onto the stack before calling outer_flush_all() if some tail call
>>> optimization is not applied.  And this is without saying what
>>> outer_flush_all() actually does.
>>>
>>> Why can't you simply do this instead:
>>>
>>>          v7_exit_coherency_flush(all);
>>>          outer_flush_all();
>>>
>>> Of course you'll have to audit everything in the outer_flush_all() path
>>> to make sure no atomic instructions such as LDREX/STREX are invoked.
>>> Those have undefined behavior after CR_C is cleared.
>>
>> What you are saying is correct but first of all I would like to
>> understand what outercache we are talking about here.
>>
>> Code snippet above is fragile, as you said, and I'd rather disable
>> the outercache before executing the power down sequence (which implies
>> cache is cleaned/invalidated and quiescent before we clear the C bit)
>> if there is an outercache to be managed.
>
> Good question.  That opens the potential for an even simpler fix!  ;-)
>
Ah right, sorry my bad somehow I assumed this is system cache at higher
level apart from the intra-cluster unified and architected L2 cache.
Now checking the DT again I don't see any outer cache controller, so
it's better to get that info.

Regards,
Sudeep

  reply	other threads:[~2014-11-25 19:21 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-20 12:27 [PATCH 0/9] Support for Fujitsu MB86S7X SoCs Vincent Yang
2014-11-20 12:27 ` Vincent Yang
2014-11-20 12:30 ` [PATCH 1/9] ARM: Add platform support " Vincent Yang
2014-11-20 12:30   ` Vincent Yang
2014-11-20 12:34 ` [PATCH 2/9] mailbox: arm_mhu: add driver for ARM MHU controller Vincent Yang
2014-11-20 12:34   ` Vincent Yang
2014-11-25 14:37   ` Sudeep Holla
2014-11-25 14:37     ` Sudeep Holla
2014-11-25 16:51     ` Jassi Brar
2014-11-25 16:51       ` Jassi Brar
2014-11-25 18:01       ` Sudeep Holla
2014-11-25 18:01         ` Sudeep Holla
2014-11-26  5:37         ` Jassi Brar
2014-11-26  5:37           ` Jassi Brar
2014-11-26  5:44           ` Andy Green
2014-11-26 14:00           ` Sudeep Holla
2014-11-26 14:00             ` Sudeep Holla
2014-11-26 16:20             ` Jassi Brar
2014-11-26 16:20               ` Jassi Brar
2014-11-26 16:38               ` Sudeep Holla
2014-11-26 16:38                 ` Sudeep Holla
2014-11-27  5:11                 ` Jassi Brar
2014-11-27  5:11                   ` Jassi Brar
2014-11-27 13:25                   ` Sudeep Holla
2014-11-27 13:25                     ` Sudeep Holla
2014-11-20 12:35 ` [PATCH 3/9] ARM: MB86S7X: Add MCPM support Vincent Yang
2014-11-21 13:02   ` Arnd Bergmann
2014-11-21 13:24     ` Jassi Brar
2014-11-25 11:48   ` Sudeep Holla
2014-11-25 13:42     ` Andy Green
2014-11-25 14:24       ` Sudeep Holla
2014-11-25 16:43         ` Andy Green
2014-11-25 17:00           ` Nicolas Pitre
2014-11-25 17:39           ` Sudeep Holla
2014-11-25 20:31             ` Andy Green
2014-11-25 17:42   ` Nicolas Pitre
2014-11-25 18:06     ` Sudeep Holla
2014-11-25 18:55       ` Nicolas Pitre
2014-11-25 18:46     ` Lorenzo Pieralisi
2014-11-25 18:59       ` Nicolas Pitre
2014-11-25 19:21         ` Sudeep Holla [this message]
2014-11-26 16:29       ` Jassi Brar
2014-11-26 17:18         ` Sudeep Holla
2014-11-27  4:59     ` Jassi Brar
2014-11-20 12:36 ` [PATCH 4/9] clk: Add clock driver for mb86s7x Vincent Yang
2014-11-20 12:36   ` Vincent Yang
2014-11-21 13:03   ` Arnd Bergmann
2014-11-21 13:03     ` Arnd Bergmann
2014-11-21 13:22     ` Jassi Brar
2014-11-21 13:22       ` Jassi Brar
2014-11-21 14:34       ` Arnd Bergmann
2014-11-21 14:34         ` Arnd Bergmann
2014-11-21 16:36         ` Jassi Brar
2014-11-21 16:36           ` Jassi Brar
2014-11-21 17:15           ` Arnd Bergmann
2014-11-21 17:15             ` Arnd Bergmann
2014-11-21 17:58             ` Jassi Brar
2014-11-21 17:58               ` Jassi Brar
2014-11-21 20:12               ` Arnd Bergmann
2014-11-21 20:12                 ` Arnd Bergmann
2014-11-20 12:37 ` [PATCH 5/9] gpio: Add Fujitsu MB86S7x GPIO driver Vincent Yang
2014-11-20 12:37   ` Vincent Yang
2014-11-27  7:33   ` Alexandre Courbot
2014-11-27  7:33     ` Alexandre Courbot
2014-12-11 16:00     ` Jassi Brar
2014-12-11 16:00       ` Jassi Brar
2014-12-03 13:32   ` Linus Walleij
2014-12-03 13:32     ` Linus Walleij
2014-12-11 16:01     ` Jassi Brar
2014-12-11 16:01       ` Jassi Brar
2014-11-20 12:38 ` [PATCH 6/9] mmc: sdhci: host: add new f_sdh30 Vincent Yang
2014-11-20 12:38   ` Vincent Yang
2014-11-20 15:22   ` Rob Herring
2014-11-20 15:22     ` Rob Herring
2014-11-20 16:59     ` Vincent Yang
2014-11-20 16:59       ` Vincent Yang
2014-11-20 18:18       ` Rob Herring
2014-11-20 18:18         ` Rob Herring
2014-11-21  1:18         ` Vincent Yang
2014-11-21  1:18           ` Vincent Yang
2014-11-20 12:38 ` [PATCH 7/9] dt: mb86s7x: add dt files for MB86S7x evbs Vincent Yang
2014-11-20 12:38   ` Vincent Yang
2014-11-21 14:26   ` Arnd Bergmann
2014-11-21 14:26     ` Arnd Bergmann
2014-11-21 16:49     ` Jassi Brar
2014-11-21 16:49       ` Jassi Brar
2014-11-21 17:09       ` Arnd Bergmann
2014-11-21 17:09         ` Arnd Bergmann
2014-11-21 17:35         ` Jassi Brar
2014-11-21 17:35           ` Jassi Brar
2014-11-21 20:14           ` Arnd Bergmann
2014-11-21 20:14             ` Arnd Bergmann
2014-11-20 12:39 ` [PATCH 8/9] of: add Fujitsu vendor prefix Vincent Yang
2014-11-20 12:39   ` Vincent Yang
2014-11-20 15:07   ` Rob Herring
2014-11-20 15:07     ` Rob Herring
2014-11-20 12:40 ` [PATCH 9/9] ARM: MB86S7x: Add configs Vincent Yang

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=5474D6C2.7060904@arm.com \
    --to=sudeep.holla@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 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.