public inbox for linux-pci@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] s390/pci: Stop usurping pdev->dev.groups
@ 2024-08-05 15:24 Lukas Wunner
  2024-08-06 19:30 ` Bjorn Helgaas
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Lukas Wunner @ 2024-08-05 15:24 UTC (permalink / raw)
  To: Niklas Schnelle, Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Bjorn Helgaas
  Cc: linux-s390, linux-pci, Alistair Francis, Jonathan.Cameron,
	alex.williamson, christian.koenig, kch, gregkh, logang,
	chaitanyak, rdunlap, Alistair Francis, Sebastian Ott

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://msgid.link/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.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
---
 arch/s390/include/asm/pci.h |  9 ++++++++-
 arch/s390/pci/Makefile      |  3 ++-
 arch/s390/pci/pci.c         |  1 -
 arch/s390/pci/pci_sysfs.c   | 14 ++++----------
 drivers/pci/pci-sysfs.c     |  5 +++++
 5 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
index 30820a6..9d920ce 100644
--- a/arch/s390/include/asm/pci.h
+++ b/arch/s390/include/asm/pci.h
@@ -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;
 
diff --git a/arch/s390/pci/Makefile b/arch/s390/pci/Makefile
index 0547a10..2c21f03 100644
--- a/arch/s390/pci/Makefile
+++ b/arch/s390/pci/Makefile
@@ -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
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index cff4838..bd9624c 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -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++) {
diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
index 0f4f1e8..1f81f6f 100644
--- a/arch/s390/pci/pci_sysfs.c
+++ b/arch/s390/pci/pci_sysfs.c
@@ -197,7 +197,7 @@ static umode_t zpci_index_is_visible(struct kobject *kobj,
 	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 umode_t zpci_index_is_visible(struct kobject *kobj,
 	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 umode_t zpci_index_is_visible(struct kobject *kobj,
 	&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,
-};
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 40cfa71..5d0f4db 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -31,6 +31,10 @@
 #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 @@ static umode_t pcie_dev_attrs_are_visible(struct kobject *kobj,
 	&pci_dev_acpi_attr_group,
 #endif
 	&pci_dev_resource_resize_group,
+	ARCH_PCI_DEV_GROUPS
 	NULL,
 };
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] s390/pci: Stop usurping pdev->dev.groups
  2024-08-05 15:24 [PATCH] s390/pci: Stop usurping pdev->dev.groups Lukas Wunner
@ 2024-08-06 19:30 ` Bjorn Helgaas
  2024-08-06 19:55   ` Lukas Wunner
  2024-08-07 15:44 ` Niklas Schnelle
  2024-08-09 20:02 ` Bjorn Helgaas
  2 siblings, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2024-08-06 19:30 UTC (permalink / raw)
  To: Lukas Wunner, Heiko Carstens, Vasily Gorbik, Alexander Gordeev
  Cc: Niklas Schnelle, Gerald Schaefer, Christian Borntraeger,
	Sven Schnelle, linux-s390, linux-pci, Alistair Francis,
	Jonathan.Cameron, alex.williamson, christian.koenig, kch, gregkh,
	logang, chaitanyak, rdunlap, Alistair Francis, Sebastian Ott

On Mon, Aug 05, 2024 at 05:24:05PM +0200, Lukas Wunner wrote:
> 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://msgid.link/20231019165829.GA1381099@bhelgaas

Huh, another new archive link format.  I guess I need to be educated
about this.  I see 127734e23aed ("Documentation: best practices for
using Link trailers"), which added the only mentions in the tree,
although it only mentions "https://patch.msgid.link" and specifically
in the context of the origin of a patch, which leaves it clear as mud
for me.

> 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.

I like this, and propose to merge via the PCI tree because it might
help enable Alistair's work on exposing DOE via sysfs (part of the
conversation Lukas mentioned above).

This would require an ack from the s390 folks, so I moved them to
the to: list.

> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> ---
>  arch/s390/include/asm/pci.h |  9 ++++++++-
>  arch/s390/pci/Makefile      |  3 ++-
>  arch/s390/pci/pci.c         |  1 -
>  arch/s390/pci/pci_sysfs.c   | 14 ++++----------
>  drivers/pci/pci-sysfs.c     |  5 +++++
>  5 files changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
> index 30820a6..9d920ce 100644
> --- a/arch/s390/include/asm/pci.h
> +++ b/arch/s390/include/asm/pci.h
> @@ -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;
>  
> diff --git a/arch/s390/pci/Makefile b/arch/s390/pci/Makefile
> index 0547a10..2c21f03 100644
> --- a/arch/s390/pci/Makefile
> +++ b/arch/s390/pci/Makefile
> @@ -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
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index cff4838..bd9624c 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -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++) {
> diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
> index 0f4f1e8..1f81f6f 100644
> --- a/arch/s390/pci/pci_sysfs.c
> +++ b/arch/s390/pci/pci_sysfs.c
> @@ -197,7 +197,7 @@ static umode_t zpci_index_is_visible(struct kobject *kobj,
>  	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 umode_t zpci_index_is_visible(struct kobject *kobj,
>  	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 umode_t zpci_index_is_visible(struct kobject *kobj,
>  	&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,
> -};
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 40cfa71..5d0f4db 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -31,6 +31,10 @@
>  #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 @@ static umode_t pcie_dev_attrs_are_visible(struct kobject *kobj,
>  	&pci_dev_acpi_attr_group,
>  #endif
>  	&pci_dev_resource_resize_group,
> +	ARCH_PCI_DEV_GROUPS
>  	NULL,
>  };
>  
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] s390/pci: Stop usurping pdev->dev.groups
  2024-08-06 19:30 ` Bjorn Helgaas
