On Thu, Oct 11, 2018 at 08:14:34PM +0000, Haiyang Zhang wrote:
> From: Haiyang Zhang <haiya...@microsoft.com>
> 
> The VF device's serial number is saved as a string in PCI slot's
> kobj name, not the slot->number. This patch corrects the netvsc
> driver, so the VF device can be successfully paired with synthetic
> NIC.
> 
> Fixes: 00d7ddba1143 ("hv_netvsc: pair VF based on serial number")
> Signed-off-by: Haiyang Zhang <haiya...@microsoft.com>
> ---
>  drivers/net/hyperv/netvsc_drv.c | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
> index 9bcaf204a7d4..8121ce34a39f 100644
> --- a/drivers/net/hyperv/netvsc_drv.c
> +++ b/drivers/net/hyperv/netvsc_drv.c
> @@ -2030,14 +2030,15 @@ static void netvsc_vf_setup(struct work_struct *w)
>       rtnl_unlock();
>  }
>  
> -/* Find netvsc by VMBus serial number.
> - * The PCI hyperv controller records the serial number as the slot.
> +/* Find netvsc by VF serial number.
> + * The PCI hyperv controller records the serial number as the slot kobj name.
>   */
>  static struct net_device *get_netvsc_byslot(const struct net_device 
> *vf_netdev)
>  {
>       struct device *parent = vf_netdev->dev.parent;
>       struct net_device_context *ndev_ctx;
>       struct pci_dev *pdev;
> +     u32 serial;
>  
>       if (!parent || !dev_is_pci(parent))
>               return NULL; /* not a PCI device */
> @@ -2048,16 +2049,22 @@ static struct net_device *get_netvsc_byslot(const 
> struct net_device *vf_netdev)
>               return NULL;
>       }
>  
> +     if (kstrtou32(pdev->slot->kobj.name, 10, &serial)) {

kobject_name()?

And that feels _very_ fragile to me.  This is now an api that you are
guaranteeing will never change?

Good luck with that!

greg k-h
_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to