From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F23BC4167B for ; Fri, 1 Dec 2023 15:11:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B74F68D0074; Fri, 1 Dec 2023 10:11:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AFD118D0001; Fri, 1 Dec 2023 10:11:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99DD08D0074; Fri, 1 Dec 2023 10:11:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 829458D0001 for ; Fri, 1 Dec 2023 10:11:40 -0500 (EST) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3FA41C0210 for ; Fri, 1 Dec 2023 15:11:40 +0000 (UTC) X-FDA: 81518588760.25.A594F23 Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by imf16.hostedemail.com (Postfix) with ESMTP id DF27D180012 for ; Fri, 1 Dec 2023 15:11:37 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=flygoat.com header.s=fm2 header.b=M0kwCK5P; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=OGHwpSUu; spf=pass (imf16.hostedemail.com: domain of jiaxun.yang@flygoat.com designates 66.111.4.29 as permitted sender) smtp.mailfrom=jiaxun.yang@flygoat.com; dmarc=pass (policy=none) header.from=flygoat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701443498; h=from:from:sender: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:dkim-signature; bh=4/nHC1n36ZRohrH97sK4NTzYkpz1AEDEk5qSQRNbDpw=; b=mrXvJWMR0pTwo772PsmoTTt1R1sm8gGaKk4oI5LyeeMjTPLNvGifdfbZC3NnB2xT+gLhRL SJukVJ0VFOb/fhr3bcCFdQN459ziZhMIDxBs40kGZlWUJoKTKYW3jnS1cDgaOX3TWnL9fn F8aLBpOBspW1uS9GtpbIk9A2fN/wfd4= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701443498; a=rsa-sha256; cv=none; b=qdz2v/iEi1YQNQb8MCdaVdFJ/gj+M2sY4J5kGwVcn/TbYmgyHWWdwBBgh8Y34Vo1wH3qcv tYVk738jTxd8hVIT0x5xrk0SaJYFMhV4fPw0hWCG5dYI4FYyyNK+/PohgzsPGWoZoU6zSU SjKbXuuA3SK9ZEjmtMtiDKo/PUkRnM0= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=flygoat.com header.s=fm2 header.b=M0kwCK5P; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=OGHwpSUu; spf=pass (imf16.hostedemail.com: domain of jiaxun.yang@flygoat.com designates 66.111.4.29 as permitted sender) smtp.mailfrom=jiaxun.yang@flygoat.com; dmarc=pass (policy=none) header.from=flygoat.com Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 26A6F5C0074; Fri, 1 Dec 2023 10:11:37 -0500 (EST) Received: from imap44 ([10.202.2.94]) by compute3.internal (MEProxy); Fri, 01 Dec 2023 10:11:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to; s=fm2; t= 1701443497; x=1701529897; bh=4/nHC1n36ZRohrH97sK4NTzYkpz1AEDEk5q SQRNbDpw=; b=M0kwCK5PODM/2YOWYeij2ndRc8ouCshzi8Tl/PsVsd4y5OWGMso XpswzNxwP6PZXY1APedcjhWZIKq21U4GWnpSgYprg0mYrfIC6GzXbXnYJ5cndqaC a4zlTeZofE6LzfgeAsZnb2gqTcR+8iSyHmXeoF7VS9q6CqwwIZ3LZRGDpIJbUCsp uvC+P4hIKP1pszzGiqw7k70EVIsBgO9lNMjqyFlcreo9jyKQJNsZ7SFNfGvG/6a2 7WfExSh6coXzFIEFhxNJYjvw0aedeHlzPzUovehe9CI5FJUiQI5nDIvYMA1nPxl1 w6GYtD9/2GY13CRHR6g7x2KTue19BJRKOOA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1701443497; x=1701529897; bh=4/nHC1n36ZRohrH97sK4NTzYkpz1AEDEk5q SQRNbDpw=; b=OGHwpSUuDec00hWSf2v74nIyFFAafTg7S7b0hsNGiIOYxSbxPB3 gE2vPMsTb0dCQv9QMWcnwTLAp9aLebKi1ma1Uj7PZXkf02HnH5jnfOlIwzTWKZES OZwdhnL0XJM7ETj0Yajp0ZSmS2QTie181YArYVwbAPHZWF00AdKvzOe9xZDf+IBQ 5d8iUCtTcV0xZUQltYOTWtVvrYvBNLExS1xUam9OlDG04O8kYA9VBbNC7amPa0v2 coNTEP5A1dzP/9ud0O5HyU/+HArC/Dnz6UtTo4fZvZY8d7mRjgsfdC3MWIlc92ce L9C47Agh0g/uuAxzO45XEaz3qyFIBV3eybA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeiledgjeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdfl ihgrgihunhcujggrnhhgfdcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtoh hmqeenucggtffrrghtthgvrhhnpedufeegfeetudeghefftdehfefgveffleefgfehhfej ueegveethfduuddvieehgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id F41B436A0075; Fri, 1 Dec 2023 10:11:33 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1178-geeaf0069a7-fm-20231114.001-geeaf0069 MIME-Version: 1.0 Message-Id: In-Reply-To: References: <245d3985-9085-4be0-8c74-d95d06334584@app.fastmail.com> <3iksuovvsln3cw3xpmjd7f7xixfvwaneu4ok56fnookvyolpco@wrxxew3thgnq> <3pgnihbrp5orh4tmj45fipbfoxdwzjh6uefitdpcea2vgkarcm@d56gv3areswl> <2148a67f-bd4f-432e-aa0d-c914a4bd5e0d@app.fastmail.com> Date: Fri, 01 Dec 2023 15:10:13 +0000 From: "Jiaxun Yang" To: "Serge Semin" Cc: "Thomas Bogendoerfer" , "Arnd Bergmann" , "Andrew Morton" , "Mike Rapoport" , "Matthew Wilcox" , "Tiezhu Yang" , "Huacai Chen" , "Yinglu Yang" , "Alexey Malahov" , "Aleksandar Rikalo" , "Aleksandar Rikalo" , "Dragan Mladjenovic" , "Chao-ying Fu" , "Marc Zyngier" , "linux-mips@vger.kernel.org" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/7] mips: dmi: Fix early remap on MIPS32 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Rspamd-Queue-Id: DF27D180012 X-Rspam-User: X-Stat-Signature: xtob6ad1p8aj31dcoow8gmszguh1855t X-Rspamd-Server: rspam03 X-HE-Tag: 1701443497-114271 X-HE-Meta: U2FsdGVkX19MTHx27A22xjEp+2tuPG2OKx13VwW5T6BVKEqJe1nZO+1YUI9+G5XUdLOIc6W76CmzcIdj5GScCQWR9+p4tj8e5/aQ8vMMGtWCZK+bSwjv+g2QvXzjdL6pF76hbD1Jt4hc3PmWAzniRoXX/W6oxc0g5VTi6WPosc9XigriWWjfj8zZv87I+i0RI8KXBRefOBGjHjWmzFZ6PtbNZ2SiL+QhP9lR0ptzj/+cPIEdlBNfyYJZwYwaPwjzajY66e0I4kv+zRaD0tlzCLqKUpjapBdAB3fgr2hxir6UlOzNuGSRtQ0KSJFZQNYUf58J+2GLX6r0vw31TxDHz6DvmzngBcu98ExWDQqABt4zwnJ3TLIDUsOe7bC7NVnmpHnst38wDxGuCBUsJQ8o35WbjiwRb8HBSuAodJm2DoVK26X1t6XZCqAND9LtWoUWlKn4nbVbiyjTz5z2tkSBtYzwWBDdPDYtBcotMqZy5rMoa7ruzhdq6PnGWB1vchBa/fwjwlTrv5XXfxxJoobgDJKjhBjtcKFcpG6PH6Y+/DS3CVnCfMR7xaJhb7AZjgq2VfAbPTgNHwHtUVvPwOLsQWIs/iLhbz5YzkCeFyytDTzWZhcoB6pw4lrnPprjA2eET3YrD8PXKLZiQsZMAwmwjqnb1vvNZpyQAQv1nAtSGYXKZA0ry2Hxo4otaQzbu3crUkoJ/xfKGZIgR6x/CATbBumEUJHlpZC6YLijJI4kKH5w78VPLooJF+D+MwjKWreb7gvA61f22DhdpZDgkoTxSThnsWHERQS8WFkkt4wVFlw69ogRmRzAlrddko6dxx608j1mMX+Tmf98jHVoux7i5aewJDs5xriFUBHpu7rNlsfiyYz6sShbxGLENgi/4nKyd6jhsuVX0MR1V0p4YXokrbQSilT9aF17HMZo8JEr9+mrffFUCTACrXpmZRxMTA13YeLKtCL1+MUhXnpXnqf x1xQzdac RCLx8qdjgQjkQ+HvhGwj6pwvDqdYMlhwVKhNN9jfgYz1p/hRY99cRVuhL9fy/EuTV52+gI8MgkrPbkaWkfzl+T7XfGAdUbZR8LL3I65ghrTSr2ssQX3klo7sSaWWXqHvtF7NGqzMaZGiC3coZk1QAZ2IHMpaTRUZ7tKKTECpbPfA1GTptmnCRqP+2WsemsbpIMQGvXxj5d4AKQDA6dG9zQqHAdanAp9daRW8Ozk12pz9WSujZHdhFCN6/+EGJWvV6rtCaXAwJ+NbI+NwmvycAg5/xPYBbOiu8fuAcjlaD0KQL/JWdLoiCKxPeAo5H6P8jruyli2nQYCJPBws85zPiaUDdTg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: =E5=9C=A82023=E5=B9=B412=E6=9C=881=E6=97=A5=E5=8D=81=E4=BA=8C=E6=9C=88 =E4= =B8=8B=E5=8D=882:54=EF=BC=8CSerge Semin=E5=86=99=E9=81=93=EF=BC=9A > On Fri, Dec 01, 2023 at 12:13:22AM +0000, Jiaxun Yang wrote: >>=20 >>=20 >> =E5=9C=A82023=E5=B9=B411=E6=9C=8830=E6=97=A5=E5=8D=81=E4=B8=80=E6=9C=88= =E4=B8=8B=E5=8D=887:16=EF=BC=8CSerge Semin=E5=86=99=E9=81=93=EF=BC=9A >> > On Tue, Nov 28, 2023 at 03:46:37PM +0000, Jiaxun Yang wrote: >> [...] >> > >> >> I'd say the safest option is to use CKSEG0 or TO_CAC here,=20 >> > >> > I would have agreed with you if MIPS didn't have that special >> > _page_cachable_default variable which is undefined for some platfor= ms >> > and which might be re-defined during the boot-up process, and if >> > MIPS64 didn't have ioremap_prot() always mapping to the uncached >> > region. But IMO updating ioremap_prot() currently seems more risky >> > than just converting dmi_early_remap() to the uncached version >> > especially seeing it won't change anything. MIPS64 always have IO >> > remapped to the uncached region. MIPS32 won't be able to have cached >> > mapping until VM is available, and paging and slabs are initialized. >> > So on the early MIPS32 bootup stages ioremap_cache() wouldn't have >> > worked anyway. >>=20 > >> I really didn't get that, using CKSEG0 on 32bit system and TO_CAC >> on 64bit system won't hurt. >>=20 >> Something like: >> #ifdef CONFIG_64BIT >> #define dmi_remap(x, l) (void *)TO_CAC(x) >> #else >> #define dmi_remap(x, l) (void *)CKSEG0(x) >> #endif >>=20 >> Can help us avoid all the hassle. Since it always ensures we are >> using same CCA to access DMI tables. We can always trust Config.K0 >> left by firmware in this case. > > Please note my only concern is about dmi_early_remap(), not > dmi_remap(). The later one can be safely left backended by the > ioremap_cache() method because at the stage it's utilized MIPS32 > version of ioremap_prot() will be able to create any mapping it's > requested to. The dmi_early_remap() function is called very early with > no paging or VM or even cache stuff initialized. So currently AFAICS > it just doesn't work on _all_ _MIPS32_ platform, because > ioremap_prot() relies on VM and slab being available to have any > cacheable mapping, which aren't at the moment of the dmi_setup() > function invocation. Seeing the ioremap_cache() is just a stub on > MIPS64 which always performs the uncached mapping, it will be > completely safe to just convert dmi_early_remap() to ioremap() with > no risk to beak anything. dmi_early_remap() semantics won't be > actually changed, it will work as before on MIPS64 and will be fixed > on MIPS32. This (AFAICS) is a completely safe fix of the problem with > just a few affected platforms around. > The only platform enabled DMI in upstream kernel is Loongson64, which I'm perfectly sure that the mapping for DMI tables *should* be Cached. It is an accident that ioremap_cache is misused here, so I'm proposing to replace it with CKSEG0/TO_CAC. Also as per MIPS UHI spec, all the data passed from bootloader to firmware should lay in KSEG0, please let me know if your platform is an exception here. Using ioremap_cache at dmi_early_remap does not sound safe to me as well. What if DMI code tried to remap something beyond KSEG range at this plac= e? The safest option here is just bypassing ioremap framework, which does not give you any advantage but only burden. I'll propose a patch later. --=20 - Jiaxun