Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3599104ybi; Mon, 29 Jul 2019 09:15:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVRfYm8qNEZ+SGHLu9aA6n5sS5lLhz5g9J+olZVBuAsPMPfD7U1tnUIR+YVGruggEMPA5+ X-Received: by 2002:a17:90a:eb08:: with SMTP id j8mr77614866pjz.72.1564416916945; Mon, 29 Jul 2019 09:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564416916; cv=none; d=google.com; s=arc-20160816; b=rc0IwSkJ8f7mEJlp8SagNi4PnSWJUIvnA+jx2Mv14jPzDINIOLpOI/AEAGUFpvrB46 NhtQmeUwSikfbciEwmJesp3VuEkFRi02pIh7JeK4qKw6BaYrVD0aM6vbxiB+bWr/upGo y+pCcr+rfI0uvHVr3tVTlApGKQJInAudbxElUnIduIunYoKsJZ1KQnXrwjI2csJP+rsC TYDbzxgSc92fF0jar/n+VYlnLqVUNk2kteaByU8YYcwvWpIFqq6Z3e9GWBb7IKeCe/ZP pgXKQjSvPgDf3plBvEzYQ+SpQoVog+8ouXj0iW18LnEzs4cDVOVU6twiv3Dzz+ek8G5N cj0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KRhSWVqqlsL4sNnqiKki+hdwEXJ8VTEYKaUDLbMamPM=; b=iSMZwznYpiFDPdY6tpFdejCKMknRTlj7slsXUsSwQRPd/YxzokH9zWrsDP8bwVRG4N dmuocBz2CetiENIqkJ6VuBWBJdgO7Z108+y+vp5FM1LYnH3ZyFvhHuM8HeFMmD8EEgJ+ u/tpG0i35oVMAmU6XN7GwK8el8drfzi+L8ZiqiJKcThx5H4XXAjaaVx9KTWPeh2c/TKU /7ZVJOAJR5kPIy3iDJY0v0OeaY8GyC1IdGmmCjGVnBoCeqKs27f7JzWt7Kfnqadhzg1p k/dnqZEOI1Alhl3CvyimuI228LgqKsrRnwSgE/CwzTja617V6lJXN69bHDDI9319ad1C aK6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=UOK0LNoA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w62si26751874pgd.209.2019.07.29.09.15.00; Mon, 29 Jul 2019 09:15:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=UOK0LNoA; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728363AbfG2O3K (ORCPT + 99 others); Mon, 29 Jul 2019 10:29:10 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46896 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726190AbfG2O3J (ORCPT ); Mon, 29 Jul 2019 10:29:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KRhSWVqqlsL4sNnqiKki+hdwEXJ8VTEYKaUDLbMamPM=; b=UOK0LNoApFOGwvTn+Y/XD3jBnG TRfhIqboSv8iqXv6omeWkilEGsmxKwQhoeVgR9UwVkpnbiS/E1ecOTCAqXTao8qWeYkvykFlXFDK/ Ye5pIUMH+Ium1hxsiHtJ8/DyYvvHVnb673b0Q1ak9Biu2jXuy2gNUEP+jaVRTxUqOUnvjDE6IuKbu iEbtj/LsXhOByx+dgF6Sv3TpkO9E88HNVVuMBM12gNDgGZtDbAE9gUqgPsBxGBPNiA/8fP7mpHFRn qcYcymO5NouySz7CZywQqyMe/t/hyPLhwBjO/65i84oIlD1Z/999t1DYXQH9Z9WD65qRbBOoShss/ 8doBh/yw==; Received: from [195.167.85.94] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hs6e9-0006K6-NS; Mon, 29 Jul 2019 14:29:06 +0000 From: Christoph Hellwig To: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Jason Gunthorpe , Ben Skeggs Cc: Ralph Campbell , Bharata B Rao , Andrew Morton , linux-mm@kvack.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/9] nouveau: factor out dmem fence completion Date: Mon, 29 Jul 2019 17:28:38 +0300 Message-Id: <20190729142843.22320-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190729142843.22320-1-hch@lst.de> References: <20190729142843.22320-1-hch@lst.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Factor out the end of fencing logic from the two migration routines. Signed-off-by: Christoph Hellwig --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 33 ++++++++++++-------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c index d469bc334438..21052a4aaf69 100644 --- a/drivers/gpu/drm/nouveau/nouveau_dmem.c +++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c @@ -133,6 +133,19 @@ static void nouveau_dmem_page_free(struct page *page) spin_unlock(&chunk->lock); } +static void nouveau_dmem_fence_done(struct nouveau_fence **fence) +{ + if (fence) { + nouveau_fence_wait(*fence, true, false); + nouveau_fence_unref(fence); + } else { + /* + * FIXME wait for channel to be IDLE before calling finalizing + * the hmem object. + */ + } +} + static void nouveau_dmem_fault_alloc_and_copy(struct vm_area_struct *vma, const unsigned long *src_pfns, @@ -236,15 +249,7 @@ nouveau_dmem_fault_finalize_and_map(struct nouveau_dmem_fault *fault) { struct nouveau_drm *drm = fault->drm; - if (fault->fence) { - nouveau_fence_wait(fault->fence, true, false); - nouveau_fence_unref(&fault->fence); - } else { - /* - * FIXME wait for channel to be IDLE before calling finalizing - * the hmem object below (nouveau_migrate_hmem_fini()). - */ - } + nouveau_dmem_fence_done(&fault->fence); while (fault->npages--) { dma_unmap_page(drm->dev->dev, fault->dma[fault->npages], @@ -748,15 +753,7 @@ nouveau_dmem_migrate_finalize_and_map(struct nouveau_migrate *migrate) { struct nouveau_drm *drm = migrate->drm; - if (migrate->fence) { - nouveau_fence_wait(migrate->fence, true, false); - nouveau_fence_unref(&migrate->fence); - } else { - /* - * FIXME wait for channel to be IDLE before finalizing - * the hmem object below (nouveau_migrate_hmem_fini()) ? - */ - } + nouveau_dmem_fence_done(&migrate->fence); while (migrate->dma_nr--) { dma_unmap_page(drm->dev->dev, migrate->dma[migrate->dma_nr], -- 2.20.1