Skip to content

Commit 265baca

Browse files
l1kbjorn-helgaas
authored andcommitted
s390/pci: Stop usurping pdev->dev.groups
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>
1 parent 8400291 commit 265baca

5 files changed

Lines changed: 19 additions & 13 deletions

File tree

arch/s390/include/asm/pci.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,14 @@ static inline bool zdev_enabled(struct zpci_dev *zdev)
191191
return (zdev->fh & (1UL << 31)) ? true : false;
192192
}
193193

194-
extern const struct attribute_group *zpci_attr_groups[];
194+
extern const struct attribute_group zpci_attr_group;
195+
extern const struct attribute_group pfip_attr_group;
196+
extern const struct attribute_group zpci_ident_attr_group;
197+
198+
#define ARCH_PCI_DEV_GROUPS &zpci_attr_group, \
199+
&pfip_attr_group, \
200+
&zpci_ident_attr_group,
201+
195202
extern unsigned int s390_pci_force_floating __initdata;
196203
extern unsigned int s390_pci_no_rid;
197204

arch/s390/pci/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
# Makefile for the s390 PCI subsystem.
44
#
55

6-
obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_clp.o pci_sysfs.o \
6+
obj-$(CONFIG_PCI) += pci.o pci_irq.o pci_clp.o \
77
pci_event.o pci_debug.o pci_insn.o pci_mmio.o \
88
pci_bus.o pci_kvm_hook.o
99
obj-$(CONFIG_PCI_IOV) += pci_iov.o
10+
obj-$(CONFIG_SYSFS) += pci_sysfs.o

arch/s390/pci/pci.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ int pcibios_device_add(struct pci_dev *pdev)
587587
if (pdev->is_physfn)
588588
pdev->no_vf_scan = 1;
589589

590-
pdev->dev.groups = zpci_attr_groups;
591590
zpci_map_resources(pdev);
592591

593592
for (i = 0; i < PCI_STD_NUM_BARS; i++) {

arch/s390/pci/pci_sysfs.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static struct attribute *zpci_ident_attrs[] = {
197197
NULL,
198198
};
199199

200-
static struct attribute_group zpci_ident_attr_group = {
200+
const struct attribute_group zpci_ident_attr_group = {
201201
.attrs = zpci_ident_attrs,
202202
.is_visible = zpci_index_is_visible,
203203
};
@@ -223,7 +223,7 @@ static struct attribute *zpci_dev_attrs[] = {
223223
NULL,
224224
};
225225

226-
static struct attribute_group zpci_attr_group = {
226+
const struct attribute_group zpci_attr_group = {
227227
.attrs = zpci_dev_attrs,
228228
.bin_attrs = zpci_bin_attrs,
229229
};
@@ -235,14 +235,8 @@ static struct attribute *pfip_attrs[] = {
235235
&dev_attr_segment3.attr,
236236
NULL,
237237
};
238-
static struct attribute_group pfip_attr_group = {
238+
239+
const struct attribute_group pfip_attr_group = {
239240
.name = "pfip",
240241
.attrs = pfip_attrs,
241242
};
242-
243-
const struct attribute_group *zpci_attr_groups[] = {
244-
&zpci_attr_group,
245-
&pfip_attr_group,
246-
&zpci_ident_attr_group,
247-
NULL,
248-
};

drivers/pci/pci-sysfs.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
#include <linux/aperture.h>
3232
#include "pci.h"
3333

34+
#ifndef ARCH_PCI_DEV_GROUPS
35+
#define ARCH_PCI_DEV_GROUPS
36+
#endif
37+
3438
static int sysfs_initialized; /* = 0 */
3539

3640
/* show configuration fields */
@@ -1624,6 +1628,7 @@ const struct attribute_group *pci_dev_groups[] = {
16241628
&pci_dev_acpi_attr_group,
16251629
#endif
16261630
&pci_dev_resource_resize_group,
1631+
ARCH_PCI_DEV_GROUPS
16271632
NULL,
16281633
};
16291634

0 commit comments

Comments
 (0)