@ 2024-08-06 19:55   ` Lukas Wunner
  2024-08-07 18:08     ` Konstantin Ryabitsev
  0 siblings, 1 reply; 6+ messages in thread
From: Lukas Wunner @ 2024-08-06 19:55 UTC (permalink / raw)
  To: Bjorn Helgaas, Konstantin Ryabitsev
  Cc: Heiko Carstens, Vasily Gorbik, Alexander Gordeev, Niklas Schnelle,
	Gerald Schaefer, Christian Borntraeger, Sven Schnelle, linux-s390,
	linux-pci, Alistair Francis, Jonathan.Cameron, alex.williamson,
	christian.koenig, kch, gregkh, logang, chaitanyak, rdunlap,
	Alistair Francis, Sebastian Ott

[cc += Konstantin]

On Tue, Aug 06, 2024 at 02:30:55PM -0500, Bjorn Helgaas wrote:
> On Mon, Aug 05, 2024 at 05:24:05PM +0200, Lukas Wunner wrote:
> > 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://msgid.link/20231019165829.GA1381099@bhelgaas
> 
> Huh, another new archive link format.  I guess I need to be educated
> about this.  I see 127734e23aed ("Documentation: best practices for
> using Link trailers"), which added the only mentions in the tree,
> although it only mentions "https://patch.msgid.link" and specifically
> in the context of the origin of a patch, which leaves it clear as mud
> for me.

I merely chose that because it's shorter than lore.kernel.org and makes
it more obvious that it's a Message-ID link to the mailing list archive.

I'm not sure whether that goes against any best practices associated
with the msgid.link domain and whether it's going to work as long as
lore.kernel.org.  Hopefully Konstantin can comment on that.

Otherwise feel free to replace when applying.

Thanks,

Lukas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] s390/pci: Stop usurping pdev->dev.groups
  2024-08-05 15:24 [PATCH] s390/pci: Stop usurping pdev->dev.groups Lukas Wunner
  2024-08-06 19:30 ` Bjorn Helgaas
@ 2024-08-07 15:44 ` Niklas Schnelle
  2024-08-09 20:02 ` Bjorn Helgaas
  2 siblings, 0 replies; 6+ messages in thread
From: Niklas Schnelle @ 2024-08-07 15:44 UTC (permalink / raw)
  To: Lukas Wunner, Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	Bjorn Helgaas
  Cc: linux-s390, linux-pci, Alistair Francis, Jonathan.Cameron,
	alex.williamson, christian.koenig, kch, gregkh, logang,
	chaitanyak, rdunlap, Alistair Francis, Sebastian Ott

On Mon, 2024-08-05 at 17:24 +0200, Lukas Wunner wrote:
> 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://msgid.link/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.
> 
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> ---
>  arch/s390/include/asm/pci.h |  9 ++++++++-
>  arch/s390/pci/Makefile      |  3 ++-
>  arch/s390/pci/pci.c         |  1 -
>  arch/s390/pci/pci_sysfs.c   | 14 ++++----------
>  drivers/pci/pci-sysfs.c     |  5 +++++
>  5 files changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
> index 30820a6..9d920ce 100644
> --- a/arch/s390/include/asm/pci.h
> +++ b/arch/s390/include/asm/pci.h
> @@ -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;
>  
> diff --git a/arch/s390/pci/Makefile b/arch/s390/pci/Makefile
> index 0547a10..2c21f03 100644
> --- a/arch/s390/pci/Makefile
> +++ b/arch/s390/pci/Makefile
> @@ -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
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index cff4838..bd9624c 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -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++) {
> diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
> index 0f4f1e8..1f81f6f 100644
> --- a/arch/s390/pci/pci_sysfs.c
> +++ b/arch/s390/pci/pci_sysfs.c
> @@ -197,7 +197,7 @@ static umode_t zpci_index_is_visible(struct kobject *kobj,
>  	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 umode_t zpci_index_is_visible(struct kobject *kobj,
>  	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 umode_t zpci_index_is_visible(struct kobject *kobj,
>  	&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,
> -};
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 40cfa71..5d0f4db 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -31,6 +31,10 @@
>  #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 @@ static umode_t pcie_dev_attrs_are_visible(struct kobject *kobj,
>  	&pci_dev_acpi_attr_group,
>  #endif
>  	&pci_dev_resource_resize_group,
> +	ARCH_PCI_DEV_GROUPS
>  	NULL,
>  };
>  

Thanks for the patch and sorry for the delay I'll be on vacation
starting tomorrow and it's a bit busy. This makes sense to me and I
agree with Bjorn that this can go via the PCI tree, especially if it is
already useful there. I also gave this a compile and boot test on and
checked that the s390 specific PCI device attributes are still there.

Acked-by: Niklas Schnelle <schnelle@linux.ibm.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] s390/pci: Stop usurping pdev->dev.groups
  2024-08-06 19:55   ` Lukas Wunner
