From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70285606A682 for ; Wed, 2 Dec 2026 22:54:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=QjRwkqs/ Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F91210E9C9; Wed, 2 Dec 2026 22:54:32 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id A819210E9C9; Wed, 2 Dec 2026 22:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796252066; x=1827788066; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=Quyw5vUNTOiFXlMNTvPO1alncNTv21kkvpIYtzlBsTU=; b=QjRwkqs/afKm/Wtn3dZYn0LiWvHsGRJk+AnyG7hWV3nDbePd4UNF+p36 uZ73YbnVgWTdLGWHkNjbmBSe/jQF6Vhdg4iiaBznQ6nw/EXaxvGiZQ3re fe02e5c+nN/3ViiTyyDSO7N8hr3CJPwT0UgYFLpF8HC8Qvw4iCWG/3tK0 vEdIN3uny+yd3S/eN7ictOaEuKYzhL9NWV5MgLGFRbtFvXHKgDVwDGxoM IFiYHWY90CZOYUpgLj27hdAfULnOBAbV7Knwca6bnJZfa3pspzfuomEKY 5MTApWjUYJ+8VnJj/y2WwSrlL58FCjswAAisf2hgODTPFlLY2/n1PWnMT A==; X-CSE-ConnectionGUID: JdG+aoqfT1GIGmVOSaROFw== X-CSE-MsgGUID: RJQVz+10QBKGKbYnAmY7YQ== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5271336" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5271336" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 14:54:24 -0800 X-CSE-ConnectionGUID: QdpbWTNkRPGc0QuO/FAQ5g== X-CSE-MsgGUID: 9q8stANdTyiIfKVsmeZflA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13950514" Received: from fmsmsx902.amr.corp.intel.com ([10.18.126.91]) by fmviesa006.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 14:54:24 -0800 Received: from FMSMSX903.amr.corp.intel.com (10.18.126.92) by fmsmsx902.amr.corp.intel.com (10.18.126.91) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 14:54:23 -0800 Received: from fmsedg903.ED.cps.intel.com (10.1.192.145) by FMSMSX903.amr.corp.intel.com (10.18.126.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57 via Frontend Transport; Wed, 2 Dec 2026 14:54:23 -0800 Received: from BL2PR02CU003.outbound.protection.outlook.com (52.101.52.10) by edgegateway.intel.com (192.55.55.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 14:54:23 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=O+dEEgDkYqJuRQ8n7YPXT9ETH/NH/fz0cbzCTa3tOnMT3TZwBNIjnfJwKiPQi78pk0VCWAxLj1qYr2rahJHTQ5h3v44j+cnWXa3oGWCZxVROuEZc0x5qJKOsvBZ/yn9Ub5KsjicIUUTIuYXMYcP8e6UyCD/iQ4LIWruMWHqAM+jonp5ePMd6nPHLQ8+jc4SWRxWo5YW4m5vh/KoVAU1qc5yY75+pXF1FjfmnyQVHaiSYWny9M5ZO3eiGBByJ7PbNtdhcKln+KZb9yflQIuzkWCFp7O0aKU2msiJRVF2yo1GgRndfE7VdvWP0ZHdEIn7MOHJNgqTLhDygu1GGxTUWsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=5cAlr6XW1259GJiUH97fdNl/9bmcGjNaNTsITUXFvlE=; b=HK/AqwxuKnGM8T5QT+XaQiYP1L0AiekXntXxceIxNTzaTCVEpYZIk9HauMRx1lcjv+2mcmLNcHBCECB9EJBdfIsZbAfarca2wS66zpHms1j3lavRrMSxwoMy3+tl3cUssN3c+V8352hCqMyxaiDxNVj9t/YydL2QxpV1VyZtC5BPeK9G1EBUVdW7OUlQVJpm9jk8sKD40s/xa1LoDrP56thW5VVxvhn8G6dIbtB9l/4Q0DpIGANPNQxhEDiczyrmBgpEGCRVcOPBgojzwAAALvWlSx48nfY7RuN2DHxR/5PPXUiNHbOK++XmmBeoCyBx/CA+BzikOAyQDxPgFnN33g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) by IA3PR11MB311547.namprd11.prod.outlook.com (2603:10b6:208:53e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 22:54:16 +0000 Received: from CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd]) by CO1PR11MB4787.namprd11.prod.outlook.com ([fe80::e7eb:a872:53d1:21fd%4]) with mapi id 15.21.0688.009; Wed, 2 Dec 2026 22:54:15 +0000 Date: Wed, 2 Dec 2026 14:54:14 -0800 From: Matthew Brost To: CC: , Subject: Re: [PATCH v4 30/33] drm/xe: Finalize defrag-IOVA moves with post-copy job Message-ID: References: <20261201234915.3305331-1-matthew.brost@intel.com> <20261201234915.3305331-31-matthew.brost@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: MW4PR04CA0199.namprd04.prod.outlook.com (2603:10b6:303:86::24) To CO1PR11MB4787.namprd11.prod.outlook.com (2603:10b6:303:95::23) X-Archived-By: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PR11MB4787:EE_|IA3PR11MB311547:EE_ X-MS-Office365-Filtering-Correlation-Id: 70464f86-520c-49f9-ff53-08df50c730c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|23010399003|1800799024|376014|22082099003|18002099003|10067099003|56012099006|261102123227099003|261028144727099003|261021121427099003|261026121527099003|261022105027099003|261022075727099003|261022113327099003|261026140227099003|261009221227099003|261009223027099003|11063799006|4143699003|6133799003; X-Microsoft-Antispam-Message-Info: MnEtu3jzAx9F9LBvYKC4qPE5LG8Mx+LLHSdNWyWNNyEBzhq7DFFzCWwPQ9H1L5tZOl2tJhBRfY3lskLW4p3P5UvR7PNSjgwL4vSOFpaTR3XCc07UyyMB2EC5tJszOBc8WOHpDSa02e1c0g9EFxnKt0VudSJ1hOI9WJNy8yIt2pSK/tiXW2mukH7AvOyuNZfMf2HscThLWCrDh2eZj++wqXAcxeYvzWJgGkenCHxbmPBGOYAlNPxBgWbuKSrAzDDLlMwGFTrVFt2hZ3oA2I3fFHvaNLLT1cm/eiebG/yUaHg9PoA7CyQjjbikl87awucTLFpNQf9xSgXHo7LMRI8gFdWl23OsUa2JCw1IV6W381cdu2gf+iSv1UGOOWqj8ow+b1fAS5bjW9o6AkJW/qEurcHm8zuubOvWthj/JtmHNorJxUP0+87pHDWELjJMzr6ZyJURoS0poRSBUtfgT5vaa775MnKFAxtsHpgT4kiKR3cwrtfELyByd98byv0jf1xaJNPHIa0ecOXlyyusjdNelD3IXPe2JIoqRhcsp9I605Wqsqcy4v1wsI4/15RBDJCIZmeshCRgZNSYAriYUh1El68xhQqYQW/59Vi7bz2E30w= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CO1PR11MB4787.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(23010399003)(1800799024)(376014)(22082099003)(18002099003)(10067099003)(56012099006)(261102123227099003)(261028144727099003)(261021121427099003)(261026121527099003)(261022105027099003)(261022075727099003)(261022113327099003)(261026140227099003)(261009221227099003)(261009223027099003)(11063799006)(4143699003)(6133799003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?U4idGAebM3w+gN6u/VwMnLSCdQYfisEn+a96kn0d2C4ODAdj7R4rJY7ACV?= =?iso-8859-1?Q?Z3eaq7MiUvdNQ/t+mk2cbqsiNfXnd0Q5f2BPn1FNxSx+lKS9b8Ax0HF1vj?= =?iso-8859-1?Q?U8LOCwnxzk3ywymykQLZOCFOdZEdhieTxHlh/iBjDFSmXYKTrRYRYsO1VZ?= =?iso-8859-1?Q?zl7X8CuVqQvXvv5lFfiNdc+1jbIzXTwE78HKUsJdoZ3nZT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2isDQntOSMuJbvOLvEgifH3pd9a85aOUtjiwnlY2IqrgQihRw51mr11KPX0a6iqN9rcfr5ocQlwT9SOs/d8z2ET0ArJ7SO+089pYEQjM8g5IJ14jVg3JL+cdUOE+YOusWD/cW0nd6CdSxGZbpGLuKqfAv63wrstNWw8Jr8oOsJkK2pWyqj/pnu5UoKPiRfHAFK5gtgtDYu0Q== X-MS-Exchange-CrossTenant-Network-Message-Id: 70464f86-520c-49f9-ff53-08df50c730c4 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4787.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 22:54:15.8164 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: lybzAVNYJAoHSfHYHuzg74rLezegt4PuSN2jolM0E6+fDTC4fzuXtGDMKl1rIpVRKPsf6N6Wi/RU7Cxt89hHHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA3PR11MB311547 X-OriginatorOrg: intel.com X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Wed, Dec 02, 2026 at 01:03:31AM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 3 potential > issues to consider: > - [High] drm/xe: missing kernel fence wait for preempt VMs in > xe_bo_trigger_rebind() > - [High] drm/xe: missing dma-resv fence dependencies in > xe_bo_defrag_iova_copy() > - [Medium] drm/xe: premature defrag list removal in xe_bo_move() on > defrag move error All three are valid. Two are fixed by earlier patches incorporating changes suggested by Sashiko. The preempt VM issue is real. It could be addressed by having the preempt rebind worker wait on all KERNEL slots for every BO mapped into the VM (arguably something it should do anyway, similar to the exec IOCTL). However, the activation code becomes quite ugly because it would need to walk the rebind list. Instead, I'm going to simply evict BOs mapped into a VM when entering preempt rebind mode/. Matt > -- > > commit a09033f4b293c49cfeeb973f5688f58056145822 > Author: Matthew Brost > > drm/xe: Finalize defrag-IOVA moves with post-copy job > > This commit wires up end-to-end defragmentation for IOVA-mapped BOs by > copying only changed pages into a packed temporary mapping, transferring > the IOVA reservation to the new TT, and running a post-copy job to relink > changed pages at their natural offsets without marking the BO evicted. > > > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > > index 1a02fe407d78a..db9a0c7bd44e0 100644 > > --- a/drivers/gpu/drm/xe/xe_bo.c > > +++ b/drivers/gpu/drm/xe/xe_bo.c > > [ ... ] > > > @@ -1181,6 +1302,159 @@ static void xe_tt_iova_transfer(struct xe_device *xe, > > old_tt->use_iova = false; > > } > > > > +/* > > + * xe_bo_defrag_iova_copy - Run an IOVA defrag move with a packed copy mapping. > > + * > > + * Only the changed (non-borrowed) pages of @new_tt are DMA mapped, packed > > + * contiguously into the front of its reservation, the GPU copy blits them from > > + * the old tt at natural offsets, and a post-copy finalize job adopts the old > > + * tt's full reservation and relinks the changed runs. Returns the finalize > > + * job's finished fence (the fence the move waits on), or an ERR_PTR on failure > > + * with all partial state unwound. > > + */ > > +static struct dma_fence * > > +xe_bo_defrag_iova_copy(struct xe_device *xe, struct xe_migrate *migrate, > > + struct xe_bo *bo, struct ttm_resource *old_mem, > > + struct ttm_resource *new_mem, struct ttm_tt *old_tt, > > + bool handle_system_ccs) > > +{ > > + struct ttm_tt *new_tt = bo->ttm.ttm; > > + struct xe_ttm_tt *new_xe_tt = container_of(new_tt, struct xe_ttm_tt, ttm); > > + struct xe_ttm_tt *old_xe_tt = container_of(old_tt, struct xe_ttm_tt, ttm); > > + struct drm_sched_entity *entity = > > + xe_dep_scheduler_entity(xe->mem.defrag.iova_sched); > > + struct xe_iova_defrag_job *job; > > + struct dma_fence *copy_fence; > > + struct dma_fence *fence; > > + struct xe_tt_iova_copy copy; > > + bool packed = false; > > + int err; > > + > > + xe_assert(xe, new_xe_tt->iova_eligible && !new_xe_tt->use_iova); > > + xe_assert(xe, old_xe_tt->use_iova && old_xe_tt->iova_linked); > > + > > + err = xe_tt_iova_copy_init(new_tt, old_tt, ©); > > + if (err) > > + return ERR_PTR(err); > > + > > + if (copy.nr_changed) { > > + err = xe_tt_map_iova_copy(xe, new_tt, ©); > > + if (err) > > + goto err_copy; > > + packed = true; > > + > > + copy_fence = xe_migrate_copy_defrag_iova(migrate, bo, old_mem, > > + new_mem, old_tt, > > + copy.nr_changed, > > + handle_system_ccs); > > + } else { > > + copy_fence = dma_fence_get_stub(); > > + } > > + if (IS_ERR(copy_fence)) { > > + err = PTR_ERR(copy_fence); > > + goto err_unmap; > > + } > > + > > + job = kzalloc(sizeof(*job), GFP_KERNEL); > > + if (!job) { > > + err = -ENOMEM; > > + goto err_fence; > > + } > > + > > + job->dep.ops = &xe_iova_defrag_job_ops; > > + job->xe = xe; > > + job->new_tt = new_tt; > > + if (packed) > > + job->copy_iova = new_xe_tt->iova; > > + job->copy_bytes = (size_t)copy.nr_changed << PAGE_SHIFT; > > + job->copy = copy; > > + > > + err = drm_sched_job_init(&job->dep.drm, entity, 1, NULL, 0); > > + if (err) > > + goto err_job; > > + > > + err = drm_sched_job_add_dependency(&job->dep.drm, > > + dma_fence_get(copy_fence)); > > + if (err) > > + goto err_job_init; > > [Severity: High] > Does job->dep.drm also need dependencies on bo->ttm.base.resv > (DMA_RESV_USAGE_BOOKKEEP) when copy_fence is dma_fence_get_stub()? > > For non-fault-mode VMs, xe_bo_trigger_rebind() does not synchronously > wait on DMA_RESV_USAGE_BOOKKEEP fences. When copy.nr_changed is 0 (or on > integrated platforms with Flat-CCS when all data pages are borrowed and > only the trailing CCS backup extra_pages changed, so __xe_migrate_copy() > creates no migration job and returns dma_fence_get_stub()), copy_fence is > already signaled and carries no bo->ttm.base.resv dependencies. > > With no unsignaled dependency on job->dep.drm, xe_iova_defrag_job_run() > unlinks and relinks xe_tt->iova immediately, and the ghost object created > by ttm_bo_move_accel_cleanup() tears down old_tt and frees its > non-borrowed pages while prior GPU work in bo->ttm.base.resv is still in > flight. > > [ ... ] > > > @@ -1574,12 +1849,25 @@ static int xe_bo_trigger_rebind(struct xe_device *xe, struct xe_bo *bo, > > dma_resv_iter_end(&cursor); > > } > > > > + /* > > + * A defrag move that reallocates IOVA-mapped backing preserves the > > + * device-visible addresses: the IOVA reservation is transferred from > > + * the old to the new tt, so the existing GPU PTEs stay valid and the > > + * BO must not be marked evicted (the rebind paths in xe_exec_ioctl() > > + * and preempt_rebind_work_func() would otherwise needlessly rebind). > > + * Preempt fences still need to be triggered, and fault-mode / L2 > > + * flush-optimized configs still need a TLB invalidation below, so only > > + * the eviction marking is skipped. > > + */ > > + defrag_iova = xe_bo_defrag_use_iova(&bo->ttm); > > + > > drm_gem_for_each_gpuvm_bo(vm_bo, obj) { > > struct xe_vm *vm = gpuvm_to_vm(vm_bo->vm); > > struct drm_gpuva *gpuva; > > > > if (!xe_vm_in_fault_mode(vm)) { > > - drm_gpuvm_bo_evict(vm_bo, true); > > + if (!defrag_iova) > > + drm_gpuvm_bo_evict(vm_bo, true); > > [Severity: High] > Can skipping drm_gpuvm_bo_evict() here allow a preempt-fence-mode VM to > resume or start GPU execution while the IOVA defrag copy and > xe_iova_defrag_job_run() are still unlinking and relinking IOMMU mappings? > > For an external BO (bo->vm == NULL), ttm_bo_move_accel_cleanup() installs > the finalize job's fence into bo->ttm.base.resv (DMA_RESV_USAGE_KERNEL), > not xe_vm_resv(vm). Previously, marking vm_bo evicted caused > preempt_rebind_work_func() to rebind the VMA, which chained > bo->ttm.base.resv's kernel fence into xe_vm_resv(vm). When > drm_gpuvm_bo_evict() is skipped, no rebind runs, and > preempt_rebind_work_func() only waits on xe_vm_resv(vm) before resuming > execution: > > drivers/gpu/drm/xe/xe_vm.c:preempt_rebind_work_func() { > ... > /* Wait on rebinds and munmap style VM unbinds */ > wait = dma_resv_wait_timeout(xe_vm_resv(vm), > DMA_RESV_USAGE_KERNEL, > false, MAX_SCHEDULE_TIMEOUT); > ... > err = resume_and_reinstall_preempt_fences(vm, &exec); > } > > Similarly, if the IOVA defrag move starts before the first compute queue > is attached to the VM, leaving vm->gpuvm.evict.list empty means a > concurrent xe_vm_add_compute_exec_queue() sees no pending eviction or > rebind and does not signal the new queue's preempt fence to wait for the > in-flight move. > > [ ... ] > > > @@ -2602,9 +2898,16 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict, > > fence = xe_migrate_clear(migrate, bo, new_mem, flags, > > ctx->interruptible); > > } else if (has_defrag_old_tt) { > > - fence = xe_migrate_copy_defrag(migrate, bo, old_mem, new_mem, > > - ttm_bo->defrag_old_tt, > > - handle_system_ccs); > > + if (defrag_iova) > > + fence = xe_bo_defrag_iova_copy(xe, migrate, bo, old_mem, > > + new_mem, > > + ttm_bo->defrag_old_tt, > > + handle_system_ccs); > > + else > > + fence = xe_migrate_copy_defrag(migrate, bo, old_mem, > > + new_mem, > > + ttm_bo->defrag_old_tt, > > + handle_system_ccs); > > } else { > > fence = xe_migrate_copy(migrate, bo, bo, old_mem, new_mem, > > handle_system_ccs, ctx->interruptible); > > [Severity: Medium] > If xe_bo_defrag_iova_copy() fails and jumps to out, does the unconditional > xe_bo_defrag_update(bo) at the end of xe_bo_move() drop the still-fragmented > BO from xe->mem.defrag.list? > > At the out label of xe_bo_move(), bo->ttm.ttm still points to the newly > populated beneficial-order TT, while ttm_bo_handle_move_mem() only > destroys that TT and restores bo->ttm = bo->defrag_old_tt after > xe_bo_move() returns: > > drivers/gpu/drm/ttm/ttm_bo.c:ttm_bo_handle_move_mem() { > ... > out_err: > if (bo->defrag_old_tt) { > ttm_tt_defrag_disown_borrowed(bo->ttm, bo->defrag_old_tt); > ttm_bo_tt_destroy(bo); > bo->ttm = bo->defrag_old_tt; > bo->defrag_old_tt = NULL; > } > } > > Because ttm_tt_is_beneficial_order_failed(bo->ttm.ttm) is false on the > new TT, xe_bo_defrag_update(bo) sees xe_bo_needs_defrag(bo) == false and > removes the BO from xe->mem.defrag.list before defrag_old_tt is restored. > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/20261201234915.3305331-1-matthew.brost@intel.com?part=30