Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4405145rwd; Tue, 23 May 2023 07:20:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ZqZVywBrujcZ7ZLcQUh2PkztrPUWAZAekEq1JNcXxqOOrAh3VwsbufGfzo+5my0p1uMOT X-Received: by 2002:a17:902:ce82:b0:19e:4bc3:b1ef with SMTP id f2-20020a170902ce8200b0019e4bc3b1efmr15369885plg.64.1684851642581; Tue, 23 May 2023 07:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684851642; cv=none; d=google.com; s=arc-20160816; b=plh/61xG7CzJ+B9efcHm4R0OhETkM+Aj20xVY4qHJ0BDZ3iC8VXc4MiT5PNRMEhg/8 DCk35PjLAiqke6EtP8AbLg3cci9hYfJEAONBbYITvpEweLHI0gWqV9bb3yvwC+F9jZhh JOuRsdim6X0uF3w1JAVBk20TmPstFTON5N0W5joCEC5bQ3DBTzqU5xkwdIlkigMnyLph eGJMKyhocwiPrgM3X8nht4lBpIKwSj2zxPhax+Lg2rMs2UTtPcHMYPccoA6WDJM4IT2s Lc3GruyUoYzA5ZLGFTZUSt0FskzqZ1ZSOXtPRpySw5KAGoTjXT8EcmaMb0YfPA52KuSt gOjg== 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=W/C8b4DiJjeWvwRZe6aiqqr/kgTHhvfN/2RtmH0QL9SRkw++Sw2l98+4je3I59EZYm SWuDQ7i88zeBNNMpxUsxC6FJ6c7JfW0sxWmfIasphEkPVHl04et7i4Sdry0oGqI5eUkx +ldT1ngffZYPAEQGZdQLYlpsb6wO9VxUdqBDeOGuaghACptBbNXG8O8HNHmgDyfMd4Ho 3n0gWjykFdPpxut12R8X1urgpPeKUnW6UxL+S0gVp/gej2qz7fShIStpJyV1Jl68sZ1O CPNXw4oofx3wFeCW6Jz0FJkcHads6u2A7ipPam0nVYvDACErS/X1cJktLpO2n0V5eg5A 8rFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=fzeFctH+; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l6-20020a170902f68600b001afd30b8fa4si797792plg.333.2023.05.23.07.20.29; Tue, 23 May 2023 07:20:42 -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=fzeFctH+; 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 S237267AbjEWOI0 (ORCPT + 99 others); Tue, 23 May 2023 10:08:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237192AbjEWOHZ (ORCPT ); Tue, 23 May 2023 10:07:25 -0400 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FFCBE58 for ; Tue, 23 May 2023 07:06:58 -0700 (PDT) Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-4f1411e8111so8183465e87.1 for ; Tue, 23 May 2023 07:06:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1684850756; x=1687442756; 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=fzeFctH+wspWO49TnIPElwVca6DLjWLQwYxkWmX/Iy1UmULCTqkJMiM0qA8MXZ/96E Dtzvq/Nx1wNuktXBNrc7rb+BddK3eOpeRmaIEM+nRheV+Bmapv0H53LUZOJqTGNjV3bP zWDe7Noi+kppHqm/7HwhlAvjZPM0NdHk76Cr/uat1pZJDm0mz4HCGb4uRkPCQwNqiDYu JW0aKwNZrkes49GmhKEiOFOCDjns4pmVJcNZeTw7Y/+UpIuTv7ewPTXRg18mgR0J2Qx3 I7hqjEkHLpYieL/NE9aRDNlp28sfW4e7RnZIt0ZnBTCL9b1MxLrV2Xk0Mrq3ZmPvUUoO qQfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684850756; x=1687442756; 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=KzMTOO8vM3hpc7gtS63HQFiFvK/DQ6aVqbOiGC4iv8btVfVTh51szncPPnDDeerl/d QFX/RY5OsdyeTSEUHCIX9G5+3wce+7IuYh6Wpj1Ll1UK0d4gRGg0ZX0H3EVlNRrY83RL Jd8XeNFpJBdo/5cBAyDaxjysqoKIs6VNpzAdi18Oyx7oIEWuL/BMk1eqZymZ/QKOw8Wu cBDws/VTiTGV2XGjql3SnbAsTylYDL3BmSsWH2bDjFb5FtslAlYYozNEzNzKzZOFFJJE DHXnkzX/Hn2r/2nJDD8e4luy4TdIyFkuwmy636leGZnndLxUZmwUi7/bwexTqAIi6M9h 1r5Q== X-Gm-Message-State: AC+VfDxXJAArR0JlWWc+M8AQQN+K25mHZ3dvh2pSwT5mfXfvCghOmmEo MF6oMJcElAOy78TmMT3CH2dDAw== X-Received: by 2002:ac2:44c8:0:b0:4f1:b3ab:cd61 with SMTP id d8-20020ac244c8000000b004f1b3abcd61mr3958413lfm.61.1684850756424; Tue, 23 May 2023 07:05:56 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id h28-20020ac2597c000000b004e9bf853c27sm1346562lfp.70.2023.05.23.07.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 May 2023 07:05:56 -0700 (PDT) From: Linus Walleij Date: Tue, 23 May 2023 16:05:35 +0200 Subject: [PATCH v3 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-v3-11-a16c19c03583@linaro.org> References: <20230503-virt-to-pfn-v6-4-rc1-v3-0-a16c19c03583@linaro.org> In-Reply-To: <20230503-virt-to-pfn-v6-4-rc1-v3-0-a16c19c03583@linaro.org> To: Andrew Morton , Geert Uytterhoeven , Vineet Gupta , Catalin Marinas , Will Deacon , Arnd Bergmann , Russell King , Greg Ungerer 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, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, Linus Walleij 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, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 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 Signed-off-by: Linus Walleij --- 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 + +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)) /* -- 2.34.1