]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/pci: Stop usurping pdev->dev.groups
authorLukas Wunner <lukas@wunner.de>
Mon, 5 Aug 2024 15:24:05 +0000 (17:24 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 9 Aug 2024 19:58:27 +0000 (14:58 -0500)
Bjorn suggests using pdev->dev.groups for attribute_groups constructed on
PCI device enumeration:

  "Is it feasible to build an attribute group in pci_doe_init() and
   add it to dev->groups so device_add() will automatically add them?"
   https://lore.kernel.org/r/20231019165829.GA1381099@bhelgaas

Unfortunately on s390, pcibios_device_add() usurps pdev->dev.groups for
arch-specific attribute_groups, preventing its use for anything else.

Introduce an ARCH_PCI_DEV_GROUPS macro which arches can define in
<asm/pci.h>.  The macro is visible in drivers/pci/pci-sysfs.c through the
inclusion of <linux/pci.h>, which in turn includes <asm/pci.h>.

On s390, define the macro to the three attribute_groups previously assigned
to pdev->dev.groups.  Thereby pdev->dev.groups is made available for use by
the PCI core.

As a side effect, arch/s390/pci/pci_sysfs.c no longer needs to be compiled
into the kernel if CONFIG_SYSFS=n.

Link: https://lore.kernel.org/r/7b970f7923e373d1b23784721208f93418720485.1722870934.git.lukas@wunner.de
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Niklas Schnelle <schnelle@linux.ibm.com>
arch/s390/include/asm/pci.h
arch/s390/pci/Makefile
arch/s390/pci/pci.c
arch/s390/pci/pci_sysfs.c
drivers/pci/pci-sysfs.c

index 30820a649e6e7cfbba67a4aae4aa41d06c523693..9d920ced6047549e4f1977f38af81ef25268c51a 100644 (file)
@@ -191,7 +191,14 @@ static inline bool zdev_enabled(struct zpci_dev *zdev)
        return (zdev->fh & (1UL << 31)) ? true : false;
 }
 
-extern const struct attribute_group *zpci_attr_groups[];
+extern const struct attribute_group zpci_attr_group;
+extern const struct attribute_group pfip_attr_group;
+extern const struct attribute_group zpci_ident_attr_group;
+
+#define ARCH_PCI_DEV_GROUPS &zpci_attr_group,           \
+                           &pfip_attr_group,            \
+                           &zpci_ident_attr_group,
+
 extern unsigned int s390_pci_force_floating __initdata;
 extern unsigned int s390_pci_no_rid;
 
index 0547a10406e72a1a0745a842228130bc0710f1a0..2c21f0394c9abe96013ba90c4f263e3f7024f3d5 100644 (file)
@@ -3,7 +3,8 @@
 # Makefile for the s390 PCI subsystem.
 #
 
-obj-$(CONFIG_PCI)      += pci.o pci_irq.o pci_clp.o pci_sysfs.o \
+obj-$(CONFIG_PCI)      += pci.o pci_irq.o pci_clp.o \
                           pci_event.o pci_debug.o pci_insn.o pci_mmio.o \
                           pci_bus.o pci_kvm_hook.o
 obj-$(CONFIG_PCI_IOV)  += pci_iov.o
+obj-$(CONFIG_SYSFS)    += pci_sysfs.o
index cff4838fad2166d621d9f299e5731c83530069ba..bd9624c20b80204980585290a027525f8d20560b 100644 (file)
@@ -587,7 +587,6 @@ int pcibios_device_add(struct pci_dev *pdev)
        if (pdev->is_physfn)
                pdev->no_vf_scan = 1;
 
-       pdev->dev.groups = zpci_attr_groups;
        zpci_map_resources(pdev);
 
        for (i = 0; i < PCI_STD_NUM_BARS; i++) {
index 0f4f1e8fc480dc0f0e5a35f1be1000e675f5f47a..1f81f6ff7b954b3748e386a2482659cf96f90098 100644 (file)
@@ -197,7 +197,7 @@ static struct attribute *zpci_ident_attrs[] = {
        NULL,
 };
 
-static struct attribute_group zpci_ident_attr_group = {
+const struct attribute_group zpci_ident_attr_group = {
        .attrs = zpci_ident_attrs,
        .is_visible = zpci_index_is_visible,
 };
@@ -223,7 +223,7 @@ static struct attribute *zpci_dev_attrs[] = {
        NULL,
 };
 
-static struct attribute_group zpci_attr_group = {
+const struct attribute_group zpci_attr_group = {
        .attrs = zpci_dev_attrs,
        .bin_attrs = zpci_bin_attrs,
 };
@@ -235,14 +235,8 @@ static struct attribute *pfip_attrs[] = {
        &dev_attr_segment3.attr,
        NULL,
 };
-static struct attribute_group pfip_attr_group = {
+
+const struct attribute_group pfip_attr_group = {
        .name = "pfip",
        .attrs = pfip_attrs,
 };
-
-const struct attribute_group *zpci_attr_groups[] = {
-       &zpci_attr_group,
-       &pfip_attr_group,
-       &zpci_ident_attr_group,
-       NULL,
-};
index 40cfa716392fbd79e075270ca64185ff4c6022c5..5d0f4db1cab78674c5e5906f321bf7a57b742983 100644 (file)
 #include <linux/aperture.h>
 #include "pci.h"
 
+#ifndef ARCH_PCI_DEV_GROUPS
+#define ARCH_PCI_DEV_GROUPS
+#endif
+
 static int sysfs_initialized;  /* = 0 */
 
 /* show configuration fields */
@@ -1624,6 +1628,7 @@ const struct attribute_group *pci_dev_groups[] = {
        &pci_dev_acpi_attr_group,
 #endif
        &pci_dev_resource_resize_group,
+       ARCH_PCI_DEV_GROUPS
        NULL,
 };