Received: by 2002:a05:6359:6284:b0:131:369:b2a3 with SMTP id se4csp4728512rwb; Tue, 8 Aug 2023 12:53:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRS+rl1XZUT/XHWEC86z29wwqUgJlWRd0p+XttFbwhAEm8S7lYaZ6LH+N3N4VOgKFXQCnz X-Received: by 2002:a05:6a00:1813:b0:657:bdf1:cce1 with SMTP id y19-20020a056a00181300b00657bdf1cce1mr613455pfa.25.1691524384188; Tue, 08 Aug 2023 12:53:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691524384; cv=none; d=google.com; s=arc-20160816; b=bUqW/iSA1J8/azdEmYE7YJ9gUDd0jpc5LLx4drOMt0N36w8wpPozZYyY3fe0QDh5H2 dNrU8ooJvn1ScHjpLOzY3UzU0gFMbs0srB64RFBaM1zEoOhLrOm2ugJuQlJL8qqq+qEV DyITsgOCi5WalwuC5oWGfSjQ6YrJZ8f7k67jXXgVLR7eF7fAwACXcIbYZb/RllqlRkLP Bvi30yN3eHU/B1zLbYpvXsF6m10ttn1O2sqBgCPvCvi9Ru1UtslwgoeOBr1zVvkgySS0 0zgqJJMUOJ+53wh/Vnp0xdiWn/GZ7+k+4/HsOLbAyNLE8vxrTZT04s0Gp5USdBS+xMRz /roA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=GnlwcxtfhGEad5ogPgdtYB2fKyOwYUFZ/Ow51BWBgcE=; fh=bjggu3qpuoLGnwZio9hQvPRAQn/DMaZp69YOGiYsE5E=; b=xd5TCVBISPqM3Trnp8Hs9rM83K8HS1azJFVzXOqxnIQ6ZLf0ubQUu8A2wrsUyxSwDz dfxCfP+iw5nrisitxmvFu86LsuUWb6xGZajLrZArIovWsyJb/iTVDaHhHAaEx/eC7l0P igwvTjB/7ytj7G272LJH2Cn+f9Oz4mvNajJzIme3z/3bT0GXjybM2Dpzw7KHcntwS/Ht iBk7J4zAstLZDoCEWnK/I+jESx2EWkj1++24yC20uNz9l9+nR3UdMZMvRi5QvqgI7PyZ yrANf+4k5r+Qndn9DYNjLg7zRrbvpJTyHmtxi2o7UaoDWQfVO+L99R6iCYzPCdkhGdnR u0qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gpGYcFpp; 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 cr15-20020a056a000f0f00b00666b1fb841dsi7434587pfb.7.2023.08.08.12.52.52; Tue, 08 Aug 2023 12:53:04 -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=gpGYcFpp; 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 S230360AbjHHTLO (ORCPT + 99 others); Tue, 8 Aug 2023 15:11:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54002 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjHHTKr (ORCPT ); Tue, 8 Aug 2023 15:10:47 -0400 Received: from mail-ed1-x534.google.com (mail-ed1-x534.google.com [IPv6:2a00:1450:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85E62DFAA5 for ; Tue, 8 Aug 2023 09:32:40 -0700 (PDT) Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5232d593646so4546628a12.0 for ; Tue, 08 Aug 2023 09:32:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691512320; x=1692117120; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=GnlwcxtfhGEad5ogPgdtYB2fKyOwYUFZ/Ow51BWBgcE=; b=gpGYcFppTWZikDzOEEht7+iSHo4ffLKkDViQmtBGnU+M6JzBJWoLwK79+5vjNVZMfD X3MSIShI28jH6qagmmBXYbjDsiP4k6njuT4colC86En2svyUF6uuxFGTD9Rz/ssF2ACq zieWrgNcfs2Ar97kfh2XEFj4POOVRLPrjh5PeeRSc5x7YCKCxSQ95l+/74D9Ogu50rWQ 9X5Dzc4wDUpSvJiyLbyZQABLi+Y0VyxvjvQoyI29Fr3LflCqWiWhnPI+dX91P4UbdAXG n9TJckMFqENEmj067ycYo3k5Y4/1Kriu9cHxK7rB0E9dr/uInEbh+z27eskEoX34EUMQ lGaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691512320; x=1692117120; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=GnlwcxtfhGEad5ogPgdtYB2fKyOwYUFZ/Ow51BWBgcE=; b=AUB2u3B/4OyTXLZ7XPS/MWQhCqbywB77cfewn/PJYPQrAwQAMZqIzOZxVpi7MGUWEx SmYgUsEXAhnZYzUAt5R3ScJXckmwZn3FqX5LzzhB4VWS/ExdWkNsvNZ9RIg6fRBfDfAw Km4tOAhVYQZbf7S4QYaQmv+kZQC6WHorgCqi6rtCmz2lMNXUqYu+juefn/wrvW8wN/n6 6AIrDvsP/CF+JDXWNeD1d8C/gVag9aQILbnXFGYUkSytxGPHYhJn5GubD4J9AZ1f7vnn v2A22l3EWoN09TbTsuKWaurT9tFKfbguoCeMyJ7O4AQaIzsE17VLOv5dz7c/UhrxCigF x0xA== X-Gm-Message-State: AOJu0YxwefgVPGaFtLWaXnURrJnxrpwhQKl45L2Jnb18OhMTQV37js16 WX40+ru8sYRrI/1HIu2jlxZCUBprTYPh0oZu1l0= X-Received: by 2002:a05:6512:401b:b0:4f8:70b8:12b1 with SMTP id br27-20020a056512401b00b004f870b812b1mr8798540lfb.4.1691483376082; Tue, 08 Aug 2023 01:29:36 -0700 (PDT) Received: from [127.0.1.1] ([85.235.12.238]) by smtp.gmail.com with ESMTPSA id o10-20020ac2494a000000b004fb7388360esm1814337lfi.188.2023.08.08.01.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Aug 2023 01:29:35 -0700 (PDT) From: Linus Walleij Date: Tue, 08 Aug 2023 10:29:34 +0200 Subject: [PATCH] Hexagon: Make pfn accessors statics inlines MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230808-hexagon-virt-to-pfn-v1-1-68d07c221f17@linaro.org> X-B4-Tracking: v=1; b=H4sIAO380WQC/x3MQQqAIBBA0avIrBuwUoquEi0sR52NhkoE0d2Tl m/x/wOFMlOBRTyQ6eLCKTb0nYAjmOgJ2TbDIIdRznLGQLfxKeLFuWJNeLqISk+71b3Rk1LQyjO T4/u/rtv7flKBYIZlAAAA To: Brian Cain Cc: linux-hexagon@vger.kernel.org, linux-kernel@vger.kernel.org, Linus Walleij X-Mailer: b4 0.12.3 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_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 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. 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..b3d4a2c065be 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 __va(pfn) << PAGE_SHIFT; +} + #define page_to_virt(page) __va(page_to_phys(page)) --- base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5 change-id: 20230808-hexagon-virt-to-pfn-457bd51a5744 Best regards, -- Linus Walleij