vfio-pci: PCI hot reset interface
The current VFIO_DEVICE_RESET interface only maps to PCI use cases where we can isolate the reset to the individual PCI function. This means the device must support FLR (PCIe or AF), PM reset on D3hot->D0 transition, device specific reset, or be a singleton device on a bus for a secondary bus reset. FLR does not have widespread support, PM reset is not very reliable, and bus topology is dictated by the system and device design. We need to provide a means for a user to induce a bus reset in cases where the existing mechanisms are not available or not reliable. This device specific extension to VFIO provides the user with this ability. Two new ioctls are introduced: - VFIO_DEVICE_PCI_GET_HOT_RESET_INFO - VFIO_DEVICE_PCI_HOT_RESET The first provides the user with information about the extent of devices affected by a hot reset. This is essentially a list of devices and the IOMMU groups they belong to. The user may then initiate a hot reset by calling the second ioctl. We must be careful that the user has ownership of all the affected devices found via the first ioctl, so the second ioctl takes a list of file descriptors for the VFIO groups affected by the reset. Each group must have IOMMU protection established for the ioctl to succeed. Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
		
					parent
					
						
							
								3bc4f3993b
							
						
					
				
			
			
				commit
				
					
						8b27ee60bf
					
				
			
		
					 2 changed files with 323 additions and 1 deletions
				
			
		|  | @ -324,6 +324,44 @@ enum { | |||
| 	VFIO_PCI_NUM_IRQS | ||||
| }; | ||||
| 
 | ||||
| /**
 | ||||
|  * VFIO_DEVICE_GET_PCI_HOT_RESET_INFO - _IORW(VFIO_TYPE, VFIO_BASE + 12, | ||||
|  *					      struct vfio_pci_hot_reset_info) | ||||
|  * | ||||
|  * Return: 0 on success, -errno on failure: | ||||
|  *	-enospc = insufficient buffer, -enodev = unsupported for device. | ||||
|  */ | ||||
| struct vfio_pci_dependent_device { | ||||
| 	__u32	group_id; | ||||
| 	__u16	segment; | ||||
| 	__u8	bus; | ||||
| 	__u8	devfn; /* Use PCI_SLOT/PCI_FUNC */ | ||||
| }; | ||||
| 
 | ||||
| struct vfio_pci_hot_reset_info { | ||||
| 	__u32	argsz; | ||||
| 	__u32	flags; | ||||
| 	__u32	count; | ||||
| 	struct vfio_pci_dependent_device	devices[]; | ||||
| }; | ||||
| 
 | ||||
| #define VFIO_DEVICE_GET_PCI_HOT_RESET_INFO	_IO(VFIO_TYPE, VFIO_BASE + 12) | ||||
| 
 | ||||
| /**
 | ||||
|  * VFIO_DEVICE_PCI_HOT_RESET - _IOW(VFIO_TYPE, VFIO_BASE + 13, | ||||
|  *				    struct vfio_pci_hot_reset) | ||||
|  * | ||||
|  * Return: 0 on success, -errno on failure. | ||||
|  */ | ||||
| struct vfio_pci_hot_reset { | ||||
| 	__u32	argsz; | ||||
| 	__u32	flags; | ||||
| 	__u32	count; | ||||
| 	__s32	group_fds[]; | ||||
| }; | ||||
| 
 | ||||
| #define VFIO_DEVICE_PCI_HOT_RESET	_IO(VFIO_TYPE, VFIO_BASE + 13) | ||||
| 
 | ||||
| /* -------- API for Type1 VFIO IOMMU -------- */ | ||||
| 
 | ||||
| /**
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Alex Williamson
				Alex Williamson