Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp7044649ybh; Thu, 8 Aug 2019 09:21:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqw1onnwJhtBkcoFG5GhZ/TLAkvM3h7y99u1wiaU6OnzZQ3lL0qmvxrK32W2EcjjaNRpVN6v X-Received: by 2002:a62:8494:: with SMTP id k142mr16226865pfd.75.1565281318209; Thu, 08 Aug 2019 09:21:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565281318; cv=none; d=google.com; s=arc-20160816; b=UyEyjs77S7tSUR9WaHeCUch9Sijk9k/9Y3PMuCpa7Iu24pcfOH5zJIZbke8HIRXc6X WyR2MVQ29rlIcNJlZkMwyE86uf2R9g/Q8tyDP0eK5V0aF/JUjIaAeHcdSdsoJP6yQXvo jnIKU8EXZAWUhFOcykikQjTclr0DKLfx5ORULvhiv3amXtIldssU6+GnfCYXaANY7CwI VuZT5elr1NEdomof+O12HN4PMr4peZi4IkivTLbCpnAnrVgqiHOI/VnVsmRCNx2RSXbF E9AhX6A3jHgpoIFaDVt0ZkDxhcolBOj4fbmTzpPrfoOAB5Q684V+Bxd7dKnBOvbDCg5x ynng== 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=13C43s4pw+qYxbSiHBqNJBxy3y8L+AabNOPsvifMBs4=; b=L/knYlSyxHnsHEyF/QyI2ByyY32LPH57hBoRzqOoWOaFT4/6Kl6IKqEYTu+np2+0D7 aSvZxwb4NCZUXViBvoQNdzCO/USDRJMwnxd8XwJOym1UydHeyHzAA0xUSVce/2b89K5r 86LhYNjVompWk81bf4nlfMcOPgOTuWtBqWWS4+8RvchLrpJ/yoYS4dHCilT5pUbFcTei 9TlZMfBk3L5HCQrfT4M9BKyVvnInm/Ft8NIQxXfAKdeEv0hX+yBU753E02SfDjbBV4MU AqO36qeqhtGMB9r0Z0rMaWFxMy432WtY/SdX6WDYkCCiNGoLF0I7Osrh1yN9N5ss7+CS D8+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=HlRA67z+; 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 g21si11220703pgk.293.2019.08.08.09.21.42; Thu, 08 Aug 2019 09:21:58 -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=HlRA67z+; 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 S2403778AbfHHPeM (ORCPT + 99 others); Thu, 8 Aug 2019 11:34:12 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:49646 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728380AbfHHPeM (ORCPT ); Thu, 8 Aug 2019 11:34:12 -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=13C43s4pw+qYxbSiHBqNJBxy3y8L+AabNOPsvifMBs4=; b=HlRA67z+7DZXRQzzlMsS7G/gsF 2f86pIZ0g34YKp5IRb1k2QL+ETeNm/rq8lsA09BotnC7Sw+FIxdazkIygvpC9Np39mZU9YYonu+1x qZGmcNt4D72r2QIXtpYRbcJEAEgVd+js+ukBUV1KP1sgTlVzheWG/cYKmD6l+Ms8Z6GzqmOxY3vyt /Kscw8q+cDoXwo8YJfVLNFXkmy+MHL2U3/lIDBR5Ie9UpXSi93XJ92d1CIfdLVGR4PSn3sdObJPf7 fzjfmKSNtTxX1hw4B6o7UBcnvMT3KLQ5eTOBCx8TAQV/LQAlwLIC5BOS/8cjeEI0g2Sz8Z2wMK9vw FPUqcdkQ==; Received: from [195.167.85.94] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hvkQZ-0005C4-2B; Thu, 08 Aug 2019 15:34:08 +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: Thu, 8 Aug 2019 18:33:41 +0300 Message-Id: <20190808153346.9061-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190808153346.9061-1-hch@lst.de> References: <20190808153346.9061-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 Reviewed-by: Ralph Campbell --- 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