On s390 systems, which use a machine level hypervisor, PCI devices are always accessed through a form of PCI pass-through which fundamentally operates on a per PCI function granularity. This is also reflected in the s390 PCI hotplug driver which creates hotplug slots for individual PCI functions. Its reset_slot() function, which is a wrapper for zpci_hot_reset_device(), thus also resets individual functions. Currently, the pci_create_slot() assigns the same pci_slot object to multifunction devices. This approach worked fine on s390 systems that only exposed virtual functions as individual PCI domains to the operating system. Since commit 44510d6fa0c0 ("s390/pci: Handling multifunctions") s390 supports exposing the topology of multifunction PCI devices by grouping them in a shared PCI domain. This creates a problem when resetting a function through the hotplug driver's slot_reset() interface. When attempting to reset a function through the hotplug driver, the shared slot assignment causes the wrong function to be reset instead of the intended one. It also leaks memory as we do create a pci_slot object for the function, but don't correctly free it in pci_slot_release(). Add a flag for struct pci_slot to allow per function PCI slots for functions managed through a hypervisor, which exposes individual PCI functions while retaining the topology. Since we can use all 8 bits for slot 'number' (for ARI devices), change slot 'number' u16 to account for special values PCI_SLOT_PLACEHOLDER and PCI_SLOT_ALL_DEVICES.
Showing the changes to include (1 of 3 files). Show all
Unified · Split
| @@ -79,17 +79,18 @@ · 78 unmodified lines | |||
| 79 | * and, if ARI Forwarding is enabled, functions may appear to be on multiple | 79 | * and, if ARI Forwarding is enabled, functions may appear to be on multiple |
| 80 | * devices. | 80 | * devices. |
| 81 | */ | 81 | */ |
| 82 | #define PCI_SLOT_ALL_DEVICES 0xfe | 82 | #define PCI_SLOT_ALL_DEVICES 0xfeff |
| 83 | 83 | ||
| 84 | /* Used to identify a slot as a placeholder */ | 84 | /* Used to identify a slot as a placeholder */ |
| 85 | #define PCI_SLOT_PLACEHOLDER 0xff | 85 | #define PCI_SLOT_PLACEHOLDER 0xffff |
| 86 | 86 | ||
| 87 | /* pci_slot represents a physical slot */ | 87 | /* pci_slot represents a physical slot */ |
| 88 | struct pci_slot { | 88 | struct pci_slot { |
| 89 | struct pci_bus *bus; /* Bus this slot is on */ | 89 | struct pci_bus *bus; /* Bus this slot is on */ |
| 90 | struct list_head list; /* Node in list of slots */ | 90 | struct list_head list; /* Node in list of slots */ |
| 91 | struct hotplug_slot *hotplug; /* Hotplug info (move here) */ | 91 | struct hotplug_slot *hotplug; /* Hotplug info (move here) */ |
| 92 | unsigned char number; /* Device nr, or PCI_SLOT_ALL_DEVICES */ | 92 | u16 number; /* Device nr, or PCI_SLOT_ALL_DEVICES */ |
| 93 | unsigned int per_func_slot:1; /* Allow per function slot */ | ||
| 93 | struct kobject kobj; | 94 | struct kobject kobj; |
| 94 | }; | 95 | }; |
| 95 | 96 | ||