Skip to content

Commit 869c058

Browse files
committed
Merge tag 'vfio-v4.13-rc4' of git://github.com/awilliam/linux-vfio
Pull VFIO fixes from Alex Williamson: - SPAPR/EEH config build fix (Murilo Opsfelder Araujo) - Fix possible device lock deadlock (Alex Williamson) - Correctly size integrated endpoint PCIe capabilities (Alex Williamson) * tag 'vfio-v4.13-rc4' of git://github.com/awilliam/linux-vfio: vfio/pci: Fix handling of RC integrated endpoint PCIe capability size vfio/pci: Use pci_try_reset_function() on initial open include/linux/vfio.h: Guard powerpc-specific functions with CONFIG_VFIO_SPAPR_EEH
2 parents 995d03a + 796b755 commit 869c058

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

drivers/vfio/pci/vfio_pci.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,14 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
226226
if (ret)
227227
return ret;
228228

229-
vdev->reset_works = (pci_reset_function(pdev) == 0);
229+
/* If reset fails because of the device lock, fail this path entirely */
230+
ret = pci_try_reset_function(pdev);
231+
if (ret == -EAGAIN) {
232+
pci_disable_device(pdev);
233+
return ret;
234+
}
235+
236+
vdev->reset_works = !ret;
230237
pci_save_state(pdev);
231238
vdev->pci_saved_state = pci_store_saved_state(pdev);
232239
if (!vdev->pci_saved_state)

drivers/vfio/pci/vfio_pci_config.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ static int vfio_exp_config_write(struct vfio_pci_device *vdev, int pos,
839839
/* Permissions for PCI Express capability */
840840
static int __init init_pci_cap_exp_perm(struct perm_bits *perm)
841841
{
842-
/* Alloc larger of two possible sizes */
842+
/* Alloc largest of possible sizes */
843843
if (alloc_perm_bits(perm, PCI_CAP_EXP_ENDPOINT_SIZEOF_V2))
844844
return -ENOMEM;
845845

@@ -1243,11 +1243,16 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)
12431243
vdev->extended_caps = (dword != 0);
12441244
}
12451245

1246-
/* length based on version */
1247-
if ((pcie_caps_reg(pdev) & PCI_EXP_FLAGS_VERS) == 1)
1246+
/* length based on version and type */
1247+
if ((pcie_caps_reg(pdev) & PCI_EXP_FLAGS_VERS) == 1) {
1248+
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END)
1249+
return 0xc; /* "All Devices" only, no link */
12481250
return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1;
1249-
else
1251+
} else {
1252+
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END)
1253+
return 0x2c; /* No link */
12501254
return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2;
1255+
}
12511256
case PCI_CAP_ID_HT:
12521257
ret = pci_read_config_byte(pdev, pos + 3, &byte);
12531258
if (ret)

include/linux/vfio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ extern int vfio_set_irqs_validate_and_prepare(struct vfio_irq_set *hdr,
152152
size_t *data_size);
153153

154154
struct pci_dev;
155-
#ifdef CONFIG_EEH
155+
#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH)
156156
extern void vfio_spapr_pci_eeh_open(struct pci_dev *pdev);
157157
extern void vfio_spapr_pci_eeh_release(struct pci_dev *pdev);
158158
extern long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
@@ -173,7 +173,7 @@ static inline long vfio_spapr_iommu_eeh_ioctl(struct iommu_group *group,
173173
{
174174
return -ENOTTY;
175175
}
176-
#endif /* CONFIG_EEH */
176+
#endif /* CONFIG_VFIO_SPAPR_EEH */
177177

178178
/*
179179
* IRQfd - generic

0 commit comments

Comments
 (0)