Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp488238ybl; Wed, 14 Aug 2019 01:01:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqyIVrLIEl+w7+rNoGR/Vq1wSlvu07hYHSolsGWy7V8ESBZArCK6sNF1rH5u3sBP1IkuBi+n X-Received: by 2002:a63:29c4:: with SMTP id p187mr38582846pgp.330.1565769659889; Wed, 14 Aug 2019 01:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565769659; cv=none; d=google.com; s=arc-20160816; b=YOE15ghbv2LuaiGJ2kXt1f8IjJHjKxH3rKMfzSwk1sOe92pDDtUSB8VaQs29+W989I DwP7HyVC93TTvUoLIW7rC+C2VThOV4gVwCmt3bGvHA0BYN9bOyPzCWjlPBPp6YrmU/XZ tjCbFz7OcrGyCFvWO+U3HqFcWKyEUtj8PjhAzIB6+xPjIrOIF4rumUTDGENc5SDzcSVD GaC0n51oJpRLF3Bqva1dk5f6cuwcBZI1Mcc08yoGPFPiMI5L6fU2JFmnDCYQ7ipEKLJI hSIEveZCX6siOUAuxPDomdDpnCJ9sVlLyi17y6AqfK8J2hcSxySOKoczlVgFNMeOuL0T pY3g== 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=PX8v8WV5cTEyu1G+a5MHVp1LtnSaVoXFZM7fqF+ZzHiz6vYVeB5c6I8MNcvFTf3vTC iTpRqtROYBD/ZaDmoKbIhdub/TLJWaXcEhRlpJfolm2zoJRk5dHh8QQuvNBaKQ8ABsuT fnffbnhwBW+DYmONk2Kg12G//NhO4ZuMqV7NeKkkcE9DoC+wjsGrqEE1XakxzGv5qpxr +fU3F7G5bL0pvW6T9IQL7wqztWBBF8wBXVvUnqw3PfQMBDQ4gzwZFGaCAjzPSNTCnL+I Ib8k4QQKvqOLKM6/d4Cj4T2689Dl1CKj4RHSBiIjE6xf64w9K3ZnEuXsyQCH9CeZReOx 2K5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ij9LwdqH; 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 s12si4810994plp.290.2019.08.14.01.00.43; Wed, 14 Aug 2019 01:00:59 -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=ij9LwdqH; 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 S1727398AbfHNH7w (ORCPT + 99 others); Wed, 14 Aug 2019 03:59:52 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:39144 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727266AbfHNH7t (ORCPT ); Wed, 14 Aug 2019 03:59:49 -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=ij9LwdqHGLo4wrAxd8rG6Kb6yC fER/ySeZKiiT3l5Qqoxhu5pFNrhI1H/Txm7yGmYQe1PONZmTZgaNvzpVzv3eT1Qo94j2ISZL46tzZ +0Tr31Az6V5GVb5f5sO12tVJiYRYd7TYYW789M1i9bCww8eGuVQ6nlYYaNr/6LQIZxnSrAHY52dXp GqKtRq/VM09VRrnKsx8Ff6KFihMdQd+6wwRu4wfVdD/EgL++Myvvf6mVeE7fzE1yfIHtRBPpCbL5S nIGPkY4wGoR5fbhlKn3C6KcJTgQrniIWJ4gqUDyVLx05oULJ5uD85VZ3wf/zBY0IVv2d9pTqVTog5 MOXeCnmA==; Received: from [2001:4bb8:180:1ec3:c70:4a89:bc61:2] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1hxoC8-00080x-Et; Wed, 14 Aug 2019 07:59:45 +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 04/10] nouveau: factor out dmem fence completion Date: Wed, 14 Aug 2019 09:59:22 +0200 Message-Id: <20190814075928.23766-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190814075928.23766-1-hch@lst.de> References: <20190814075928.23766-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