From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 020C0CD4F26 for ; Fri, 19 Jun 2026 08:54:55 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4ghWbQ5xqTz3bsd; Fri, 19 Jun 2026 18:53:38 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=172.105.4.254 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1781859218; cv=none; b=cPk+1Mg0yKMuK3qmH1dop/62KB/N9bHycbl6Yn3QdVRk9pXl+TDUvifwPhlbkgRCbpscKItmekzS+3GxJ9x0mMuGXkOnNwM5aCZmYXbzW22Py4RetZMOju/X1NI8JizcO/MMWqIz5BcR9SkrljNjMJZoDIExmkfRlsvAgTEZu3v4u5ULF6IHfOCdYrrH6RNsV6Ch3Sz9+uvYxIDKXmxSbOA/7SuinuVw94NyB6yW410CriePedVhADdfSqP8REUHHua9vfqeyIl7IUOjNgLBLImVCi9EiXqzF8/ea4MXJoXN0TZsdCT8tdb0/cDM5z+pryqF1La+F+ha2zhF02RMzw== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1781859218; c=relaxed/relaxed; bh=AEt6yMxt+anDbS/xfw6iqNjqi9OlzbWZj7cBi3ZQBhw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=kUu6KiVHl0purfxDujiMEBGrasDwyzW7w96vji/4s4R4ULZe68jRWVHMnhKfct8BSeiEs/r35z0QJn3l7spX2es/jxgtGYly2bjHVEokP/I6mGcc5JddWSJv7D/TE1ejjunYVltkBN404xmh5nmV5ngNPvfNu4YpmDufZr8Ef00Knf3U1yZXzWK8kwAfcFRAunrCOi03WH9mT/bzZjdQBjxb2H5VfaE/u3sdIq7lBBpzND0dCzFkDS/KdwsD+VvkBdIj8FcDKmYbjyIteKxo8R4zaWn2LvNVAYayyrg7ioqXXIudlwdD/R8CjhOmuMWZF2shVSpW5BNnqRa22PSMXQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YR7iqatK; dkim-atps=neutral; spf=pass (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org) smtp.mailfrom=kernel.org Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YR7iqatK; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=kernel.org (client-ip=172.105.4.254; helo=tor.source.kernel.org; envelope-from=kwilczynski@kernel.org; receiver=lists.ozlabs.org) Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4ghWbP6YmWz3bsZ for ; Fri, 19 Jun 2026 18:53:37 +1000 (AEST) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 0ABE2601E2; Fri, 19 Jun 2026 08:53:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 769F91F00A3D; Fri, 19 Jun 2026 08:53:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781859215; bh=AEt6yMxt+anDbS/xfw6iqNjqi9OlzbWZj7cBi3ZQBhw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=YR7iqatK+cx4aYp6j5tWzOuzMZJB0txouHE9bTlGvW0HPY4heYYHga1kXZ+YKjyNP E7drzIXDvtVBCjndnrWFcqc/Wm40uJZIQOAK6xmt3w4hUzhltEhe/Njp7N2adLkil0 R32L5Yb0XO1sc7o9DyAn5dyfGuEwSbnqWwHcoOvVyLGGUJbaSel6ORZ2AO6UcopuFh nrLgGV2fNEIUp8e2ivUkR+UZFJc3CLuoujqPHdS16JN4QE+Wy9i1+ilgQPP/BhV5Ja kVk4zoH1apiKNPSTe1xDDOn8t0pp9RbSfDCNw9pJBTcTn6aMFMXb+2To7gxOTpRdoQ CNUEKwaiwjAGg== 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 v8 25/25] PCI/sysfs: Limit BAR resize attribute scope to platforms with PCI mmap Date: Fri, 19 Jun 2026 08:52:00 +0000 Message-ID: <20260619085200.3729431-26-kwilczynski@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260619085200.3729431-1-kwilczynski@kernel.org> References: <20260619085200.3729431-1-kwilczynski@kernel.org> X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently, __resource_resize_store() uses sysfs_remove_groups() and sysfs_create_groups() on pci_dev_resource_attr_groups to tear down and recreate the resourceN files after a BAR resize, so the updated BAR sizes are visible in sysfs. The resourceN files only exist on platforms that define HAVE_PCI_MMAP or ARCH_GENERIC_PCI_MMAP_RESOURCE. On platforms that define neither, pci_dev_resource_attr_groups is NULL and the sysfs_remove_groups() and sysfs_create_groups() calls in __resource_resize_store() become no-ops. Resizable BAR (ReBAR) is a PCI Express extended capability (PCI_EXT_CAP_ID_REBAR) that requires PCIe extended config space. Every PCIe-capable architecture defines HAVE_PCI_MMAP or ARCH_GENERIC_PCI_MMAP_RESOURCE (via arch headers or the asm-generic/pci.h fallback). Architectures without either only support conventional PCI and cannot have any ReBAR-capable devices. Thus, move the resize show and store helpers, the per-BAR attribute definitions, and the attribute group behind the existing #ifdef HAVE_PCI_MMAP || ARCH_GENERIC_PCI_MMAP_RESOURCE guard, and fold the group reference in pci_dev_groups[] into the existing #if block. Tested-by: Shivaprasad G Bhat Signed-off-by: Krzysztof WilczyƄski --- drivers/pci/pci-sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index dd87b83ba3a9..4216ed520d41 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1652,6 +1652,7 @@ static const struct attribute_group pci_dev_reset_method_attr_group = { .is_visible = pci_dev_reset_attr_is_visible, }; +#if defined(HAVE_PCI_MMAP) || defined(ARCH_GENERIC_PCI_MMAP_RESOURCE) static ssize_t __resource_resize_show(struct device *dev, int n, char *buf) { struct pci_dev *pdev = to_pci_dev(dev); @@ -1766,6 +1767,7 @@ static const struct attribute_group pci_dev_resource_resize_attr_group = { .attrs = resource_resize_attrs, .is_visible = resource_resize_attr_is_visible, }; +#endif static struct attribute *pci_dev_dev_attrs[] = { &dev_attr_boot_vga.attr, @@ -1840,8 +1842,8 @@ const struct attribute_group *pci_dev_groups[] = { &pci_dev_resource_io_attr_group, &pci_dev_resource_uc_attr_group, &pci_dev_resource_wc_attr_group, -#endif &pci_dev_resource_resize_attr_group, +#endif &pci_dev_config_attr_group, &pci_dev_rom_attr_group, &pci_dev_reset_attr_group, -- 2.54.0