Message ID | 20230503-virt-to-pfn-v6-4-rc1-v2-11-0948d38bddab@linaro.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1261457vqo; Mon, 22 May 2023 00:16:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6DIfadg2h7zCOHeeXDzvbBbtg5ntP3Sly4VgPFhc/b0UkLkfAeO7G+Lij+vOIgovAW8vHh X-Received: by 2002:a05:6a20:8f05:b0:10b:d045:f0cf with SMTP id b5-20020a056a208f0500b0010bd045f0cfmr1551756pzk.23.1684739761703; Mon, 22 May 2023 00:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684739761; cv=none; d=google.com; s=arc-20160816; b=GwK07oYmpkF/Uiou1KxxDY30e/LFSPU3I055c19oeW1fC5DefyYmuH61kaX8Dud4zA II0tYBEkZmKM2xbi/5HHQ0FSLPkDFiPA3vOlG3U4WClAtOQaHXKUX7GlHAWanwp5WzGL VwOYlpyZQQf82GAV8YAuIW7nzS9f6xONXG2X8H5T2fFfFX9xT32Tuf29oTLSWQKEefGg sqw6+jj2gxNdH+rlZEA2SnprKbCwfMIlQwyVs61B1uPUx38StFKcbX4/BDhYYIhh5Nzh MeQIVoGCeP/+5i/jpJhGFnG/38Dyy9kD+No+JZD3zDl/9kDmLVFyOhhzPBh1iYcqle2J 7MLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=721W88MgL2sNJMPnk6EOnDreN0TGHiKcLljkK4k+Xz4=; b=a28VhuLuIoW0gkKl/X2kczyr8RHsT2dkGjLhaffw8rCgY0U8zl8Zzf7WrAYlzb9T1D MJX50KMBq7NSx7FdZYZlxaUU2zjAPIhtK2mlUxHZXvb/xe2zlZ1//2gAq3FAieOK8mEr 3MD0rAkQ8GUrVhQ6JprcG40L20kW7mYRVxf3/BoIPNpDOFPZWllEKNMETs6nRYj9iZhH KDFUost1LP4Wx7YgBlQj3cvVbqz7Mn6/v9psL75RH1u9BKrrxeRBah9+y9uYEZYxFEA0 YNXvT6baZzEqTO8dD+7WyogvF52K3K26PALcoumIPiYQueyAYOLeIDnnfd25g3i2n7F8 u1Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XQtAW71u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a5-20020a637045000000b005309e9ab3b8si4208635pgn.795.2023.05.22.00.15.46; Mon, 22 May 2023 00:16:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XQtAW71u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232214AbjEVHCm (ORCPT <rfc822;cscallsign@gmail.com> + 99 others); Mon, 22 May 2023 03:02:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232255AbjEVHBd (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 22 May 2023 03:01:33 -0400 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F41219B for <linux-kernel@vger.kernel.org>; Mon, 22 May 2023 00:00:53 -0700 (PDT) Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2af20198f20so41912251fa.0 for <linux-kernel@vger.kernel.org>; Mon, 22 May 2023 00:00:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684738851; x=1687330851; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=721W88MgL2sNJMPnk6EOnDreN0TGHiKcLljkK4k+Xz4=; b=XQtAW71u4fTNd1m3CoQ2jBdXD9/L9co0wiCGXKPV7VPHkFBkn2paLpq4u7Zun4vihP Jt89fVfIK/kqwIEhUG0rEaMiY9youfI2gwNHpVmFNoLUlHPTqMB+dSsLsyZ0Nud3GfbF dtwCWhOjSDsxmfy8EsojhF7c8s35Z8LE87tWI+GqyJFAAak2TwvLXaQdq7RckdkYTHnU 18kKgbLJk4GVeA4A4vRYQZN2Dj0n1wcSakUxJpXVVadQkTB4oxfQonCpFh8YOMyqM+LF 0rSyjSqVr+DzD+fnTYDbXV9mB2Zq6QefKszArXVUbAr8pzAQFYflvnoSfXBTu+vX7dJn HUmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684738851; x=1687330851; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=721W88MgL2sNJMPnk6EOnDreN0TGHiKcLljkK4k+Xz4=; b=DFFEvEQjx6vVsG/Jvc9TLcR2iYwOya5OC2LpCKIEENLQJhr0lLihTn5oiYjGs/VlWI phrtHBsNeBz6qC0QwTQEIoRcvbaMIOjzv02CfPQlZCPpTJUAAaXvW195D8lT3N1qAEuz SL+qYcScF3UPjfnx450q2SJhHd19PrY1c2hm/Wvu8opJklF06XCrol8krNkqE2Myrl43 tsn4V0VUJ5KOy6i4RkIOvp7J4kCkqIhS44xsYA6gZmNlLznwjbMC6J/MdlAKVn4Q1qQO ePFNHb+u/igoXci02s2DWHQhvG3UAyRVrkmF9ujMFjYcpIhz0vNPtQPRFvPxrthbYE03 NfdA== X-Gm-Message-State: AC+VfDxjfTuQQK2PinAgwkVkAaCgBX6O4TBJU38dvnnXTdfbLi8bMjVW y1WJp9vB/4hooXp3mAG+S7XUZQ== X-Received: by 2002:a2e:8e89:0:b0:2b0:259d:f670 with SMTP id z9-20020a2e8e89000000b002b0259df670mr453615ljk.4.1684738850979; Mon, 22 May 2023 00:00:50 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id q4-20020a2e8744000000b002adb98fdf81sm1010187ljj.7.2023.05.22.00.00.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 May 2023 00:00:50 -0700 (PDT) From: Linus Walleij <linus.walleij@linaro.org> Date: Mon, 22 May 2023 09:00:46 +0200 Subject: [PATCH v2 11/12] arm64: memory: Make virt_to_pfn() a static inline MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230503-virt-to-pfn-v6-4-rc1-v2-11-0948d38bddab@linaro.org> References: <20230503-virt-to-pfn-v6-4-rc1-v2-0-0948d38bddab@linaro.org> In-Reply-To: <20230503-virt-to-pfn-v6-4-rc1-v2-0-0948d38bddab@linaro.org> To: Andrew Morton <akpm@linux-foundation.org>, Geert Uytterhoeven <geert@linux-m68k.org>, Vineet Gupta <vgupta@kernel.org>, Catalin Marinas <catalin.marinas@arm.com>, Will Deacon <will@kernel.org>, Arnd Bergmann <arnd@arndb.de>, Russell King <linux@armlinux.org.uk>, Greg Ungerer <gerg@linux-m68k.org> Cc: linux-mm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-snps-arc@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, Linus Walleij <linus.walleij@linaro.org> X-Mailer: b4 0.12.1 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766577680443517057?= X-GMAIL-MSGID: =?utf-8?q?1766577680443517057?= |
Series |
arch: Make virt_to_pfn into a static inline
|
|
Commit Message
Linus Walleij
May 22, 2023, 7 a.m. UTC
Making virt_to_pfn() a static inline taking a strongly typed (const void *) makes the contract of a passing a pointer of that type to the function explicit and exposes any misuse of the macro virt_to_pfn() acting polymorphic and accepting many types such as (void *), (unitptr_t) or (unsigned long) as arguments without warnings. Since arm64 is using <asm-generic/memory_model.h> to provide __phys_to_pfn() we need to move the inclusion of that header up, so we can resolve the static inline at compile time. Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> --- arch/arm64/include/asm/memory.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index c735afdf639b..4d85212b622e 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -331,6 +331,14 @@ static inline void *phys_to_virt(phys_addr_t x) return (void *)(__phys_to_virt(x)); } +/* Needed already here for resolving __phys_to_pfn() in virt_to_pfn() */ +#include <asm-generic/memory_model.h> + +static inline unsigned long virt_to_pfn(const void *kaddr) +{ + return __phys_to_pfn(virt_to_phys(kaddr)); +} + /* * Drivers should NOT use these either. */ @@ -339,7 +347,6 @@ static inline void *phys_to_virt(phys_addr_t x) #define __pa_nodebug(x) __virt_to_phys_nodebug((unsigned long)(x)) #define __va(x) ((void *)__phys_to_virt((phys_addr_t)(x))) #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) -#define virt_to_pfn(x) __phys_to_pfn(__virt_to_phys((unsigned long)(x))) #define sym_to_pfn(x) __phys_to_pfn(__pa_symbol(x)) /*