HomeFreeBSD

Reliably return PCI_GETCONF_LAST_DEVICE from PCIOCGETCONF.

Description

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.

Reviewed by: vangyzen, imp
MFC after: 1 month
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D7445

Details

Provenance
jhbAuthored on
Reviewer
vangyzen
Differential Revision
D7445: Reliably return PCI_GETCONF_LAST_DEVICE from PCIOCGETCONF.
Parents
rS303880: Track the base absolute ID of ingress and egress queues.
Branches
Unknown
Tags
Unknown