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 A74D0C4167B for ; Tue, 28 Nov 2023 12:42:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DC2186B0274; Tue, 28 Nov 2023 07:42:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D70DD6B027B; Tue, 28 Nov 2023 07:42:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C119A6B027D; Tue, 28 Nov 2023 07:42:17 -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 AE93F6B0274 for ; Tue, 28 Nov 2023 07:42:17 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7FFFC1401DF for ; Tue, 28 Nov 2023 12:42:17 +0000 (UTC) X-FDA: 81507325914.01.DA98CAE Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by imf23.hostedemail.com (Postfix) with ESMTP id 4C952140018 for ; Tue, 28 Nov 2023 12:42:15 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=arndb.de header.s=fm3 header.b=xv5DXXzq; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=CS+dsxwk; dmarc=none; spf=pass (imf23.hostedemail.com: domain of arnd@arndb.de designates 66.111.4.27 as permitted sender) smtp.mailfrom=arnd@arndb.de ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1701175335; 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=Ue6oReQLoZ5Oz8hCPsHTLUlG6EjRwmqut/I46LFQnpk=; b=HSQQ5qkDcYs712NknjRozLQcEUF0ajA1mTCBy3EdEJkOfEIAuYZxfj42o5MabndWcHA0i6 ej14ba8fYZfRJuWIHZrTruu3ZGl2vbD540p4aaKvozrRAFXL0uHlur1UeKC5RX5v+0I8pA 3z+C64VqWNbL2I8SrDogUOn5kIfgbaQ= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=arndb.de header.s=fm3 header.b=xv5DXXzq; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=CS+dsxwk; dmarc=none; spf=pass (imf23.hostedemail.com: domain of arnd@arndb.de designates 66.111.4.27 as permitted sender) smtp.mailfrom=arnd@arndb.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701175335; a=rsa-sha256; cv=none; b=cuGIYmRlt0FWM/uISU4JeM5cLA9aCA2tDFv3KZ9mWfztZrjgiN+g+vzEhe/LjW8XNFss69 FznNj7ov8qXwizs65J6rhYfcR1YuJDQVx1vzS8sy908lDsluGAjey1kTM1FhGvuKbWLjP6 r1LLUd9qf6/Y/0q0fUahkZMYLx31TJU= Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 830725C015A; Tue, 28 Nov 2023 07:42:14 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Tue, 28 Nov 2023 07:42:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; 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=fm3; t= 1701175334; x=1701261734; bh=Ue6oReQLoZ5Oz8hCPsHTLUlG6EjRwmqut/I 46LFQnpk=; b=xv5DXXzqPoGR20U+yXYQPN2++85NxKAgeM/vF6pFQNuDkC0wBPW Yq+pnW45hZjQNbnyE3nOdKIjoJCsgR4QBn+d/+GuuoR/pts468sgBSCvVl8906d+ 3CbPa0sVI5a54PaRKBeCTzWUekfNbx60CnuWd3CyoLf8ROv5lxj/WsfKJPbkI4YQ YLwmpTUM5MIPqj8FvkwNr2WR4a9wLw2dKdRl8p84/B3he+JfKBpR5OVjxbQNnuYR MubfJCxk5BfCzy1E7+uLPh8fsfk08vRc65I+4ZzLYySiSjiwFgee4hebHLNL575i HegOUsGzTU/2ZUoxf2nCE89p/oZ4P/RcgwA== 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= 1701175334; x=1701261734; bh=Ue6oReQLoZ5Oz8hCPsHTLUlG6EjRwmqut/I 46LFQnpk=; b=CS+dsxwk8PJI5KpTR1LLt4P/a76kqkvG6LmdCkVC5ME7ucKQcAy IATnEs5LUhkc/SYVEIxJAc0eM8nNuw9TH99tr3Q8XcLK3aoeR9t9/fXzZYnyUcRA ld3ic+aTVTaU4MVdm6yXNjCyjS+LjCfrOdjhr4KlcyPVshu3QfkdhZNu7uWm5gVR 0j2SUbPzHhLoXU6OytgZbfxWAwuYCEEDeLxEn2XMMNZdxYYNF7YDjOQLfSHdOOWB WxwPIaiMmFLJL+HLagGVv+BPT7E/PLkaOj7WlIliaWvV2z3cEF4989wULiAHDDAl HR0SiqzCTWoO5LPO7D0VaFpiOBnSu3tjgtQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeifedggedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtgfesthhqredtreerjeenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpeegfeejhedvledvffeijeeijeeivddvhfeliedvleevheejleetgedukedt gfejveenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grrhhnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 96C34B6008D; Tue, 28 Nov 2023 07:42:12 -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: References: <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: Tue, 28 Nov 2023 13:41:51 +0100 From: "Arnd Bergmann" To: "Serge Semin" , "Jiaxun Yang" Cc: "Thomas Bogendoerfer" , "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-Rspam-User: X-Stat-Signature: ocp6b8zhd36qxsdqgdtz3c53j9wec5wc X-Rspamd-Server: rspam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DFcC1vP6G32mX88SlZGVb0lAaZWOjeL9avmQpkMVKQiNUHTpO7qlhpoCfYajjvFj7uyzLFJd01O+WfXc5Ztl6eSJ+Bk8bvW0FJ5bd67WIWBoeOuoAMA0znZ/FSgArQ2fH6hySKbzGnZBh2aWscezFFlXIt28j5TxWM+yyeZJOi+Hnr1Um6tUH3/O4z9L5LGrhPaASHtMS/kPRAfllVoklSwzWBGn8Q3K0ghT7mBBxOCq48q5D5H8ZEijHSzx7bQp8EanmwG2ew5VRLg== 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: On Mon, Nov 27, 2023, at 17:23, Serge Semin wrote: > On Fri, Nov 24, 2023 at 10:03:49PM +0000, Jiaxun Yang wrote: >> =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: >>=20 >> Thanks for such detailed conclusion! >> I'd prefer go solution 1, with comments below. >> > >> > 1. Use unmapped cached region utilization in the MIPS32 ioremap_pro= t() >> > 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 u= se >> > the unmapped cached region utilized for the IO-remaps called with t= he >> > "_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 (unles= s 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 u= sing KSEG1, >> > - * otherwise map using page tables. >> > + * Map uncached/default-cached objects in the low 512mb of = address >> > + * 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_add= r); >> > + else if (flags =3D=3D _page_cachable_default) >> > + return (void __iomem *) CKSEG0ADDR(phys_add= r); >> > + } >> > >> > 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. >>=20 >> 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. > > I wouldn't say there aren't much users. ioremap_wc() and it's > devm-version is widely utilized in the GPU and network and some other > subsystems. ioremap_cache() isn't widespread indeed. In anyway even a > single user must be supported in safely calling the method if it's > provided by the arch-code, otherwise the method could be considered as > just a bogus stub to have the kernel successfully built. I bet you'll > agree with that. But that's not the point in this case. ioremap_wc() is useful for mapping PCI attached memory such as frame buffers, but ioremap_cache() is generally underspecified because the resulting pointer is neither safe to dereference nor to pass into readl()/writel()/memcpy_fromio() on all architectures. There was an effort to convert the remaining ioremap_cache() calls into memremap() a few years ago, not sure if that's still being worked on but it would be the right thing to do. Arnd