Page MenuHomeFreeBSD

LinuxKPI: pci: properly define PCI_ANY_ID
AbandonedPublic

Authored by bz on Apr 24 2025, 2:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 5, 8:59 AM
Unknown Object (File)
Sat, Oct 4, 6:26 AM
Unknown Object (File)
Fri, Sep 26, 7:33 PM
Unknown Object (File)
Thu, Sep 18, 5:20 AM
Unknown Object (File)
Sep 2 2025, 3:54 AM
Unknown Object (File)
Sep 1 2025, 11:43 PM
Unknown Object (File)
Aug 29 2025, 10:35 AM
Unknown Object (File)
Aug 28 2025, 5:06 PM
Subscribers

Details

Reviewers
None
Group Reviewers
linuxkpi
Summary

PCI vendor/device/subvendor/subdevice IDs are all uint16_t.
If we pass PCI_ANY_ID to a properly typed function we get a warning
given -1U is an unsigned int and that is a different constant value
than uint16_t -1. Add the cast to avoid this problem.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 63710
Build 60594: arc lint + arc unit

Event Timeline

bz requested review of this revision.Apr 24 2025, 2:34 PM

Hmm, Linux struct pci_device_id has a __u32 vendor, device
Do we use this in any context that would have a 32-bit var?

Hmm, Linux struct pci_device_id has a __u32 vendor, device
Do we use this in any context that would have a 32-bit var?

Grml. I was passing it to [lkpi_]pci_get_device() but that's likely u_int on Linux too? So maybe I need to fix that instead.? But then struct pci_dev also has them as uint16_t in LinuxKPI? Did we go too BSD here and Linux was doing other things beyond the namespace? @jhb knows lots of PCI. Any reason some/all of Linux may have them as uint32_t rather than uint16_t?

bz planned changes to this revision.Apr 27 2025, 9:43 PM

The registers are 16-bit in the hardware. Linux might be using 32-bit ints just to be more efficient on architectures that don't handle shorts as well. What do the relevant APIs in Linux itself use for the types?

In D50008#1141668, @jhb wrote:

The registers are 16-bit in the hardware. Linux might be using 32-bit ints just to be more efficient on architectures that don't handle shorts as well. What do the relevant APIs in Linux itself use for the types?

uint_t. I think I need to fix lkpi_]pci_get_device() which takes uint16_t but haven't had a chance to grep for it yet. Still fighting more changes to PCI to make the branch compile again. I'll update this here the next days.