linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: haiyangz@microsoft.com
Cc: davem@davemloft.net, netdev@vger.kernel.org, olaf@aepfle.de,
	sthemmin@microsoft.com, linux-kernel@vger.kernel.org,
	devel@linuxdriverproject.org, vkuznets@redhat.com
Subject: Re: [PATCH net-next] hv_netvsc: fix vf serial matching with pci slot info
Date: Fri, 12 Oct 2018 08:36:20 +0200	[thread overview]
Message-ID: <20181012063620.GA20393@kroah.com> (raw)
In-Reply-To: <20181011201434.30737-1-haiyangz@linuxonhyperv.com>

On Thu, Oct 11, 2018 at 08:14:34PM +0000, Haiyang Zhang wrote:
> From: Haiyang Zhang <haiyangz@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 <haiyangz@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

  parent reply	other threads:[~2018-10-12  6:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-11 20:14 [PATCH net-next] hv_netvsc: fix vf serial matching with pci slot info Haiyang Zhang
2018-10-11 22:30 ` Haiyang Zhang
2018-10-12  6:27   ` Vitaly Kuznetsov
2018-10-12  6:36 ` Greg KH [this message]
2018-10-12 17:38   ` Haiyang Zhang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181012063620.GA20393@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=devel@linuxdriverproject.org \
    --cc=haiyangz@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olaf@aepfle.de \
    --cc=sthemmin@microsoft.com \
    --cc=vkuznets@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).