Skip to content

PCI: Convert dynamic sysfs objects into static

Krzysztof Wilczyński linux-pci 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest20 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/20PCI: Convert dynamic "config" sysfs object into staticdrivers/pci/pci-sysfs.c+25 -390 replies
2/20PCI: Convert dynamic "rom" sysfs object into staticdrivers/pci/pci-sysfs.c include/linux/pci.h+29 -390 replies
3/20PCI: Convert dynamic "reset" sysfs object into staticdrivers/pci/pci-sysfs.c drivers/pci/remove.c+26 -270 replies
4/20PCI/VPD: Convert dynamic "vpd" sysfs object into staticdrivers/pci/pci-sysfs.c drivers/pci/pci.h drivers/pci/vpd.c+18 -460 replies
5/20PCI: Convert dynamic "index" and "label" sysfs objects into staticdrivers/pci/pci-label.c drivers/pci/pci-sysfs.c drivers/pci/pci.h+80 -1620 replies
6/20sysfs: Introduce BIN_ATTR_ADMIN_RO and BIN_ATTR_ADMIN_RWinclude/linux/sysfs.h+23 -00 replies
7/20PCI: Convert PCI sysfs objects to use BIN_ATTR_ADMIN_RW macrodrivers/pci/pci-sysfs.c drivers/pci/vpd.c+23 -230 replies
8/20PCI: Move to kstrtobool() to handle user inputdrivers/pci/pci-sysfs.c+45 -450 replies
9/20PCI: Use sysfs_emit() and sysfs_emit_at() in "show" functionsdrivers/pci/pci-label.c drivers/pci/pci-sysfs.c+56 -630 replies
10/20PCI: Update style to be more consistentdrivers/pci/pci-sysfs.c+251 -2190 replies
11/20PCI: Rearrange attributes from the pci_dev_groupdrivers/pci/pci-sysfs.c+369 -3260 replies
12/20PCI: Rearrange attributes from the pci_dev_config_attr_groupdrivers/pci/pci-sysfs.c+168 -1680 replies
13/20PCI: Rearrange attributes from the pci_dev_rom_attr_groupdrivers/pci/pci-sysfs.c+93 -930 replies
14/20PCI: Rearrange attributes from the pci_dev_reset_attr_groupdrivers/pci/pci-sysfs.c+45 -450 replies
15/20PCI: Rearrange attributes from the pci_dev_attr_groupdrivers/pci/pci-sysfs.c+37 -370 replies
16/20PCI: Rearrange attributes from the pci_dev_hp_attr_groupdrivers/pci/pci-sysfs.c+60 -600 replies
17/20PCI: Rearrange attributes from the pci_bridge_attr_groupdrivers/pci/pci-sysfs.c+54 -540 replies
18/20PCI: Rearrange attributes from the pcie_dev_attr_groupdrivers/pci/pci-sysfs.c+53 -530 replies
19/20PCI: Rearrange attributes from the pci_bus_groupdrivers/pci/pci-sysfs.c+24 -240 replies
20/20PCI: Rearrange attributes from the pcibus_groupdrivers/pci/pci-sysfs.c+25 -250 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 00/20] PCI: Convert dynamic sysfs objects into static

Hello,

Currently, a lot of PCI-related sysfs objects that are created when either the PCI driver is initialised or when a new device is added are dynamically created under the "/sys/bus/pci/devices/..." path.

All the attributes are added when late_initcall() function executes when the PCI driver, and hence the PCI sub-system, is initialised, and also when the function pci_bus_add_devices() executes when a device is added:

late_initcall()
pci_sysfs_init()
pci_create_sysfs_dev_files()
sysfs_create_bin_file()

pci_bus_add_devices()

    pci_bus_add_device()
      pci_create_sysfs_dev_files()
        ...

When a device is stopped and removed the pci_remove_sysfs_dev_files() function executes dynamically removing all the attributes that were previously added:

pci_stop_bus_device()

    pci_stop_dev()
      pci_remove_sysfs_dev_files()
        sysfs_remove_bin_file()

The current implementation is known to cause problems [1].

As most of the PCI-related attributes does not need to be created and removed dynamically, and thus there is no need to also manage their create and remove life cycle manually.

This series aims to convert the majority of the dynamic sysfs objects into static ones so that the PCI driver core can manage them automatically when the device is either added or removed.

The aim is also to first reduce the reliance on using late_initcall() and eventually remove the need for it completely - this hopefully should move everything closer towards addressing the issue that has been identified in [1].

Aside from converting sysfs objects, this series also offers a series of style clean-up patches offering updates, style changes, etc.

1. https://lore.kernel.org/linux-pci/20200716110423.xtfyb3n6tn5ixedh@pali/

Krzysztof

Krzysztof Wilczyński (20):
PCI: Convert dynamic "config" sysfs object into static
PCI: Convert dynamic "rom" sysfs object into static
PCI: Convert dynamic "reset" sysfs object into static PCI/VPD: Convert dynamic "vpd" sysfs object into static
PCI: Convert dynamic "index" and "label" sysfs objects into static
sysfs: Introduce BIN_ATTR_ADMIN_RO and BIN_ATTR_ADMIN_RW
PCI: Convert PCI sysfs objects to use BIN_ATTR_ADMIN_RW macro
PCI: Move to kstrtobool() to handle user input
PCI: Use sysfs_emit() and sysfs_emit_at() in "show" functions
PCI: Update style to be more consistent
PCI: Rearrange attributes from the pci_dev_group
PCI: Rearrange attributes from the pci_dev_config_attr_group
PCI: Rearrange attributes from the pci_dev_rom_attr_group
PCI: Rearrange attributes from the pci_dev_reset_attr_group
PCI: Rearrange attributes from the pci_dev_attr_group
PCI: Rearrange attributes from the pci_dev_hp_attr_group
PCI: Rearrange attributes from the pci_bridge_attr_group
PCI: Rearrange attributes from the pcie_dev_attr_group
PCI: Rearrange attributes from the pci_bus_group
PCI: Rearrange attributes from the pcibus_group

 drivers/pci/pci-label.c |  241 ++----
 drivers/pci/pci-sysfs.c | 1655 ++++++++++++++++++++-------------------
 drivers/pci/pci.h       |   16 +-
 drivers/pci/remove.c    |    2 +
 drivers/pci/vpd.c       |   58 +-
 include/linux/pci.h     |    1 -
 include/linux/sysfs.h   |   23 +
 7 files changed, 976 insertions(+), 1020 deletions(-)
Signature · 1 line
2.31.0