Re: [PATCH V1 10/13] PCI: hv: Build device id for a VMBus device, export PCI devid function

Bjorn Helgaas
2026-04-27T16:35:29Z

On Tue, Apr 21, 2026 at 07:32:36PM -0700, Mukesh R wrote:
> On Hyper-V, most hypercalls related to PCI passthru to map/unmap regions,
> interrupts, etc need a device id as a parameter. This device id refers
> to that specific device during the lifetime of passthru.
>
> An L1VH VM only contains VMBus based devices. A device id for a VMBus
> device is slightly different in that it uses the hv_pcibus_device info
> for building it to make sure it matches exactly what the hypervisor
> expects. This VMBus based device id is needed when attaching devices in
> an L1VH based guest VM. Before building it, a check is done to make sure
> the device is a valid VMBus device.
>
> In remaining cases, PCI device id is used. So, also make pci device
> id build function public.

s/id/ID/ throughout, including subject line, since "id" is not really
a word by itself. Well, it *is* a word, but not the one you want here :)

s/pci/PCI/, although I would prefer if you just mentioned the name of
the function instead. I guess this refers to
hv_build_devid_type_pci()? Or maybe hv_pci_vmbus_device_id()?
Or hv_build_devid_oftype()?

> +++ b/include/asm-generic/mshyperv.h
> +#if IS_ENABLED(CONFIG_PCI_HYPERV)
> +u64 hv_pci_vmbus_device_id(struct pci_dev *pdev);
> +#else /* IS_ENABLED(CONFIG_PCI_HYPERV) */
> +static inline u64 hv_pci_vmbus_device_id(struct pci_dev *pdev)
> +{ return 0; }
> +#endif /* IS_ENABLED(CONFIG_PCI_HYPERV) */

IMO the "IS_ENABLED()" comments here are just clutter since it's only
six lines and it's obvious what the #else and #endif belong to.