Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1482707rdh; Fri, 24 Nov 2023 14:04:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IH90tZaAGRqJXjsgbPXTyrJHuj+mYwfVSBa6BsKxzYGULUh6Tm1bQbIBPQa/SZb92woHJQ4 X-Received: by 2002:a05:6870:9e0b:b0:1fa:1ebb:8e86 with SMTP id ps11-20020a0568709e0b00b001fa1ebb8e86mr240211oab.52.1700863467149; Fri, 24 Nov 2023 14:04:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700863467; cv=none; d=google.com; s=arc-20160816; b=hsnsk1vZWUiIHwEkubpok1TtoLmxyRZhMtj6iekAWVTFbGWMLDgFvIG6S5na6Kz+fv hP2FHKtQ+kxdCIFXG0LcwgJrvSrTqThiStZrEP6uYSgXB/YuYeRmaHnepO8Ol73nwrBH XykP+rUaBJmMtx3QgZ+fgcQb/48LdmP7dZhxmCYfA2BGH9PGmQv/DgHnZZhbeUGSD0J+ +Qb5se07FM0NkLfaXgc+xYaR8n6xI2OFbukOfHZ3cyXnIFqofUqcI4h6DRGQNJEP9+hK crocx5cYaTL7lDRHgbe0uH4s56URZyI51Vp9wegvXekQUrYN+zF1HMM+kYgB0fMwtoRv mi9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:subject:cc:to:from :date:references:in-reply-to:message-id:mime-version:user-agent :feedback-id:dkim-signature:dkim-signature; bh=3UtEYHzWi0cxnEeCsISUpA7msvYeRg40USlPBvQDAxw=; fh=OsfvMP6b8YRGtbHw9ryX5hINofMLrNl7rCjodfE5/4w=; b=CUkqHhMDvgcyFqecV1xBMlSAAOZsy+MHuE+88wvyH1lyvljcf1HvB5KijGV4+gfpmw OETyxb+exP0qyEmLpUhw8pAfyNtAaMvJ8WrdTVRQepSUYdWSWxPrSrhvO6xWehxUjNKe 7bPXUPF6dlaTgbgTpE/311Qmlq6BwJQh7Bo8scNtu2OUaH69O/fVgMrYXPOk+b4CGQ/q WJRk8o+gkj7847TZRLpuI3xNzrNj4IywqKo7O3m16g7XNZzCrU9V+iGZ/xtQX2lzH7TL fQ341b5rOdNLZA9TsFYPKb2WJsCLMtTnqDSdObQ22qW350bBoYz/ulCUp+jMr1hYoWW8 pRoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm2 header.b=A+OmL5iu; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="twOj/8Jc"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id y6-20020a056830108600b006d7f02c49cdsi1764473oto.34.2023.11.24.14.04.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 14:04:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm2 header.b=A+OmL5iu; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b="twOj/8Jc"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 3E0CF80A999C; Fri, 24 Nov 2023 14:04:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229710AbjKXWEI (ORCPT + 99 others); Fri, 24 Nov 2023 17:04:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229557AbjKXWEH (ORCPT ); Fri, 24 Nov 2023 17:04:07 -0500 Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81E77127; Fri, 24 Nov 2023 14:04:13 -0800 (PST) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 5C23F5C017F; Fri, 24 Nov 2023 17:04:10 -0500 (EST) Received: from imap44 ([10.202.2.94]) by compute3.internal (MEProxy); Fri, 24 Nov 2023 17:04:10 -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= 1700863450; x=1700949850; bh=3UtEYHzWi0cxnEeCsISUpA7msvYeRg40USl PBvQDAxw=; b=A+OmL5iuR0zReaEYJ15GjQZg4vyIFXItuIFwm5dyiW5T4gkg5vB O3y1vEmDpFw4XObQBw8S+hZRpzogyJyTFmhG2+30qmPo4cAzhli//p7Xo0xlYdm1 HAyMt5+hPPBYMAmiaiJ28TApebpiNxFRXs4GB7HBWyVtBQUMvcn/4s/jVsg/IWws XssMoqNkkSUyZUh627dVqhMVg53/fr4mKmvapK+ChgQrurZJBfS4Yc7m/1MQYKc6 sidfB5JX2x1DmjiQdvNNzsevqfIMP6hcV70YbnA+hZB2vgAekGpuscafQCq3EtT3 dsfKyA/+zzMUAho0X0+YX3mWlJOpbjr74Pw== 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= 1700863450; x=1700949850; bh=3UtEYHzWi0cxnEeCsISUpA7msvYeRg40USl PBvQDAxw=; b=twOj/8Jcx0NWHjeF1j6wOPWK7iooNT5JJaNkH43/2QPNogNn/tb 7JlN9Jgl7OH0//175OqqtGkvZXNETNHDVrjnRTE2dYC2aRe8NS3cBxfRS3TkrgxS q9RHfaYXLVDlKtbRO1wccGQQV2UIDnVyL9C45hhb0IlJbfkJO8g+JknA9uHVVwVY PnwjCl/fo6dt0YHUl1yy0R1NvLc243cufFp0E0HkrrOwy4AAt69IbDeA1D9IcSv0 CjrzG+GgyJXkCwAwh2nx0r7aclfam9EFjZ41h4zMGoX7okhqfPOQ8VnxZ9/rU30z sSKm3gGHvGJK1CTFz/SuqgqFbC1X6DA4MiA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehhedgudehjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgfgsehtqhertderreejnecuhfhrohhmpedf lfhirgiguhhnucgjrghnghdfuceojhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtg homheqnecuggftrfgrthhtvghrnhepudefgeeftedugeehffdtheefgfevffelfefghefh jeeugeevtefhudduvdeihefgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomhepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 0886F36A0075; Fri, 24 Nov 2023 17:04:08 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-1234-gac66594aae-fm-20231122.001-gac66594a MIME-Version: 1.0 Message-Id: In-Reply-To: <3iksuovvsln3cw3xpmjd7f7xixfvwaneu4ok56fnookvyolpco@wrxxew3thgnq> References: <20231122182419.30633-1-fancer.lancer@gmail.com> <20231122182419.30633-2-fancer.lancer@gmail.com> <8ca730b9-fa8c-46ea-bdc5-158da0f29c3a@app.fastmail.com> <245d3985-9085-4be0-8c74-d95d06334584@app.fastmail.com> <3iksuovvsln3cw3xpmjd7f7xixfvwaneu4ok56fnookvyolpco@wrxxew3thgnq> Date: Fri, 24 Nov 2023 22:03:49 +0000 From: "Jiaxun Yang" To: "Serge Semin" , "Thomas Bogendoerfer" Cc: "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-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Fri, 24 Nov 2023 14:04:24 -0800 (PST) =E5=9C=A82023=E5=B9=B411=E6=9C=8824=E6=97=A5=E5=8D=81=E4=B8=80=E6=9C=88 = =E4=B8=8B=E5=8D=886:52=EF=BC=8CSerge Semin=E5=86=99=E9=81=93=EF=BC=9A > On Thu, Nov 23, 2023 at 05:33:31PM +0000, Jiaxun Yang wrote: >>=20 [...] >> Actually dmi_setup() is called before cpu_cache_init(). > > To preliminary sum the discussion, indeed there can be issues on the > platforms which have DMI initialized on the cached region. Here are > several solutions and additional difficulties I think may be caused by > implementing them: Thanks for such detailed conclusion! I'd prefer go solution 1, with comments below. > > 1. Use unmapped cached region utilization in the MIPS32 ioremap_prot() > method. > This solution a bit clumsy than it looks on the first glance. > ioremap_prot() can be used for various types of the cachability > mapping. Currently it's a default-cacheable CA preserved in the > _page_cachable_default variable and Write-combined CA saved in > boot_cpu_data.writecombine. Based on that we would have needed to use > the unmapped cached region utilized for the IO-remaps called with the > "_page_cachable_default" mapping flags passed only. The rest of the IO > range mappings, including the write-combined ones, would have been > handled by VM means. This would have made the ioremap_prot() a bit > less maintainable, but still won't be that hard to implement (unless I > miss something): > --- a/arch/mips/mm/ioremap.c > +++ b/arch/mips/mm/ioremap.c > /* > - * Map uncached objects in the low 512mb of address space usin= g KSEG1, > - * otherwise map using page tables. > + * Map uncached/default-cached objects in the low 512mb of add= ress > + * space using KSEG1/KSEG0, otherwise map using page tables. > */ > - if (IS_LOW512(phys_addr) && IS_LOW512(last_addr) && > - flags =3D=3D _CACHE_UNCACHED) > - return (void __iomem *) CKSEG1ADDR(phys_addr); > + if (IS_LOW512(phys_addr) && IS_LOW512(last_addr)) { > + if (flags =3D=3D _CACHE_UNCACHED) > + return (void __iomem *) CKSEG1ADDR(phys_addr); > + else if (flags =3D=3D _page_cachable_default) > + return (void __iomem *) CKSEG0ADDR(phys_addr); > + } > > Currently I can't figure out what obvious problems it may cause. But > It seems suspicious that the cacheable IO-mapping hasn't been > implemented by the unmapped cacheable region in the first place. In > anyway this solution looks more dangerous than solution 2. because it > affects all the MIPS32 platforms at once. I just made a quick grep in tree, and it seems like we don't have much user of ioremap_cache (as well as ioremap_uc/wc) here so I think it is a safe assumption. > > 2. Convert dmi_remap_early() to ioremap_uc() (actually just ioremap() > as noted by Arnd). > As Jiaxun correctly noted this may cause problems on the platforms > which don't flush caches before jumping out to the kernel. Thomas said > that kernel flushes the caches early on boot, but Jiaxun noted that > it's still done after early DMI setup. So the issue with solution 2 is > that the setup_arch() method calls dmi_setup() before it flushes the > caches by means of the cpu_cache_init() method. I guess it can be > fixed just by moving the dmi_setup() method invocation to be after the > cpu_cache_init() is called. This solution looks much less invasive > than solution 1. I recall Tiezhu made dmi_setup() here for reasons. The first reason is t= hat DMI is placed at memory space that is not reserved, so it may get clobbe= red after mm is up. The second is we may have some early quirks depends on D= MI information. Thanks. > > So what do you think? What solution do you prefer? Perhaps > alternative? > > -Serge(y) > >>=20 >> Thanks >> > >> > Thomas. >> > >> > --=20 >> > Crap can work. Given enough thrust pigs will fly, but it's not nece= ssarily a >> > good idea. [ RFC1925= , 2.3 ] >>=20 >> --=20 >> - Jiaxun --=20 - Jiaxun