From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10D3BC4361B for ; Thu, 17 Dec 2020 19:06:50 +0000 (UTC) Received: from dpdk.org (dpdk.org [92.243.14.124]) by mail.kernel.org (Postfix) with ESMTP id 6D7D9239E4 for ; Thu, 17 Dec 2020 19:06:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6D7D9239E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=marvell.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dev-bounces@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id CC28ACA58; Thu, 17 Dec 2020 20:06:29 +0100 (CET) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id EA151CA46 for ; Thu, 17 Dec 2020 20:06:27 +0100 (CET) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BHJ5ZI8006168; Thu, 17 Dec 2020 11:06:26 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=pfpt0220; bh=RlRhF/5CrX3AuKr7mKPGBRVQLA2rAO12kUMWz447pDs=; b=Cf4zI+1srsQ56occZQSqPg1hm73GINSMuHGPRmjWCf4ZSMLX3JZXhoYmJ6gbHS1+vyoM zXe7rgDvwbqYhkFzQGtnwbsH3f74y1YX+gm1zsOIEl7wQtSDLjv70mX7i3Ts9erCZNpx y0uDU7zHBiC5dTIn/AaipiE67PyA+n/Q9hFyRvkViVyj5AFGP24HKunBPZnkfhqXyvXg Psv61TnyQdbn+emEwQI/ZBLD0g+P2b/lmMUUAXb9qVXvocExbHKpGig6QivxdL1oQSFZ abOBZXmLb2zFZ4ylxJd/634PoY7TbYy6FtEJSUP8Ob7wcVuuerY0291RVWF1+pV9jlH8 tQ== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 35cx8tgrtg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 17 Dec 2020 11:06:26 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 17 Dec 2020 11:06:18 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 17 Dec 2020 11:06:18 -0800 Received: from hyd1588t430.marvell.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 95F143F7045; Thu, 17 Dec 2020 11:06:16 -0800 (PST) From: Nithin Dabilpuram To: , David Christensen , CC: , , Nithin Dabilpuram Date: Fri, 18 Dec 2020 00:36:00 +0530 Message-ID: <20201217190604.29803-1-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20201012081106.10610-1-ndabilpuram@marvell.com> References: <20201012081106.10610-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.343, 18.0.737 definitions=2020-12-17_13:2020-12-17, 2020-12-17 signatures=0 Subject: [dpdk-dev] [PATCH v6 0/4] fix issue with partial DMA unmap 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Partial DMA unmap is not supported by VFIO type1 IOMMU in Linux. Though the return value is zero, the returned DMA unmap size is not same as expected size. So add test case and fix to both heap triggered DMA mapping and user triggered DMA mapping/unmapping. Refer vfio_dma_do_unmap() in drivers/vfio/vfio_iommu_type1.c Snippet of comment is below. /* * vfio-iommu-type1 (v1) - User mappings were coalesced together to * avoid tracking individual mappings. This means that the granularity * of the original mapping was lost and the user was allowed to attempt * to unmap any range. Depending on the contiguousness of physical * memory and page sizes supported by the IOMMU, arbitrary unmaps may * or may not have worked. We only guaranteed unmap granularity * matching the original mapping; even though it was untracked here, * the original mappings are reflected in IOMMU mappings. This * resulted in a couple unusual behaviors. First, if a range is not * able to be unmapped, ex. a set of 4k pages that was mapped as a * 2M hugepage into the IOMMU, the unmap ioctl returns success but with * a zero sized unmap. Also, if an unmap request overlaps the first * address of a hugepage, the IOMMU will unmap the entire hugepage. * This also returns success and the returned unmap size reflects the * actual size unmapped. * We attempt to maintain compatibility with this "v1" interface, but * we take control out of the hands of the IOMMU. Therefore, an unmap * request offset from the beginning of the original mapping will * return success with zero sized unmap. And an unmap request covering * the first iova of mapping will unmap the entire range. This behavior can be verified by using first patch and add return check for dma_unmap.size != len in vfio_type1_dma_mem_map() v6: - Fixed issue with x86-32 build introduced by v5. v5: - Changed vfio test in test_vfio.c to use system pages allocated from heap instead of mmap() so that it comes in range of initially configured window for POWER9 System. - Added acked-by from David for 1/4, 2/4. v4: - Fixed issue with patch 4/4 on x86 builds. v3: - Fixed external memory test case(4/4) to use system page size instead of 4K. - Fixed check-git-log.sh issue and rebased. - Added acked-by from anatoly.burakov@intel.com to first 3 patches. v2: - Reverted earlier commit that enables mergin contiguous mapping for IOVA as PA. (see 1/3) - Updated documentation about kernel dma mapping limits and vfio module parameter. - Moved vfio test to test_vfio.c and handled comments from Anatoly. Nithin Dabilpuram (4): vfio: revert changes for map contiguous areas in one go vfio: fix DMA mapping granularity for type1 IOVA as VA test: add test case to validate VFIO DMA map/unmap test: change external memory test to use system page sz app/test/meson.build | 1 + app/test/test_external_mem.c | 3 +- app/test/test_vfio.c | 107 +++++++++++++++++++++++++++++++++ doc/guides/linux_gsg/linux_drivers.rst | 10 +++ lib/librte_eal/linux/eal_vfio.c | 93 +++++++++++----------------- lib/librte_eal/linux/eal_vfio.h | 1 + 6 files changed, 157 insertions(+), 58 deletions(-) create mode 100644 app/test/test_vfio.c -- 2.8.4