summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKrzysztof Wilczyński <kwilczynski@kernel.org>2026-05-08 04:35:27 +0000
committerBjorn Helgaas <bhelgaas@google.com>2026-06-23 15:19:08 -0500
commitcf616e0b188beac528f46d656bffd065f4f19529 (patch)
treed3282f841839f0b3bedfc5597a129b3e992f8236
parentca617c60af9f6bb74216645ce4362dcb96697d52 (diff)
PCI/sysfs: Warn about BAR resize failure in __resource_resize_store()
Add a pci_warn() to __resource_resize_store(), so that BAR resize failures are visible to the user, which can help troubleshoot any potential resource resize issues. While at it, rename the resource_resize_is_visible() to resource_resize_attr_is_visible() along with the corresponding group variable to align with the naming convention used by the resource attribute groups. Also, change the order of pci_dev_groups[] such that the resize group is now located alongside the other resource groups. Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Tested-by: Shivaprasad G Bhat <sbhat@linux.ibm.com> Link: https://patch.msgid.link/20260508043543.217179-9-kwilczynski@kernel.org
-rw-r--r--drivers/pci/pci-sysfs.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 3bb808e0e80a..3db44df63b53 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1679,6 +1679,9 @@ static ssize_t __resource_resize_store(struct device *dev, int n,
sysfs_remove_groups(&pdev->dev.kobj, pci_dev_resource_attr_groups);
ret = pci_resize_resource(pdev, n, size, 0);
+ if (ret)
+ pci_warn(pdev, "Failed to resize BAR %d: %pe\n",
+ n, ERR_PTR(ret));
pci_assign_unassigned_bus_resources(bus);
@@ -1726,7 +1729,7 @@ static struct attribute *resource_resize_attrs[] = {
NULL,
};
-static umode_t resource_resize_is_visible(struct kobject *kobj,
+static umode_t resource_resize_attr_is_visible(struct kobject *kobj,
struct attribute *a, int n)
{
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
@@ -1734,9 +1737,9 @@ static umode_t resource_resize_is_visible(struct kobject *kobj,
return pci_rebar_get_current_size(pdev, n) < 0 ? 0 : a->mode;
}
-static const struct attribute_group pci_dev_resource_resize_group = {
+static const struct attribute_group pci_dev_resource_resize_attr_group = {
.attrs = resource_resize_attrs,
- .is_visible = resource_resize_is_visible,
+ .is_visible = resource_resize_attr_is_visible,
};
int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
@@ -1857,6 +1860,7 @@ const struct attribute_group *pci_dev_groups[] = {
&pci_dev_resource_uc_attr_group,
&pci_dev_resource_wc_attr_group,
#endif
+ &pci_dev_resource_resize_attr_group,
&pci_dev_config_attr_group,
&pci_dev_rom_attr_group,
&pci_dev_reset_attr_group,
@@ -1868,7 +1872,6 @@ const struct attribute_group *pci_dev_groups[] = {
#ifdef CONFIG_ACPI
&pci_dev_acpi_attr_group,
#endif
- &pci_dev_resource_resize_group,
ARCH_PCI_DEV_GROUPS
NULL,
};