Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp428050rwb; Wed, 28 Sep 2022 04:49:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ZIPtCdLMuXYcsplXSzz7kiF9nAUfYjmSxtavjleqwBZ5UhWSlTcH4iKHxpPOJECLDOI9s X-Received: by 2002:a17:902:c702:b0:178:9fb3:419a with SMTP id p2-20020a170902c70200b001789fb3419amr32694110plp.35.1664365795628; Wed, 28 Sep 2022 04:49:55 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664365795; cv=pass; d=google.com; s=arc-20160816; b=KLHfBPQD1zH8RcqTccm1jGQ0YAoqNHDBzWiJTIFDu+DsOQSE0NlURMG5aJYwklSAgi hBPhuNd4cAQCL73pVHq6cgA0+57P+caOxbN/GnoyF0EUe4m3g5yW5javNEsKmUd7HaC5 kiMz4WCh3EkzF/8q10mLAtSpN3lBz3DHNoLqVZZANZ905/5W1vQdjoAdTe1NZ64BKfLx sxZjp65UaOSii8/EY6L60KN1lscUHYsf+8ndMMMFhlfd5MymG1/0zQD0hoNg11Oc/8ig qAmnamsP2Qprr0uCOl9fC4QkXJD+qo0V7OtrmNKCZx8gsiXaw1ibf8U3hBazBj4AzIN/ 0Zcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:in-reply-to:date:subject :cc:to:from:user-agent:references:dkim-signature; bh=to8CWe3DpOILEdqvd0CkWpSDlh4LPqjI2W24vj2NZOU=; b=KlL+bpYc3J4PJYPgzwSToc6n0tL1rJtj6CPBzXEh3fjxaP4ZhEIKXjLEIM6pLkRFCX Qwdkh1+ptws2VK3hGp+dxCklpK+Q4cXEJnTGR7Lz1pO+C8oh0RU+7lC0Dq1/VHbUNh0S AEPtlSYhqdRsc1GfphbIVujELFEa/McjYAiv8yuhJPAwT9ngYPVisjjaT9xxRceGjQLB Drvd72o9jxw7yYGMZVc571iwBrvPpCpPKjBh4A+khCMeGP93FAyW5qNTq922GQJp/phX zvUCp+CsLA+wzaKPG9bOGnVn8j3/TL90bQlCN/GZEsh1MW5rj4pNumv4cK0FmtibMc0u Wvug== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=PWLcTa+6; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020a17090301c700b0016eeb210483si4722173plh.321.2022.09.28.04.49.44; Wed, 28 Sep 2022 04:49:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=PWLcTa+6; arc=pass (i=1 spf=pass spfdomain=nvidia.com dkim=pass dkdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233276AbiI1LcK (ORCPT + 99 others); Wed, 28 Sep 2022 07:32:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232256AbiI1LcI (ORCPT ); Wed, 28 Sep 2022 07:32:08 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2058.outbound.protection.outlook.com [40.107.223.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC06881B37 for ; Wed, 28 Sep 2022 04:32:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O7Ueh1K/fbzASTKGt96uk9snauPZ7rRoERM/cbTZl4y3PgRoASCIFY09LWfmDqP2EjEyp1UZEltE7J/W48cfeMLtNqvDHxhhB8InQn9Q9iWraavYehF7vShfk7nn0ruWerGloCDVmEkOVSwlqcN9fzHfMDh+kPe79wBUn1KHLSIdKiFGNDOvzVgevflq7XBcoNh9t6qSyQYVVKKhdjzDUDr3tewDCz65nfDAl74irxryx4DkAWl8QxRWml3RQTzbTM1F9n+7s9Zne3EEETlwUuLeIhVoopFXtt0no97Z7J3xC5hq2vjg8/m/ayIxftPwQRCrBflNJaX6QuP6lHRYaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=to8CWe3DpOILEdqvd0CkWpSDlh4LPqjI2W24vj2NZOU=; b=aTIQjKusl6xmwaV1i1QutoF/AapiopVCPjlPrh7Ubn9EWNM62dFjtwJdptCapo/yIVGx6vkgxdb577QgWsGS+3xOpoiRj+aukQCzJk2Q//BsGHBM6jX+DIFHro/B2sntWu7TPDhnUy537BBctsYt8reDXOYMDJEWFvwwoZqGsmZkICCQpZ0LYnzadWNYpw/nxL638AqZJ+NNzHigDk+rqlW0kk2PQ4DOs40duhatoifJGRsj+poVpcY8dZixnd54/l167dLstJCka3o+mj44EC36EHEFdFrS4fi3vGmJMSYltQLfnOI/fXk4zqcgUcVeCxaGtH0aetEUP+QIPSau0g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=to8CWe3DpOILEdqvd0CkWpSDlh4LPqjI2W24vj2NZOU=; b=PWLcTa+6qJp35SD43kp1RzBX02p5QsfvbRDtM7cwfmDCAtnlXwoW6ovoAbv1Hcocklf6fEgEXILznSmV1SvRyVgvLPJ8KPXg0YSiDV9YeNAyAIZUhAPxXUw7nccUmFhtQ+7hFZGMTjKGbMhYv/GuPJqFSsTXlvnbOnDbYuW/cmz+WbsxIs233O/uoZhGuQAvDTv8LV39RkZPjsczc+zJaIVBoSqBVCrVRQyx8+61INKBrI59eLSKyT6+GWdWnJFzNFEzcFJVVnCZKfDTtinStIzfYWFBe3vma+z1K7Qg+glKQAY+JeVlyPQqzZ1nBovSXrx+stFuCp8Ew4u3bD9SZA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) by DM4PR12MB6469.namprd12.prod.outlook.com (2603:10b6:8:b6::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.24; Wed, 28 Sep 2022 11:32:05 +0000 Received: from BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::4064:6c13:72e5:a936]) by BYAPR12MB3176.namprd12.prod.outlook.com ([fe80::4064:6c13:72e5:a936%5]) with mapi id 15.20.5654.026; Wed, 28 Sep 2022 11:32:04 +0000 References: User-agent: mu4e 1.6.9; emacs 27.1 From: Alistair Popple To: Lyude Paul Cc: linux-mm@kvack.org, Andrew Morton , Michael Ellerman , Nicholas Piggin , Felix Kuehling , Alex Deucher , Christian =?utf-8?Q?K=C3=B6nig?= , "Pan, Xinhui" , David Airlie , Daniel Vetter , Ben Skeggs , Karol Herbst , Ralph Campbell , "Matthew Wilcox (Oracle)" , Alex Sierra , John Hubbard , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Jason Gunthorpe , Dan Williams Subject: Re: [PATCH 5/7] nouveau/dmem: Refactor nouveau_dmem_fault_copy_one() Date: Wed, 28 Sep 2022 21:30:18 +1000 In-reply-to: Message-ID: <87a66jpweq.fsf@nvdebian.thelocal> Content-Type: text/plain X-ClientProxiedBy: SYXPR01CA0081.ausprd01.prod.outlook.com (2603:10c6:0:2e::14) To BYAPR12MB3176.namprd12.prod.outlook.com (2603:10b6:a03:134::26) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BYAPR12MB3176:EE_|DM4PR12MB6469:EE_ X-MS-Office365-Filtering-Correlation-Id: 78eef31f-0652-49bf-9ee5-08daa1451157 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yu5RUUOtnzpq7r/F2K05vkaQCqBFprbWtRh+8ACpScPcGrL/WpH3aHDjnWGsSs8t9aLJaWNSfSHrtJ4B3RXxI0y9DZMOEJUQgRMibBHl9bs4rtWKmrBWwzhRd11mkSelLxRi91Dsx8o07WQCkdPhydc9TcZU3rOqRoNCBaPbcGII2PSv4HwwAbWtQmOb2Rz5hE0wPqf1J6J7r3I8G01hD2UMvX/0ZhbtE0bk9voHqsILW9vYg9X4WEZtAxrDt2rIuGAOXCP0Hjj8+GwiEVCxjvU0uHC24LQe7bdGf/LZsevRDoPJ2Vd3wahp/WkchliQNJeag+sP42qBWn63XXNKXxkLIu3/dazutaRL9+uQ9zWFLQjNe2nkYpjRsJQDq19zBBQbCxp8zLnkpahEwmlJIwCqJcXdr3g5ADYXHuHID/0qYMcrj4GgnHyZt6vg37YMWY0m13f8G976qH5QYzfIJpHPKwp1Z35SjchVWOSzzMvaCNDHLoRrybtIuRGm9DH1N8IoPPX3FqiCPjNEkGXoKNxvqXDeUxyORZEbQ7kGAedoRp4+GtG95f0hXOYcSnsQLdXhwh9VGILhwMg4E4V5Bx+EK0fkoHfmfUhXxw7dxcuLgtxaPF4CvtGJ3pwLCvZ6oqFYQSGirUvYasge9KCK34chLl9VHRwOSAAcVbWwsAWSnq7T6hhpAi/SumrvocHVrddokaebBbhqWp0Htd95Lg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BYAPR12MB3176.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(39860400002)(376002)(346002)(366004)(451199015)(38100700002)(316002)(86362001)(54906003)(6916009)(6486002)(5660300002)(66946007)(186003)(83380400001)(7416002)(8936002)(478600001)(4326008)(66476007)(8676002)(66556008)(9686003)(2906002)(41300700001)(6512007)(26005)(6506007)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?NIc0Poe3/aWkjXaUJSxUZAbRLdTB5s+3kNF7FiSP2KI/cWrbdRf2ZT6dVPhd?= =?us-ascii?Q?Lb+5ZScGZqf20xbWIM7q2bzn7lkSugNMLw32S06e7wsaZTOSf3Jvzl4+/Iai?= =?us-ascii?Q?22uDJigA0iova9qInRvC4P2rCa82hgjxGz1J/gDzcJSLJ6lkfA5193JpI7Bf?= =?us-ascii?Q?xT03bvJLrtPbUYdwDUTO6qlrV+GgzP/2TXiA81+E2OYjsnhS5CPZHviKdBZb?= =?us-ascii?Q?mIv11qbMYfUri7Wx31Nm3R9mJJj1BfUR+B6RyNg7D08biZePffoOIFvtgRIY?= =?us-ascii?Q?mZLQAx+vNDHdHS5GO89J6BXIw7fbUNidiChIVc/DF9AgFxL6impqd5QFPCwn?= =?us-ascii?Q?Q1YHRtRgg6J6dAYKHhk/FW7Ntp+Gbk91D6ok+suk8bZ6qTE59v9TURDKTbis?= =?us-ascii?Q?LXtR/c9uYUHq1GZes7SaevdOM4dBhPP1SorhWx/mryLgIov5xuvF0+LThkw8?= =?us-ascii?Q?jwvBQzMIPC+bBZJ6dZMEA7fv2OVjKrjVcWaw6Hv6RbOEtxUZrXLxj0uKkRq3?= =?us-ascii?Q?4APZzOpUT8A77hqH9fcMjQvpETdVurZVOkyShMs93zj3z0SNzQX9Kx+mCdeO?= =?us-ascii?Q?okeTR+NAA03lAYgZ8lMZa+1g8BhkTL8ZElw0QKd7k2d11nGazWEYtYOOwmcr?= =?us-ascii?Q?Hlfl34Gtrm8Pt8o1F4cVio3+po9DlfZDSaIVXvmBs+HtzHDhooSfgLMWBM7V?= =?us-ascii?Q?Edmi8MTuYL+YGTP1KadOsXAut23aU0iFWtlbBZgDCvC9bYs3givn+tJEuuWr?= =?us-ascii?Q?UqQCEUDMKKjRot467RvISlML9rgCjiDL17NyUgBESgPbAFmDKRnEsw46dcFK?= =?us-ascii?Q?Lop6gk0arQfgmanVL65N+P8dI8Cd4N52qa/qqzQmflPbuOjpgr1ASsJUoe3k?= =?us-ascii?Q?pMaM2b2j1ybCIN+xQgC4UtSpKQtm4zRUvvh9A+EDnknn+JZam9ZdJVJaoVyc?= =?us-ascii?Q?1eXt6j9/dymYLJ/CtmInL+P/O7+ejeZPUDG1AqwXtchp/Vi86zJMuWneyuZS?= =?us-ascii?Q?bAjjdaPd5ehNjyvGF6dU1hKT5Uk6so4iy0Kny31doXjWOpsAJechdGIC6WsO?= =?us-ascii?Q?QjRWGavYqOM6QplEJUwqoitqANHy6q1HfY/rV3IlvvOgMRR//Xqwjqb5wuiI?= =?us-ascii?Q?Pyp5ebGln2nDNhwNc+NgQ9W5zC/F7x1+yyjMZt8G5wp6Vr7uYmgAG2VWs/Rk?= =?us-ascii?Q?EaTiYAvcntZeDs7d7X6yyhp3hfy+7J+MxL+MlXm7W/jjcq88si2P2Wu9UKnk?= =?us-ascii?Q?OTaGoJsLgcr+90avC6kp6l+sX0Mx2N9Ss7rIKJNKBZElWZtqDuJ0+bpbmQzR?= =?us-ascii?Q?yGEh2o+N2yfjz21kEwYNFCfu7VVMdP4cyL+Kna10SKI4Tg8qZNOMdedJJ65v?= =?us-ascii?Q?3WSjz0FHsra2+L+jZymqs7+7NwHQiTRYxaxmaIQYHIw896DfWURgjsV2jlDW?= =?us-ascii?Q?EhRIUvkyAhOGwOGEY+rNd78mvjYDdEG46jT0ijTS3B10Rjj3sLRgBwNElWlR?= =?us-ascii?Q?gNpP83f0QnjexGCbvcvw6RvNQwx137EDUz5k0pXZF3iKyWP6jEuXGwKYg7JQ?= =?us-ascii?Q?MY7Bx62eEu9TksSKHh0eGW4Gpx9lBrRcG9Wna0cB?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 78eef31f-0652-49bf-9ee5-08daa1451157 X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB3176.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2022 11:32:04.6647 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NyO3P1hBMXZujEc4N5yYHFkfYuzOE9I0U2QkUZ3yN0afLoYqoa89V1KCqCC9Kz8p0nhFBK9n9Pmp+ilO64M/kQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6469 X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lyude Paul writes: > On Mon, 2022-09-26 at 16:03 +1000, Alistair Popple wrote: >> nouveau_dmem_fault_copy_one() is used during handling of CPU faults via >> the migrate_to_ram() callback and is used to copy data from GPU to CPU >> memory. It is currently specific to fault handling, however a future >> patch implementing eviction of data during teardown needs similar >> functionality. >> >> Refactor out the core functionality so that it is not specific to fault >> handling. >> >> Signed-off-by: Alistair Popple >> --- >> drivers/gpu/drm/nouveau/nouveau_dmem.c | 59 +++++++++++++-------------- >> 1 file changed, 29 insertions(+), 30 deletions(-) >> >> diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c >> index f9234ed..66ebbd4 100644 >> --- a/drivers/gpu/drm/nouveau/nouveau_dmem.c >> +++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c >> @@ -139,44 +139,25 @@ static void nouveau_dmem_fence_done(struct nouveau_fence **fence) >> } >> } >> >> -static vm_fault_t nouveau_dmem_fault_copy_one(struct nouveau_drm *drm, >> - struct vm_fault *vmf, struct migrate_vma *args, >> - dma_addr_t *dma_addr) >> +static int nouveau_dmem_copy_one(struct nouveau_drm *drm, struct page *spage, >> + struct page *dpage, dma_addr_t *dma_addr) >> { >> struct device *dev = drm->dev->dev; >> - struct page *dpage, *spage; >> - struct nouveau_svmm *svmm; >> - >> - spage = migrate_pfn_to_page(args->src[0]); >> - if (!spage || !(args->src[0] & MIGRATE_PFN_MIGRATE)) >> - return 0; >> >> - dpage = alloc_page_vma(GFP_HIGHUSER, vmf->vma, vmf->address); >> - if (!dpage) >> - return VM_FAULT_SIGBUS; >> lock_page(dpage); >> >> *dma_addr = dma_map_page(dev, dpage, 0, PAGE_SIZE, DMA_BIDIRECTIONAL); >> if (dma_mapping_error(dev, *dma_addr)) >> - goto error_free_page; >> + return -EIO; >> >> - svmm = spage->zone_device_data; >> - mutex_lock(&svmm->mutex); >> - nouveau_svmm_invalidate(svmm, args->start, args->end); >> if (drm->dmem->migrate.copy_func(drm, 1, NOUVEAU_APER_HOST, *dma_addr, >> - NOUVEAU_APER_VRAM, nouveau_dmem_page_addr(spage))) >> - goto error_dma_unmap; >> - mutex_unlock(&svmm->mutex); >> + NOUVEAU_APER_VRAM, >> + nouveau_dmem_page_addr(spage))) { >> + dma_unmap_page(dev, *dma_addr, PAGE_SIZE, DMA_BIDIRECTIONAL); >> + return -EIO; >> + } > > Feel free to just align this with the starting (, as long as it doesn't go > above 100 characters it doesn't really matter imho and would look nicer that > way. > > Otherwise: > > Reviewed-by: Lyude Paul Thanks! I'm not sure I precisely understood your alignment comment above but feel free to let me know if I got it wrong in v2. > Will look at the other patch in a moment > >> >> - args->dst[0] = migrate_pfn(page_to_pfn(dpage)); >> return 0; >> - >> -error_dma_unmap: >> - mutex_unlock(&svmm->mutex); >> - dma_unmap_page(dev, *dma_addr, PAGE_SIZE, DMA_BIDIRECTIONAL); >> -error_free_page: >> - __free_page(dpage); >> - return VM_FAULT_SIGBUS; >> } >> >> static vm_fault_t nouveau_dmem_migrate_to_ram(struct vm_fault *vmf) >> @@ -184,9 +165,11 @@ static vm_fault_t nouveau_dmem_migrate_to_ram(struct vm_fault *vmf) >> struct nouveau_drm *drm = page_to_drm(vmf->page); >> struct nouveau_dmem *dmem = drm->dmem; >> struct nouveau_fence *fence; >> + struct nouveau_svmm *svmm; >> + struct page *spage, *dpage; >> unsigned long src = 0, dst = 0; >> dma_addr_t dma_addr = 0; >> - vm_fault_t ret; >> + vm_fault_t ret = 0; >> struct migrate_vma args = { >> .vma = vmf->vma, >> .start = vmf->address, >> @@ -207,9 +190,25 @@ static vm_fault_t nouveau_dmem_migrate_to_ram(struct vm_fault *vmf) >> if (!args.cpages) >> return 0; >> >> - ret = nouveau_dmem_fault_copy_one(drm, vmf, &args, &dma_addr); >> - if (ret || dst == 0) >> + spage = migrate_pfn_to_page(src); >> + if (!spage || !(src & MIGRATE_PFN_MIGRATE)) >> + goto done; >> + >> + dpage = alloc_page_vma(GFP_HIGHUSER, vmf->vma, vmf->address); >> + if (!dpage) >> + goto done; >> + >> + dst = migrate_pfn(page_to_pfn(dpage)); >> + >> + svmm = spage->zone_device_data; >> + mutex_lock(&svmm->mutex); >> + nouveau_svmm_invalidate(svmm, args.start, args.end); >> + ret = nouveau_dmem_copy_one(drm, spage, dpage, &dma_addr); >> + mutex_unlock(&svmm->mutex); >> + if (ret) { >> + ret = VM_FAULT_SIGBUS; >> goto done; >> + } >> >> nouveau_fence_new(dmem->migrate.chan, false, &fence); >> migrate_vma_pages(&args);