Skip to content

Commit 7df047b

Browse files
committed
Merge tag 'vfio-v6.4-rc1' of https://github.com/awilliam/linux-vfio
Pull VFIO updates from Alex Williamson: - Expose and allow R/W access to the PCIe DVSEC capability through vfio-pci, as we already do with the legacy vendor capability (K V P Satyanarayana) - Fix kernel-doc issues with structure definitions (Simon Horman) - Clarify ordering of operations relative to the kvm-vfio device for driver dependencies against the kvm pointer (Yi Liu) * tag 'vfio-v6.4-rc1' of https://github.com/awilliam/linux-vfio: docs: kvm: vfio: Suggest KVM_DEV_VFIO_GROUP_ADD vs VFIO_GROUP_GET_DEVICE_FD ordering vfio: correct kdoc for ops structures vfio/pci: Add DVSEC PCI Extended Config Capability to user visible list.
2 parents 21d2be6 + 705b004 commit 7df047b

3 files changed

Lines changed: 17 additions & 0 deletions

File tree

Documentation/virt/kvm/devices/vfio.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,8 @@ KVM_DEV_VFIO_GROUP attributes:
3939
- @groupfd is a file descriptor for a VFIO group;
4040
- @tablefd is a file descriptor for a TCE table allocated via
4141
KVM_CREATE_SPAPR_TCE.
42+
43+
The GROUP_ADD operation above should be invoked prior to accessing the
44+
device file descriptor via VFIO_GROUP_GET_DEVICE_FD in order to support
45+
drivers which require a kvm pointer to be set in their .open_device()
46+
callback.

drivers/vfio/pci/vfio_pci_config.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ static const u16 pci_ext_cap_length[PCI_EXT_CAP_ID_MAX + 1] = {
9696
[PCI_EXT_CAP_ID_SECPCI] = 0, /* not yet */
9797
[PCI_EXT_CAP_ID_PMUX] = 0, /* not yet */
9898
[PCI_EXT_CAP_ID_PASID] = 0, /* not yet */
99+
[PCI_EXT_CAP_ID_DVSEC] = 0xFF,
99100
};
100101

101102
/*
@@ -1101,6 +1102,7 @@ int __init vfio_pci_init_perm_bits(void)
11011102
ret |= init_pci_ext_cap_err_perm(&ecap_perms[PCI_EXT_CAP_ID_ERR]);
11021103
ret |= init_pci_ext_cap_pwr_perm(&ecap_perms[PCI_EXT_CAP_ID_PWR]);
11031104
ecap_perms[PCI_EXT_CAP_ID_VNDR].writefn = vfio_raw_config_write;
1105+
ecap_perms[PCI_EXT_CAP_ID_DVSEC].writefn = vfio_raw_config_write;
11041106

11051107
if (ret)
11061108
vfio_pci_uninit_perm_bits();
@@ -1440,6 +1442,11 @@ static int vfio_ext_cap_len(struct vfio_pci_core_device *vdev, u16 ecap, u16 epo
14401442
return PCI_TPH_BASE_SIZEOF + (sts * 2) + 2;
14411443
}
14421444
return PCI_TPH_BASE_SIZEOF;
1445+
case PCI_EXT_CAP_ID_DVSEC:
1446+
ret = pci_read_config_dword(pdev, epos + PCI_DVSEC_HEADER1, &dword);
1447+
if (ret)
1448+
return pcibios_err_to_errno(ret);
1449+
return PCI_DVSEC_HEADER1_LEN(dword);
14431450
default:
14441451
pci_warn(pdev, "%s: unknown length for PCI ecap %#x@%#x\n",
14451452
__func__, ecap, epos);

include/linux/vfio.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct vfio_device {
6767
/**
6868
* struct vfio_device_ops - VFIO bus driver device callbacks
6969
*
70+
* @name: Name of the device driver.
7071
* @init: initialize private fields in device structure
7172
* @release: Reclaim private fields in device structure
7273
* @bind_iommufd: Called when binding the device to an iommufd
@@ -139,6 +140,8 @@ int vfio_iommufd_emulated_attach_ioas(struct vfio_device *vdev, u32 *pt_id);
139140
#endif
140141

141142
/**
143+
* struct vfio_migration_ops - VFIO bus device driver migration callbacks
144+
*
142145
* @migration_set_state: Optional callback to change the migration state for
143146
* devices that support migration. It's mandatory for
144147
* VFIO_DEVICE_FEATURE_MIGRATION migration support.
@@ -164,6 +167,8 @@ struct vfio_migration_ops {
164167
};
165168

166169
/**
170+
* struct vfio_log_ops - VFIO bus device driver logging callbacks
171+
*
167172
* @log_start: Optional callback to ask the device start DMA logging.
168173
* @log_stop: Optional callback to ask the device stop DMA logging.
169174
* @log_read_and_clear: Optional callback to ask the device read

0 commit comments

Comments
 (0)