Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp179933imd; Wed, 31 Oct 2018 16:56:18 -0700 (PDT) X-Google-Smtp-Source: AJdET5eYaZEhvSvf8VdY+lyRzFdXVhMOjVpqXRC+p8D9qMmCQUP2YI1rPx/SnNwuE39EBaxyzsWD X-Received: by 2002:a63:a112:: with SMTP id b18mr5059797pgf.440.1541030178736; Wed, 31 Oct 2018 16:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541030178; cv=none; d=google.com; s=arc-20160816; b=AgXPgazBry9yxidXfaYePOmJwdvfsuu6A4WOyDpYbPoja2wpztSikgjWShxk7OTxFK 31DjecDKUBdctULwTiHO/wi4XgBOohj84kELk1lpo/vbjQy2V8LdfbLiAMhyQr66qRAC NlAb8n9H3LarujOdVHKwRcXfrEclSj1WAs43wcZzlLF1OHDr5Pj5oNnkZh02FzMKmbR9 16Ofx9/gdfKNsrBQMVxLeLfEA0dDnWP5/rzyXzHlNwLofjw8lWPwLcw23ukF6l6l47YC CcZ11lPIZ0b29juW4J+9msnoIdCjQU5tqXutyxYuvQtPk052E/t2TNILGCgSiT/Cu40t EVag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Hpov4iTDeoaDP3G9StXAp6KZ4O5O1FUc7n9qnsXcJzc=; b=HvDZ1GN3D/O9H35KSgeb/4BIizSWoxEAkIFbvUAce7YAvhjJLfcfpnYDxznNb8LW7H cZjinbcY/m0ECAl5tNgnXJIyg+U8C97ZRzgOie0+NKhcnIHJLjoR+lv58UKx1w4ine3K pgeknZlwYgjEgiEQXaVYTcfoVBzfhist6B2OkmjpWUkLtXKm6IMoiyLekADVuVuYAdDC NWSRsILtTppL5IqwKcny471gEBoGv94TmiGJpBdiQbJWX98aZWJY6+8gBNvxO17L+GkY Zt5UrCqCaDcXGIradxP5swcEtWTxHddxs9mDKocSzGhM7I73292rTFkBaR73obpL6TdY /ofQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GyMuJUC/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37-v6si28722914pgp.211.2018.10.31.16.56.04; Wed, 31 Oct 2018 16:56:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="GyMuJUC/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727721AbeKAIy4 (ORCPT + 99 others); Thu, 1 Nov 2018 04:54:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:52678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726985AbeKAIGB (ORCPT ); Thu, 1 Nov 2018 04:06:01 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D332520821; Wed, 31 Oct 2018 23:05:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541027151; bh=uiIlivfjhieJ8WKAcPSmgEjxtZvoDTvb5mWZlOpjfH4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GyMuJUC/H3LW7IpQx+/fFTW0MxUip56LZSgYUxf1CvyQqgjN6yG3BVplPPHc0yhqA QmfFmAbIcI0yPVquvWUdQVZkc0LFXFMNZD6Uw3ao/sRaF3UQdQ9UOdv8X0IZNwIIXq NAoCNJ78KLPQu9OZwX9ubMdMnU1iH41PdzPqVivw= From: Sasha Levin To: stable@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Haiyang Zhang , "David S . Miller" , Sasha Levin Subject: [PATCH AUTOSEL 4.19 009/146] hv_netvsc: fix vf serial matching with pci slot info Date: Wed, 31 Oct 2018 19:03:24 -0400 Message-Id: <20181031230541.28822-9-sashal@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181031230541.28822-1-sashal@kernel.org> References: <20181031230541.28822-1-sashal@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Haiyang Zhang [ Upstream commit 005479556197f80139771960dda0dfdcd2d2aad5 ] 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") Reported-by: Vitaly Kuznetsov Signed-off-by: Haiyang Zhang Reviewed-by: Stephen Hemminger Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- 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 3af6d8d15233..1c37a821895b 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -2022,14 +2022,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 */ @@ -2040,16 +2041,22 @@ static struct net_device *get_netvsc_byslot(const struct net_device *vf_netdev) return NULL; } + if (kstrtou32(pci_slot_name(pdev->slot), 10, &serial)) { + netdev_notice(vf_netdev, "Invalid vf serial:%s\n", + pci_slot_name(pdev->slot)); + return NULL; + } + list_for_each_entry(ndev_ctx, &netvsc_dev_list, list) { if (!ndev_ctx->vf_alloc) continue; - if (ndev_ctx->vf_serial == pdev->slot->number) + if (ndev_ctx->vf_serial == serial) return hv_get_drvdata(ndev_ctx->device_ctx); } netdev_notice(vf_netdev, - "no netdev found for slot %u\n", pdev->slot->number); + "no netdev found for vf serial:%u\n", serial); return NULL; } -- 2.17.1