Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp870045rdg; Wed, 11 Oct 2023 07:47:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExjSvPLWCv3gVLwEZDgjkhWgYrq6EqkzP6xrqk/juiZKud3pNxnK2tRYGPhC5x7Yoxg1Xv X-Received: by 2002:a05:6358:1c9:b0:13c:cdef:25ab with SMTP id e9-20020a05635801c900b0013ccdef25abmr19518269rwa.24.1697035621932; Wed, 11 Oct 2023 07:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697035621; cv=none; d=google.com; s=arc-20160816; b=NlngUWkRiQE7cX3Pd1OYL5o9783XD5VtQbTmb9GXRcg4a763q1k/oz3ZzGFkLu3v6Y tgYQa7MKLcQZTdb6qWC4o9UXB+0/d5ZtPwiPei+cTsKWQ2i9Odp1GnkBm2F4FIXNWi8W gndbWkqnWBDp/a57NjAykYgZxiezipGkPDJWU1g5z4ciYu2IOnqjC+H5z69XWrax40ah juyJGGQiMdtM3kVA6T6RBvljw19CmtRqBa71otD9wcBf1TWgkW5wBzeNYXUl+faYUncc aDisMW5aDFLVsp9/avMyYwvr+6PkE3XtfAbVKL6SRdkV5QwGBWC2pUNB6ZcLMBtlP4AK q0bg== 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 :message-id:date:references:in-reply-to:subject:cc:to:from :dkim-signature; bh=+QVKjHGSsp7llyLK7zXvNe55S5HhglD1KOhqWrzK24o=; fh=a+RWw5OVHdLBRD9n8fnySpCwPT1C9hXylvpqpHsXZrk=; b=p/HBRFsVNPtVA/z+S6L4nek3qZjXzt8ZES6gbk9c0gCpIw1BY6zzAtJ9fgKDFEd+Lz 4/L81hS8LSjzqkEeSD0QR06BXlMqDUYpr0csaBMyHW4MUQSCdTJTrZZlw7xLout+AEDQ RIg/IxQMKEVhAArR6fZCLEST1XaqEOKtpzb4NmE3k/47J343VKJkU+c9xYdg0HEy0E19 cbVUn8M15KIsyCMCHLp5cnDqaku8c2YOT8wwJhWRQJFwvHtXHrz0aW+K/gqrPTApCr9I ea0eaRaC8yLD4Gl4l33xgbED25TQtNUV1mkGbcFeuq454CezfUNe83dJNQiCPzgTWnue 7qAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=efH6MLyF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id ct7-20020a056a000f8700b0068fbd15c036si11880190pfb.286.2023.10.11.07.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Oct 2023 07:47:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=efH6MLyF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 53F428144193; Wed, 11 Oct 2023 07:46:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346952AbjJKOqo (ORCPT + 99 others); Wed, 11 Oct 2023 10:46:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346706AbjJKOqd (ORCPT ); Wed, 11 Oct 2023 10:46:33 -0400 Received: from relay1-d.mail.gandi.net (relay1-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::221]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E23D2CF; Wed, 11 Oct 2023 07:46:29 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id A47A3240006; Wed, 11 Oct 2023 14:46:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1697035588; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+QVKjHGSsp7llyLK7zXvNe55S5HhglD1KOhqWrzK24o=; b=efH6MLyFYuKhVRsjsyQIblreJjjFhdUvrP5SIy7uZrN57o+MGaBWpe60IvUsA06T59aCRI 0790bKGL0Q07jyaZwaDkl/cvzo2ZPcDGSCON/4vtiPXpc4MMNbq/UVSYJ6oFYk4b7YSEwV hXaqJSs2sB/02RlvLWyMuu3J76p1VzXe0E9ibdPEKkWzw4vKe9uMX04889lq+BU/g14xgl 0/ytgcvLysO37RAI1C7JlJ26pSJXnpSBPD3Tb3RqYwkBhTGh0BxZz5XlbkfzJPIxahdVb4 NZB7h7jzUmygp+rBhXjFNr8UrQ/oFHf1Grvnfi1np6EIscieXSEgBn8PPHFSvw== From: Gregory CLEMENT To: Jiaxun Yang , "paulburton@kernel.org" , Thomas Bogendoerfer , "linux-mips@vger.kernel.org" , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vladimir Kondratiev , Tawfik Bayouk , Alexandre Belloni , =?utf-8?Q?Th=C3=A9o?= Lebrun , Thomas Petazzoni Subject: Re: [PATCH 03/11] MIPS: support RAM beyond 32-bit In-Reply-To: References: <20231004161038.2818327-1-gregory.clement@bootlin.com> <20231004161038.2818327-4-gregory.clement@bootlin.com> <87edi3bxcl.fsf@BL-laptop> Date: Wed, 11 Oct 2023 16:46:26 +0200 Message-ID: <878r89b4jh.fsf@BL-laptop> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: gregory.clement@bootlin.com X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Wed, 11 Oct 2023 07:46:59 -0700 (PDT) X-Spam-Level: ** Hello Jiaxun, > =E5=9C=A82023=E5=B9=B410=E6=9C=889=E6=97=A5=E5=8D=81=E6=9C=88 =E4=B8=8B= =E5=8D=884:59=EF=BC=8CGregory CLEMENT=E5=86=99=E9=81=93=EF=BC=9A >> Hello Jiaxun, >> >>> =E5=9C=A82023=E5=B9=B410=E6=9C=884=E6=97=A5=E5=8D=81=E6=9C=88 =E4=B8=8B= =E5=8D=885:10=EF=BC=8CGregory CLEMENT=E5=86=99=E9=81=93=EF=BC=9A >>>> From: Vladimir Kondratiev >>>> >>>> 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 ben= efit >>> 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 accessib= le > at KSEG0 and kernel runs from here. As per my interpretion of your code E= yeQ5 > is also doing this? If not could you please briefly describe the memory m= ap? > > 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 --=20 Gregory Clement, Bootlin Embedded Linux and Kernel engineering http://bootlin.com