Page MenuHomeFreeBSD

Reliably return PCI_GETCONF_LAST_DEVICE from PCIOCGETCONF.
ClosedPublic

Authored by jhb on Aug 8 2016, 9:04 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Dec 26, 3:18 PM
Unknown Object (File)
Dec 10 2024, 2:13 PM
Unknown Object (File)
Nov 3 2024, 6:49 AM
Unknown Object (File)
Oct 31 2024, 3:34 PM
Unknown Object (File)
Oct 5 2024, 8:42 AM
Unknown Object (File)
Oct 4 2024, 9:36 PM
Unknown Object (File)
Sep 30 2024, 9:46 AM
Unknown Object (File)
Sep 28 2024, 5:07 AM
Subscribers
None

Details

Summary

Reliably return PCI_GETCONF_LAST_DEVICE from PCIOCGETCONF.

Previously the loop in PCIIOCGETCONF would terminate as soon as it
found enough matches. Now it will continue iterating through the
PCI device list and only terminate if it finds another matching device
for which it has no room to store a conf structure. This means that
PCI_GETCONF_LAST_DEVICE is reliably returned when the number of
matching devices is equal to the number of slots in the matches
buffer. For example, if a program requests the conf structure for a
single PCI function with a specified domain/bus/slot/function it will
now get PCI_GETCONF_LAST_DEVICE instead of PCI_GETCONF_MORE_DEVS.

While here, simplify the loop conditional a bit more by explicitly
breaking out of the loop if copyout() fails and removing a redundant
i < pci_numdevs check.

Test Plan
  • Invoke PCIOCGETCONF with a pattern to match a single PCI function and a matches buffer with 1 conf structure.

Diff Detail

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

Event Timeline

jhb retitled this revision from to Reliably return PCI_GETCONF_LAST_DEVICE from PCIOCGETCONF..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added a reviewer: imp.

So it does look like we document the current behavior. I suppose in theory code could decide to accept the MORE_DEVS and not do a followup call to verify it got LAST_DEVICE with a match count of 0 to avoid having to walk to the end of the list. However, that seems a bit sloppy to me. I think these semantics make more sense.

This revision is now accepted and ready to land.Aug 9 2016, 2:25 PM
imp edited edge metadata.
This revision was automatically updated to reflect the committed changes.