VFIO fixes for v4.13-rc4

- SPAPR/EEH config build fix (Murilo Opsfelder Araujo)
 
  - Fix possible device lock deadlock (Alex Williamson)
 
  - Correctly size integrated endpoint PCIe capabilities (Alex Williamson)
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.14 (GNU/Linux)
 
 iQIcBAABAgAGBQJZg5dIAAoJECObm247sIsijNgP/3bcd0y1JQD5n6aCgZGdUxI1
 RY/n1guN3RiiQFKpG3sGKGNOg1GL6HdoP9ifSH44ZCpTdVogGNok5ZPlyl8AkbHA
 r5hAhxKAaSC/PCNusVxAqTFHH2wQoAKe3AVpoWsUJ2sdWmIYBZURdgxKkdHwV+UN
 66ndlUodmmVylVpMdhpEh/T07D4rIDcAIf3fQeXT2ajNr7qL1ObTEyBnR0CL2kAL
 w6DeUOVXp2sKFTA4yVApjb2hIGCass9tlW2fWcieJd06+PGz2ExMrMGZpCqRsQJt
 UonMDzXRav/IFxkK+x2kwE9C4537bmg2DPvKhXd91pt3La2senSCzYGteYIL4/Uc
 madQgUPpVDx5NcqeKW3f1isCK+3qulfw6BtEckQiRqvJI/ftdZf/T93moLEUtQd7
 axbExt2lLh1RS0xiqm2wmpO34oW/UbHhBX435/YPbh8JrmqiHvVtoJAzIq17buPR
 f4z+We3JvyOJ9kX5TgKT+lfobz7ZNYwK9WtmVh7mTNv7WYvfiZtJgQqqsOVXL8ql
 KVecEfbTpfG07ofBxUCQkWHCyH4tglyzyaCz2uh37G2mtLvaW6CWDk8A5SMpFAd+
 ActM4icBiFLwUXIAAtnA3cDqJlYdXVGWynSs4MJAUJZtra5nNSTuGvd4Eil2SaFf
 dRVpner34sWYWGBRLlTo
 =dF3c
 -----END PGP SIGNATURE-----

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
This commit is contained in:
Linus Torvalds 2017-08-03 15:25:14 -07:00
commit 869c058fbe
3 changed files with 19 additions and 7 deletions

View File

@ -226,7 +226,14 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
if (ret)
return ret;
vdev->reset_works = (pci_reset_function(pdev) == 0);
/* If reset fails because of the device lock, fail this path entirely */
ret = pci_try_reset_function(pdev);
if (ret == -EAGAIN) {
pci_disable_device(pdev);
return ret;
}
vdev->reset_works = !ret;
pci_save_state(pdev);
vdev->pci_saved_state = pci_store_saved_state(pdev);
if (!vdev->pci_saved_state)

View File

@ -839,7 +839,7 @@ static int vfio_exp_config_write(struct vfio_pci_device *vdev, int pos,
/* Permissions for PCI Express capability */
static int __init init_pci_cap_exp_perm(struct perm_bits *perm)
{
/* Alloc larger of two possible sizes */
/* Alloc largest of possible sizes */
if (alloc_perm_bits(perm, PCI_CAP_EXP_ENDPOINT_SIZEOF_V2))
return -ENOMEM;
@ -1243,11 +1243,16 @@ static int vfio_cap_len(struct vfio_pci_device *vdev, u8 cap, u8 pos)
vdev->extended_caps = (dword != 0);
}
/* length based on version */
if ((pcie_caps_reg(pdev) & PCI_EXP_FLAGS_VERS) == 1)
/* length based on version and type */
if ((pcie_caps_reg(pdev) & PCI_EXP_FLAGS_VERS) == 1) {
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END)
return 0xc; /* "All Devices" only, no link */
return PCI_CAP_EXP_ENDPOINT_SIZEOF_V1;
else
} else {
if (pci_pcie_type(pdev) == PCI_EXP_TYPE_RC_END)
return 0x2c; /* No link */
return PCI_CAP_EXP_ENDPOINT_SIZEOF_V2;
}
case PCI_CAP_ID_HT:
ret = pci_read_config_byte(pdev, pos + 3, &byte);
if (ret)

View File

@ -152,7 +152,7 @@ extern int vfio_set_irqs_validate_and_prepare(struct vfio_irq_set *hdr,
size_t *data_size);
struct pci_dev;
#ifdef CONFIG_EEH
#if IS_ENABLED(CONFIG_VFIO_SPAPR_EEH)
extern void vfio_spapr_pci_eeh_open(struct pci_dev *pdev);
extern void vfio_spapr_pci_eeh_release(struct pci_dev *pdev);
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,
{
return -ENOTTY;
}
#endif /* CONFIG_EEH */
#endif /* CONFIG_VFIO_SPAPR_EEH */
/*
* IRQfd - generic