From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id E01D75587; Mon, 21 Jan 2019 11:21:25 +0100 (CET) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6466528352; Mon, 21 Jan 2019 05:21:25 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 21 Jan 2019 05:21:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s=mesmtp; bh=NfLJiHMwK3kbHVFLSU0Bq0v0GISHWf/bvWc3Fzi7T7g=; b=nmkLHG3pDtiG T+NZTdqt8Ib3MG75o5FmBAKhxOErUuDrI/5Ex7EKkDCuDSvp3EFc6eiKVw+dtQGu Jk99TkvTy/XUIzjddYNqTqQQYyNXCvAd18sO9mLfcKw9l7B9QEo8ueD9exn9o+ll /qia2tk6oHfAdyLwsHRGFi7U8/jRB3k= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=NfLJiHMwK3kbHVFLSU0Bq0v0GISHWf/bvWc3Fzi7T 7g=; b=MeldQNBnBGtWei2QjHKXOQSoghbUGZ3c6+34Jos3k+n6CU696C+Ay9rZN RdQKRWe5X9Api6raQbCmLbLs9JdUYaDnKL0Eqth7rIJO8fCvHpAmdkBH96FYL9Ao FAlCDsDf9IhuFypKvszf6LLDoZD4QL+dEdBFVANEcriJUGNULRM7yWb3E9TYwGh7 OUxrzzmcyz9hf5YU1CsIOa+pc/8ZS1SauilqSshLgLyLECUGkfCVW001TVlgFJZM pAnnIh0Z5EQF+IvCE19K7DvGc1rAZlW9ybZtWK0lUMsMboqZ201TkfKmLdzAYwZV VK3yrmOH7zjvJpCHMLEzxzGqizokA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtledrheeigdduhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfhuthenuceurghilhhouhhtmecufedt tdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvufffkfgjfh gggfgtsehtufertddttddvnecuhfhrohhmpefvhhhomhgrshcuofhonhhjrghlohhnuceo thhhohhmrghssehmohhnjhgrlhhonhdrnhgvtheqnecukfhppeejjedrudefgedrvddtfe drudekgeenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhho nhdrnhgvthenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from xps.localnet (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id D70C1100BA; Mon, 21 Jan 2019 05:21:23 -0500 (EST) From: Thomas Monjalon To: "Burakov, Anatoly" Cc: "Wang, Xiao W" , "dev@dpdk.org" , "Zhang, Qi Z" , "qingfu.cqf@alibaba-inc.com" , "Stojaczyk, Dariusz" , "stable@dpdk.org" , ferruh.yigit@intel.com Date: Mon, 21 Jan 2019 11:21:22 +0100 Message-ID: <19848055.XTa4X5ecso@xps> In-Reply-To: <1b5e395c-1d0e-ffd4-3eb5-8e1d4f77152d@intel.com> References: <1b5e395c-1d0e-ffd4-3eb5-8e1d4f77152d@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-stable] [PATCH v2] vfio: allow secondary process to query IOMMU type X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Jan 2019 10:21:26 -0000 21/01/2019 11:13, Burakov, Anatoly: > On 19-Jan-19 3:23 AM, Wang, Xiao W wrote: > > Hi Anatoly, > > > > From: Burakov, Anatoly > >> > >> It is only possible to know IOMMU type of a given VFIO container > >> by attempting to initialize it. Since secondary process never > >> attempts to set up VFIO container itself (because they're shared > >> between primary and secondary), it never knows which IOMMU type > >> the container is using, and never sets up the appropriate config > >> structures. This results in inability to perform DMA mappings in > >> secondary process. > >> > >> Fix this by allowing secondary process to query IOMMU type of > >> primary's default container at device initialization. > >> > >> Note that this fix is assuming we're only interested in default > >> container. > >> > >> Bugzilla ID: 174 > >> > >> Fixes: 6bcb7c95fe14 ("vfio: share default container in multi-process") > >> Cc: dariusz.stojaczyk@intel.com > >> Cc: stable@dpdk.org > >> > >> Signed-off-by: Anatoly Burakov > >> --- > >> > >> Notes: > >> v2: > >> - Check if we found our IOMMU type within list of IOMMU types > >> - Don't request new default container fd as this should have > >> been done during rte_vfio_enable() > >> > >> lib/librte_eal/linuxapp/eal/eal_vfio.c | 88 +++++++++++++++++++ > >> lib/librte_eal/linuxapp/eal/eal_vfio.h | 12 ++- > >> .../linuxapp/eal/eal_vfio_mp_sync.c | 16 ++++ > >> 3 files changed, 115 insertions(+), 1 deletion(-) > >> > >> diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c > >> b/lib/librte_eal/linuxapp/eal/eal_vfio.c > >> index 72cc65151..c821e8382 100644 > >> --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c > >> +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c > >> @@ -549,6 +549,65 @@ vfio_mem_event_callback(enum rte_mem_event > >> type, const void *addr, size_t len, > >> } > >> } > >> > >> +static int > >> +vfio_sync_default_container(void) > >> +{ > >> + struct rte_mp_msg mp_req, *mp_rep; > >> + struct rte_mp_reply mp_reply; > >> + struct timespec ts = {.tv_sec = 5, .tv_nsec = 0}; > >> + struct vfio_mp_param *p = (struct vfio_mp_param *)mp_req.param; > >> + int iommu_type_id; > >> + unsigned int i; > >> + > >> + /* cannot be called from primary */ > >> + if (rte_eal_process_type() != RTE_PROC_SECONDARY) > >> + return -1; > >> + > >> + /* default container fd should have been opened in rte_vfio_enable() > >> */ > >> + if (!default_vfio_cfg->vfio_enabled || > >> + default_vfio_cfg->vfio_container_fd < 0) { > >> + RTE_LOG(ERR, EAL, "VFIO support is not initialized\n"); > >> + return -1; > >> + } > >> + > >> + /* find default container's IOMMU type */ > >> + p->req = SOCKET_REQ_IOMMU_TYPE; > > > > Since this function is to sync IOMMU type for the default container, should we make the req type as > > SOCKET_REQ_DEFAULT_IOMMU_TYPE? > > Hi, > > Sure, that can be done. However, i don't think it warrants a respin > unless there's more important stuff to fix also. This patch is a > stop-gap, and this stuff will be rewritten for 19.05, so getting this > right is not that important :). Anatoly, I don't understand what is the use case. It does not look critical enough to be merged late in 19.02.