From mboxrd@z Thu Jan 1 00:00:00 1970 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 5921515539A; Fri, 8 May 2026 04:37:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778215025; cv=none; b=D0WwHPGWHjSZDSj7S2+sPnPd6xuHXIK7hUWSLx3C/gY8ELaqYqFs/6ZrHqATlgegkej0h0fwgxZrwlnC7GB2N3B939+Iy8MDDyNTRsXl035rS7JuKcU1TRPju8psppw8YRrMoKgpTPlQlY+R4nfMcoB90XuWYuPORDuFysoUlGA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778215025; c=relaxed/simple; bh=dvrWWiezWy8a25eOYZ7kT3ZuDPygnOIs6x7THQzp8XQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=L1MMo31jlpuF3X/IhUii28/UYqSEfvQkB2VSnLX2LXrwWSLSEUmcdFa8zyaO8+Eo2CYj6CpHIdkxSHX8LkxAVQqUxyqcCu+umUXTsNnVboS+oBm4RxQlEh42ljwcxtpwg+/u6e98UhUV1ylBq6Etn9STwmoylWkL5WEX3ItM29o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gojkxWSs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gojkxWSs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE601C2BCB0; Fri, 8 May 2026 04:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778215025; bh=dvrWWiezWy8a25eOYZ7kT3ZuDPygnOIs6x7THQzp8XQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gojkxWSsjs4HHq9Sz1NSR2O576qHSQJY9wjQgo3bfowHdAoHZaa2OE4OAIT5iyLuP 1VpquJbvclXBjRHzxZVoiaJSQm2KwI5VPFtECPmugIzmuvpF01L1CdZ1Yjr+cEJVC3 Ak226U0ylzCooHHs2Q9NZp3EfiQYOOGqhd63jMVXMSq71IBWsjMVr+Wq9sjwozh97L QxTwsxqawiRzUVwLTbNnwDEOqzjD2/st35DFOcvcz+br+7wpfW5xaoSw4uBOuLmCxM BqUa22aGeF+PkSv+tOokpEGR+dM9F5rxgNRml1vbS7Jb+3HweCOElZNafhXQPdmZh+ Iuvqb+63kgpMQ== From: =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= To: Bjorn Helgaas Cc: Bjorn Helgaas , Manivannan Sadhasivam , Lorenzo Pieralisi , Alex Williamson , Magnus Lindholm , Matt Turner , Richard Henderson , Christophe Leroy , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Dexuan Cui , =?UTF-8?q?Krzysztof=20Ha=C5=82asa?= , Lukas Wunner , "Oliver O'Halloran" , Saurabh Singh Sengar , Shuan He , Srivatsa Bhat , =?UTF-8?q?Ilpo=20J=C3=A4rvinen?= , linux-pci@vger.kernel.org, linux-alpha@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH v7 21/24] PCI/sysfs: Add __weak pci_legacy_has_sparse() helper Date: Fri, 8 May 2026 04:35:40 +0000 Message-ID: <20260508043543.217179-22-kwilczynski@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260508043543.217179-1-kwilczynski@kernel.org> References: <20260508043543.217179-1-kwilczynski@kernel.org> Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, Alpha's sparse/dense legacy attribute handling is done via pci_adjust_legacy_attr(), which updates dynamically allocated attributes at runtime. The upcoming conversion to static attributes needs a way to determine sparse support at visibility check time. Add a __weak pci_legacy_has_sparse() that returns false by default. Alpha overrides it to check has_sparse() on the bus host controller. Tested-by: Shivaprasad G Bhat Signed-off-by: Krzysztof WilczyƄski --- arch/alpha/include/asm/pci.h | 2 ++ arch/alpha/kernel/pci-sysfs.c | 7 +++++++ drivers/pci/pci-sysfs.c | 6 ++++++ drivers/pci/pci.h | 4 ++++ 4 files changed, 19 insertions(+) diff --git a/arch/alpha/include/asm/pci.h b/arch/alpha/include/asm/pci.h index ef19295f2e33..95de7ffd59e8 100644 --- a/arch/alpha/include/asm/pci.h +++ b/arch/alpha/include/asm/pci.h @@ -86,6 +86,8 @@ extern int pci_mmap_legacy_page_range(struct pci_bus *bus, enum pci_mmap_state mmap_state); extern void pci_adjust_legacy_attr(struct pci_bus *bus, enum pci_mmap_state mmap_type); +extern bool pci_legacy_has_sparse(struct pci_bus *bus, + enum pci_mmap_state type); #define HAVE_PCI_LEGACY 1 extern const struct attribute_group pci_dev_resource_attr_group; diff --git a/arch/alpha/kernel/pci-sysfs.c b/arch/alpha/kernel/pci-sysfs.c index 89329910b890..2d46502ba09b 100644 --- a/arch/alpha/kernel/pci-sysfs.c +++ b/arch/alpha/kernel/pci-sysfs.c @@ -185,6 +185,13 @@ int pci_mmap_legacy_page_range(struct pci_bus *bus, struct vm_area_struct *vma, return hose_mmap_page_range(hose, vma, mmap_type, sparse); } +bool pci_legacy_has_sparse(struct pci_bus *bus, enum pci_mmap_state type) +{ + struct pci_controller *hose = bus->sysdata; + + return has_sparse(hose, type); +} + /** * pci_adjust_legacy_attr - adjustment of legacy file attributes * @bus: bus to create files under diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 7ba12b2abe48..1e6786463e4e 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -983,6 +983,12 @@ static int pci_mmap_legacy_io(struct file *filp, struct kobject *kobj, return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io); } +bool __weak pci_legacy_has_sparse(struct pci_bus *bus, + enum pci_mmap_state type) +{ + return false; +} + /** * pci_adjust_legacy_attr - adjustment of legacy file attributes * @b: bus to create files under diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 71a1fde1e505..c64c7f5f0bcf 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -392,6 +392,10 @@ static inline int pci_no_d1d2(struct pci_dev *dev) } +#ifdef HAVE_PCI_LEGACY +bool pci_legacy_has_sparse(struct pci_bus *bus, enum pci_mmap_state type); +#endif + #ifdef CONFIG_SYSFS extern const struct attribute_group *pci_dev_groups[]; extern const struct attribute_group *pci_dev_attr_groups[]; -- 2.54.0