@ 2024-08-07 18:08     ` Konstantin Ryabitsev
  0 siblings, 0 replies; 6+ messages in thread
From: Konstantin Ryabitsev @ 2024-08-07 18:08 UTC (permalink / raw)
  To: Lukas Wunner
  Cc: Bjorn Helgaas, Heiko Carstens, Vasily Gorbik, Alexander Gordeev,
	Niklas Schnelle, Gerald Schaefer, Christian Borntraeger,
	Sven Schnelle, linux-s390, linux-pci, Alistair Francis,
	Jonathan.Cameron, alex.williamson, christian.koenig, kch, gregkh,
	logang, chaitanyak, rdunlap, Alistair Francis, Sebastian Ott

On Tue, Aug 06, 2024 at 09:55:38PM GMT, Lukas Wunner wrote:
> [cc += Konstantin]
> 
> On Tue, Aug 06, 2024 at 02:30:55PM -0500, Bjorn Helgaas wrote:
> > On Mon, Aug 05, 2024 at 05:24:05PM +0200, Lukas Wunner wrote:
> > > 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://msgid.link/20231019165829.GA1381099@bhelgaas
> > 
> > Huh, another new archive link format.  I guess I need to be educated
> > about this.  I see 127734e23aed ("Documentation: best practices for
> > using Link trailers"), which added the only mentions in the tree,
> > although it only mentions "https://patch.msgid.link" and specifically
> > in the context of the origin of a patch, which leaves it clear as mud
> > for me.
> 
> I merely chose that because it's shorter than lore.kernel.org and makes
> it more obvious that it's a Message-ID link to the mailing list archive.
> 
> I'm not sure whether that goes against any best practices associated
> with the msgid.link domain and whether it's going to work as long as
> lore.kernel.org.  Hopefully Konstantin can comment on that.

I think it's perfectly fine to use msgid.link URLs for general links to
mailing list archives. The reason we introduced patch.msgid.link was
specifically to distinguish general links to discussions from links pointing
at the origin of the commit.

-K

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] s390/pci: Stop usurping pdev->dev.groups
  2024-08-05 15:24 [PATCH] s390/pci: Stop usurping pdev->dev.groups Lukas Wunner
  2024-08-06 19:30 ` Bjorn Helgaas
  2024-08-07 15:44 ` Niklas Schnelle
@ 2024-08-09 20:02 ` Bjorn Helgaas
  2 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2024-08-09 20:02 UTC (permalink / raw)
  To: Lukas Wunner
  Cc: Niklas Schnelle, Gerald Schaefer, Heiko Carstens, Vasily Gorbik,
	Alexander Gordeev, Christian Borntraeger, Sven Schnelle,
	linux-s390, linux-pci, Alistair Francis, Jonathan.Cameron,
	alex.williamson, christian.koenig, kch, gregkh, logang,
	chaitanyak, rdunlap, Alistair Francis, Sebastian Ott

