From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by dpdk.org (Postfix) with ESMTP id 5F9431B521 for ; Thu, 12 Jul 2018 11:32:27 +0200 (CEST) Received: by mail-wr1-f67.google.com with SMTP id j5-v6so14440998wrr.8 for ; Thu, 12 Jul 2018 02:32:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=sgS6T7KteqUOxm+WWM80I4FUa25DKaGE2qGf9W9Zh1c=; b=qtZJDLMDDTLhMbEnOSmj4KfJv4Ga/X4JtFCxVguiRAbdV1DX60ZiXD0adpNR1X8mEs 8jcE5GNuM9LnZifIHm6OIX0qf49NsvocR41gjO88d9rm80dDcAmOyDqg7KfhgeUEJZct MH4BEv7aTh2uiHtgBdUO1/4SC3P+7pjboweLRApd2I3JilPyEaGpY6evtmiKDKPvLU4m Zk3LKNkzStK8Y23AdsT4WgC8LGWMkvLrPWi18iWZFVv2tR7LB0S8umm5926Ti9im2SPM GFpMPanbYJ+TuYIdaVNhaRkXIsKqlo7usFWhv7pAOaSAuP8VSdReY5e/dSTzuSI7erlI lIlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=sgS6T7KteqUOxm+WWM80I4FUa25DKaGE2qGf9W9Zh1c=; b=oDdFxooIuzWkuaEpp8xT3ECpr0XHznat/eeseAklHnbGixcoNBd5A6gretJ+q7FEe5 dr/vFR07iSPMLAxViyekSxTBRDWsRYpt9tWZjm36mQ+IfkvPVbqgzt0a8CTvvrIo4aCW U/AuRuze0rHACL2SyOBD9zRTV0HvCo220K2uJFwwRDhOMShVN35tpljTPYLC2TJA5M8+ qzIuVOifvtNXY7D5ZQ+RwR28VktgxV5zmT1I5C6AfI3dZaNzatiTu++u/WsONKYkzSP4 pCp8A7+j6Ern1zGJId9zRKtAaA7fIdse0GCHk36OI2zktaqwQCTYVpVse6/YkO1GC18d 7/pA== X-Gm-Message-State: AOUpUlEoeo2vDNPv3gF0b784T9XESs6QO6IfKqgrYPkwBP9taEFW++7f oPLRy8nzOIX4D2eUgHfaAJlFMw== X-Google-Smtp-Source: AAOMgpeoYwMF9Lbl7x8mv40aInXSo9UExDgk3WN6KWJo0papqC5pXjOVRIzAHejvur8qTqILGeFc8A== X-Received: by 2002:a5d:6550:: with SMTP id z16-v6mr1094266wrv.194.1531387946641; Thu, 12 Jul 2018 02:32:26 -0700 (PDT) Received: from bidouze.vm.6wind.com (host.78.145.23.62.rev.coltfrance.com. [62.23.145.78]) by smtp.gmail.com with ESMTPSA id x16-v6sm5651255wme.12.2018.07.12.02.32.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Jul 2018 02:32:25 -0700 (PDT) Date: Thu, 12 Jul 2018 11:32:09 +0200 From: =?iso-8859-1?Q?Ga=EBtan?= Rivet To: "Burakov, Anatoly" Cc: Qi Zhang , thomas@monjalon.net, konstantin.ananyev@intel.com, dev@dpdk.org, bruce.richardson@intel.com, ferruh.yigit@intel.com, benjamin.h.shelton@intel.com, narender.vangati@intel.com, stable@dpdk.org Message-ID: <20180712093209.x7r4lzazlxsvvcwu@bidouze.vm.6wind.com> References: <20180607123849.14439-1-qi.z.zhang@intel.com> <20180712011514.45006-1-qi.z.zhang@intel.com> <20180712011514.45006-3-qi.z.zhang@intel.com> <20058c30-7587-7c23-d783-b7a8153592b8@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20058c30-7587-7c23-d783-b7a8153592b8@intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Subject: Re: [dpdk-dev] [PATCH v13 02/19] bus/pci: fix PCI address compare 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: Thu, 12 Jul 2018 09:32:27 -0000 Hi, On Thu, Jul 12, 2018 at 10:24:44AM +0100, Burakov, Anatoly wrote: > On 12-Jul-18 2:14 AM, Qi Zhang wrote: > > When use memcmp to compare two PCI address, sizeof(struct rte_pci_addr) > > is 4 bytes aligned, and it is 8. While only 7 byte of struct rte_pci_addr > > is valid. So compare the 8th byte will cause the unexpected result, which > > happens when repeatedly attach/detach a device. > > > > Fixes: c752998b5e2e ("pci: introduce library and driver") Shouldn't be the original commit be Fixes: 94c0776b1bad ("vfio: support hotplug") instead? > > Cc: stable@dpdk.org > > > > Signed-off-by: Qi Zhang > > --- > > drivers/bus/pci/linux/pci_vfio.c | 13 ++++++++++++- > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/bus/pci/linux/pci_vfio.c b/drivers/bus/pci/linux/pci_vfio.c > > index aeeaa9ed8..dd25c3542 100644 > > --- a/drivers/bus/pci/linux/pci_vfio.c > > +++ b/drivers/bus/pci/linux/pci_vfio.c > > @@ -43,6 +43,17 @@ static struct rte_tailq_elem rte_vfio_tailq = { > > }; > > EAL_REGISTER_TAILQ(rte_vfio_tailq) > > +/* Compair two pci address */ > > +static int pci_addr_cmp(struct rte_pci_addr *addr1, struct rte_pci_addr *addr2) > > +{ > > + if (addr1->domain == addr2->domain && > > + addr1->bus == addr2->bus && > > + addr1->devid == addr2->devid && > > + addr1->function == addr2->function) > > + return 0; > > + return 1; > > +} > > Generally, change looks OK to me, but I think we already have this function > in PCI library - rte_pci_addr_cmp(). Is there a specific reason to > reimplement it here? > +1 > > + > > int > > pci_vfio_read_config(const struct rte_intr_handle *intr_handle, > > void *buf, size_t len, off_t offs) > > @@ -642,7 +653,7 @@ pci_vfio_unmap_resource(struct rte_pci_device *dev) > > vfio_res_list = RTE_TAILQ_CAST(rte_vfio_tailq.head, mapped_pci_res_list); > > /* Get vfio_res */ > > TAILQ_FOREACH(vfio_res, vfio_res_list, next) { > > - if (memcmp(&vfio_res->pci_addr, &dev->addr, sizeof(dev->addr))) > > + if (pci_addr_cmp(&vfio_res->pci_addr, &dev->addr)) > > continue; > > break; > > } > > > > > -- > Thanks, > Anatoly -- Gaëtan Rivet 6WIND