Message ID | 20231004161038.2818327-4-gregory.clement@bootlin.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp242815vqb; Wed, 4 Oct 2023 09:11:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/NKqoxQgtuaMrdZU79o+j3Bg/Dx9NEbyjXUMsLREQXvCC7btwnTy6FbjmacilN4NYM9wl X-Received: by 2002:a05:6a20:7487:b0:14e:43b0:5f99 with SMTP id p7-20020a056a20748700b0014e43b05f99mr2912457pzd.52.1696435895525; Wed, 04 Oct 2023 09:11:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696435895; cv=none; d=google.com; s=arc-20160816; b=VfXWNuPIRBv+iMdxjmUfYPr9pzUb3pw4nGQAOzr6/v+UGx1pDnLGdHKKk8p8t8qU0Z +az2znpGhiLjl9ELZ9pVCH2Hfr3nKPani0fOAyNG0ROTv3SLwH+mrHFHkZX3PLkjKlXm ApS0pfTKkGYgzO7YAP8vfpVgzlu5A0rTuUEI0U7ZOQXy7BsZBQbOJ4UutefjPTay8P9R Hdy80rI3QX+RcgyB2/rvTLpdOk5SmCRR750suBwXf4mA8JeCy9hDrwLOMCoKhjAUpWuN ALYzIm8l6OMPOe8odde26mTzCQ3xSvAhrphQEc7sr+r5L8O/pqTuj4ZMiLNE347Yq9ML 18/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VOjmWr0mfjgBp7nTWHYGPwk6e22EOwSF4b0ZHDI/Irc=; fh=Se1ENV7S1WlWgaTZX3WsmbP5gu1FYEREoZ/dljQcGVE=; b=FPj61UC5VloSieZgvcNIJnZ9GzG+DFVD7+c0Vt4N9oAuoKMk2rYIKQXGMA2q+5UvtQ 3fWQ32pT6zam0D4MA98sp/q45dDi3aPTUxZX4+/C3S9vCuJ5Sl1wrOgedb05rLVLzCJP R6tEQFHWBaCAk8716WHprW3QNyH7Pdj8UWMAHwWKcPOrDfRQEdfVwe7+YMbHX/qmIN4e b6hnMUYmUemnMBpoc+z9H8VNBLVFJkpX6fddRMail5BL4KwXnQ6XKrROfKAHnQKACHjD rCMWnrwojahJ4jNF71qh6dnycj8ZoGeQmLOSiR5EH4e7Kddg7Q2PPhUXgiN9YVrtllCX PqHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mK6smk9v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id l3-20020a170902f68300b001c7755dccbcsi4419024plg.619.2023.10.04.09.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 09:11:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=mK6smk9v; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 6EF2A8348D92; Wed, 4 Oct 2023 09:11:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243262AbjJDQLD (ORCPT <rfc822;ezelljr.billy@gmail.com> + 19 others); Wed, 4 Oct 2023 12:11:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243244AbjJDQK4 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 4 Oct 2023 12:10:56 -0400 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::224]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7A47C0; Wed, 4 Oct 2023 09:10:52 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id D2623E0006; Wed, 4 Oct 2023 16:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696435851; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VOjmWr0mfjgBp7nTWHYGPwk6e22EOwSF4b0ZHDI/Irc=; b=mK6smk9vHL4Vz1l1in2vpkrJfRKPFK5FWJ/iGAp0VFPia3gMZAa1jSIoybLSXms4wEB9+5 EuY4Q042RL7K5FRQZieMtyubzN4Fvnyr8/udm4tmIqYNj91o0GAEaa9MN/80cprFJd0iYF tAT2DermcTvyHEMy2rrieelCWPFbTM/2D6JBQtyGWdjWdEg+AbBo8u6whRPOfBY9gI1LU4 EH5/7oXEYrasvjmvAxcI+ePVL6Hhe3PLrPI8cotMRE85SvO1BInV+MG/6j8olGOfNSMv5j ukHuI4V3mIF/9845SJCizcDJC74Z2HatyWu561L7nvPkKRTrQRMD21BgbOKPNw== From: Gregory CLEMENT <gregory.clement@bootlin.com> To: Paul Burton <paulburton@kernel.org>, Thomas Bogendoerfer <tsbogend@alpha.franken.de>, linux-mips@vger.kernel.org, Rob Herring <robh+dt@kernel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vladimir Kondratiev <vladimir.kondratiev@intel.com>, Tawfik Bayouk <tawfik.bayouk@mobileye.com>, Alexandre Belloni <alexandre.belloni@bootlin.com>, =?utf-8?q?Th=C3=A9o_Lebr?= =?utf-8?q?un?= <theo.lebrun@bootlin.com>, Thomas Petazzoni <thomas.petazzoni@bootlin.com>, Gregory CLEMENT <gregory.clement@bootlin.com> Subject: [PATCH 03/11] MIPS: support RAM beyond 32-bit Date: Wed, 4 Oct 2023 18:10:30 +0200 Message-Id: <20231004161038.2818327-4-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231004161038.2818327-1-gregory.clement@bootlin.com> References: <20231004161038.2818327-1-gregory.clement@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: gregory.clement@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_PASS,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 04 Oct 2023 09:11:16 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778841965772497057 X-GMAIL-MSGID: 1778841965772497057 |
Series |
Add support for the Mobileye EyeQ5 SoC
|
|
Commit Message
Gregory CLEMENT
Oct. 4, 2023, 4:10 p.m. UTC
From: Vladimir Kondratiev <vladimir.kondratiev@intel.com> Support platforms where RAM is mapped beyond 32-bit. The kernel parameter ddr32_alias allows to setup the alias to point outside the first 4 GB of memory. Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@intel.com> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> --- arch/mips/kernel/smp-cps.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
Comments
On Wed, Oct 4, 2023, at 18:10, Gregory CLEMENT wrote: > From: Vladimir Kondratiev <vladimir.kondratiev@intel.com> > > Support platforms where RAM is mapped beyond 32-bit. > > The kernel parameter ddr32_alias allows to setup the alias to point > outside the first 4 GB of memory. > > Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@intel.com> > Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> This needs a better explanation, and probably a rewrite. Having to pass the memory address on the command line does not sound like an appropriate way to boot the kernel, so I think either this needs to be detected from the running kernel itself, or passed through DT. Arnd
在2023年10月4日十月 下午5:10,Gregory CLEMENT写道: > From: Vladimir Kondratiev <vladimir.kondratiev@intel.com> > > Support platforms where RAM is mapped beyond 32-bit. > > The kernel parameter ddr32_alias allows to setup the alias to point > outside the first 4 GB of memory. Are you trying to fix the problem that if kernel text is loaded in XKPHYS there is no way to to set EBASE to that region? The common practice for other 64bit MIPS system is to load kernel in KSEG0 and add low 4G mirror with rest of the high memory to buddy system. By doing this Kernel still have access to all memory beyond 32 bit, the only draw back is Kernel's text and data can't be relocted beyond 32-bit. Loading kernel into KSEG0 (i.e. with KBUILD_SYM32) have significant benefit on performance, so I think you shouldn't try to load kernel into XKPHYS without a good reason, but it might be helpful to add a BUG_ON at CPS driver to handle such situation. Btw: Is your target hardware publicly available? Folks at CIP United are looking for EyeQ5 boards for a while, they are supporting MIPS R6 support at various projects. Thanks Jiaxun > > Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@intel.com> > Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> > --- > arch/mips/kernel/smp-cps.c | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c > index 47e76722a306..fcfb19487612 100644 > --- a/arch/mips/kernel/smp-cps.c > +++ b/arch/mips/kernel/smp-cps.c > @@ -34,6 +34,16 @@ static unsigned __init core_vpe_count(unsigned int > cluster, unsigned core) > return min(smp_max_threads, mips_cps_numvps(cluster, core)); > } > > +static int ddr32_alias; > + > +static int __init ddr32_alias_setup(char *str) > +{ > + get_option(&str, &ddr32_alias); > + > + return 0; > +} > +early_param("ddr32_alias", ddr32_alias_setup); > + > /** > * plat_core_entry - query reset vector for NMI/reset > * > @@ -52,7 +62,7 @@ static u32 plat_core_entry(void) > { > #if defined(CONFIG_USE_XKPHYS) > return (UNCAC_ADDR(mips_cps_core_entry) & 0xffffffff) > - | CM_GCR_Cx_RESET_BASE_MODE; > + | ddr32_alias | CM_GCR_Cx_RESET_BASE_MODE; > #else > return CKSEG1ADDR((unsigned long)mips_cps_core_entry); > #endif > -- > 2.40.1
Hello Jiaxun, > 在2023年10月4日十月 下午5:10,Gregory CLEMENT写道: >> From: Vladimir Kondratiev <vladimir.kondratiev@intel.com> >> >> Support platforms where RAM is mapped beyond 32-bit. >> >> The kernel parameter ddr32_alias allows to setup the alias to point >> outside the first 4 GB of memory. > > Are you trying to fix the problem that if kernel text is loaded in > XKPHYS there is no way to to set EBASE to that region? Yes that exactly we try to fix. > > The common practice for other 64bit MIPS system is to load kernel > in KSEG0 and add low 4G mirror with rest of the high memory to buddy > system. By doing this Kernel still have access to all memory beyond > 32 bit, the only draw back is Kernel's text and data can't be relocted > beyond 32-bit. > > Loading kernel into KSEG0 (i.e. with KBUILD_SYM32) have significant benefit > on performance, so I think you shouldn't try to load kernel into XKPHYS > without a good reason, but it might be helpful to add a BUG_ON at > CPS driver to handle such situation. I guess that being in KSEG0 allows to use shorter pointer. But in our case the RAM is physically connected beyond 32bits, so it is not accessible in KSEG0. > > Btw: Is your target hardware publicly available? Folks at CIP United > are looking for EyeQ5 boards for a while, they are supporting MIPS R6 > support at various projects. We use evaluation boards and I don't know if they are publicly available. Gregory > > Thanks > Jiaxun > >> >> Signed-off-by: Vladimir Kondratiev <vladimir.kondratiev@intel.com> >> Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com> >> --- >> arch/mips/kernel/smp-cps.c | 12 +++++++++++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c >> index 47e76722a306..fcfb19487612 100644 >> --- a/arch/mips/kernel/smp-cps.c >> +++ b/arch/mips/kernel/smp-cps.c >> @@ -34,6 +34,16 @@ static unsigned __init core_vpe_count(unsigned int >> cluster, unsigned core) >> return min(smp_max_threads, mips_cps_numvps(cluster, core)); >> } >> >> +static int ddr32_alias; >> + >> +static int __init ddr32_alias_setup(char *str) >> +{ >> + get_option(&str, &ddr32_alias); >> + >> + return 0; >> +} >> +early_param("ddr32_alias", ddr32_alias_setup); >> + >> /** >> * plat_core_entry - query reset vector for NMI/reset >> * >> @@ -52,7 +62,7 @@ static u32 plat_core_entry(void) >> { >> #if defined(CONFIG_USE_XKPHYS) >> return (UNCAC_ADDR(mips_cps_core_entry) & 0xffffffff) >> - | CM_GCR_Cx_RESET_BASE_MODE; >> + | ddr32_alias | CM_GCR_Cx_RESET_BASE_MODE; >> #else >> return CKSEG1ADDR((unsigned long)mips_cps_core_entry); >> #endif >> -- >> 2.40.1 > > -- > - Jiaxun
在2023年10月9日十月 下午4:59,Gregory CLEMENT写道: > Hello Jiaxun, > >> 在2023年10月4日十月 下午5:10,Gregory CLEMENT写道: >>> From: Vladimir Kondratiev <vladimir.kondratiev@intel.com> >>> >>> Support platforms where RAM is mapped beyond 32-bit. >>> >>> The kernel parameter ddr32_alias allows to setup the alias to point >>> outside the first 4 GB of memory. >> >> Are you trying to fix the problem that if kernel text is loaded in >> XKPHYS there is no way to to set EBASE to that region? > > Yes that exactly we try to fix. > >> >> The common practice for other 64bit MIPS system is to load kernel >> in KSEG0 and add low 4G mirror with rest of the high memory to buddy >> system. By doing this Kernel still have access to all memory beyond >> 32 bit, the only draw back is Kernel's text and data can't be relocted >> beyond 32-bit. >> >> Loading kernel into KSEG0 (i.e. with KBUILD_SYM32) have significant benefit >> on performance, so I think you shouldn't try to load kernel into XKPHYS >> without a good reason, but it might be helpful to add a BUG_ON at >> CPS driver to handle such situation. > > I guess that being in KSEG0 allows to use shorter pointer. But in our > case the RAM is physically connected beyond 32bits, so it is not > accessible in KSEG0. For most system there should be a mirror of part of DDR which is accessible at KSEG0 and kernel runs from here. As per my interpretion of your code EyeQ5 is also doing this? If not could you please briefly describe the memory map? For Kernel in KSEG0 the pointer is still 64bit but we can use fewer inst to load ABS pointer into register, see [1]. >> >> Btw: Is your target hardware publicly available? Folks at CIP United >> are looking for EyeQ5 boards for a while, they are supporting MIPS R6 >> support at various projects. > > We use evaluation boards and I don't know if they are publicly > available. > > Gregory > [1]: https://elinux.org/images/1/1f/New-tricks-mips-linux.pdf Thanks - Jiaxun
Hello Jiaxun, > 在2023年10月9日十月 下午4:59,Gregory CLEMENT写道: >> Hello Jiaxun, >> >>> 在2023年10月4日十月 下午5:10,Gregory CLEMENT写道: >>>> From: Vladimir Kondratiev <vladimir.kondratiev@intel.com> >>>> >>>> Support platforms where RAM is mapped beyond 32-bit. >>>> >>>> The kernel parameter ddr32_alias allows to setup the alias to point >>>> outside the first 4 GB of memory. >>> >>> Are you trying to fix the problem that if kernel text is loaded in >>> XKPHYS there is no way to to set EBASE to that region? >> >> Yes that exactly we try to fix. >> >>> >>> The common practice for other 64bit MIPS system is to load kernel >>> in KSEG0 and add low 4G mirror with rest of the high memory to buddy >>> system. By doing this Kernel still have access to all memory beyond >>> 32 bit, the only draw back is Kernel's text and data can't be relocted >>> beyond 32-bit. >>> >>> Loading kernel into KSEG0 (i.e. with KBUILD_SYM32) have significant benefit >>> on performance, so I think you shouldn't try to load kernel into XKPHYS >>> without a good reason, but it might be helpful to add a BUG_ON at >>> CPS driver to handle such situation. >> >> I guess that being in KSEG0 allows to use shorter pointer. But in our >> case the RAM is physically connected beyond 32bits, so it is not >> accessible in KSEG0. > > For most system there should be a mirror of part of DDR which is accessible > at KSEG0 and kernel runs from here. As per my interpretion of your code EyeQ5 > is also doing this? If not could you please briefly describe the memory map? > > For Kernel in KSEG0 the pointer is still 64bit but we can use fewer inst > to load ABS pointer into register, see [1]. > There is a kind of mirror but its physical address start at 0x8000000 so beyond the first 512MBytes that are used for KSEG0. In short the 32bits mapping is the following: - the controllers registers of the SoC are located until 0x8000000, - then from 0x8000000 to 0x10000000 there is the alias to low addresses of the DDR - then the SPIflash is mapped to from 0x10000000 to 0x20000000 - after the PCIe Memory 32-bit addr space is from 0x20000000 to 0x40000000 Gregory > [1]: https://elinux.org/images/1/1f/New-tricks-mips-linux.pdf
在2023年10月11日十月 下午3:46,Gregory CLEMENT写道: > Hello Jiaxun, > [...] > > There is a kind of mirror but its physical address start at 0x8000000 > so beyond the first 512MBytes that are used for KSEG0. Really, KSEG0 range is 0x00000000 to 0x20000000, and 0x08000000 to 0x10000000 is definitely within that range. But I'd agree that 0x08000000 to 0x10000000 (32MB) seems too small for kernel text and data. So yeah, it makes sense to load kernel into XKPHYS. My sugesstion is, kernel does not have to be aware of the mirror deisgn. Say that you have DDR fully mapped at 0x100000000, you can split memory space into two trunks: 0x08000000 to 0x10000000 and 0x102000000 to end of the dram. Since memblock always allocate from first continuous range in system, we can guarantee that ebase is allocated with in the first trunk. Thanks > > In short the 32bits mapping is the following: > > - the controllers registers of the SoC are located until 0x8000000, > - then from 0x8000000 to 0x10000000 there is the alias to low addresses > of the DDR > - then the SPIflash is mapped to from 0x10000000 to 0x20000000 > - after the PCIe Memory 32-bit addr space is from 0x20000000 to > 0x40000000 > > Gregory > >> [1]: https://elinux.org/images/1/1f/New-tricks-mips-linux.pdf > > -- > Gregory Clement, Bootlin > Embedded Linux and Kernel engineering > http://bootlin.com
On Thu, 12 Oct 2023, Jiaxun Yang wrote: > > There is a kind of mirror but its physical address start at 0x8000000 > > so beyond the first 512MBytes that are used for KSEG0. > > Really, KSEG0 range is 0x00000000 to 0x20000000, and 0x08000000 to 0x10000000 > is definitely within that range. > > But I'd agree that 0x08000000 to 0x10000000 (32MB) seems too small for kernel > text and data. So yeah, it makes sense to load kernel into XKPHYS. Hmm, my calculation indicates the range shown spans 128MiB, which I think is usually suitably large to hold kernel static text and data even for the richest configurations. Regardless, loading into XKPHYS isn't wrong, with some platforms we've been doing it for decades now. Maciej
diff --git a/arch/mips/kernel/smp-cps.c b/arch/mips/kernel/smp-cps.c index 47e76722a306..fcfb19487612 100644 --- a/arch/mips/kernel/smp-cps.c +++ b/arch/mips/kernel/smp-cps.c @@ -34,6 +34,16 @@ static unsigned __init core_vpe_count(unsigned int cluster, unsigned core) return min(smp_max_threads, mips_cps_numvps(cluster, core)); } +static int ddr32_alias; + +static int __init ddr32_alias_setup(char *str) +{ + get_option(&str, &ddr32_alias); + + return 0; +} +early_param("ddr32_alias", ddr32_alias_setup); + /** * plat_core_entry - query reset vector for NMI/reset * @@ -52,7 +62,7 @@ static u32 plat_core_entry(void) { #if defined(CONFIG_USE_XKPHYS) return (UNCAC_ADDR(mips_cps_core_entry) & 0xffffffff) - | CM_GCR_Cx_RESET_BASE_MODE; + | ddr32_alias | CM_GCR_Cx_RESET_BASE_MODE; #else return CKSEG1ADDR((unsigned long)mips_cps_core_entry); #endif