Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp181359rdb; Mon, 15 Jan 2024 17:31:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IGN9SBFZFDuHVvk8kPQXfzu3NSZjYUwdnkVAe2pJddpJKb9SMGoDXLWZxTH14FaHNmvr5E4 X-Received: by 2002:a05:6871:3a0b:b0:1fb:a96:bd76 with SMTP id pu11-20020a0568713a0b00b001fb0a96bd76mr10994758oac.15.1705368713605; Mon, 15 Jan 2024 17:31:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705368713; cv=none; d=google.com; s=arc-20160816; b=HlJBq7xjTAPwtfc+jfzSdMXGWrbjnqDhIwXjyRxhLot0YCmUI+MNi5RutWgF4g6JKz 9mN+mJBDXxuZR9XI9dbpHzNyF7Hin3cs5mdfWpzB6A+eJ/YzC4moizkItR8qbtrsNEGX ArdlGCtC7r7G7XpHEXIFFP3tGKNTyVip8qJD8fIh96Rk6x/QowBQ9nqdlicTsCeCCz3U 2X2qCsFU7wzMITUa+qslQGH/ynFOjYDxk4P82cHoVS0nAC1cF7Y4My484znl7qGmYUKe HCW80XBp/6tkPiya57fi6pUZhmUuScmIWf1Kox1r5u7cBgRS6I82rP/hieCOt89TiCYn v8fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=+wnc+h9FQLNgtzLveih7ML/4+QCQgbYRnRRHnQfwVa8=; fh=U/Vbgp6xLWXQI1MNVjuDubemuygfLhlmr1zEe1sUM74=; b=xFXZ4zeoEBEYI0UXGdKsgZHZHPUGt55HIN+TMbl6qWK+gLdw+x14n6fRS+73BDguR1 r2I0d6woUGcKBL21XSzwELfIW8QuU7VY72NQI3aJwq558i50n9/JN77sRB8GVjf9egt7 SVtPGkxUIXIi6f6nBWcALaKsa31WNCvtUpjchThvPJVHfn8Zj8ugRaoPwOtdFz4n3s+5 UgAcSK1rugF4qZR9heSPTKP3DhcFVghthvOHSFA4MCuySdKJ063YuahfpuUO13xkvoCW OAz2fYFulBzeICxhy0MhJrWdJeHx92gR5yF6V4e6azQQ9gjvCjq3zQgrlww3fPWWxHT2 zL5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JgoT/KRp"; spf=pass (google.com: domain of linux-kernel+bounces-26853-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26853-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id a19-20020a656413000000b005ce00b1ef79si9617926pgv.289.2024.01.15.17.31.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 17:31:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26853-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="JgoT/KRp"; spf=pass (google.com: domain of linux-kernel+bounces-26853-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26853-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9F35F281AD6 for ; Tue, 16 Jan 2024 01:31:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C3F5D20B16; Tue, 16 Jan 2024 01:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JgoT/KRp" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03F1D22F17; Tue, 16 Jan 2024 01:06:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86BE1C43390; Tue, 16 Jan 2024 01:06:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705367211; bh=Xoyym8SbFaFTJhnzUgEkGRcabuTho3/U89WhI3ZWbn8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JgoT/KRpG3f5x1hYeHEe21MTUpkmSuDp1z90DD9UL70snIPvJLNYy0zjP5YMbSyGn h1n57sAeQ/v6u/PizYzJtnoAoAnX2CZbo2vmEvSsfHZAWqz+eEEAPtQw3yAgc47d4p tTK+okY5jQeTXqScO9Hn0YJDvudDEiWE5eKWBhjNpiq6DnpL4b8xtvcE7io5F78GpL RObD2otTQgzfsc7YZAimZtVCnMIVERpt9P68h7AkXQnD8G+ZiyVslBFvVU9mxVTV0X kpvPksOITmTvuwIJlibLg/jS/RxdzF2BS+B4RVwKqs2npArzJZe4H7B/i6ryfwadN7 LLqkqeI2UkN/A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Linus Walleij , Brian Cain , Arnd Bergmann , Sasha Levin , david@redhat.com, rppt@kernel.org, mpe@ellerman.id.au, linux-hexagon@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 03/14] Hexagon: Make pfn accessors statics inlines Date: Mon, 15 Jan 2024 20:06:05 -0500 Message-ID: <20240116010642.218876-3-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116010642.218876-1-sashal@kernel.org> References: <20240116010642.218876-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.73 Content-Transfer-Encoding: 8bit From: Linus Walleij [ Upstream commit d6e81532b10d8deb2bc30f7b44f09534876893e3 ] 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 Signed-off-by: Arnd Bergmann Signed-off-by: Sasha Levin --- 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 7cbf719c578e..2d8c681c3469 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. @@ -126,8 +129,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)) -- 2.43.0