linux/drivers/pci/hotplug
Lukas Wunner a7da21613c PCI: hotplug: Drop hotplug_slot_info
Ever since the PCI hotplug core was introduced in 2002, drivers had to
allocate and register a struct hotplug_slot_info for every slot:
https://git.kernel.org/tglx/history/c/a8a2069f432c

Apparently the idea was that drivers furnish the hotplug core with an
up-to-date card presence status, power status, latch status and
attention indicator status as well as notify the hotplug core of changes
thereof.  However only 4 out of 12 hotplug drivers bother to notify the
hotplug core with pci_hp_change_slot_info() and the hotplug core never
made any use of the information:  There is just a single macro in
pci_hotplug_core.c, GET_STATUS(), which uses the hotplug_slot_info if
the driver lacks the corresponding callback in hotplug_slot_ops.  The
macro is called when the user reads the attribute via sysfs.

Now, if the callback isn't defined, the attribute isn't exposed in sysfs
in the first place (see e.g. has_power_file()).  There are only two
situations when the hotplug_slot_info would actually be accessed:

* If the driver defines ->enable_slot or ->disable_slot but not
  ->get_power_status.

* If the driver defines ->set_attention_status but not
  ->get_attention_status.

There is no driver doing the former and just a single driver doing the
latter, namely pnv_php.c.  Amend it with a ->get_attention_status
callback.  With that, the hotplug_slot_info becomes completely unused by
the PCI hotplug core.  But a few drivers use it internally as a cache:

cpcihp uses it to cache the latch_status and adapter_status.
cpqhp uses it to cache the adapter_status.
pnv_php and rpaphp use it to cache the attention_status.
shpchp uses it to cache all four values.

Amend these drivers to cache the information in their private slot
struct.  shpchp's slot struct already contains members to cache the
power_status and adapter_status, so additional members are only needed
for the other two values.  In the case of cpqphp, the cached value is
only accessed in a single place, so instead of caching it, read the
current value from the hardware.

Caution:  acpiphp, cpci, cpqhp, shpchp, asus-wmi and eeepc-laptop
populate the hotplug_slot_info with initial values on probe.  That code
is herewith removed.  There is a theoretical chance that the code has
side effects without which the driver fails to function, e.g. if the
ACPI method to read the adapter status needs to be executed at least
once on probe.  That seems unlikely to me, still maintainers should
review the changes carefully for this possibility.

Rafael adds: "I'm not aware of any case in which it will break anything,
[...] but if that happens, it may be necessary to add the execution of
the control methods in question directly to the initialization part."

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>  # drivers/pci/hotplug/rpa*
Acked-by: Sebastian Ott <sebott@linux.ibm.com>        # drivers/pci/hotplug/s390*
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com> # drivers/platform/x86
Cc: Len Brown <lenb@kernel.org>
Cc: Scott Murray <scott@spiteful.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Oliver OHalloran <oliveroh@au1.ibm.com>
Cc: Gavin Shan <gwshan@linux.vnet.ibm.com>
Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Cc: Corentin Chary <corentin.chary@gmail.com>
Cc: Darren Hart <dvhart@infradead.org>
2018-09-18 17:52:15 -05:00
..
Kconfig PCI: shpchp: Convert SHPC to be builtin only 2018-06-02 00:18:28 -05:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
acpi_pcihp.c PCI: shpchp: Separate existence of SHPC and permission to use it 2018-06-26 15:38:28 -05:00
acpiphp.h PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
acpiphp_core.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
acpiphp_glue.c PCI: Fix is_added/is_busmaster race condition 2018-07-31 11:27:54 -05:00
acpiphp_ibm.c More ACPI updates for v4.16-rc1 2018-02-09 09:44:25 -08:00
cpci_hotplug.h PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
cpci_hotplug_core.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
cpci_hotplug_pci.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
cpcihp_generic.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
cpcihp_zt5550.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
cpcihp_zt5550.h PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
cpqphp.h PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
cpqphp_core.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
cpqphp_ctrl.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
cpqphp_nvram.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
cpqphp_nvram.h PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
cpqphp_pci.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
cpqphp_sysfs.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
ibmphp.h PCI: hotplug: Constify hotplug_slot_ops 2018-09-18 17:52:15 -05:00
ibmphp_core.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
ibmphp_ebda.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
ibmphp_hpc.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
ibmphp_pci.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
ibmphp_res.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
pci_hotplug_core.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
pciehp.h PCI: pciehp: Reshuffle controller struct for clarity 2018-09-18 17:52:15 -05:00
pciehp_core.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
pciehp_ctrl.c PCI: pciehp: Rename controller struct members for clarity 2018-09-18 17:52:15 -05:00
pciehp_hpc.c PCI: pciehp: Rename controller struct members for clarity 2018-09-18 17:52:15 -05:00
pciehp_pci.c PCI: pciehp: Unify controller and slot structs 2018-09-18 17:52:15 -05:00
pnv_php.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
rpadlpar.h PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
rpadlpar_core.c pci-v4.16-changes 2018-02-06 09:59:40 -08:00
rpadlpar_sysfs.c pci-v4.16-changes 2018-02-06 09:59:40 -08:00
rpaphp.h PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
rpaphp_core.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
rpaphp_pci.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
rpaphp_slot.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
s390_pci_hpc.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
sgi_hotplug.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
shpchp.h PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
shpchp_core.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
shpchp_ctrl.c PCI: hotplug: Drop hotplug_slot_info 2018-09-18 17:52:15 -05:00
shpchp_hpc.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00
shpchp_pci.c Merge branch 'pci/spdx' into next 2018-02-01 11:40:07 -06:00
shpchp_sysfs.c PCI: Add SPDX GPL-2.0+ to replace GPL v2 or later boilerplate 2018-01-28 15:49:06 -06:00