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, Mar 28, 12:03 PM
Unknown Object (File)
Feb 28 2024, 4:36 AM
Unknown Object (File)
Dec 8 2023, 7:48 PM
Unknown Object (File)
Nov 27 2023, 2:08 AM
Unknown Object (File)
Nov 11 2023, 11:33 AM
Unknown Object (File)
Oct 28 2023, 6:01 AM
Unknown Object (File)
Oct 24 2023, 8:14 PM
Unknown Object (File)
Oct 24 2023, 3:00 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 Passed
Unit
No Test Coverage
Build Status
Buildable 4729
Build 4783: arc lint + arc unit

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.