From patchwork Thu Aug 17 12:56:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 9906289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CF2D460386 for ; Thu, 17 Aug 2017 13:03:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B5EAA28AF5 for ; Thu, 17 Aug 2017 13:03:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA87028AF9; Thu, 17 Aug 2017 13:03:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RCVD_IN_SORBS_SPAM,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0EA2D28AFF for ; Thu, 17 Aug 2017 13:03:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 63F136E5B3; Thu, 17 Aug 2017 13:03:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org X-Greylist: delayed 410 seconds by postgrey-1.35 at gabe; Thu, 17 Aug 2017 13:03:46 UTC Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by gabe.freedesktop.org (Postfix) with ESMTPS id 69F976E5B4; Thu, 17 Aug 2017 13:03:46 +0000 (UTC) Received: by theia.8bytes.org (Postfix, from userid 1000) id 5B2B7257; Thu, 17 Aug 2017 14:56:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1502974615; bh=X2uzF0hY8utq8X22oEwvN7OvSvcqaViLvCG2lEjv+Ck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BrlblZSbFVgEkUaQWymvWYS5nVTgWzDMYLG9VMegymTmTbcaa7Y9t4zHJxXM/f3Mx RXta+5OkH4qtzzqEe+t+9lYan+lrjitgVPf2vuQj8r186mkRJuC9M72alb4Jfm0/Ae d3HqUh7QsHRaSq2HaUq+H1JF6PPbVxn1S2hwAnR+TRNaE57dXHcKF0QgsxZ2Dzl5aX Mv7vksvBD64SQ5BUvyGHpwlYfRs9ABR/OE8Cc1gtMWXdKtScPWFU7aBg0aDTwAXcIE rhFOsIUEv78HXBh+69QELAoQXL+UraKm0mRx/3FRpWLojgdKNfqufubeW0zZJ1uJhC 4r7yJv6OhEWkg== From: Joerg Roedel To: iommu@lists.linux-foundation.org Subject: [PATCH 08/13] drm/nouveau/imem/gk20a: Use sychronized interface of the IOMMU-API Date: Thu, 17 Aug 2017 14:56:31 +0200 Message-Id: <1502974596-23835-9-git-send-email-joro@8bytes.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502974596-23835-1-git-send-email-joro@8bytes.org> References: <1502974596-23835-1-git-send-email-joro@8bytes.org> Cc: Joerg Roedel , nouveau@lists.freedesktop.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Ben Skeggs , Suravee Suthikulpanit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Joerg Roedel The map and unmap functions of the IOMMU-API changed their semantics: They do no longer guarantee that the hardware TLBs are synchronized with the page-table updates they made. To make conversion easier, new synchronized functions have been introduced which give these guarantees again until the code is converted to use the new TLB-flush interface of the IOMMU-API, which allows certain optimizations. But for now, just convert this code to use the synchronized functions so that it will behave as before. Cc: Ben Skeggs Cc: David Airlie Cc: dri-devel@lists.freedesktop.org Cc: nouveau@lists.freedesktop.org Signed-off-by: Joerg Roedel --- drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c index cd5adbe..3f0de47 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/instmem/gk20a.c @@ -322,8 +322,9 @@ gk20a_instobj_dtor_iommu(struct nvkm_memory *memory) /* Unmap pages from GPU address space and free them */ for (i = 0; i < node->base.mem.size; i++) { - iommu_unmap(imem->domain, - (r->offset + i) << imem->iommu_pgshift, PAGE_SIZE); + iommu_unmap_sync(imem->domain, + (r->offset + i) << imem->iommu_pgshift, + PAGE_SIZE); dma_unmap_page(dev, node->dma_addrs[i], PAGE_SIZE, DMA_BIDIRECTIONAL); __free_page(node->pages[i]); @@ -458,14 +459,15 @@ gk20a_instobj_ctor_iommu(struct gk20a_instmem *imem, u32 npages, u32 align, for (i = 0; i < npages; i++) { u32 offset = (r->offset + i) << imem->iommu_pgshift; - ret = iommu_map(imem->domain, offset, node->dma_addrs[i], - PAGE_SIZE, IOMMU_READ | IOMMU_WRITE); + ret = iommu_map_sync(imem->domain, offset, node->dma_addrs[i], + PAGE_SIZE, IOMMU_READ | IOMMU_WRITE); if (ret < 0) { nvkm_error(subdev, "IOMMU mapping failure: %d\n", ret); while (i-- > 0) { offset -= PAGE_SIZE; - iommu_unmap(imem->domain, offset, PAGE_SIZE); + iommu_unmap_sync(imem->domain, offset, + PAGE_SIZE); } goto release_area; }