From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lj1-f193.google.com (mail-lj1-f193.google.com [209.85.208.193]) by dpdk.org (Postfix) with ESMTP id 7D8062AA0 for ; Tue, 6 Nov 2018 06:41:14 +0100 (CET) Received: by mail-lj1-f193.google.com with SMTP id u6-v6so10305517ljd.1 for ; Mon, 05 Nov 2018 21:41:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Wx2yef1hScBPjCeSRdnZnPTsL8tSJ56MxiJsQ75Co3I=; b=fe0Xbr66BIY5gR5BPcDdmSKyUJMiIwV05iXQCvA5CkoeBIikIof0r/sgxjidD6hQeN /ojCEKlUI+5tDIbN1nUsqK5rEK2W0MAyEvBTHx6EhAtRXQ7+M8Vxf/kI8j8RcUJ9ZWRc 9MCTVww0lEBHaNIG/O7ppnWNL493oF+r+lY6a67SzJSdjJTGPAe+Bhlrwuo3PHDASIsa ebZ8Goodshy2DDp1RdNBXhLCJ1USrn+g1u4zg/91+Si0ZC2LFePT/xi9PyUdTQVFKsZL 7vw1477CouZnnRvIobSom2rpO9OXGt3kcIOQFkWEXzxQ/IxcQ90vJGsxOVRbIKJbxXbF n2Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Wx2yef1hScBPjCeSRdnZnPTsL8tSJ56MxiJsQ75Co3I=; b=PnWKT4iqMwtL0Ogxb52UvlpefKj3hwgbpVtjhheqT72swD9zfjBSWjZse5rVg9Wa8+ rU4cuA4hFdV/7efp9WiH9+ROsZB8vdGRmSInAMSjry2biyaZWaDFHBPXiYBm4li+OvsG WdiorYN5HvW3gPVBB7TBnK9HVbu4880aqly7Azojbe6uieAdp+t6t+FLL+dFoZPtjyAF f8pj6evnvEyS9Eaqx9LMyJ44o6dEd7DwnmtyTELXHdLQ4PXOn/9OFXdgXB4pd6BOe6a4 aPtBV1RPm/q8ZCOTFN4yHXu7E5A2OfOhG3dfcQD1rzY0DFxLMPLfm9Ac99N0kQkJW5BK XGGg== X-Gm-Message-State: AGRZ1gIZXgmuBj7pwvjEKyFExqI4NZgB5f5wbFEOIlpGXv5/ktiWXZRU 1OaTb/ujEIR4s7zJDb6ZbaMxdznYbK8fOw== X-Google-Smtp-Source: AJdET5eygyLZeZO1eC4IfuQBrLkcjC4qiqA1w98rv9pMAAHfsrE53+BqQjKaGoQzzaIJPO76aYxdag== X-Received: by 2002:a2e:9dd0:: with SMTP id x16-v6mr7283915ljj.164.1541482873630; Mon, 05 Nov 2018 21:41:13 -0800 (PST) Received: from localhost.localdomain (89-78-174-111.dynamic.chello.pl. [89.78.174.111]) by smtp.gmail.com with ESMTPSA id d126-v6sm7248990lfe.75.2018.11.05.21.41.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Nov 2018 21:41:12 -0800 (PST) From: Dariusz Stojaczyk To: dev@dpdk.org, gaetan.rivet@6wind.com Cc: Darek Stojaczyk , qi.z.zhang@intel.com Date: Tue, 6 Nov 2018 06:40:15 +0100 Message-Id: <20181106054015.28280-1-darek.stojaczyk@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181105070447.67700-1-dariusz.stojaczyk@intel.com> References: <20181105070447.67700-1-dariusz.stojaczyk@intel.com> Subject: [dpdk-dev] [PATCH v2] bus/pci: update device devargs on each rescan X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Nov 2018 05:41:14 -0000 From: Darek Stojaczyk Bus rescan is done e.g. during the device hotplug, where devargs are re-allocated. By not updating the rte_device->devargs pointer we potentially make it a dangling one, as previous devargs could have been (or will be soon) freed. Fixes: 55e411b301c3 ("bus/pci: fix resource mapping override") Cc: qi.z.zhang@intel.com Signed-off-by: Darek Stojaczyk --- Changes since v1: * introduce additional pci_devargs_lookup() check to make the code slightly more readable (Gaetan Rivet) drivers/bus/pci/linux/pci.c | 5 +++++ drivers/bus/pci/pci_common.c | 3 ++- drivers/bus/pci/private.h | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index c99d523f0..a32d4848e 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -379,6 +379,11 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) RTE_LOG(ERR, EAL, "Unexpected device scan at %s!\n", filename); } + + if (pci_devargs_lookup(dev2) != + dev2->device.devargs) + pci_name_set(dev2); + free(dev); } return 0; diff --git a/drivers/bus/pci/pci_common.c b/drivers/bus/pci/pci_common.c index 6276e5d69..fcaf76ed2 100644 --- a/drivers/bus/pci/pci_common.c +++ b/drivers/bus/pci/pci_common.c @@ -42,7 +42,8 @@ const char *rte_pci_get_sysfs_path(void) return path; } -static struct rte_devargs *pci_devargs_lookup(struct rte_pci_device *dev) +struct rte_devargs * +pci_devargs_lookup(struct rte_pci_device *dev) { struct rte_devargs *devargs; struct rte_pci_addr addr; diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index 13c3324bb..8b2e904f0 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -43,6 +43,17 @@ void pci_name_set(struct rte_pci_device *dev); /** + * Find matching up-to-date devargs for a given device. + * + * @param pci_dev + * PCI device + * @return + * A devargs pointer or NULL + */ +struct rte_devargs * +pci_devargs_lookup(struct rte_pci_device *dev); + +/** * Add a PCI device to the PCI Bus (append to PCI Device list). This function * also updates the bus references of the PCI Device (and the generic device * object embedded within. -- 2.11.0