HomeFreeBSD

pci: Don't try to read cfg registers of non-existing devices

Description

pci: Don't try to read cfg registers of non-existing devices

Instead of returning 0xffs some controllers, such as Layerscape generate
an external exception when someone attempts to read any register
of config space of a non-existing device other than PCIR_VENDOR.
This causes a kernel panic.
Fix it by bailing during device enumeration if a device vendor register
returns invalid value. (0xffff)
Use this opportunity to replace some hardcoded values with a macro.

I believe that this change won't have any unintended side-effects since
it is safe to assume that vendor == 0xffff -> hdr_type == 0xffff.

Sponsored by: Alstom
Obtained from: Semihalf
Reviewed by: jhb
MFC after: 2 weeks
Differential revision: https://reviews.freebsd.org/D33059

Details

Provenance
mindal_semihalf.comAuthored on Nov 23 2021, 8:13 AM
wmaCommitted on Nov 25 2021, 8:53 AM
Reviewer
jhb
Differential Revision
D33059: pci: Don't try to read cfg registers of non-existing devices
Parents
rG37c03d4de3d2: ObsoleteFiles: Remove old CAM driver man pages
Branches
Unknown
Tags
Unknown