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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56409CEDD9B for ; Wed, 9 Oct 2024 14:07:02 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4XNvpC6nLmz3bb2; Thu, 10 Oct 2024 01:06:59 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=103.168.172.146 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1728482819; cv=none; b=oGX1FLhrSyKYgalL7xT6i26OsdQ/B5jZgh0agpPKndCHcvsZ1ZrjOOC1JelLMfr6KYfqe1MPxZZrYmsZJNPPVcqGvc0y5keRICo0Ww4uQAtVqhg/BlE/ECxrJtjxguJFFm4uhv4wULYMCl3ivmsz3IkoKKXWw/btdDfmejhXs0LwP98BVA2mlslEWkHEX0yXeRN8xJoqpSm5lcZchh1Cdb7t4GKWxGw7ax8uLuynFAArUUaUUEEgUHl137XfBdYOL8iwSzciPvhNpxr0/HitwhtRz8GXlaxU//zqvh2L2Cz39ciEZdK0mj6CRQKG354uGKvsVPDla928Z6FEkAk2mw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1728482819; c=relaxed/relaxed; bh=7AEiig9c/7wiIG97Hr2tulDdk8lJo3CwPWgfvG3cqr0=; h=MIME-Version:Date:From:To:Cc:Message-Id:In-Reply-To:References: Subject:Content-Type; b=BqtZAKxvOScdxcrDW3eCubvtbsiTfI/NpEon78+wnx3FBdVr4wZ5d4VFV7R4An6LAqLN5UPCezZKtDseRAppQ6b+EvGwBE2W86FTaQBwTDClyyO/ZS0f2VX/XhbCILI1p7zRj1R8vSHQNp4MfFXn+4UoyP8GdESck1M9GoRTwLMNzjnSx1/VeK6YbJrpfgLPRachdKtOEM6Pz4RH7mnR+DXgDKpgRQsEz6EXNzb45gvahPd5TPUHzq2lHUataUooFf4lbazuB+wU4weBL3PFRu0F7l6AtvjvSDpdA473xBQBkhPGTmLK5KxuX/aH9y82WPH+oOUG66W/i2ax2fMyng== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=arndb.de; dkim=pass (2048-bit key; unprotected) header.d=arndb.de header.i=@arndb.de header.a=rsa-sha256 header.s=fm1 header.b=oQOs8kCK; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=oMeceCAt; dkim-atps=neutral; spf=pass (client-ip=103.168.172.146; helo=fout-a3-smtp.messagingengine.com; envelope-from=arnd@arndb.de; receiver=lists.ozlabs.org) smtp.mailfrom=arndb.de Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=arndb.de header.i=@arndb.de header.a=rsa-sha256 header.s=fm1 header.b=oQOs8kCK; dkim=pass (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm2 header.b=oMeceCAt; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=arndb.de (client-ip=103.168.172.146; helo=fout-a3-smtp.messagingengine.com; envelope-from=arnd@arndb.de; receiver=lists.ozlabs.org) Received: from fout-a3-smtp.messagingengine.com (fout-a3-smtp.messagingengine.com [103.168.172.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4XNvp56w7Wz2xrJ for ; Thu, 10 Oct 2024 01:06:52 +1100 (AEDT) Received: from phl-compute-10.internal (phl-compute-10.phl.internal [10.202.2.50]) by mailfout.phl.internal (Postfix) with ESMTP id EEAA61380261; Wed, 9 Oct 2024 10:06:48 -0400 (EDT) Received: from phl-imap-11 ([10.202.2.101]) by phl-compute-10.internal (MEProxy); Wed, 09 Oct 2024 10:06:48 -0400 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:subject:subject:to:to; s=fm1; t=1728482808; x=1728569208; bh=7AEiig9c/7wiIG97Hr2tulDdk8lJo3CwPWgfvG3cqr0=; b= oQOs8kCK/NnoDFbeh8NYIFgnU7EWDJq210AZ17pgPcVr0s8t4Vq4QjsRC0QOkm8Q jU6UCfS39M7vux56KrOng2F6Y0yrmrZzpWAKeXdUH11BGy73irTZQZopAtPBoIkT 1qC9nbDwA8/QYmCZINeI38PZMF52GH342I+9Xx4uF8HHCQoNYhw+Gl6pC0Fq/eRT sKFmEByr3o62fi0DvAiYokJQUdQeXxzYLELzNb+wrIAU5eDcakrfFxQHKQxdH1O9 SfHAqBhlAMLApF0BxQP2CZcSwupwtvb+I4PNSyMIrfCHzthssd5U3WwMYy/6epDW rVBtFbK/Zt7gxM1+EguZpg== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1728482808; x= 1728569208; bh=7AEiig9c/7wiIG97Hr2tulDdk8lJo3CwPWgfvG3cqr0=; b=o MeceCAtz/bmQ10Z5D2RfVpXPfnSZkZguqJBx9lKa+IB8SFlwBCPlk5eEgsedk1Ie lXF69pWqnMlOmP8/el8nzFs+N+NKzBsmp91Bivm/h9eXpymcH4Zmlqw+RhggqN5v usMX3ePPR7QMH2UIKTSUK5NKiCsVomo/cryyyOEe4cHwZWQ8kdXYlrry93U9sDmP SfRh7XW/SZAqG14pXP1hy4afWVVe8+b+b1MEnAvf/sRjrbTolgC7ZYkemBMpUUMw AKYoXUl+0OsZy23/NtcODfuTUpj4FP4ZVjVxsYouXmnW5e1V615fvPw2n3qtF3rL qCd2RQ66eCJAJaUhMoWfw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrvdeffedgjeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgfgsehtjeertdertddt necuhfhrohhmpedftehrnhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrd guvgeqnecuggftrfgrthhtvghrnhephfdthfdvtdefhedukeetgefggffhjeeggeetfefg gfevudegudevledvkefhvdeinecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprghrnhgusegrrhhnuggsrdguvgdpnhgspghrtghpthhtohepudel pdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehlihhnuhigqdgrrhhmqdhkvghrnh gvlheslhhishhtshdrihhnfhhrrgguvggrugdrohhrghdprhgtphhtthhopehlihhnuhig qdhrihhstghvsehlihhsthhsrdhinhhfrhgruggvrggurdhorhhgpdhrtghpthhtoheplh hinhhugidqshhnphhsqdgrrhgtsehlihhsthhsrdhinhhfrhgruggvrggurdhorhhgpdhr tghpthhtoheplhhinhhugidquhhmsehlihhsthhsrdhinhhfrhgruggvrggurdhorhhgpd hrtghpthhtoheplhhinhhugidqmheikehksehlihhsthhsrdhlihhnuhigqdhmieekkhdr ohhrghdprhgtphhtthhopehlohhonhhgrghrtghhsehlihhsthhsrdhlihhnuhigrdguvg hvpdhrtghpthhtoheplhhinhhugihpphgtqdguvghvsehlihhsthhsrdhoiihlrggsshdr ohhrghdprhgtphhtthhopehhtghhsehlshhtrdguvgdprhgtphhtthhopehlihhnuhigqd grlhhphhgrsehvghgvrhdrkhgvrhhnvghlrdhorhhg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 6D3232220071; Wed, 9 Oct 2024 10:06:48 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Post: List-Subscribe: , , List-Unsubscribe: MIME-Version: 1.0 Date: Wed, 09 Oct 2024 14:06:27 +0000 From: "Arnd Bergmann" To: "Christoph Hellwig" Cc: linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, "linux-csky@vger.kernel.org" , linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, "linux-openrisc@vger.kernel.org" , linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, Linux-Arch Message-Id: <3e12014e-47a7-4cae-bcd1-87d301e1f80c@app.fastmail.com> In-Reply-To: <20241009114334.558004-2-hch@lst.de> References: <20241009114334.558004-1-hch@lst.de> <20241009114334.558004-2-hch@lst.de> Subject: Re: [PATCH] asm-generic: provide generic page_to_phys and phys_to_page implementations Content-Type: text/plain Content-Transfer-Encoding: 7bit On Wed, Oct 9, 2024, at 11:43, Christoph Hellwig wrote: > page_to_phys is duplicated by all architectures, and from some strange > reason placed in where it doesn't fit at all. > > phys_to_page is only provided by a few architectures despite having a lot > of open coded users. > > Provide generic versions in to make these > helpers more easily usable. > > Signed-off-by: Christoph Hellwig This is clearly a good idea, and I'm happy to take that through the asm-generic tree if there are no complaints. Do you have any other patches that depend on it? > -/* > - * Change "struct page" to physical address. > - */ > -static inline phys_addr_t page_to_phys(struct page *page) > -{ > - unsigned long pfn = page_to_pfn(page); > - > - WARN_ON(IS_ENABLED(CONFIG_DEBUG_VIRTUAL) && !pfn_valid(pfn)); > - > - return PFN_PHYS(pfn); > -} This part is technically a change in behavior, not sure how much anyone cares. > diff --git a/include/asm-generic/memory_model.h > b/include/asm-generic/memory_model.h > index 6796abe1900e30..3d51066f88f819 100644 > --- a/include/asm-generic/memory_model.h > +++ b/include/asm-generic/memory_model.h > @@ -64,6 +64,9 @@ static inline int pfn_valid(unsigned long pfn) > #define page_to_pfn __page_to_pfn > #define pfn_to_page __pfn_to_page > > +#define page_to_phys(page) __pfn_to_phys(page_to_pfn(page)) > +#define phys_to_page(phys) pfn_to_page(__phys_to_pfn(phys)) I think we should try to have a little fewer nested macros to evaluate here, right now this ends up expanding __pfn_to_phys, PFN_PHYS, PAGE_SHIFT, CONFIG_PAGE_SHIFT, page_to_pfn and __page_to_pfn. While the behavior is fine, modern gcc versions list all of those in an warning message if someone passes the wrong arguments. Changing the two macros above into inline functions would help as well, but may cause other problems. On a related note, it would be even better if we could come up with a generic definition for either __pa/__va or virt_to_phys/phys_to_virt. Most architectures define one of the two pairs in terms of the other, which leads to confusion with header include order. Arnd