From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752758AbcHZMfH (ORCPT ); Fri, 26 Aug 2016 08:35:07 -0400 Received: from mail-db5eur01on0049.outbound.protection.outlook.com ([104.47.2.49]:27383 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751014AbcHZMfF (ORCPT ); Fri, 26 Aug 2016 08:35:05 -0400 X-Greylist: delayed 6672 seconds by postgrey-1.27 at vger.kernel.org; Fri, 26 Aug 2016 08:35:05 EDT From: Yongcai Huang To: Russell King - ARM Linux CC: "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "shawnguo@kernel.org" , "kernel@pengutronix.de" , Fabio Estevam , "robh+dt@kernel.org" , "mark.rutland@arm.com" Subject: RE: [PATCH 3/3] ARM: imx: add SMP support for i.MX7D Thread-Topic: [PATCH 3/3] ARM: imx: add SMP support for i.MX7D Thread-Index: AQHR/0m8REtIaHPNrU+vEjd14XL3VaBbF0yAgAARCUA= Date: Fri, 26 Aug 2016 12:20:15 +0000 Message-ID: References: <1472209971-32469-1-git-send-email-Anson.Huang@nxp.com> <1472209971-32469-4-git-send-email-Anson.Huang@nxp.com> <20160826111356.GM1041@n2100.armlinux.org.uk> In-Reply-To: <20160826111356.GM1041@n2100.armlinux.org.uk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=anson.huang@nxp.com; x-originating-ip: [199.59.231.64] x-ms-office365-filtering-correlation-id: d9335330-c902-45f1-00e0-08d3cdab563e x-microsoft-exchange-diagnostics: 1;VI1PR0402MB2750;6:BsU0gJ2uIKwR+6UguOEUGCBgrb+9ukkhNOUOiFOp+scSvR/J2ZsFM0JKgDbGbX8wKbm7QenR/BaMdXJwT18SsZcKyDlsYT0sh4x2WtnM/NYchnhWnaqyg2rawwTWNPqofN5TFOqyQJmHBX2P9PyclL8fb3gjDWJaYiWmhfEGmkH9k0MyZJpvLO8W2enVq/HuuIslyvPeSvSrfJqTttGtGJlXRhRa8P4yWLClS/nWwPJcXOy0qLJPr3kTwSUnsq8MkjEAyaw79HUpYxjVVOGb4vF7WfXkMgqFMJE9RzksGd2Fnh5H66khWfp6eu1DSeNh2EvWdUzgpwRYfi/+pi2Rng==;5:6un7pypoRg0vRbKf2Hl4TiiC4XDJbk37/rINu9GCgeBjGYIJXZZD8YhWjE2o8xSvsnRTOyPTxuoxRQmQAxw0d0s5FWPYueWMktAvWZEHzLkvtmytIaraAJmNXbtLbdMSWldq6YDJGPkMlu3l2KbV+g==;24:x/fsxKyaH/f+XAd/4ETgqonP/UCksLkMXKe66HE78sLDnyCNWvX2b4PsEgUBUgEmauGa4RX24qyhQ72Kb2VrEZvxDtFCiFAJ03+cfvf9mL4=;7:XxcokwjHcqCafnU4AhK4RwGb1SU0BeXAq/Fcq88XEd1fkRNH5caGqhc9r/pgZk4mDDTBVhHNTU41Dszu8lsWGqf4WjBp/YtfVtDZECshIPJai7jvlwqrPhAcWWKLBrKJXl39/+Lzl1wapDrljVRpsV/t4xhsT24tOnRrcoVdLgvQ6jpGjyfo17X/YNIlz62MyLWSAYPZN+Zh/DvRwDqJ2Cj8EvD5tPwRmSKt/6I4vAfibFg+1RBq1nRcb+0X3Uk2 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0402MB2750; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917)(9452136761055)(185117386973197)(788757137089)(258649278758335); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6055026);SRVR:VI1PR0402MB2750;BCL:0;PCL:0;RULEID:;SRVR:VI1PR0402MB2750; x-forefront-prvs: 00462943DE x-forefront-antispam-report: SFV:NSPM;SFS:(10009020)(6009001)(7916002)(24454002)(377424004)(377454003)(189002)(199003)(13464003)(19580405001)(101416001)(575784001)(110136002)(189998001)(5002640100001)(68736007)(5250100002)(87936001)(86362001)(97736004)(76176999)(54356999)(5660300001)(106116001)(106356001)(105586002)(33656002)(9686002)(92566002)(586003)(74316002)(3660700001)(76576001)(50986999)(66066001)(19580395003)(3280700002)(102836003)(6116002)(81166006)(305945005)(2950100001)(7736002)(15975445007)(8676002)(7696003)(8936002)(7846002)(81156014)(4326007)(3846002)(2900100001)(2906002)(21314002);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR0402MB2750;H:AM3PR04MB1315.eurprd04.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Aug 2016 12:20:15.8526 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB2750 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by mail.home.local id u7QCZBe8010582 Best Regards! Anson Huang > -----Original Message----- > From: Russell King - ARM Linux [mailto:linux@armlinux.org.uk] > Sent: 2016-08-26 7:14 PM > To: Yongcai Huang > Cc: linux-arm-kernel@lists.infradead.org; devicetree@vger.kernel.org; linux- > kernel@vger.kernel.org; shawnguo@kernel.org; kernel@pengutronix.de; > Fabio Estevam ; robh+dt@kernel.org; > mark.rutland@arm.com > Subject: Re: [PATCH 3/3] ARM: imx: add SMP support for i.MX7D > > On Fri, Aug 26, 2016 at 07:12:51PM +0800, Anson Huang wrote: > > i.MX7D has 2 cortex-a7 ARM core, add support for booting up SMP kernel > > with 2 CPUs. > > > > The existing i.MX SMP code is designed for i.MX6 series SoCs which > > have cortex-a9 ARM core, but i.MX7D has 2 cortex-a7 ARM core, so we > > need to add runtime check for those differences between cortex-a9 and > > cortex-a7. > > > > Signed-off-by: Anson Huang > > --- > > arch/arm/mach-imx/headsmp.S | 11 +++++++++++ > > arch/arm/mach-imx/mach-imx7d.c | 2 ++ > > arch/arm/mach-imx/platsmp.c | 19 ++++++++++++++++++- > > arch/arm/mach-imx/src.c | 38 ++++++++++++++++++++++++++++++---- > ---- > > 4 files changed, 61 insertions(+), 9 deletions(-) > > > > diff --git a/arch/arm/mach-imx/headsmp.S b/arch/arm/mach- > imx/headsmp.S > > index 6c28d28..a26e459 100644 > > --- a/arch/arm/mach-imx/headsmp.S > > +++ b/arch/arm/mach-imx/headsmp.S > > @@ -26,7 +26,18 @@ diag_reg_offset: > > .endm > > > > ENTRY(v7_secondary_startup) > > + .word 0xc070 @ 0xc07 is cortex-a7 id > > + .word 0xfff0 @ mask for core type > > + > > ARM_BE8(setend be) @ go BE8 if entered LE > > + mrc p15, 0, r0, c0, c0, 0 > > + adr r1, v7_secondary_startup > > + ldr r2, [r1] > > + ldr r3, [r1, #0x4] > > + and r0, r0, r3 > > + cmp r0, r2 > > + beq secondary_startup > > + > > Total NAK on the above. There's no way that we want to even try executing > those two .word values (and I don't care if "it works when tested", we just > don't try and execute data.) Sure, I misunderstood the way of putting .word, actually, for i.MX7D, I can just call common secondary_startup instead of v7_seondary_startup, so I can remove all changes in this file. > > > set_diag_reg > > b secondary_startup > > ENDPROC(v7_secondary_startup) > > diff --git a/arch/arm/mach-imx/mach-imx7d.c > > b/arch/arm/mach-imx/mach-imx7d.c index 26ca744..ef3dce6 100644 > > --- a/arch/arm/mach-imx/mach-imx7d.c > > +++ b/arch/arm/mach-imx/mach-imx7d.c > > @@ -99,6 +99,7 @@ static void __init imx7d_init_machine(void) > > > > static void __init imx7d_init_irq(void) { > > + imx_gpcv2_check_dt(); > > imx_init_revision_from_anatop(); > > imx_src_init(); > > irqchip_init(); > > @@ -111,6 +112,7 @@ static const char *const imx7d_dt_compat[] > > __initconst = { }; > > > > DT_MACHINE_START(IMX7D, "Freescale i.MX7 Dual (Device Tree)") > > + .smp = smp_ops(imx_smp_ops), > > .init_irq = imx7d_init_irq, > > .init_machine = imx7d_init_machine, > > .dt_compat = imx7d_dt_compat, > > diff --git a/arch/arm/mach-imx/platsmp.c b/arch/arm/mach-imx/platsmp.c > > index 711dbbd..63af911 100644 > > --- a/arch/arm/mach-imx/platsmp.c > > +++ b/arch/arm/mach-imx/platsmp.c > > @@ -60,8 +60,17 @@ static int imx_boot_secondary(unsigned int cpu, > > struct task_struct *idle) static void __init imx_smp_init_cpus(void) > > { > > int i, ncores; > > + unsigned long val, arch_type; > > > > - ncores = scu_get_core_count(scu_base); > > + asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r" (arch_type)); > > + > > + if (((arch_type >> 4) & 0xfff) == 0xc07) { > > This is buggy. Plus, we have macros for this. Please use the macros in > asm/cputype.h to achieve these tests. Thanks, I will use read_cpuid_id() API intead of putting asm code here. > > > + /* cortex-a7 core number is in bit[25:24] of CP15 L2CTLR */ > > + asm volatile("mrc p15, 1, %0, c9, c0, 2" : "=r" (val)); > > + ncores = ((val >> 24) & 0x3) + 1; > > + } else { > > + ncores = scu_get_core_count(scu_base); > > + } > > > > for (i = ncores; i < NR_CPUS; i++) > > set_cpu_possible(i, false); > > @@ -74,6 +83,14 @@ void imx_smp_prepare(void) > > > > static void __init imx_smp_prepare_cpus(unsigned int max_cpus) { > > + unsigned long arch_type; > > + > > + asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r" (arch_type)); > > + > > + /* no need for cortex-a7 */ > > + if (((arch_type >> 4) & 0xfff) == 0xc07) > > Ditto. Ditto. > > > + return; > > + > > imx_smp_prepare(); > > > > /* > > diff --git a/arch/arm/mach-imx/src.c b/arch/arm/mach-imx/src.c index > > 70b083f..1fda72a 100644 > > --- a/arch/arm/mach-imx/src.c > > +++ b/arch/arm/mach-imx/src.c > > @@ -18,6 +18,7 @@ > > #include > > #include > > #include "common.h" > > +#include "hardware.h" > > > > #define SRC_SCR 0x000 > > #define SRC_GPR1 0x020 > > @@ -30,6 +31,15 @@ > > #define BP_SRC_SCR_CORE1_RST 14 > > #define BP_SRC_SCR_CORE1_ENABLE 22 > > > > +/* below are for i.MX7D */ > > +#define SRC_GPR1_V2 0x074 > > +#define SRC_A7RCR0 0x004 > > +#define SRC_A7RCR1 0x008 > > +#define SRC_M4RCR 0x00C > > + > > +#define BP_SRC_A7RCR0_A7_CORE_RESET0 0 > > +#define BP_SRC_A7RCR1_A7_CORE1_ENABLE 1 > > + > > static void __iomem *src_base; > > static DEFINE_SPINLOCK(scr_lock); > > > > @@ -87,12 +97,21 @@ void imx_enable_cpu(int cpu, bool enable) > > u32 mask, val; > > > > cpu = cpu_logical_map(cpu); > > - mask = 1 << (BP_SRC_SCR_CORE1_ENABLE + cpu - 1); > > spin_lock(&scr_lock); > > - val = readl_relaxed(src_base + SRC_SCR); > > - val = enable ? val | mask : val & ~mask; > > - val |= 1 << (BP_SRC_SCR_CORE1_RST + cpu - 1); > > - writel_relaxed(val, src_base + SRC_SCR); > > + if (cpu_is_imx7d()) { > > It's about time iMX folk learned that "imx*" is a SoC and _not_ a CPU. > It should be "soc_is_imx7d()" because we're wanting to know whether the > _SoC_ is an iMX7D. The _CPU_ is a _Cortex-A7_. Agree, I will add a new patch in this patch set to replace all the cpu_is_xxx with Soc_is_xxx. Thanks for review. Anson. > > -- > RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ > FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up > according to speedtest.net.