From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id AD03B2082 for ; Tue, 6 Nov 2018 23:21:42 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Nov 2018 14:21:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,473,1534834800"; d="scan'208";a="278878312" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by fmsmga006.fm.intel.com with ESMTP; 06 Nov 2018 14:21:41 -0800 Received: from fmsmsx113.amr.corp.intel.com (10.18.116.7) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 6 Nov 2018 14:21:40 -0800 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX113.amr.corp.intel.com (10.18.116.7) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 6 Nov 2018 14:21:40 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.161]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.199]) with mapi id 14.03.0415.000; Wed, 7 Nov 2018 06:21:38 +0800 From: "Zhang, Qi Z" To: Dariusz Stojaczyk , "dev@dpdk.org" , "gaetan.rivet@6wind.com" CC: "Stojaczyk, Dariusz" Thread-Topic: [PATCH v2] bus/pci: update device devargs on each rescan Thread-Index: AQHUdZNdDoaOvL1y+E+apI5AqNQ7G6VDPeSg Date: Tue, 6 Nov 2018 22:21:38 +0000 Message-ID: <039ED4275CED7440929022BC67E70611532E04E5@SHSMSX103.ccr.corp.intel.com> References: <20181105070447.67700-1-dariusz.stojaczyk@intel.com> <20181106054015.28280-1-darek.stojaczyk@gmail.com> In-Reply-To: <20181106054015.28280-1-darek.stojaczyk@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMmRhNjMzMGEtNDAwMi00M2NkLThhOGEtMzE2YmQyYjZhYzlhIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoicmppN0dqN0FWY2FjMmNRWEJneFNxMkpqRDY2ZXhMS21lb1p5cldOU1ZLTklkczZTenVjVlwvMVNcL3ZWUVZlWVBsIn0= x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [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 22:21:43 -0000 > -----Original Message----- > From: Dariusz Stojaczyk [mailto:darek.stojaczyk@gmail.com] > Sent: Monday, November 5, 2018 10:40 PM > To: dev@dpdk.org; gaetan.rivet@6wind.com > Cc: Stojaczyk, Dariusz ; Zhang, Qi Z > > Subject: [PATCH v2] bus/pci: update device devargs on each rescan >=20 > From: Darek Stojaczyk >=20 > Bus rescan is done e.g. during the device hotplug, where devargs are > re-allocated. By not updating the rte_device->devargs pointer we potentia= lly > make it a dangling one, as previous devargs could have been (or will be s= oon) > freed. Yes, this is the similar issue we met on vdev. The key problem is we have rte_devargs_insert will destroy a devargs which = is still referenced by a rte_device I'm thinking , why not just keep always keep a snapshot of devargs in rte_d= evice to make things simple? We could introduce a API like rte_dev_assign_devargs(dev, devargs) which ha= ndled the clone and destroy stuff and can be used for all buses. If that idea is acceptable, I would prefer the issue in this patch could be= fixed in pci_name_set by clone a new copy as workaround. >=20 > Fixes: 55e411b301c3 ("bus/pci: fix resource mapping override") > Cc: qi.z.zhang@intel.com >=20 > Signed-off-by: Darek Stojaczyk > --- > Changes since v1: > * introduce additional pci_devargs_lookup() check to make > the code slightly more readable (Gaetan Rivet) >=20 > 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(-) >=20 > diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c in= dex > 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) !=3D > + 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; > } >=20 > -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); >=20 > /** > + * 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 fun= ction > * also updates the bus references of the PCI Device (and the generic de= vice > * object embedded within. > -- > 2.11.0