On Mon, Nov 05, 2018 at 02:52:00PM +0000, Stojaczyk, Dariusz wrote: > Hi Gaetan, > > > -----Original Message----- > > From: Gaëtan Rivet [mailto:gaetan.ri...@6wind.com] > > Subject: Re: [dpdk-dev] [PATCH 1/3] bus/pci: update device devargs on each > > rescan > > > > Hi Darek, > > > > On Mon, Nov 05, 2018 at 08:04:45AM +0100, Darek Stojaczyk wrote: > > > 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.zh...@intel.com > > > > > > Signed-off-by: Darek Stojaczyk <dariusz.stojac...@intel.com> > > > --- > > > drivers/bus/pci/linux/pci.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c > > > index f87533c5c..f3172960e 100644 > > > --- a/drivers/bus/pci/linux/pci.c > > > +++ b/drivers/bus/pci/linux/pci.c > > > @@ -349,10 +349,10 @@ pci_scan_one(const char *dirname, const struct > > rte_pci_addr *addr) > > > if (ret < 0) { > > > rte_pci_insert_device(dev2, dev); > > > } else { /* already registered */ > > > + pci_name_set(dev2); > > > > This is rather unfortunate to call pci_name_set() > > to trigger the mapping devargs <-> devices. > > > > pci_devargs_lookup could be made non-static instead, > > if that's sufficient. > > This is unfortunately trigerred by the generic eal device hotplug path which > looks as follows: > > da = calloc(sizeof rte_devargs); > [...] > rte_devargs_insert(da); # frees the previous devargs that rte_device still > references > da->bus->scan(); # this should update the dangling devargs/name pointer in > rte_device > > Instead of making pci_devargs_lookup public, we would have to introduce a new > bus callback for updating devargs of only a single device and that would be a > really, realy ugly overkill. Thomas already mentioned in the subsequent patch > within this series that we might want to re-think the devargs design in the > next release. >
No, of course, I'm not saying to make pci_devargs_lookup public, only private to the PCI bus, and within the bus, non-static. This way, instead of calling pci_name_set(), you call instead only pci_devargs_lookup(). > > Given that the PCI id matches because the device > > is a duplicate (already registered), then the name itself probably does > > not need to be updated. > > The issue here was that old devargs/name could have been freed. > The new name is the same as the old one, it's just in a different buffer. > > I know calling pci_name_set() on each device during scan is not perfect, but > IMO it's enforced by the current rte_devargs design. Besides, this used to be > the original behavior before 55e411b301c3 ("bus/pci: fix resource mapping > override"). > > Thanks, > D. > > > > > > <snip> > > > > -- > > Gaëtan Rivet > > 6WIND -- Gaëtan Rivet 6WIND