Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4153817ybi; Mon, 29 Jul 2019 20:26:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9xlrG9jzgIaaek7Jau77e9X1vyB/7Mx5LYBpjCbPlT6ikAui+7H0tsWNNDrtSDjsFVMET X-Received: by 2002:a17:902:b909:: with SMTP id bf9mr19404349plb.309.1564457187250; Mon, 29 Jul 2019 20:26:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564457187; cv=none; d=google.com; s=arc-20160816; b=BC7biJwyskQeGW+5lp5gVaLHoukWODarmsgZnsyo8WpKJQC9gc26qZeQmuj1niOiGG vowMmox9hukqLhIGXJHJsMgEdSudwjhidz5jNj9fHpjw70LxamD2lDxrfLq+5n5OyeGh bsbikwPtp1w6wDDXkf8N9McZfGDnD1vRP1Us7N9pTbWPs8EnPbStLD6b2UHjHljrv4kq 7jA4ftSYInmWPTqt25IE8gdCptmS1kvTYAsmh9A9UXacPSqMrB0fp0N28sqlMerEqA5g VUfi+Zp8z/mlDXrKNUPayXP3AQ/ZGURnWyfW2tOaHhgjGMiLWl34RRoQLYgmIvGHEc0S yq2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=IyoLCbDcsQakqt7A6+W1y7A2qFkbkRJjy2RWDtkVLUI=; b=HU/O6GyuSwtmA7JndcoBFpm1YxLqMFuqPKu0IrTnHbVfCYpfGFrwim5ftMUmiQo10u cctEEN2uynHAn7ssG+7LAkrNbAjQqqeVriU5UI4VsuKuLqyzAFKIrnvcn7UD7Nj6VsLm fYZ8Quu5mTgoKD4LIpScsmesZOwpglNLaYGTAZRJAa5BSbU564+FcwPvoNjkpaU10QiC yYtusxOG/ZnVk39mkJ4stprmlmhk6JPltp16aC/iI/X+71wIClDSqenYDRLx9M9U9Qmj nqhquR3GJSmqHGdv6YF74YY7HnaAeiOHJzoTWnUSDjzJTLbC2S2HoAplPi7Fkeo0D5dY GJew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=NnhEWDfT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i127si26939549pfc.177.2019.07.29.20.26.12; Mon, 29 Jul 2019 20:26:27 -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=pass header.i=@nvidia.com header.s=n1 header.b=NnhEWDfT; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729576AbfG2XXX (ORCPT + 99 others); Mon, 29 Jul 2019 19:23:23 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:17149 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727985AbfG2XXX (ORCPT ); Mon, 29 Jul 2019 19:23:23 -0400 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 29 Jul 2019 16:23:23 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Mon, 29 Jul 2019 16:23:22 -0700 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Mon, 29 Jul 2019 16:23:22 -0700 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Mon, 29 Jul 2019 23:23:18 +0000 Subject: Re: [PATCH 4/9] nouveau: factor out dmem fence completion To: Christoph Hellwig , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jason Gunthorpe , Ben Skeggs CC: Bharata B Rao , Andrew Morton , , , , References: <20190729142843.22320-1-hch@lst.de> <20190729142843.22320-5-hch@lst.de> X-Nvconfidentiality: public From: Ralph Campbell Message-ID: Date: Mon, 29 Jul 2019 16:23:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 In-Reply-To: <20190729142843.22320-5-hch@lst.de> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1564442603; bh=IyoLCbDcsQakqt7A6+W1y7A2qFkbkRJjy2RWDtkVLUI=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=NnhEWDfT1JRU+yGkNl7isRXL14uONAN+nufQA88N/0WVIGrrXe2VPqIZreLa/iM58 rrsdH0JGvyxCRjxz6XDeOPcGsuqp6VptCocClcF1kIwsJAO2D/NW+YCRhXkKRipLWH botVKAowNZ8G7vOFHGBaKmiBYWS1vuuThPema3w2Ff252O84tPPld7ORsNwKXIEt5A gy8P/4HuT/jTrKaPQhTu13ZkYDnUvoPnsagy2yRGHgm6DOUlXGql+9UP9Sm4gEKhVK NDxlPJ7YZ/ogVkIam9GCXsqywqwYliQ/7clBqKCCjHiZXNN49ipCt3w4wGcTwD6dAu svSbpqgfcVg3A== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/29/19 7:28 AM, Christoph Hellwig wrote: > 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], >