On Mon, Aug 05, 2024 at 05:24:05PM +0200, Lukas Wunner wrote:
> 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://msgid.link/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.
> 
> Signed-off-by: Lukas Wunner <lukas@wunner.de>

Applied with Niklas' ack to pci/sysfs for v6.12, thanks!

> ---
>  arch/s390/include/asm/pci.h |  9 ++++++++-
>  arch/s390/pci/Makefile      |  3 ++-
>  arch/s390/pci/pci.c         |  1 -
>  arch/s390/pci/pci_sysfs.c   | 14 ++++----------
>  drivers/pci/pci-sysfs.c     |  5 +++++
>  5 files changed, 19 insertions(+), 13 deletions(-)
> 
> diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h
> index 30820a6..9d920ce 100644
> --- a/arch/s390/include/asm/pci.h
> +++ b/arch/s390/include/asm/pci.h
> @@ -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;
>  
> diff --git a/arch/s390/pci/Makefile b/arch/s390/pci/Makefile
> index 0547a10..2c21f03 100644
> --- a/arch/s390/pci/Makefile
> +++ b/arch/s390/pci/Makefile
> @@ -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
> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index cff4838..bd9624c 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
> @@ -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++) {
> diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
> index 0f4f1e8..1f81f6f 100644
> --- a/arch/s390/pci/pci_sysfs.c
> +++ b/arch/s390/pci/pci_sysfs.c
> @@ -197,7 +197,7 @@ static umode_t zpci_index_is_visible(struct kobject *kobj,
>  	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 umode_t zpci_index_is_visible(struct kobject *kobj,
>  	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 umode_t zpci_index_is_visible(struct kobject *kobj,
>  	&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,
> -};
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 40cfa71..5d0f4db 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -31,6 +31,10 @@
>  #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 @@ static umode_t pcie_dev_attrs_are_visible(struct kobject *kobj,
>  	&pci_dev_acpi_attr_group,
>  #endif
>  	&pci_dev_resource_resize_group,
> +	ARCH_PCI_DEV_GROUPS
>  	NULL,
>  };
>  
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-09 20:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-05 15:24 [PATCH] s390/pci: Stop usurping pdev->dev.groups Lukas Wunner
2024-08-06 19:30 ` Bjorn Helgaas
2024-08-06 19:55   ` Lukas Wunner
2024-08-07 18:08     ` Konstantin Ryabitsev
2024-08-07 15:44 ` Niklas Schnelle
2024-08-09 20:02 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox