From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from dpdk.org (dpdk.org [92.243.14.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 0F4A7A04AF;
	Sat, 22 Aug 2020 00:08:10 +0200 (CEST)
Received: from [92.243.14.124] (localhost [127.0.0.1])
	by dpdk.org (Postfix) with ESMTP id 137F42B91;
	Sat, 22 Aug 2020 00:08:09 +0200 (CEST)
Received: from mga12.intel.com (mga12.intel.com [192.55.52.136])
 by dpdk.org (Postfix) with ESMTP id AAA621E2B
 for <dev@dpdk.org>; Sat, 22 Aug 2020 00:08:07 +0200 (CEST)
IronPort-SDR: tjqSJLPxQigY2OVwXwqD/0a4SgPY3zeMz8/KBIBr7tdRMZ8OyxIG8Pn7BTVI28Au4YVIGO6gL0
 pgXSNTCAEWtA==
X-IronPort-AV: E=McAfee;i="6000,8403,9720"; a="135177263"
X-IronPort-AV: E=Sophos;i="5.76,338,1592895600"; d="scan'208";a="135177263"
X-Amp-Result: SKIPPED(no attachment in message)
X-Amp-File-Uploaded: False
Received: from orsmga002.jf.intel.com ([10.7.209.21])
 by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384;
 21 Aug 2020 15:08:06 -0700
IronPort-SDR: D+u9rnbCOwoSQ6UAcjHifSn73iZdxMXKaWYhyloXn3OFweG78skiqXehGQg/1T4+ftx2ZHFufv
 5K+TA+1Rs6iQ==
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.76,338,1592895600"; d="scan'208";a="311563206"
Received: from jrharri1-skx.ch.intel.com ([143.182.137.73])
 by orsmga002.jf.intel.com with ESMTP; 21 Aug 2020 15:08:06 -0700
From: Jim Harris <james.r.harris@intel.com>
To: dev@dpdk.org
Cc: Jim Harris <james.r.harris@intel.com>
Date: Fri, 21 Aug 2020 15:06:50 -0700
Message-Id: <20200821220650.7901-1-james.r.harris@intel.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH] pci/linux: copy new id for inserted device
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

When a device is inserted into an existing BDF slot
that has not been probed, we must overwrite the old
PCI ID with the ID of the new function. Otherwise
we may not probe the function with the correct driver,
if at all.

Signed-off-by: Jim Harris <james.r.harris@intel.com>
---
 drivers/bus/pci/linux/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c
index a2198abf4..4701661e5 100644
--- a/drivers/bus/pci/linux/pci.c
+++ b/drivers/bus/pci/linux/pci.c
@@ -352,6 +352,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 				if (!rte_dev_is_probed(&dev2->device)) {
 					dev2->kdrv = dev->kdrv;
 					dev2->max_vfs = dev->max_vfs;
+					memcpy(&dev2->id, &dev->id, sizeof(dev2->id));
 					pci_name_set(dev2);
 					memmove(dev2->mem_resource,
 						dev->mem_resource,
@@ -365,7 +366,8 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr)
 					 * need to do anything here unless...
 					 **/
 					if (dev2->kdrv != dev->kdrv ||
-						dev2->max_vfs != dev->max_vfs)
+						dev2->max_vfs != dev->max_vfs ||
+						memcmp(&dev2->id, &dev->id, sizeof(dev2->id))
 						/*
 						 * This should not happens.
 						 * But it is still possible if
-- 
2.20.1