DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Stojaczyk, Dariusz" <dariusz.stojaczyk@intel.com>
To: "Gaëtan Rivet" <gaetan.rivet@6wind.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>,
	"thomas@monjalon.net" <thomas@monjalon.net>,
	"Zhang, Qi Z" <qi.z.zhang@intel.com>
Subject: Re: [dpdk-dev] [PATCH 1/3] bus/pci: update device devargs on each rescan
Date: Mon, 5 Nov 2018 14:52:00 +0000	[thread overview]
Message-ID: <FBE7E039FA50BF47A673AD0BD3CD56A846229ED8@HASMSX105.ger.corp.intel.com> (raw)
In-Reply-To: <20181105141033.z3i3qfjoh6z26f4v@bidouze.vm.6wind.com>

Hi Gaetan,

> -----Original Message-----
> From: Gaëtan Rivet [mailto:gaetan.rivet@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.zhang@intel.com
> >
> > Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@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.

> 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

  reply	other threads:[~2018-11-05 14:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-05  7:04 Darek Stojaczyk
2018-11-05  7:04 ` [dpdk-dev] [PATCH 2/3] devargs: delay freeing previous devargs when overriding them Darek Stojaczyk
2018-11-05  7:30   ` Thomas Monjalon
2018-11-05  8:25     ` Stojaczyk, Dariusz
2018-11-05  9:46       ` Thomas Monjalon
2018-11-05 16:24         ` Gaëtan Rivet
2018-11-05  7:04 ` [dpdk-dev] [PATCH 3/3] eal: handle bus rescan failures during hotplug Darek Stojaczyk
2018-11-05 14:10 ` [dpdk-dev] [PATCH 1/3] bus/pci: update device devargs on each rescan Gaëtan Rivet
2018-11-05 14:52   ` Stojaczyk, Dariusz [this message]
2018-11-05 16:27     ` Gaëtan Rivet
2018-11-06  5:40 ` [dpdk-dev] [PATCH v2] " Dariusz Stojaczyk
2018-11-06 22:21   ` Zhang, Qi Z
2018-11-06 23:40     ` Gaëtan Rivet
2018-11-12  0:47       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FBE7E039FA50BF47A673AD0BD3CD56A846229ED8@HASMSX105.ger.corp.intel.com \
    --to=dariusz.stojaczyk@intel.com \
    --cc=dev@dpdk.org \
    --cc=gaetan.rivet@6wind.com \
    --cc=qi.z.zhang@intel.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).