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 A09B3C4167B for ; Tue, 28 Nov 2023 21:59:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 10E456B0368; Tue, 28 Nov 2023 16:59:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0BF5E6B0369; Tue, 28 Nov 2023 16:59:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EC8656B036B; Tue, 28 Nov 2023 16:59:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id E1A7E6B0368 for ; Tue, 28 Nov 2023 16:59:46 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id B6FBAC0333 for ; Tue, 28 Nov 2023 21:59:46 +0000 (UTC) X-FDA: 81508730772.29.3FC5706 Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by imf11.hostedemail.com (Postfix) with ESMTP id 9CBBC40017 for ; Tue, 28 Nov 2023 21:59:44 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=arndb.de header.s=fm3 header.b=YadBYp87; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=YRhLjdkU; dmarc=none; spf=pass (imf11.hostedemail.com: domain of arnd@arndb.de designates 66.111.4.26 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=1701208784; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=d8dJOAJYV2mmOf6TcGIvZmDZwHIgzbX0ltRZ3M1V2lw=; b=iTIVP/44YqGsW9zOUmFiYNtSFFGQbWXOQjXgUA5Szxuam7A5Kgb+4Ygsbp0YxAh2bK/T6F W726z7rcPhUfUHEp+E+ISbtmDGjbK214SboBDfesMjlSqx/zDYZDcM6E6JsKWgE9pGdkFs aeyn76jtkle3aWIM0wdd/BYVUU4tz+0= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=arndb.de header.s=fm3 header.b=YadBYp87; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=YRhLjdkU; dmarc=none; spf=pass (imf11.hostedemail.com: domain of arnd@arndb.de designates 66.111.4.26 as permitted sender) smtp.mailfrom=arnd@arndb.de ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701208784; a=rsa-sha256; cv=none; b=jzyLsq/0+Y8obacc40nQKtjC9a4DXERmdBmM8D5R7KmrUaht1TKsypWWjQcmX5M7H4jvNi xm7w+V37/oxl/uDuJ5R6ztvM53rnoNd2pBQSJhGcGOWu9ZnOR1h17KO+OyfRw87n3PiiXQ 9LRJcLBU1mj4ezHbaZjNvtprFzA5Br4= Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id C9DE05C01C9; Tue, 28 Nov 2023 16:59:43 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Tue, 28 Nov 2023 16:59:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc: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=1701208783; x=1701295183; bh=d8 dJOAJYV2mmOf6TcGIvZmDZwHIgzbX0ltRZ3M1V2lw=; b=YadBYp87SiMJCaGzl2 yVc3F50keLYMG0BPExwY8/BqRr1jtomyhEMHUHcjv1B7Y0wKLCawIKdX6iESbFQQ 4vhEAkznbyaTd6QYK3Aw58pnQHFyNK7vOzA0xuTo1K++WTdH5Hw9XWP9l0j+6nVn aMeRCc5Uf2YujIdPdbaVOX/Bh3mZ+/TW16bSdDf4ucNINlZNB1pXhksKlpfCROo/ 6m4seBQbPWXnNI+dzGPyZfycWzf88q44WxOIe7T3h+z2rLUlaWRhfIufbJOOfLdV ItxFUAyRfq4woqYXsdgd8c8vLoaSeWJRAzQis6EPnhDwx7jnuVX6WuyHBj8WbET3 jmvQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=1701208783; x=1701295183; bh=d8dJOAJYV2mmO f6TcGIvZmDZwHIgzbX0ltRZ3M1V2lw=; b=YRhLjdkUetYblVbHU3qi3TsBj1N2h l371QqfFu4yKaZo3e7wvdFu3CVifWDqBD8dyKz2ggJ4czdkoJzGz06jtLorXUU+6 RvWcCmE9CLI7OpYTNPr2fSgg/fdrdB14owu5Zn/rvCfBNCJ5xtt187Tvi1UaG+gT fGPzNFACe1HInjwdphnTR9FoPucssW079THQ01K0hPBWOAJK/e6lVzFBv4ZMT7sK EizBVnE11+dpAYOLLJ3xMQxHPUPqh2PKIrrp9zU5mkLJ6cRdtHa1u7X0wmPT+B+t 3tEeaZWfKA5axK/pCDxMSm/P9w+dco8mszuqdC14OBpH/v2oah6z2Xfww== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeifedgudehgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedt keetffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grrhhnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 4C268B60089; Tue, 28 Nov 2023 16:59:42 -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: <00c225bf-ed99-4721-9d6a-1e58cdffc79f@app.fastmail.com> In-Reply-To: References: <8ca730b9-fa8c-46ea-bdc5-158da0f29c3a@app.fastmail.com> <245d3985-9085-4be0-8c74-d95d06334584@app.fastmail.com> <3iksuovvsln3cw3xpmjd7f7xixfvwaneu4ok56fnookvyolpco@wrxxew3thgnq> Date: Tue, 28 Nov 2023 22:59:10 +0100 From: "Arnd Bergmann" To: "Serge Semin" Cc: "Jiaxun Yang" , "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 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 9CBBC40017 X-Stat-Signature: h3wegot3tr3ankjcnnjr88qx5wcjcbib X-Rspam-User: X-HE-Tag: 1701208784-78608 X-H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aas8NzSl4boADHv3QaDUjl+AgnfUYE/QAPjTPt7NA6NQa3EqvIAuZLI7VbrisVdIC4kvFGAQFAYE5A5xQrdjHq5zxlQPSB/9XHslCwr6IDWxlYiK17sj4nvdhfjqRUddTm4L6tz/4yx64Yews70cfJf+tIZNmYSaaogLN+5HirZV0K764dLrWymetV 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 Tue, Nov 28, 2023, at 14:52, Serge Semin wrote: > On Tue, Nov 28, 2023 at 01:41:51PM +0100, Arnd Bergmann wrote: >> On Mon, Nov 27, 2023, at 17:23, Serge Semin wrote: >> > On Fri, Nov 24, 2023 at 10:03:49PM +0000, Jiaxun Yang wrote: >> 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. > > I don't know about ARM64 (which for instance has it utilized to access > the DMI region), but at least in case of MIPS32 (a fortiori MIPS64 > seeing the ioremap_cache() method actually returns a pointer to the > uncached region) I don't see a reason why it wouldn't be safe in both > cases described by you. All IO and memory regions are accessed by the > generic load and store instructions. The only difference is that the > MMIO-space accessors normally implies additional barriers, which just > slow down the execution, but shouldn't cause any other problem. Could > you clarify why do you think otherwise? On arch/powerpc, CONFIG_PPC_INDIRECT_MMIO makes all ioremap() type functions return a token that can be passed into the readl/writel family but that is not a pointer you can dereference. On s390, the mechanism is different, but similarly __iomem tokens are not pointers at all. >> 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. > > I see. Thanks for the pointing out to that. I guess it could be done > for MIPS too (at least on our MIPS32 platform DMI is just a memory > region pre-initialized by the bootloader), but the conversion would > require much efforts. Alas currently I can't afford to get it > implemented in the framework of this patchset. (I saved your note in > my MIPS TODO list though. Let's hope eventually I'll be able to get > back to this topic.) I just noticed that the only architectures that actually provide ioremap_cache() are x86, arm, arm64, mips, loongarch, powerpc, sh and xtensa. The ones that have ACPI support still definitely need it, most of the other ones can probably be fixed without too much trouble. Arnd