From patchwork Thu May 11 11:59:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 92494 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4313809vqo; Thu, 11 May 2023 05:04:45 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ77YVzC2ekDSJy1ZCx//0UHHsKQ7VUgs489rLY8ZGplMUdHYET8rQdAMulLuFWKXMfkajKx X-Received: by 2002:a05:6a20:7353:b0:fb:8140:cec6 with SMTP id v19-20020a056a20735300b000fb8140cec6mr25219778pzc.8.1683806684758; Thu, 11 May 2023 05:04:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683806684; cv=none; d=google.com; s=arc-20160816; b=gCHswfjQdsd7KQQHpgap2l+Yawo8rra+8q7s+GT5MTH//ISsjkUqkgBYDr4l98+EYg eiYnmUai1oZjmg0xQut9107YKFoGLAbnzxpCCRx1VybfoizLyvzThFfIh7j2WlSssFF6 fXCaqSVobjtYwcdMhlaDDbNuqsIMvsQaXDUvx6vz6rVZ1IBCUfj0wNzYdr5yhlk6j+Rs kT8TpMdJP3Ba1UBVJZ8JlfUol6yGOqyzYHFL3NpNfAMYeyq2GnidZGJbf5fTJCYRr5DY ZJBmIwNiX8NwMxABaioUkByWG5PgBNV+KsB6T3J47DjZCmYgfuTOVjN/TFJMutCI+c27 Ji1A== 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=uJU163QagIQsrvP5Rw+8jaAtPEKkrWxHz6dgH9Ny+pM=; b=OSeC4RZuMIL3nwD8c7GAlyjMCx+tQgKbS+Xu2gEbPL6VApznBl/yk6IZ1JRtH4KK4b 5DwfGXofSTwHW5BSCubaz5kjZ6cJo9+39NP7dLnyocTlmKFfOUEDyPeHAK5PBx7Z1pR6 MY9k9ji/UjLfR5uarHifhbwvWUUhlRhULasfksoCz1X42KArr8ByYBjh4/GW8SvMnOMC PCtUvbhlyOKKlRE4o96KO1habf+sHdGpw2m4drJSKq7coV+9D1dB3YOSW9ubGziRKV1C dYDRvpdQs001/DlRm4ljJMJhtisGORItzCZxBTVdZJvq+VbPWzFOX94+HxJExPBbZmbb cswA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OVzygYKF; 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 s10-20020a63770a000000b0052c885da616si7453011pgc.337.2023.05.11.05.04.11; Thu, 11 May 2023 05:04:44 -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=OVzygYKF; 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 S238091AbjEKMBT (ORCPT + 99 others); Thu, 11 May 2023 08:01:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237989AbjEKMA0 (ORCPT ); Thu, 11 May 2023 08:00:26 -0400 Received: from mail-lf1-x12f.google.com (mail-lf1-x12f.google.com [IPv6:2a00:1450:4864:20::12f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F19A7D050 for ; Thu, 11 May 2023 04:59:57 -0700 (PDT) Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-4effb818c37so9655020e87.3 for ; Thu, 11 May 2023 04:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683806397; x=1686398397; 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=uJU163QagIQsrvP5Rw+8jaAtPEKkrWxHz6dgH9Ny+pM=; b=OVzygYKFGH1TTuxbFUj+CoSj3NrTaizXuR71JpjrxDkWl2PVUYhH5JT70fm6co/+NH tgSpK7iB7XOIFx/oZ27wrlRvxiiOU0TkhphL4Cjxz38b+G77ryH+u4qiryaQVZOcLNF0 H0/G73Db2ZLdNZ+R+FwIBPtPTT8FO9chca9MkRhxDx0g0MNcweB6mimyP670IWhPwMJJ Zi33byy7BPYmwDP7tGDqy3rZxw7unhbkfjS7DQcxkZzUfpvfhpgVrM2yoH5+zUDj/FTE k6lQKniemblf8dnVu3vStZsdx03og3rxM39S2DuvQLZfuDbOnEOTZqUyvlVqW9qAn7Vc 1b6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683806397; x=1686398397; 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=uJU163QagIQsrvP5Rw+8jaAtPEKkrWxHz6dgH9Ny+pM=; b=hFn06hG4Y1kEAoK3aRmXFFq5VvOMeE9Kb83wQmyyl/BIobIzLpo+PlRNVqD+kAsMEl pDvq3likdkd+g8NiUfEY0+sA1ZoyTSc+76N4YvrmmCW5Uv+iHgBe1DNyT0HFH2+YWvUz IgynAxEz+g1ZZcSYnmLelos29WYBrYWbSubQ2s8uIIYHtIvYR60qWz0uH3za1XTh2PHh 2ug1T2uGEUsNhpelHSa3yUK0/PCuAwA4/qaCl+wsc30my7y49ThqOKr5RrHDlDoBFY8x thkyyTR1a5HRhbd8ySs3P1v6LL/0b9Ilq8Q949ypfXX6iKA4g6tStme48FDWA8ZNqHJ0 tz+g== X-Gm-Message-State: AC+VfDy8aqEJI8wzdd5zaLBLSUsxZbTfRsFNX0KXFzzMSop/H/4Xw5ea laUuOF6JLkgFE4Yi0iQ0LRAAEw== X-Received: by 2002:a19:ad43:0:b0:4ef:d5fb:c37c with SMTP id s3-20020a19ad43000000b004efd5fbc37cmr2214552lfd.69.1683806397378; Thu, 11 May 2023 04:59:57 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id f16-20020ac25090000000b004cb23904bd9sm1100841lfm.144.2023.05.11.04.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 May 2023 04:59:57 -0700 (PDT) From: Linus Walleij Date: Thu, 11 May 2023 13:59:28 +0200 Subject: [PATCH 11/12] arm64: memory: Make virt_to_pfn() a static inline MIME-Version: 1.0 Message-Id: <20230503-virt-to-pfn-v6-4-rc1-v1-11-6c4698dcf9c8@linaro.org> References: <20230503-virt-to-pfn-v6-4-rc1-v1-0-6c4698dcf9c8@linaro.org> In-Reply-To: <20230503-virt-to-pfn-v6-4-rc1-v1-0-6c4698dcf9c8@linaro.org> To: Geert Uytterhoeven , Vineet Gupta , Catalin Marinas , Will Deacon , Arnd Bergmann , Russell King , Greg Ungerer Cc: 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 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765599278261121061?= X-GMAIL-MSGID: =?utf-8?q?1765599278261121061?= 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. Signed-off-by: Linus Walleij Acked-by: Catalin Marinas --- 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)) /*