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: 13252475 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 54093C7EE23 for ; Tue, 23 May 2023 14:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xp9XSZGz1rW5CxJ2P2/ZFB8ROAbLTUabnnAHIPK9Y3c=; b=AQGdPgrWWm4PLQ BOlSpHlh3itP+u7jfsAxvqmtH1kwUQYiDk/CTAEiq3C2zrPzRu0tGs/tlD/lnD6SwLAaIVDOxZRPf 0B9WH8Kq47OtFrMKEcMny4dy/yMJWn74eHDpOVRXT/r64EnNCr3bOPgw59u7EuyJf/7k8Ejqx3+X1 m2E5QHlWwWdiTH/0Wx6xmVfFfF+JfDyG0C6uZpjmVcXFUNwFgzKLUrddfOD3+PmTtKMtPxfIrWAje W1hPNqpsb5sg9I5j6R63ToBqVDUCjBPdK622w0LvXS8xEazlOygaCKeQZYyAmoI5UCPGY5KOgEzTe QIJdgzQBm3dLeQmYXoig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q1TDZ-00AWsG-2D; Tue, 23 May 2023 14:42:29 +0000 Received: from desiato.infradead.org ([90.155.92.199]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1TDX-00AWqr-2K for linux-arm-kernel@bombadil.infradead.org; Tue, 23 May 2023 14:42:27 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=721W88MgL2sNJMPnk6EOnDreN0TGHiKcLljkK4k+Xz4=; b=A+SVbiPfr6zCjT2WlNpw+ZLcyd itagXMljWvJexmJIFB1rLjlTG9lNntTAIrNIBy8zdEltQ6PiYpxcab0sIznmLQfWxQCl0zfOzSZCn mdI6KOTgbvLEoY9R08/klygwBlnULzW6OeEQWeUt6H9zg23DF/zQ1ULaBpbA8FoMvuyIvSCjcYwNC MuN2gTI3+At3BZV1lmQoRX6BVuDGibaUQqt9GiaPekvH0t5vdDkWEYdL9iO4q4qJzkgaYRNA1bo6Z 7k0Mn+a+eVz3qAmOXPstWrNX9IQ4boS0wgR2mBDhaJBZhT+jvCRbdL7//Ho9Zc5u5KUWoWL5Zeozr 3JnXHWtg==; Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q1SfC-003Xyh-0L for linux-arm-kernel@lists.infradead.org; Tue, 23 May 2023 14:07:00 +0000 Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f4b384c09fso2310220e87.3 for ; Tue, 23 May 2023 07:06:57 -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=HgNRy0KjEWsyVlRLBXQjxTAkMCpjUuXA+OWmond+CDCsIgzAHxTP8GdZ1V9IFL0ePC +bm3GBVLnFIR4or2oXwMVf+37zAQta93UjXaNZPU+2sZw6UJlrkJkPDjkqprRChtdwEj TcOiK8oqtSb0jHXizo/gra2ttS3bqp2IvjZeo3JjbiVJVO9wbyZY0/+RnPtHpxO9yw10 AL52RzDZRXYC5tfNHjzmZXphGwS7QUPRW5a3fRZk7LLhlWHefHTjVGE4uEZTRYpvd5v6 lXUMgwL015vSt9lwajPhzL/cj0cm5FoJ+e8v0p27VEV0GPBEl9/yLFrVtXAw74M4YaSe ERhA== X-Gm-Message-State: AC+VfDwy5HaulOLZGkTtfKXB0l6WACbSmn4qa971pVEd4owf9qt/ykM5 LXJOjVPD1aH76KC5GBWPgGWSJQ== X-Google-Smtp-Source: ACHHUZ5UFM6na3wkD054/zYIWV2BKg/wO+VAD3UUEzInrp7pevvoaoeYweWFaAj8kQad51xlmVIoxg== 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230523_150658_381817_2F631957 X-CRM114-Status: GOOD ( 13.20 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.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)) /*