Page MenuHomeFreeBSD

Reset PCI pass through devices via PCI-e FLR during VM start and end.
ClosedPublic

Authored by jhb on Sep 2 2016, 12:15 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 11, 1:30 AM
Unknown Object (File)
Sat, Nov 1, 12:30 AM
Unknown Object (File)
Fri, Oct 31, 5:22 PM
Unknown Object (File)
Fri, Oct 31, 5:22 PM
Unknown Object (File)
Fri, Oct 31, 3:49 PM
Unknown Object (File)
Fri, Oct 31, 12:58 PM
Unknown Object (File)
Fri, Oct 31, 12:57 PM
Unknown Object (File)
Fri, Oct 31, 7:39 AM
Subscribers

Details

Summary

Reset PCI pass through devices via PCI-e FLR during VM start and end.

Add routines to trigger a function level reset (FLR) of a PCI-express
device via the PCI-express device control register. This also includes
support routines to wait for pending transactions to complete as well
as calculating the maximum completion timeout permitted by a device.

Change the ppt(4) driver to reset pass through devices before attaching
to a VM during startup and before detaching from a VM during shutdown.

Test Plan
  • Passed a Chelsio T5 VF through to a bhyve VM. The VF works ok inside the VM and works again if I start a new one. Added some log messages to verify that it did do the writes to initiate a FLR, but I have not been able to confirm via the devlog of the parent PF if the FLR was noticed. (It's not clear if the firmware on the T5 logs messages for PCI-e initiated FLR requests. It does for device resets requested via a device firmware request.)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb retitled this revision from to Reset PCI pass through devices via PCI-e FLR during VM start and end..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added reviewers: grehan, imp.
jhb added a subscriber: np.
rpokala added inline comments.
sys/dev/pci/pci.c
5955 ↗(On Diff #19958)

return (50 * 1000); /* perhaps? */

wblock added inline comments.
share/man/man9/pci.9
450 ↗(On Diff #19958)

s/If/When/ to avoid repetition with the previous sentence.

478 ↗(On Diff #19958)

If/then sentences can be tedious for the reader. Some can be rearranged to avoid the built-in pause, like this one:

.Nm pcie_wait_for_pending_transactions
returns
.Dv true
if
.Fa dev
is not a PCI-express device.

This is the equivalent of a Perl/Ruby postfix if, really. Or rather, those are the equivalent of this type of wording.

722 ↗(On Diff #19958)

Some of the redundancy can be reduced, here and elsewhere:

.Fn pcie_flr
requests a Function Level Reset
​.Pq FLR
​of
.Fa dev .
727 ↗(On Diff #19958)

Maybe just

.Dv false
is returned.``

(removing "this function")
731 ↗(On Diff #19958)

Yes! This is better.

743 ↗(On Diff #19958)

Maybe just

busmastering is re-enabled and
.Dv false
is returned.
jhb marked 6 inline comments as done.
jhb edited edge metadata.
  • Fix value of default timeout.
  • Various wording suggestions from Warren.
imp edited edge metadata.

Looks good to me (though I defer to Warren on the docs).

This revision is now accepted and ready to land.Sep 2 2016, 7:19 PM
wblock added a reviewer: wblock.
jhb edited edge metadata.
  • Expand pause_ms() and remove it.
This revision now requires review to proceed.Sep 6 2016, 8:30 PM
jhb edited edge metadata.

Rebase.

This revision was automatically updated to reflect the committed changes.