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 6CF43606A322 for ; Wed, 2 Dec 2026 21:01:25 +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=hgYxUHJR Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B4F3B10EA19; Wed, 2 Dec 2026 21:01:19 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by gabe.freedesktop.org (Postfix) with ESMTPS id CDD5010EA19; Wed, 2 Dec 2026 21:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796245273; x=1827781273; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=6fJVuG6bdeRU9bQH462YMJwZ95Y870wPyudKSJOv5Sg=; b=hgYxUHJRFmTU6BBUNKxg83CwsSzkH9P4Kp9VfvyriWxhcH37mOyawhwh AZ8U0lyMgzFcXGVQG+1VOMYKzpxloSA1xfv9ivJ8ald4V2YYitpOUmv6T DTNp/+xgPXsSYaDi5HxM0m6mNd1KKD6TEbmldCHuRb4sMNaYWinhPfPoc vRO9iTZwWM2XY9z2kjBku13zJBxuDxb1KvvT4dXG6X7g8Z81rBF+qICPQ 7kg//XaMT8x8aZs06HuCz0ysndGjYoJhLLYlMCCHHhB711geA1/ZgjwCH g/Xha+JkOiYr6steTYzQXBpD/X2wYtYL8B1dL52g//rKJgT6zo4VhC5FG Q==; X-CSE-ConnectionGUID: hTlYu/hrQxiQ08K2eqiMag== X-CSE-MsgGUID: Lfjt5TsVQ4KsnbpTNLBBgg== X-IronPort-AV: E=McAfee;i="6800,10657,11984"; a="5028944" X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="5028944" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 13:01:12 -0800 X-CSE-ConnectionGUID: 7/A8K3mEQb2stQruHtz05Q== X-CSE-MsgGUID: 23p1GlrMT8SsR9R0tkhqLw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,247,1787036400"; d="scan'208";a="13851419" Received: from orsmsx901.amr.corp.intel.com ([10.22.229.23]) by fmviesa002.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Dec 2026 13:01:12 -0800 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by ORSMSX901.amr.corp.intel.com (10.22.229.23) 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 13:01:11 -0800 Received: from ORSEDG903.ED.cps.intel.com (10.7.248.13) by ORSMSX901.amr.corp.intel.com (10.22.229.23) 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 13:01:11 -0800 Received: from BN8PR05CU002.outbound.protection.outlook.com (52.101.57.41) by edgegateway.intel.com (134.134.137.113) 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 13:01:11 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZlRlw3jdyrU3LJIhbq+lFMSJA5N0lemqcl7ddIxPsi6hgrCdhZQmdELTXXuz7T2SKNRt5PHp/7ybjgBNliOjJh2jSMFNg+VQXBKDpm/9pH40KlbaQC6EPP6Va4NH1vzaEGd0pIeignYNfl1BgTkK0oIqy/4Eb5b2EbMcHuip007dkz6ZCxkNZ9qUpfHTCrq0e78XSVl9X2yHryFciPMM8xQ7RZ1w3NrfA1sZRCOPaL0Aizt3803P/VJOW7yvg+61JbNqvI1j3vcZ++Hi1EFcL3JBo2seI5a9A2ks2Rd3kKUSroGX7FUHRiWjFk2zTHFGLDmVFvMrz+206V9YNFGcZA== 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=MxlG0nZFSRopyiIOQrguhmvs4ibm3N3b36Q82gT0nVw=; b=sr23yO6OFf3tDkapDEbrE9tjolTc5CsESufKuuJ29YWyTNyuUiF1qFGQ2H/Lasb1DmPlIumeu1+yHYbox2uxEM2sPBtq1/94P4xd57hznYAfD89EWAa9And46/HUHKjsJZ++cdMTxJsoOv4oWLjQEri0/X9jL7NGgW7N6h+8vrZljLO46jcNQnLBV6U9gCsRityLUlEGCmpPL3YtoCKRHRCIiNn4j44B1muFYRfXdPAyfukeW0coOyWkktO1kvJg0g+EdxADcuXSEYRvyieD2kehXxiKGvLVOlOaiCjO4DP7aQh1n3TU9YG5uEbWYQnbEYlq6f1JcufZipJEpvKQeg== 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 PH7PR11MB7720.namprd11.prod.outlook.com (2603:10b6:510:2b3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.11; Wed, 2 Dec 2026 21:01:05 +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 21:01:05 +0000 Date: Wed, 2 Dec 2026 13:01:03 -0800 From: Matthew Brost To: CC: , Subject: Re: [PATCH v4 16/33] drm/xe: Handle defrag moves in xe_bo_move() Message-ID: References: <20261201234915.3305331-1-matthew.brost@intel.com> <20261201234915.3305331-17-matthew.brost@intel.com> Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-ClientProxiedBy: MW4PR02CA0010.namprd02.prod.outlook.com (2603:10b6:303:16d::8) 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_|PH7PR11MB7720:EE_ X-MS-Office365-Filtering-Correlation-Id: c74f2d1a-d555-4a14-80cf-08df50b76122 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|366016|1800799024|23010399003|11063799006|4143699003|6133799003|261009223027099003|22082099003|18002099003|10067099003|56012099006|261102123227099003|261022105027099003|261022075727099003|261028144727099003|261021121427099003|261026121527099003|261026140227099003; X-Microsoft-Antispam-Message-Info: lb8xjp0uhs5ZXk3jXY/qvaGyVXqvNHyjiYT1EdX30ZVCamKmXV4W1NpzcPQ/Q+0oB3aLhWG3x9xN60n/WahFssJk8aXpBWPugYT07hSL8pVkfzlXIrqz4fakQTc74Xr7AFItRl9inpi6v6v48cLLvpHl5RqTangdnCapPjAmydOftQgkD1JxMo3ejTPXmjkUDzdM2/sU/OexBCiSUaIIo+wXqzf61voNMT7UfngTeIM2tky1qPYJfb9GUrsP9JjcqHSaCq5B/0zM/zc1miPIZ2CePc06F78vbU1aTJr41mEDW9mvG8M24sX7WTNwliFNgVFtoNcQ0StI1Nwnpy1Pc365vHaHF2e8/XFFBDqSRBx7OUX68/T96zqRUmeQf1fOt+XSwlTTFVHfSHAQX0MSQptymu7fowOuJO7kmgK8ayOo3icHkt3bfpqac0O7BEUSNxQIbDyDx6Y5LlGAWOhJhZy8/hXPX9xqgHjW/fNne1YLgtxoKH3HSZB5dLTCvlkLsB2tzN2qYIJBG5XKzBgnIz+D6MyXHuH42j5vrmvyrUeCsbwjsx3uzNjrMxfPpjWHZdwaQ6NtoGF9Vb/AaQXatHHM0iVByHgoNLbrPJaxSMs= 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)(376014)(366016)(1800799024)(23010399003)(11063799006)(4143699003)(6133799003)(261009223027099003)(22082099003)(18002099003)(10067099003)(56012099006)(261102123227099003)(261022105027099003)(261022075727099003)(261028144727099003)(261021121427099003)(261026121527099003)(261026140227099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?0yoWjrFyVgU8E6JOwW4fOtJPikkfvso5lm+FH9qREVJN/gogSrzL8jxpYW?= =?iso-8859-1?Q?N58bUBUwFIrjOcd+tRp5eurjKSlYN9oyjpne1B7TXhiTR9fp7ijH/kbtP6?= =?iso-8859-1?Q?TkWHJymgI/IlYgVGmi+Lk9u/aCkZm58f9eS1jgPse6QxyODBl+secqnP5A?= =?iso-8859-1?Q?jEphY81ABqXnbo1BJcVa0GY0eAvSZEW0mPZ51BPevOY20iXbNpPjrdFsSz?= =?iso-8859-1?Q?TtqEVYeTBWoiX3HOxgypP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yMmkHgE5CMbuGGChXzBmbW822RGwAct+12p2m2jsx/HUu2qRnYFlnkknUny0a1PfPAisH1Z+yenbA/oFQoRm1JlIHO+9HRVFo9R1psGHJfIEpKx+g== X-MS-Exchange-CrossTenant-Network-Message-Id: c74f2d1a-d555-4a14-80cf-08df50b76122 X-MS-Exchange-CrossTenant-AuthSource: CO1PR11MB4787.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 21:01:04.9883 (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: vyIgE4ytkTzlP/2SIks7L1eLrBYEkfapGMCVb9nSoyIOTo5+shE+bRI1cZcceXV1lRL6iPlUsZqlhE/wRZuQxg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR11MB7720 X-OriginatorOrg: intel.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "dri-devel" 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 12:19:05AM +0000, sashiko-bot@kernel.org wrote: > Thank you for your contribution! Sashiko AI review found 2 potential > issues to consider: > - [High] drm/xe: unreserved dma_resv fence slot in xe_bo_move() after > move_notify Fixed by dropping 'Flush L2 asynchronously in xe_bo_trigger_rebind()' which is my plan. > - [Medium] drm/xe: premature defrag list removal in xe_bo_move() on > defrag failure Flagged in earlier patch too (14), fixing there. Matt > -- > > commit cbbba44cdb964f67db155806c03129d18d8b4375 > Author: Matthew Brost > > drm/xe: Handle defrag moves in xe_bo_move() > > This commit teaches xe_bo_move() to handle defragmentation moves by > copying the old ttm_tt contents stored in defrag_old_tt to the newly > allocated backing via xe_migrate_copy_defrag(). > > > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c > > index 0351079eae64e..7448e43eedf58 100644 > > --- a/drivers/gpu/drm/xe/xe_bo.c > > +++ b/drivers/gpu/drm/xe/xe_bo.c > > @@ -1300,6 +1300,7 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict, > > bool move_lacks_source; > > bool tt_has_data; > > bool needs_clear; > > + bool has_defrag_old_tt = !!ttm_bo->defrag_old_tt; > > bool handle_system_ccs = (!IS_DGFX(xe) && xe_bo_needs_ccs_pages(bo) && > > ttm && ttm_tt_is_populated(ttm)) ? true : false; > > int ret = 0; > > @@ -1340,6 +1341,13 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict, > > move_lacks_source = !old_mem || (handle_system_ccs ? (!bo->ccs_cleared) : > > (!mem_type_is_vram(old_mem_type) && !tt_has_data)); > > > > + /* > > + * A defrag move always copies the existing contents from the stashed > > + * old tt into the freshly (re)allocated backing. > > + */ > > + if (has_defrag_old_tt) > > + move_lacks_source = false; > > + > > needs_clear = (ttm && ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC) || > > (!ttm && ttm_bo->type == ttm_bo_type_device); > > > > @@ -1383,9 +1391,12 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict, > > /* > > * Failed multi-hop where the old_mem is still marked as > > * TTM_PL_FLAG_TEMPORARY, should just be a dummy move. > > + * > > + * For a defrag move the old and new tt differ, so fallthrough to the > > + * copy path instead of treating it as a no-op. > > */ > > if (old_mem_type == XE_PL_TT && > > - new_mem->mem_type == XE_PL_TT) { > > + new_mem->mem_type == XE_PL_TT && !has_defrag_old_tt) { > > ttm_bo_move_null(ttm_bo, new_mem); > > goto out; > > } > > [Severity: Medium] > Can a failed defrag move drop bo from xe->mem.defrag.list while leaving it > on its fragmented backing? > > If xe_tt_map_sg(), xe_bo_move_notify(), or xe_migrate_copy_defrag() fails, > control jumps to the out label where xe_bo_defrag_update(bo) runs > unconditionally before ttm_bo_handle_move_mem() rolls ttm_bo->ttm back to > ttm_bo->defrag_old_tt: > > drivers/gpu/drm/xe/xe_bo.c:xe_bo_move() { > ... > out: > ... > if (!ret && ttm_bo->resource && ttm_bo->resource->mem_type == XE_PL_TT) > bo->lru_stamp = jiffies; > > xe_bo_defrag_update(bo); > > return ret; > } > > At that point ttm_bo->ttm still points to the newly allocated beneficial- > order ttm_tt, so xe_bo_needs_defrag() sees > !ttm_tt_is_beneficial_order_failed(tt) and calls xe_bo_defrag_remove(bo). > ttm_bo_handle_move_mem() then destroys the new ttm_tt and restores > bo->ttm = bo->defrag_old_tt, leaving the fragmented BO resident in > XE_PL_TT but untracked for future defragmentation. > > > @@ -1472,6 +1483,12 @@ 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) { > > + struct xe_ttm_tt *old_xe_tt = > > + container_of(ttm_bo->defrag_old_tt, struct xe_ttm_tt, ttm); > > + > > + fence = xe_migrate_copy_defrag(migrate, bo, old_mem, new_mem, > > + old_xe_tt->sg, handle_system_ccs); > > } else { > > fence = xe_migrate_copy(migrate, bo, bo, old_mem, new_mem, > > handle_system_ccs, ctx->interruptible); > > [Severity: High] > Can ttm_bo_move_accel_cleanup() hit BUG_ON(fobj->num_fences >= > fobj->max_fences) in dma_resv_add_fence() after a defrag move's > xe_bo_move_notify()? > > ttm_bo_handle_move_mem() reserves one fence slot in bo->base.resv before > calling xe_bo_move(). For a defrag move, xe_bo_move() runs > xe_bo_move_notify() -> xe_bo_trigger_rebind() -> > xe_vm_flush_vm_bo_tlb_async() -> xe_vma_tlb_flush_client(): > > drivers/gpu/drm/xe/xe_vm.c:xe_vma_tlb_flush_client() { > ... > err = dma_resv_reserve_fences(resv, 1); > if (err) > goto out_put; > > /* Cannot fail; takes its own ref on @dep and returns a referenced fence. */ > fence = xe_tlb_inval_job_push(job, dep); > dma_resv_add_fence(resv, fence, DMA_RESV_USAGE_KERNEL); > ... > } > > Because dma_resv_reserve_fences(resv, 1) does not reallocate when at least > one free slot already exists, adding the TLB invalidation fence can > consume the final slot that ttm_bo_handle_move_mem() reserved, leaving > fobj->num_fences == fobj->max_fences. With no fence wait or > dma_resv_reserve_fences() between xe_bo_move_notify() and > ttm_bo_move_accel_cleanup(), adding the migration fence from a different > fence context then triggers BUG_ON(fobj->num_fences >= fobj->max_fences). > > -- > Sashiko AI review · https://sashiko.dev/#/patchset/20261201234915.3305331-1-matthew.brost@intel.com?part=16