linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3] PCI: Identifying detached virtual functions
@ 2020-08-13 15:40 Matthew Rosato
  2020-08-13 15:40 ` [PATCH v3] PCI: Introduce flag for " Matthew Rosato
  0 siblings, 1 reply; 10+ messages in thread
From: Matthew Rosato @ 2020-08-13 15:40 UTC (permalink / raw)
  To: alex.williamson, bhelgaas
  Cc: schnelle, pmorel, mpe, oohall, linux-s390, linux-kernel, kvm, linux-pci

Changes for v3:
- Moved detached_vf setting to pcibios_bus_add_device
- Extended the change in vfio_config_init to be generic (include 
  vendor / device ID / INTx emulation)
- Added a dev_is_vf macro in the same style as dev_is_pf to
  encapsualate the checking of is_virtfn || detached_vf

Changes for v2:
- Added code to vfio_basic_config_read() and vfio_config_init() to
  extend emulation to userspace
- Added detached_vf check to vfio_bar_restore()
- @Niklas/@Pierre, I removed your review tags since I made changes,
  please have another look


As discussed previously in a qemu-devel thread:

https://www.mail-archive.com/qemu-devel@nongnu.org/msg725141.html

s390x has the notion of unlinked VFs being available at the LPAR-level
(Virtual Functions where the kernel does not have access to the associated
Physical Function).  These devices are currently not marked as is_virtfn.
There seems to be some precedent (ex: in powerpc, eeh_debugfs_break_device())
where pdev->is_virtfn && pdev->physfn == 0 is used to detect these sort of
detached VFs.  We toyed with the idea of doing this but it causes additional
fallout as various other areas of kernel code have an expectation that
is_virtfn=1 implies there is a linked PF available to the kernel. 

In the s390x case, the firmware layer underneath handles the VF emulation
as it still has access to the PF that the LPAR (and thus the kernel) cannot
see.  But one thing this firmware layer does not do is emulate the
PCI_COMMAND_MEMORY bit, which was OK until vfio-pci started enforcing it
via abafbc55.  The vfio-pci check is waived for VFs as of ebfa440c, but
vfio-pci can't actually tell that these particular devices are VFs.

The proposed patch attempts to identify these detached VFs and subsequently
provide this information to vfio-pci so that it knows to also accept the
lack of PCI_COMMAND_MEMORY for these sorts of devices.  For now the bit is
only set for s390x but other architectures could opt in to it as well if
needed.

Matthew Rosato (1):
  PCI: Introduce flag for detached virtual functions

 arch/s390/pci/pci_bus.c            | 13 +++++++++++++
 drivers/vfio/pci/vfio_pci_config.c |  8 ++++----
 include/linux/pci.h                |  4 ++++
 3 files changed, 21 insertions(+), 4 deletions(-)

-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-09-01  9:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-13 15:40 [PATCH v3] PCI: Identifying detached virtual functions Matthew Rosato
2020-08-13 15:40 ` [PATCH v3] PCI: Introduce flag for " Matthew Rosato
2020-08-24 14:21   ` Matthew Rosato
2020-08-25 20:43     ` Alex Williamson
2020-08-27 18:31   ` Bjorn Helgaas
2020-08-27 19:17     ` Alex Williamson
2020-08-27 20:33       ` Bjorn Helgaas
2020-08-28  9:09         ` Niklas Schnelle
2020-09-01  9:45           ` Tian, Kevin
2020-08-27 19:21     ` Matthew Rosato

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).