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 12E2CC61DF4 for ; Fri, 24 Nov 2023 22:34:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6474E6B0686; Fri, 24 Nov 2023 17:34:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F7C46B0687; Fri, 24 Nov 2023 17:34:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 498226B0688; Fri, 24 Nov 2023 17:34:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 3A2B36B0686 for ; Fri, 24 Nov 2023 17:34:50 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0AD2D1201D2 for ; Fri, 24 Nov 2023 22:34:50 +0000 (UTC) X-FDA: 81494303940.21.E84406D Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf05.hostedemail.com (Postfix) with ESMTP id B2D7610001B for ; Fri, 24 Nov 2023 22:34:47 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=flygoat.com header.s=fm2 header.b=nAweOz3Y; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=puCY3FCl; spf=pass (imf05.hostedemail.com: domain of jiaxun.yang@flygoat.com designates 66.111.4.26 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=1700865288; 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=cITV9NLe1Pev7AShBkoPVTITzs2wGg66LfUzxkV4dXM=; b=A9RFsubO4A2IasButtiuOEToLq62tu/dQZvYcTj9RiyQvl86SkJeYc2ZEDICSwPVlm9yAl bUfZgyGzZTW4Yo+C4Tu7G/gPhBU9a4QIRtdmu7+0SoMAIpzi8Vrjz3tibR5B1pWLZDFhma aPSYrpi53iuiv8hELsjng07h4gBWsvI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700865288; a=rsa-sha256; cv=none; b=lmc1ghbHHJp/UX/dLa6BoRwHxFfqXoPc75RC3LQyAf9okaYtmge2Zc89bXWs9dcYyomk9j OnGuXeXzJ95LD+Mzm8MeM68bvOeYjgU6/HnwERyrgZ/Lc5vGlSh7qJXKTUDB/onptMdklv cyT3q82ilxUPf9decVFhrl3A5oMuG4s= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=flygoat.com header.s=fm2 header.b=nAweOz3Y; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=puCY3FCl; spf=pass (imf05.hostedemail.com: domain of jiaxun.yang@flygoat.com designates 66.111.4.26 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 0B2D45C0166; Fri, 24 Nov 2023 17:34:47 -0500 (EST) Received: from imap44 ([10.202.2.94]) by compute3.internal (MEProxy); Fri, 24 Nov 2023 17:34:47 -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= 1700865287; x=1700951687; bh=cITV9NLe1Pev7AShBkoPVTITzs2wGg66LfU zxkV4dXM=; b=nAweOz3YwxiIka2d6mBZi72XfvT5fH4r2Kvp5bjWDssH5B7/WQG rWiH/RAOnu6iEeBIC/xYOWuMHfmjl+wnwMMy7nKVWkmbCzZmxH3vDuiohM420y8f e/8cfeh1yasAJK377PKz9Lb+dbjKJdcm/0KchHKL0+y3G3JGj0kNwlBtadiR5ZKK 3QfYr1NwntuSTFY1MIG8eF4BlQsSFGJRiyRxYKv2ryw/O0utvFQZtFITVOUaEfn+ lQWEanNIC8n/jkTzuoPcwNohWDAq8Lk5LOZERTNWN4jjSWxSf/p/aWD5zobK+qXJ znrMZgMIgOSnUR0twQVz1M9D6R0K8J9FPow== 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= 1700865287; x=1700951687; bh=cITV9NLe1Pev7AShBkoPVTITzs2wGg66LfU zxkV4dXM=; b=puCY3FCl1l9FvNkLfYz8HwXlbCtsSO2dTM/iWlQar5cBvJG0LxX aboAkH81lwqsw5AsOLtP/mW7ljddsSmAjpxkzxSqR1npeMOzf6ycDL8/VmxLR0T8 crXqUyFqioArjymhfniTSWNTGTgXYWdpKfCtFpi9DkWtnhVh6/OudQeHpkTKSjLO 5btgHs04lbsNLTh+uh+H6st73KSvJleGOLrSpXTQsR3XdjfHHb600HDZuZJ/Tdj5 gyVoF6sB1pcdcHVTXhbdivIYJcSz7HvgbAGhcw2mJ9g6dQMACcskQO4tZD1Xf3M+ gTD27hVfjnXLiLQQjHGyNPLmbtGtKdspd3Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehiedgtdduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdfl ihgrgihunhcujggrnhhgfdcuoehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtoh hmqeenucggtffrrghtthgvrhhnpedufeegfeetudeghefftdehfefgveffleefgfehhfej ueegveethfduuddvieehgfenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 9237536A0075; Fri, 24 Nov 2023 17:34:46 -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: <7040f3a6-64f4-4110-9bf6-e65db85ea034@app.fastmail.com> 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:34:28 +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-Rspamd-Queue-Id: B2D7610001B X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: nyzhfypgfaxwx3ajdpdudbrorcfupy36 X-HE-Tag: 1700865287-933342 X-HE-Meta: U2FsdGVkX19QtW63W5PifozNNeJaSasfqh0GEhwkaZq4sskkO4im/3SAXDm3Mux0u0Y2Ohp3eg0MRgmlIMaYkWU49H9aTQYcC6fcx6sCiB0jXvQsVLX4pGRNsAADw8ZgpQwtDe92M269hrY7cRe/P0Rn39+ukaVybUM3DWTyVpTFLOLYgZuJtPy+VuKST3AKvQY8b5fNeDFiUN9UOrEcGwvnRlvOXViFG6pzj7ctThTDlcBSIhKW2xx2FrQjYDdR+/8ErLrekfAC8aXer1BvwDoX3mvBOCER/xMV+84ceidl/enXT2dPUpzQL1+eKgG2mupYpE4LtJbY2asxJFMGYsbpdbTnR2Hv/hJYs0f7teu0S/gspyxAUe8YvdVQXkmNKzkXq6TlqC4+OymrOIkBp5BbBFe65aXtgtefjYD5FfZiX/G34OMISLyHYsIjCKYD0FBhhMr2CA2RPP/Z0GKr+frqo/IgtU34pxZ3rtAlrGvivW1Zb1YmsQEsaFpPAaNXNbW6JmXJk+XePvOj2gWTj97f8m86DKFPlf0UAqTdtkKaGWWpJEKoGYOVE4unMlj7w34UayrqNoG8JjCNZXVirSSooFWsko0FfD9eSPYj9zIuCouYI/qUO0xkiXfFQ9J2KXFdtaA1wCxgHXcWQffCGAv2DyYQl7/BW223fnbseN8Rzox5oaGir2U9DppziiL7VcAqjUIAQCLK1om5rAQL1wW1wIl/lKC1O/oLl/HEys1NOcqx9sdyEdeYsSh3cRV4Ey/wk9qrZV5AY0+r3hHWPfA8AuNpWJ9wXS+alytzm9Gzxhylq0r4XOEh6stWDliNdyy8bw5AABTC8kOmmwR1KMQhmsoxsRFgnmwmy5LX467guMW1UpsQQfsQ6VhsySDdDC7zlEbcGC6m2wkevMBrvpnNMBDjDEQ5SKN5MHDuuyO1B/37TNXuP109NDF67FDeZrrxk6DHeuEk3anua0g NFRjhqkv ZUKtmMMxIyEHV329iwO3255C9sgUzZv8/TCSBSaxLjUPfgx1H/pd2Ndyss6u1voUxQ3HUxVNXQ+3wdhr3n9nfj8l0Cf1kco/VXd58LVqBgIA9L8yBsMnoJgFwW2bhPg2APEMGwh4a1Bb0Sw6Uc4FtxrtfFPqUHXi4zQu/H9PJ3njm7J+YBrlTqQR2ilzqP/wzgTKl1mxEJdee9/UmDp2EzjvOkeuNRL1xAnEU8wBme+1CbePVqWQWBUPY/RfZSICR6JnTliz8+rnC1ZDMR+i5tnpNWer9htRC4jW63pljDkZ244MPL9T0CUBxVl+FU/82pFtAYrTSv3ZuVQbPJH+bjBIDSg== 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=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 >>=20 >> =E5=9C=A82023=E5=B9=B411=E6=9C=8823=E6=97=A5=E5=8D=81=E4=B8=80=E6=9C=88= =E4=B8=8B=E5=8D=884:07=EF=BC=8CThomas Bogendoerfer=E5=86=99=E9=81=93=EF= =BC=9A >> > On Thu, Nov 23, 2023 at 03:07:09PM +0000, Jiaxun Yang wrote: >> >>=20 >> [...] >> > >> > the problem with all 32bit unmapped segments is their limitations in >> > size. But there is always room to try to use unmapped and fall back >> > to mapped, if it doesn't work. But I doubt anybody is going to >> > implement that. >>=20 >> Yep, I guess fallback should be implemented for ioremap_cache as well. >>=20 >> > >> >> >> AFAIK for Loongson DMI is located at cached memory so using ior= emap_uc >> >> >> blindly will cause inconsistency. >> >> > >> >> > why ? >> >>=20 >> >> Firmware sometimes does not flush those tables from cache back to = memory. >> >> For Loongson systems (as well as most MTI systems) cache is enable= d by >> >> firmware. >> > >> > kernel flushes all caches on startup, so there shouldn't be a probl= em. >>=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: > > 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); > + } > A nip, _page_cachable_default is set in cpu_cache_init() as well. We'd better move it to cpu-probe.c, or give it a reasonable default value. Thanks --=20 - Jiaxun