From patchwork Wed Nov 15 13:28:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 165358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2535553vqg; Wed, 15 Nov 2023 05:29:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGXHu1+xoNH5VeeTD65WIXr09yTRQc1EoLOOPsurzBY0TspeNZ+/l3GLz/Vf3lC1UUyEi29 X-Received: by 2002:a17:902:bf02:b0:1cc:45db:e21e with SMTP id bi2-20020a170902bf0200b001cc45dbe21emr5004082plb.37.1700054944866; Wed, 15 Nov 2023 05:29:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700054944; cv=none; d=google.com; s=arc-20160816; b=YcWhMTiNnByfCBM05rK9ySXcC7h/6LUAEhoJX86vf931OxyAH6n6YGmiVSuNC6LDkw l/vfN5QjM+52TuJaiVZ3/J08DSGnZN8yg8N16OkHwHxXH9pdm1yA0izxUOoPsHYp0vEH EtqoGIW/3D+GLlmXVlOAqAdSKlIJgYsPvo9mawD755B8j5EmVw+91FEOJwC+wVRPU/vJ x6qwkXD2qpvEZT9AbxPEDqP9LzGNGkKnoIHQG4L79KXRUUphOZlNm4LQKMi8MmVsFChn k2vLsLwaxyLE53/ucFu6EP4xtfXHzMG9VlhAR91DTLuwRSksqD5aPhQgkCSLjYqtasHb elSQ== 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=HrVNEt2cc/SjP2EDNi8Ypx4BpRW+YQfrsXMUopTWpaU=; fh=vhVM6SZxKPr2veBMjcAvhDXNjn/VVJMcYxTy29AXVyE=; b=X/crntYgmTqBbLDKE7j0qg7J+Q6W5aBZSpgU4yiCox/IbtUap0+9XtAKWM254AsGAu LYXZsk+kmK4zQWapO9Tgp3G9KNoGYxVi9h9zXiHIV55QywkkAYIn1Et5Q6CMnWVELp4K HeYmiv3P6EaCQvlEBy4zUEEw0I0kcNy84hhhO4Gd4H3nTdx1/jE6bZhqeFm/+2kaTC2i 85I5OrDmkD7DUTfO0cGhj91GDb8jBOkX2Epj7SAFgMptL67JQaM75U4JKJyU7cJ/I42w pVpxukZy1LMVH8vtVNiTcZx7lNvZNg53LQT1JsWEs28wyaBQjr0hSJEAnOGz2FkD2bKT 6HXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zprRwOvA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id p12-20020a170902eacc00b001cc43368c9bsi9699154pld.630.2023.11.15.05.29.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 05:29:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zprRwOvA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id E0F8F819A68A; Wed, 15 Nov 2023 05:29:01 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344080AbjKON2p (ORCPT + 28 others); Wed, 15 Nov 2023 08:28:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343973AbjKON2W (ORCPT ); Wed, 15 Nov 2023 08:28:22 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6A6819E for ; Wed, 15 Nov 2023 05:28:18 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-50970c2115eso9545473e87.1 for ; Wed, 15 Nov 2023 05:28:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700054897; x=1700659697; darn=vger.kernel.org; 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=HrVNEt2cc/SjP2EDNi8Ypx4BpRW+YQfrsXMUopTWpaU=; b=zprRwOvA48KLn950pgJrHqrGlQt3miOl3BufhUUpa3Iz/8XNOva97WZEFZoPaKAGyI aoYlFtcfm/rZDEg/rvpx6aCC5rxE2AyfeW2HnC2y/2wPkr5+VT1UN/wK3v/z4J+Sa1aX A4cwgmE3Jw/YtqHu5U/1e7rAVFggFyS19n9SAIDVBAfMctziWLh52DhvnRpCrIvufDKQ /UYV/xPt+JwoLfQe+0MzT3W03mBq8GsgDEwdWEHRY9BFwCD24ynJiz8HPfxVDan2iayC 82w+W1GNye5SGAsp7HpOxVHR8H4XSd+btDDQqgDsPzB7Q49Wm4/qol9F8iAIz7qFQ+vl YjAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700054897; x=1700659697; 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=HrVNEt2cc/SjP2EDNi8Ypx4BpRW+YQfrsXMUopTWpaU=; b=uhikUuSslqOCQ1UQ6TAMHdNi9Q6iqPFL4yBEDJB+zK/+2l+3AWX7Z7ZfSzF9Ni9CJT Y1+pEQWW9U2dmCXfDbqPkbc2O0Ix2GyBU1DJ7C52LG75aasExg67FF/GL4N9gQRtqaXM JiChQwh3EcqhY3fKTlZgfaLZ1En640RlQgh77REnaKKTNZ/E2Q9qIaOqBUlVZCaMDHhK Eu/LXYJA6nkHZOre/1Hyh/5b3qumk2iiFntAflRbJxDojdeSbnkoOdjYdFgo8McHP1AP 4yIaBd2HCdT/gUnZJbbEOp1YLygXQkV0gO1PDyAwrsgReEQifL3QoHlaMRhDkKXckuZi ffmQ== X-Gm-Message-State: AOJu0YyXJFgXKeuwHw4bd7xaToAs9hdBp1kFFIwgNv83c/ynV9RATHCh iNbMzWpK7z/f5xQGA14aWLvaGQ== X-Received: by 2002:a05:6512:4846:b0:507:9702:8e09 with SMTP id ep6-20020a056512484600b0050797028e09mr8331107lfb.2.1700054896889; Wed, 15 Nov 2023 05:28:16 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l12-20020a19c20c000000b00507b1da672bsm1648705lfc.174.2023.11.15.05.28.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 05:28:16 -0800 (PST) From: Linus Walleij Date: Wed, 15 Nov 2023 14:28:14 +0100 Subject: [PATCH 1/2] ARC: mm: Make virt_to_pfn() a static inline MIME-Version: 1.0 Message-Id: <20231115-virt-to-phy-arch-tree-v1-1-8b61296eae73@linaro.org> References: <20231115-virt-to-phy-arch-tree-v1-0-8b61296eae73@linaro.org> In-Reply-To: <20231115-virt-to-phy-arch-tree-v1-0-8b61296eae73@linaro.org> To: Arnd Bergmann , Vineet Gupta , Brian Cain Cc: linux-arch@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hexagon@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 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=ham 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 05:29:01 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782636813978102600 X-GMAIL-MSGID: 1782636813978102600 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. In order to do this we move the virt_to_phys() and below the definition of the __pa() and __va() macros so it compiles. The macro version was also able to do recursive symbol resolution. Signed-off-by: Linus Walleij --- arch/arc/include/asm/page.h | 21 ++++++++++++--------- arch/arc/include/asm/pgtable-levels.h | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h index 02b53ad811fb..def0dfb95b43 100644 --- a/arch/arc/include/asm/page.h +++ b/arch/arc/include/asm/page.h @@ -84,15 +84,6 @@ typedef struct { typedef struct page *pgtable_t; -/* - * Use virt_to_pfn with caution: - * If used in pte or paddr related macros, it could cause truncation - * in PAE40 builds - * As a rule of thumb, only use it in helpers starting with virt_ - * You have been warned ! - */ -#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) - /* * When HIGHMEM is enabled we have holes in the memory map so we need * pfn_valid() that takes into account the actual extents of the physical @@ -122,6 +113,18 @@ extern int pfn_valid(unsigned long pfn); #define __pa(vaddr) ((unsigned long)(vaddr)) #define __va(paddr) ((void *)((unsigned long)(paddr))) +/* + * Use virt_to_pfn with caution: + * If used in pte or paddr related macros, it could cause truncation + * in PAE40 builds + * As a rule of thumb, only use it in helpers starting with virt_ + * You have been warned ! + */ +static inline unsigned long virt_to_pfn(const void *kaddr) +{ + return __pa(kaddr) >> PAGE_SHIFT; +} + #define virt_to_page(kaddr) pfn_to_page(virt_to_pfn(kaddr)) #define virt_addr_valid(kaddr) pfn_valid(virt_to_pfn(kaddr)) diff --git a/arch/arc/include/asm/pgtable-levels.h b/arch/arc/include/asm/pgtable-levels.h index fc417c75c24d..86e148226463 100644 --- a/arch/arc/include/asm/pgtable-levels.h +++ b/arch/arc/include/asm/pgtable-levels.h @@ -159,7 +159,7 @@ #define pmd_clear(xp) do { pmd_val(*(xp)) = 0; } while (0) #define pmd_page_vaddr(pmd) (pmd_val(pmd) & PAGE_MASK) #define pmd_pfn(pmd) ((pmd_val(pmd) & PAGE_MASK) >> PAGE_SHIFT) -#define pmd_page(pmd) virt_to_page(pmd_page_vaddr(pmd)) +#define pmd_page(pmd) virt_to_page((void *)pmd_page_vaddr(pmd)) #define set_pmd(pmdp, pmd) (*(pmdp) = pmd) #define pmd_pgtable(pmd) ((pgtable_t) pmd_page(pmd)) From patchwork Wed Nov 15 13:28:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 165357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp2535501vqg; Wed, 15 Nov 2023 05:28:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IEKx8IsiTkLdAVB2YcH2cwcl7QucGtiiimgupP1DtdGXIdHiroDEFqWNjdHlPQhq+360wlN X-Received: by 2002:a05:6a00:9390:b0:6c9:af71:1de7 with SMTP id ka16-20020a056a00939000b006c9af711de7mr3327700pfb.11.1700054939428; Wed, 15 Nov 2023 05:28:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700054939; cv=none; d=google.com; s=arc-20160816; b=Fu3Mvq8J6bgT6lckKc6Ew84jwwICOXKInHyfVJUCElwhgTDREOkRg1qdrZrbDnJmRJ pHeMfrUbEHp11YGhlX/EVZX9b+o8Dygm/XEjoUR/PREH7GOLEkk5Essr2If45ndMBbhw EuWFul6WV0WV9H2cYBfH4cW9LBUlwOqRUzSn6AseZ9pG9hqV5GKl63tS5y93VPgqGQuv 75aXUAlJEM4YEBYdCXzxO3l3GHU3zwETqKd/D5iJ9YZjsEAntp4Ys+JucL9hI0AYrbEk kAViDeTlQgixTEYFBWum7anS1a1NByqnka1dAVu/LC0UtTrAHacmaJWXaQhZluF1hfWj e8AA== 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=27kbaYc9o/j9wTLBAVP45tsETwTbQIy8zKNs3tAOssU=; fh=vhVM6SZxKPr2veBMjcAvhDXNjn/VVJMcYxTy29AXVyE=; b=jZfka04te/kJ8W5MyBCdAAlygR/PbMTI5XPhti/zcOhgREQgXn7mXnK0Ab5GZ8pOG9 MV9/+dG9AtGM+njDyS7w0AzJZxrBUSlCbNIwoGj9AxS0RPGktiBe3N5pHozMGBoTH4Cr Pn8q9HXO+M7oVwN15JtunjXmBvEEOc2kGmhfu701aFHWGnE4mkLWGps0rzECYtMwqQd9 J5ZyuKWn93C4kUouQznlz1jlbAtaM1nQofHedJdZ08jYG2kllWTg8N0MLVRb20H3ov9f 4xYC+vljZ4BU16XMgxMHMC8QhSdVQs6vJchIqDPXOpDbLkj0YEmhoUiPkRQTqGfIC95Z WJOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aFf3AUw6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id a19-20020aa78653000000b006c339539752si9836491pfo.363.2023.11.15.05.28.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 05:28:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=aFf3AUw6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 2553F8197EB5; Wed, 15 Nov 2023 05:28:58 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344086AbjKON2r (ORCPT + 28 others); Wed, 15 Nov 2023 08:28:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343979AbjKON2X (ORCPT ); Wed, 15 Nov 2023 08:28:23 -0500 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73608A6 for ; Wed, 15 Nov 2023 05:28:19 -0800 (PST) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-5079f9ec8d9so935295e87.0 for ; Wed, 15 Nov 2023 05:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1700054898; x=1700659698; darn=vger.kernel.org; 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=27kbaYc9o/j9wTLBAVP45tsETwTbQIy8zKNs3tAOssU=; b=aFf3AUw6HACU8INstTlF/4ZpPhEi2toseHhRelR0G9Kohvz1QugxFEBsainSppF+PS mhZjZSaHuPt4Y9HIHYbmU8vP42iu6FUPO4K4vXJphrAsSI4p5dQOc5XktMwum5ozpWHV 4X5fAC5EGNQ2bbAUqhCAHA4ui9AB9pVXQcn3acig9ijKkSzGbnXqmqvP/r+xUsC9yN6U POUsAITTRqug1bdnvGtcf1WMz6pHpUCdu1Hzupzzxb/7NZvD2gAbnERgBa3UzwTZlzFJ JtWWDQgH2rNiC3cWkfvuYFym/fRJHLsoJXoDjoZAQv1y461T8Pr3zYCwmF/iRq0+pDF3 ZpMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700054898; x=1700659698; 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=27kbaYc9o/j9wTLBAVP45tsETwTbQIy8zKNs3tAOssU=; b=bczh5N/xPMyMElRKUywnPk+kAYe2HWiR0JUXYfc0iX/KfjU3TMwap0KTeFBjgxnIYf FtvQ6qQqZ7qb4Ya9VM3IhRAaRLuyxxcoLLHdgQ0ZHp/SqLVGwIFSlCc5I8TqLdmizqPG P44s9gClRRGdCeZ0oqG/Nz5AnnxObXIxWYaG9M2MMyhVfGUYGC/Kj2O6UpuzoTHSMI8n Vx5K9XE4KhBT7hB6C5RUXuvm7Zr1DIGxqvy5MhEQbMItTBa1t4hBNjHMQw/QgY7Ks4JF qWQQGwcjpIYygpGr4Pt4w9dp4mzvuF3S9DupfL9aRsjLLuacQe1Kx1EMAZ/20bCLE87H WPJw== X-Gm-Message-State: AOJu0Yw8efhClU812aZwB7RkemG1bv/ok6ID5reouqY0/Y71JYbw2Y1P iMHyJw+wZ3/vv9mQpwfTw8LPkA== X-Received: by 2002:a05:6512:2248:b0:4fe:4896:b6ab with SMTP id i8-20020a056512224800b004fe4896b6abmr2401582lfu.15.1700054897725; Wed, 15 Nov 2023 05:28:17 -0800 (PST) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id l12-20020a19c20c000000b00507b1da672bsm1648705lfc.174.2023.11.15.05.28.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Nov 2023 05:28:17 -0800 (PST) From: Linus Walleij Date: Wed, 15 Nov 2023 14:28:15 +0100 Subject: [PATCH 2/2] Hexagon: Make pfn accessors statics inlines MIME-Version: 1.0 Message-Id: <20231115-virt-to-phy-arch-tree-v1-2-8b61296eae73@linaro.org> References: <20231115-virt-to-phy-arch-tree-v1-0-8b61296eae73@linaro.org> In-Reply-To: <20231115-virt-to-phy-arch-tree-v1-0-8b61296eae73@linaro.org> To: Arnd Bergmann , Vineet Gupta , Brian Cain Cc: linux-arch@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-kernel@vger.kernel.org, linux-hexagon@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.4 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=ham 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 15 Nov 2023 05:28:58 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782636808152011006 X-GMAIL-MSGID: 1782636808152011006 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. For symmetry do the same with pfn_to_virt(). For compiletime resolution of __pa() we need PAGE_OFFSET which was not available to __pa() and resolved by the preprocessor wherever __pa() was used. Fix this by explicitly including where required, following the pattern of the architectures page.h file. Acked-by: Brian Cain Signed-off-by: Linus Walleij --- arch/hexagon/include/asm/page.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/arch/hexagon/include/asm/page.h b/arch/hexagon/include/asm/page.h index 9c03b9965f07..10f1bc07423c 100644 --- a/arch/hexagon/include/asm/page.h +++ b/arch/hexagon/include/asm/page.h @@ -78,6 +78,9 @@ typedef struct page *pgtable_t; #define __pgd(x) ((pgd_t) { (x) }) #define __pgprot(x) ((pgprot_t) { (x) }) +/* Needed for PAGE_OFFSET used in the macro right below */ +#include + /* * We need a __pa and a __va routine for kernel space. * MIPS says they're only used during mem_init. @@ -125,8 +128,16 @@ static inline void clear_page(void *page) */ #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) -#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT) -#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT) +static inline unsigned long virt_to_pfn(const void *kaddr) +{ + return __pa(kaddr) >> PAGE_SHIFT; +} + +static inline void *pfn_to_virt(unsigned long pfn) +{ + return (void *)((unsigned long)__va(pfn) << PAGE_SHIFT); +} + #define page_to_virt(page) __va(page_to_phys(page))