Re: [PATCH v2 1/7] PCI/IOV: Return u16 from pci_sriov_get_totalvfs()
"Alexandre Courbot" <[email protected]>
| Newsgroups | dev.linux.lists.nova-gpu,org.kernel.vger.linux-kernel,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <[email protected]> |
On Tue Jun 23, 2026 at 4:43 AM JST, Zhi Wang wrote: > pci_sriov_get_totalvfs() reports a VF count, not an errno-style > status. It returns 0 when SR-IOV is unavailable or the device is not a > PF, and otherwise returns the PF's driver_max_VFs value. > > driver_max_VFs is stored as a u16 in struct pci_sriov. It is derived > from the SR-IOV TotalVFs field or from a driver-provided limit, so the > implementation cannot return a negative value. > > Change the declaration, CONFIG_PCI_IOV stub, and implementation to > return u16. Update callers to store the result in u16 variables, remove > obsolete negative-value checks, and use unsigned format specifiers where > needed. > > Cc: Bjorn Helgaas <[email protected]> > Cc: [email protected] > Signed-off-by: Zhi Wang <[email protected]> Suggested-by: Alexandre Courbot <[email protected]> Link: https://lore.kernel.org/all/[email protected]/ > --- > drivers/crypto/hisilicon/qm.c | 8 +++++--- > drivers/crypto/intel/qat/qat_common/adf_sriov.c | 6 +++--- > drivers/gpu/drm/xe/xe_sriov_pf.c | 6 ++---- > drivers/misc/genwqe/card_base.c | 6 ++---- > drivers/net/ethernet/cavium/thunder/nic_main.c | 2 +- > drivers/net/ethernet/emulex/benet/be_main.c | 3 ++- > drivers/net/ethernet/mellanox/mlx5/core/sriov.c | 3 ++- > drivers/net/ethernet/sfc/ef10_sriov.c | 2 +- I believe that you can avoid converting all these drivers in this patch. The implicit `u16 -> int` conversion done by C should result in the expected behavior, and it will be fewer Acked-by to collect. I.e. just updating drivers/pci/iov.c and include/linux/pci.h should be sufficient as the first step. Specific drivers can then be updated using separate patches that will be easier to merge individually, if you want to do so.