From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id E8E31A0096 for ; Fri, 7 Jun 2019 04:28:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BFEECF64; Fri, 7 Jun 2019 04:28:37 +0200 (CEST) Received: from nh605-vm4.bullet.mail.ssk.yahoo.co.jp (nh605-vm4.bullet.mail.ssk.yahoo.co.jp [182.22.90.77]) by dpdk.org (Postfix) with SMTP id C074923D for ; Fri, 7 Jun 2019 04:28:35 +0200 (CEST) Received: from [182.22.66.103] by nh605.bullet.mail.ssk.yahoo.co.jp with NNFMP; 07 Jun 2019 02:28:32 -0000 Received: from [182.22.91.206] by t601.bullet.mail.ssk.yahoo.co.jp with NNFMP; 07 Jun 2019 02:28:32 -0000 Received: from [127.0.0.1] by omp609.mail.ssk.yahoo.co.jp with NNFMP; 07 Jun 2019 02:28:32 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 960636.40440.bm@omp609.mail.ssk.yahoo.co.jp Received: (qmail 79854 invoked by alias); 7 Jun 2019 02:28:32 -0000 Received: from unknown (HELO takeshibookpuro.dhcp.hakozaki.ibm.com) (203.141.91.13 with login) by ymobsmtp6001.mail.ssk.ynwp.yahoo.co.jp with SMTP; 7 Jun 2019 02:28:32 -0000 X-YMail-JAS: Y9N23ZoVM1nrWw.twlsHhFiAg5VZAG0.9706_BhEhJuZhqEk0SvtDEMPdAbb2sYTHj6daUCshaiasTAW3QfKB6mBXYKroWNfRfS58vBl5V1gy_0nZ8wulMBUcpz7jd7AvzG.JUFJrhFfn9E- X-Apparently-From: X-YMail-OSG: FgfOTWMVM1m80v2LXDdtHUUOyLLdK20Jsd87SLhDpqPHKVA 4Wy2emLFR5GP.2bu7G3WC.Y9rS3riRMR3SPozRHl5M5KmUSxBJ.yYBCripmu LXwxgUzaW07MWGrOQTXNFBwgx_AWrE_V8efNhgSMrwnEw4DvDE4voa3HFyKX UjDu9HXcsSGXu46IoAqtqDrkP8_6T6kHKyff_oVjKYV509ErcpNhy.jOKbWy CXQ3e1cy3ReJrDkBKcNbHNofN9iBlJZZW_G3w.mQqRLVU05wweKQQToR2qWU 8RB0N68r_8Ah6qd6T68pP7bDBFTP7oPBDjrJhiC7f1cAx_B.fasuv7Cn6bt2 qjrU9P_I6ijogWeASjVx94z6XSgEVEPhCSKEoBciWKbTQ1H8ocRJLpDDggLM 0mqdPN8vOZjnJo3Dh5y.w4_q3hfEynX.Szx0FkoGrz5mNWCJ10KKSMgX7XDo Q4nJxCIpaicKQFH2TPp8hnINU7wZpWSEpU3RiQMF.2CoAKQ1yFEL0gJWPraG XJ_LgEu9eEp.HwWDjpI7KKMenDMwYc0cK6EXfxH_6jwxs71mgFWv3OaOAdjb FLA3fGbC1BrWWzVb_5bpL6u6Bb6o- From: Takeshi Yoshimura To: dev@dpdk.org Cc: Takeshi Yoshimura Date: Fri, 7 Jun 2019 11:28:29 +0900 Message-Id: <20190607022830.2044-1-tyos@jp.ibm.com> X-Mailer: git-send-email 2.17.2 (Apple Git-113) Subject: [dpdk-dev] [PATCH] vfio: retry creating sPAPR DMA window 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" sPAPR allows only page_shift from VFIO_IOMMU_SPAPR_TCE_GET_INFO ioctl. However, Linux 4.17 or before returns incorrect page_shift for Power9. I added the code for retrying creation of sPAPR DMA window. Signed-off-by: Takeshi Yoshimura --- lib/librte_eal/linux/eal/eal_vfio.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/linux/eal/eal_vfio.c b/lib/librte_eal/linux/eal/eal_vfio.c index 6892a2c14..f16c5c3c0 100644 --- a/lib/librte_eal/linux/eal/eal_vfio.c +++ b/lib/librte_eal/linux/eal/eal_vfio.c @@ -1448,9 +1448,29 @@ vfio_spapr_create_new_dma_window(int vfio_container_fd, /* create new DMA window */ ret = ioctl(vfio_container_fd, VFIO_IOMMU_SPAPR_TCE_CREATE, create); if (ret) { - RTE_LOG(ERR, EAL, " cannot create new DMA window, " - "error %i (%s)\n", errno, strerror(errno)); - return -1; + /* try possible page_shift and levels for workaround */ + uint32_t levels; + + for (levels = 1; levels <= info.ddw.levels; levels++) { + uint32_t pgsizes = info.ddw.pgsizes; + + while (pgsizes != 0) { + create->page_shift = 31 - __builtin_clz(pgsizes); + create->levels = levels; + ret = ioctl(vfio_container_fd, + VFIO_IOMMU_SPAPR_TCE_CREATE, create); + if (!ret) + break; + pgsizes &= ~(1 << create->page_shift); + } + if (!ret) + break; + } + if (ret) { + RTE_LOG(ERR, EAL, " cannot create new DMA window, " + "error %i (%s)\n", errno, strerror(errno)); + return -1; + } } if (create->start_addr != 0) { -- 2.17.1