Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/pci: refactor zpci function states

The current zdev->state mixes the configuration states supported by CLP
with an additional Online state which is used inconsistently to include
enabled zPCI functions which are not yet visible to the common PCI
subsytem. In preparation for a clean separation between architected
configuration states and fine grained function states remove the Online
function state.

Where we previously checked for Online it is more accurate to check if
the function is enabled to avoid an edge case where a disabled device
was still treated as Online. This also simplifies checks whether
a function is configured as this is now directly reflected by its
function state.

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>

authored by

Niklas Schnelle and committed by
Heiko Carstens
f6576a1b 98ce70b7

+5 -14
-1
arch/s390/include/asm/pci.h
··· 85 85 ZPCI_FN_STATE_STANDBY = 0, 86 86 ZPCI_FN_STATE_CONFIGURED = 1, 87 87 ZPCI_FN_STATE_RESERVED = 2, 88 - ZPCI_FN_STATE_ONLINE = 3, 89 88 }; 90 89 91 90 struct zpci_bar_struct {
+4 -6
arch/s390/pci/pci.c
··· 661 661 if (rc) 662 662 goto out_dma; 663 663 664 - zdev->state = ZPCI_FN_STATE_ONLINE; 665 664 return 0; 666 665 667 666 out_dma: ··· 769 770 return 0; 770 771 771 772 error_disable: 772 - if (zdev->state == ZPCI_FN_STATE_ONLINE) 773 + if (zdev_enabled(zdev)) 773 774 zpci_disable_device(zdev); 774 775 error_destroy_iommu: 775 776 zpci_destroy_iommu(zdev); ··· 786 787 if (zdev->zbus->bus) 787 788 zpci_remove_device(zdev, false); 788 789 789 - switch (zdev->state) { 790 - case ZPCI_FN_STATE_ONLINE: 791 - case ZPCI_FN_STATE_CONFIGURED: 790 + if (zdev_enabled(zdev)) 792 791 zpci_disable_device(zdev); 793 - fallthrough; 792 + 793 + switch (zdev->state) { 794 794 case ZPCI_FN_STATE_STANDBY: 795 795 if (zdev->has_hp_slot) 796 796 zpci_exit_slot(zdev);
+1 -7
drivers/pci/hotplug/s390_pci_hpc.c
··· 20 20 21 21 #define SLOT_NAME_SIZE 10 22 22 23 - static int zpci_fn_configured(enum zpci_state state) 24 - { 25 - return state == ZPCI_FN_STATE_CONFIGURED || 26 - state == ZPCI_FN_STATE_ONLINE; 27 - } 28 - 29 23 static inline int zdev_configure(struct zpci_dev *zdev) 30 24 { 31 25 int ret = sclp_pci_configure(zdev->fid); ··· 79 85 struct pci_dev *pdev; 80 86 int rc; 81 87 82 - if (!zpci_fn_configured(zdev->state)) 88 + if (zdev->state != ZPCI_FN_STATE_CONFIGURED) 83 89 return -EIO; 84 90 85 91 pdev = pci_get_slot(zdev->zbus->bus, zdev->devfn);