Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3489792imu; Sun, 11 Nov 2018 16:16:05 -0800 (PST) X-Google-Smtp-Source: AJdET5fPW5d/1H7qdQAkDYQAak9C38PU1as8nYTTqW2/J7UyVep+/lXYCgLcglWlgDWm9gi+cH3L X-Received: by 2002:a62:cc4:: with SMTP id 65-v6mr17881688pfm.127.1541981765622; Sun, 11 Nov 2018 16:16:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981765; cv=none; d=google.com; s=arc-20160816; b=cmCcfzNUe9XWUxnfY1OibXvCTTXupNbOhaRpSXT/2OPrpFa4oQJSae9mdwgLLnHkXE 9/dtx0PJIwTF1PPf9/542gbEQUbp424LNmU777gO4d2jmqYRomWMbhxyZiIhebYik+K7 aU3z/HBTYx0QjreT/m921L7wnTK50xLchsXBnOzXL1fF8vHANYf+iRHhd05ttSwjlTvM NOiurL+Ni63L8IxdnXj/WGi4o73oMgFWTlmWAAHd4rwJTO4U1CAp2kH5qRKZxx58isZe aeYnJKhoXcVF/Uu/2YCvX9qXdGEiN4aGQHP+hmPcrulTfkJ5wbrRNZaFgMhVYnrYqXld XDxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qh61yKS2zLHYhsIwcyIz/6vT32ZdfZYUhlE2srt/4Uc=; b=mXl5zFmg3yb/+glhs4gKyix319T4OIT8z2syK1rp+wqEXoSPojIlDT/GRGypwVwFp7 PsyaB5eaIu8Tsv8Xmkp4HX449c9bLliVvgbEuUDzq7LtsT0eai3yG4ZtQq4Iwizi0SLZ cTidXjQsdALtPjH7kAeTutflmdgftpxdYGqLMnrIiAehpey4+Xnz64FEC6g9mNBcOI+I R2ChxYBjHXNzN3mq7cvdnLrYvBhrlDXpP7OZhcv1KAm/9k3Y6JmLlEVR635DbLyHQGdp 9plQ9QdG59zLRRMyMAjmqLNs/P6PmRNBdhUM4COfhommSkN/DmlWOF7W0SiiIunhOVQx RjJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=s0DQDGsP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g137-v6si18065537pfb.34.2018.11.11.16.15.50; Sun, 11 Nov 2018 16:16:05 -0800 (PST) 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=s0DQDGsP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730308AbeKLIRK (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:10 -0500 Received: from mail.kernel.org ([198.145.29.99]:59220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730158AbeKLIRH (ORCPT ); Mon, 12 Nov 2018 03:17:07 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B4D4F216FD; Sun, 11 Nov 2018 22:27:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975230; bh=5hnr1Rmyob4ry1WzG0VAzPyEh/SadHV+wnJ4Kd6zz9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s0DQDGsPenBogtYgi08NWxudEVVBd1GtJD1fUXXtfQGZjOkXnqecwMituCrultY3m 8RdA55b0DJAUS4zbuS7J5KNfXGNqssNROX5lgsfojko9Nwpo6TO3ycFmnHo1AMWaR1 hFJS/MYDksVAAKXXPj+YRbsddXze3G1rH1huIlxE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vitaly Kuznetsov , Haiyang Zhang , Stephen Hemminger , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 055/361] hv_netvsc: fix vf serial matching with pci slot info Date: Sun, 11 Nov 2018 14:16:42 -0800 Message-Id: <20181111221627.767521037@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/net/hyperv/netvsc_drv.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- 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_ 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_bys 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; }