From patchwork Tue May 23 14:05:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 98011 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2171586vqo; Tue, 23 May 2023 07:09:51 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5gBdV9Jf1szKh/2DQGTZnjPzZF1YSEuAk1waxyh6k3rFDoVjp5Peuv6x9gF66EUiCDC49b X-Received: by 2002:a05:6a20:7d81:b0:10c:8e4e:f303 with SMTP id v1-20020a056a207d8100b0010c8e4ef303mr2204873pzj.44.1684850991453; Tue, 23 May 2023 07:09:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684850991; cv=none; d=google.com; s=arc-20160816; b=Z3VLna8vmk1Udgw7O6zktuFsBAx5Q/RV3udIbVTfPlKWBmPakRKfEWTtqZHnAKmKe3 MnzeE/afkj+wEp6BoHDf3sHhM46njp3UqR7Pmsk4SPc0tGSw7K3aM00Qh33qGDMwm/X7 GjMKeHo/n6pzJBL3TUrTmlnCHrW/MG0VZT+0LoXhyVXVsdpV8TNSVCvg/CmKon3dBJgZ 4kIG8H1pMvVf8lilAf+qoQAWee1eKvpyJIQC8F0954XZFd3B0C46Zl18OgtdWzWM9oyK IXTqHPqMci9mYelisVjD1+ZtZPcpJKLh33mcbzMFOQbktLuzTiONHziWO3Up4aXtp1AC 3Byw== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j29-20020a633c1d000000b0050bd8dd1b5asi6487618pga.43.2023.05.23.07.09.38; Tue, 23 May 2023 07:09:51 -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 S237268AbjEWOI0 (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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766694313110819703?= X-GMAIL-MSGID: =?utf-8?q?1766694313110819703?= 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)) /*