From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.remote-ip=192.198.163.19 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=fail; t=1796193790; b=iKw6nTvaOSQUiAWqB5LNyqHaL/p596fHNXkD7i8S9BHggtA3b6SJA/sSC0cVdYeOklLm dwVNBwCPYuTb2GX5D8/MPFVseSAhqMEKwOb84TRvmmf3G0mUxzMHmjfX61Ux2lv1T2xOa I99UCAQ862eeKD36OxJ/nBZmO/IoFR2HXHYmsEyPn12i9a+J5EpE9uSTxRvrenv+JVPKP uQaiYEAUwLWnW3GvVOcw9ARB5xMeidiNcC1lj25l+iUhoOGRajRA4Cczt2S4I1q0g9/dJ oM9YI3bpjU4LOqug1w8ZnOIqMB2IeLF2YRNV7ZyUIxBMtFrAON01hlCzpPKs0VFO1ag== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796193790; h=DMARC-Filter:DKIM-Signature:X-CSE-ConnectionGUID:X-CSE-MsgGUID: X-IronPort-AV:X-IronPort-AV:Received:X-CSE-ConnectionGUID: X-CSE-MsgGUID:X-ExtLoop1:X-IronPort-AV:Received:Received:Received: Received:Received:Received:Date:From:To:CC:Subject:Message-ID: References:Content-Type:Content-Disposition:Content-Transfer-Encoding: In-Reply-To:X-ClientProxiedBy:MIME-Version:X-MS-PublicTrafficType: X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id: X-LD-Processed:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-Exchange-RoutingPolicyChecked: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-MailboxType: X-MS-Exchange-CrossTenant-UserPrincipalName: X-MS-Exchange-Transport-CrossTenantHeadersStamped:X-OriginatorOrg; bh=jzAb1Xg37b6HGtPHHx4F3oMDkA64tkhWg/L+cxQ5V0U=; b=WZEqWun7A/vdH9vpDiY1tlNnXmJP4Up8MCR1v/SjLzThUBQlSmeFfrS0M31DMNlMcICJ JukOdX0DmWsBEzTt8ywNmIubPs2bqnzeO9+tnSLgebrGlnei/o6qNRfCklSNzABayWJru F+pQTmArsF1qyI4XPaS+pMvWx7+nKvGf5NyLb1cVFOu081PwbVPAgAgTVuDmAacHJophN uc9k6DItquJJwMEDCI0FYFTdA0/8svcChCjJ4VinAwEuvZ2qv7dQMQw7EhUAeO3EZsEWA brDzmNTgF4FteBLffvoIzfulJG3MMqTd9bA+lT1E172SNkJLZvmQ06Nnq32GL5nhGjA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=OM2deT08; arc=fail smtp.remote-ip=192.198.163.19 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 476F9606A31A for ; Wed, 2 Dec 2026 06:43:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 476F9606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com 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=OM2deT08 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796193790; x=1827729790; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=jzAb1Xg37b6HGtPHHx4F3oMDkA64tkhWg/L+cxQ5V0U=; b=OM2deT08JeAxAH1NIo2f4nET2bLK15M7/aqu+DrGxHnxbm02FdUGFZm/ wE+kAwyNrUUBfnekueQxyhbuZG2jySQMGoUfjvG3IMBRd2IIBuvBCaTdV avJjoqxplYIr0W0MEfhDI8TLBxedRkV4UpgcmF1gnX37pC+fR4ltlx2gj 6vErcebOXmSXptz8M1XAtCFegWO8aOIPa5T6pcgrXgG67LTjT6jbrMb21 Zdgq1XrWBqzQztL73NqbjY3OUWramppER4DSvmUV05DmnthjmEMAESsJg kfKNl1u3eZ1EuO9zxMCEgvW0C8IbCt6pBvIJcWIBCBQZJ+vVNVtffAoZB w==; X-CSE-ConnectionGUID: 91F7E4QSSkmDH+5+FktfGQ== X-CSE-MsgGUID: N4jJPQUKQ6Oq1K7jqzKaYg== X-IronPort-AV: E=McAfee;i="6800,10657,11983"; a="5119127" X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="5119127" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 22:43:09 -0800 X-CSE-ConnectionGUID: LX2jjA2YR3CjlgGzNGlxGg== X-CSE-MsgGUID: uTRVAli8QKGXbL+yCpGIhw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.27,246,1787036400"; d="scan'208";a="13430745" Received: from orsmsx903.amr.corp.intel.com ([10.22.229.25]) by orviesa002.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Dec 2026 22:43:10 -0800 Received: from ORSMSX901.amr.corp.intel.com (10.22.229.23) by ORSMSX903.amr.corp.intel.com (10.22.229.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Tue, 1 Dec 2026 22:43:08 -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; Tue, 1 Dec 2026 22:43:08 -0800 Received: from BN1PR04CU002.outbound.protection.outlook.com (52.101.56.6) 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; Tue, 1 Dec 2026 22:43:08 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=PkHK4np9cooWutaljVpQCE4KTWkj+PFCpV3zeRJHPjLT7N85An8AeH04CGNwVq+c4dnz3QRlJilQ5nugdK4aQAEdyilxCQtGYM0wmLthwDHcF/eiTZ3tFeXIaLZRi1TDh0WLY0ZqUs2QEJZHBNTLoSk9eYDSTNSAihzie8uBKDQv/OKBmuUDZb8ao9UCg46R9IFLLNBPzmSZMS3LzC99pmHmgvqhwGgDookKcON1LZDDitcPVFwtRiKN5ovycZnx3H6DCuPa6JmDHTmQcaoYzycittTb1TqpuvJTVfMUbt/tLyieojsL/0iHMcxdu4Q8+5/STpwU78RVnVrC9akGXg== 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=y/OeTkwqedodzyRANZHo1Dw7TRzwYN9DWzzhWDJHHqo=; b=Endbu63AMdaEMYKU2bL2bhiyHzyXibxz9Oeb+pzNFa4jMEfZGAnFm26CcL209fJLzW7KkGzoBXQDWTopnjTCbBFEVyHhMEt8BalhjrJg1+jrcm0VCxcRiHr7WvWc24mhyRDrhpPNg9KeskU9S/WVwIpqtOmcpexEIOOhUyI7Q6dSc8o5uu63CuGO/mUzuf5/6iEu5F4S0p7BUHM+ikp9pI4IhIlrXBSWQVV22CiDqd+2vcQz0jKuzON935mCYmSGcaxsdioO12QVq8DMm97APUY5twrG/TirwsPo/c4iJTOPKZ0XM0z4WdWCdGBA0HrLI7X1WsH6a0tpg9rtHjmAOA== 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 MW3PR11MB4684.namprd11.prod.outlook.com (2603:10b6:303:5d::14) by MW3PR11MB4699.namprd11.prod.outlook.com (2603:10b6:303:54::13) 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 06:43:00 +0000 Received: from MW3PR11MB4684.namprd11.prod.outlook.com ([fe80::2f5a:96ce:f7e4:c315]) by MW3PR11MB4684.namprd11.prod.outlook.com ([fe80::2f5a:96ce:f7e4:c315%7]) with mapi id 15.21.0688.009; Wed, 2 Dec 2026 06:43:00 +0000 Date: Tue, 1 Dec 2026 22:42:57 -0800 From: Niranjana Vishwanathapura To: Matthew Brost CC: , , Carlos Santa , Ryan Neph , Natalie Vock , Arun Pravin , Matthew Auld , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , , Thomas =?iso-8859-1?Q?Hellstr=F6m?= Subject: Re: [PATCH v4 15/33] drm/xe: Add xe_migrate_copy_defrag() for on-GPU defrag copies Message-ID: References: <20261201234915.3305331-1-matthew.brost@intel.com> <20261201234915.3305331-16-matthew.brost@intel.com> Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20261201234915.3305331-16-matthew.brost@intel.com> X-ClientProxiedBy: SJ0PR03CA0051.namprd03.prod.outlook.com (2603:10b6:a03:33e::26) To MW3PR11MB4684.namprd11.prod.outlook.com (2603:10b6:303:5d::14) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW3PR11MB4684:EE_|MW3PR11MB4699:EE_ X-MS-Office365-Filtering-Correlation-Id: 663a0769-281f-4312-71b4-08df503f81a1 X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|7416014|376014|23010399003|366016|22082099003|10067099003|56012099006|261028144727099003|261102123227099003|261021121427099003|261021123027099003|261026121527099003|261022105027099003|261026140227099003|261009223027099003|11063799006|4143699003|18002099003|6133799003|3023799007; X-Microsoft-Antispam-Message-Info: lYxVwNQ0GlakbiDao9UpBXcgUljECAhmjUgGNLEGg310SLn6fmYTyPajY5pLnVcEctCFvTU+l4Q/sYbirqYj7GcYOzDLdP5poKtBxCKxzEL3Gm/m79srZUIMJnL1F9J/Dct8DIDJxnb3kLnKxVrgyMZOOTVkdGNhBGkh5R6GGAAnvWLJKOSfuHmq5RRC4v9J+SThMgWkt4/7QJvxhkLU2Rwh8hYO1i/qp0XbmXFiCkHhk86xXf7H6X0UmER2fCP51QhQlNc1/HOW8pvAzUhsVEJU8SzMDEvir4Qw+Y+DRPGJEX40I4gy8ovK8jmO+0IONjvZOmteEW5nnkiZbvoLQ7QRyfxQ65MZ6zGcSkYGLQINfOC2SGg921EgZ9Fx0Mzpl+VMq9ETtMkuj17LUzm8T36CGFrbxvzHXNua1893lt3kPdPE8MXRGE3qHLqKxIo7ReYvx6Yd/Re9Ci1uQWwa1d7V5p1V5bijI5fy1TWK3AtbjCgl9+VR72RpBl395x2OXybJ7j9/BlXJFCr/D1kxTlV6f0FDuO43WuabcJdXyGysxs8IsoJz+uBBKMHT4gkddknn+DobqBsZKRvtPA2ev3Gro5be5C0oajBVMAtmofm9R2uae6uMu7LCUrQUZmuVa95b2DDaQTJXWkhw3ofNhc2l5BN3tEyldOA1s8+pefE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW3PR11MB4684.namprd11.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(7416014)(376014)(23010399003)(366016)(22082099003)(10067099003)(56012099006)(261028144727099003)(261102123227099003)(261021121427099003)(261021123027099003)(261026121527099003)(261022105027099003)(261026140227099003)(261009223027099003)(11063799006)(4143699003)(18002099003)(6133799003)(3023799007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?XGB+qchtirdSWFGKELQUxywVd2CHj/JZYczZdQjNijbvWHvMDY4+3b4dje?= =?iso-8859-1?Q?silPFlGs1JBrmMDlvTIgws801QxlT+Av+6HEM6X/3ojnv++xXOwrUV/K7D?= =?iso-8859-1?Q?1IxLXsQ1fUQzDxzoWfs4YLgC0lxq716FbeZP4PlzhipeoMcx7f71jIfHBY?= =?iso-8859-1?Q?qVKk1J+oUWUK2rHmk64+TR47BNAkeKhiXw7VgKwpbL/7+frk6JS+69yh2r?= =?iso-8859-1?Q?SKrILinUt8yyejGj5miCQv6v5BprAkYrS++QqeSP9i0AOHzEAlbjwECk0C?= =?iso-8859-1?Q?JTOGUcGyQLG9eqNUOvJvO+7rWdtIbFTXJBEPPIL3/ROUJzaTCPw2atcdXX?= =?iso-8859-1?Q?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ptVy47FgOxIwb8GW1Ry0b538+zDa5d0Lmu2CGIZcV7IqvrDgSsQlCMsuDWdF8O1A== X-MS-Exchange-CrossTenant-Network-Message-Id: 663a0769-281f-4312-71b4-08df503f81a1 X-MS-Exchange-CrossTenant-AuthSource: MW3PR11MB4684.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 06:43:00.0778 (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: qo1rXhS73R6mUW3YLD9Vf52CVjwZD5I0H4Th6H6siVrLx750VxPwu2FeIh17xRfG5KHXL58ufb6QDywrmRheUCdCT2ID5KuR8ie3ts7tv9ik7yPXWCZ6lcQmTHwT4kLP X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR11MB4699 X-OriginatorOrg: intel.com On Tue, Dec 01, 2026 at 03:48:57PM -0800, Matthew Brost wrote: >Add xe_migrate_copy_defrag(), a copy helper for the upcoming page >defragmentation path where a single BO has its backing reallocated at a >more beneficial page order and its contents must be relocated from the >old pages to the new ones entirely on the GPU. > >The contents are relocated in up to two passes: > > - Data pass (always): copy the data pages verbatim. The pages are > mapped without the compression PAT, so the (possibly compressed) > bytes are copied as-is rather than being decompressed and > recompressed, and no CCS aux copy is appended. > > - CCS pass (need_ccs): copy the CCS aux (compression) state. Both the > old and new data pages are mapped with the compression PAT so the > copy engine accesses the aux state indirectly, issuing one > indirect -> indirect XY_CTRL_SURF_COPY_BLT; the data blit is skipped. > >The two passes are issued separately because they require opposite >compression PAT settings on the data page mappings (cleared for the >verbatim data copy, set for the indirect CCS access), which a single >mapping cannot satisfy. Both passes run in order on the same migrate >queue and are captured by the returned fence. > >The source pages are passed explicitly via an sg_table argument (the >old, still populated backing) since they no longer match the BO's >current backing. The boolean arguments to __xe_migrate_copy() are replaced >by a single enum xe_migrate_copy_mode, since the copy variants are >mutually exclusive. > >v4: > - s/struct xe_migrate_copy_flags/enum xe_migrate_copy_mode (Niranjana) > >Cc: Carlos Santa >Cc: Ryan Neph >Cc: Natalie Vock >Cc: Arun Pravin >Cc: Matthew Auld >Cc: Maarten Lankhorst >Cc: Maxime Ripard >Cc: Thomas Zimmermann >Cc: David Airlie >Cc: Simona Vetter >Cc: dri-devel@lists.freedesktop.org >Cc: linux-kernel@vger.kernel.org >Cc: Thomas Hellström >Assisted-by: LLM >Signed-off-by: Matthew Brost >--- > drivers/gpu/drm/xe/xe_migrate.c | 133 ++++++++++++++++++++++++++++---- > drivers/gpu/drm/xe/xe_migrate.h | 8 ++ > 2 files changed, 127 insertions(+), 14 deletions(-) > >diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c >index 23575f9dc651..0f469942ae6e 100644 >--- a/drivers/gpu/drm/xe/xe_migrate.c >+++ b/drivers/gpu/drm/xe/xe_migrate.c >@@ -1292,16 +1292,50 @@ static bool is_devmem(struct xe_bo *bo, struct ttm_resource *res) > > return true; > } >+/** >+ * enum xe_migrate_copy_mode - Mode for __xe_migrate_copy() >+ * @XE_MIGRATE_COPY_NORMAL: Regular copy of data (and CCS aux state if needed). >+ * @XE_MIGRATE_COPY_CCS_ONLY: Only copy the CCS aux state, aliasing the >+ * destination data mapping to the source (used when the data pages are shared >+ * between src/dst). >+ * @XE_MIGRATE_COPY_VRAM_RESOLVE: Decompression (VRAM -> system) resolve; >+ * always uses the compression PAT index for the data copy. >+ * @XE_MIGRATE_COPY_DEFRAG_DATA: Defrag move pass that copies the data pages >+ * between two distinct page sets (old @src_sg pages -> new pages) without >+ * touching the CCS aux state. The data pages are mapped without the >+ * compression PAT so the (possibly compressed) bytes are copied verbatim >+ * rather than being decompressed and recompressed, and no CCS aux copy is >+ * appended; the aux state is migrated separately by the >+ * @XE_MIGRATE_COPY_DEFRAG_CCS pass. >+ * @XE_MIGRATE_COPY_DEFRAG_CCS: Defrag move pass that migrates only the CCS aux >+ * state between two distinct page sets (old @src_sg pages -> new pages). The >+ * data blit is skipped (the data was copied by the >+ * @XE_MIGRATE_COPY_DEFRAG_DATA pass) and both the source and destination data >+ * pages are mapped with the compression PAT so the aux state is copied >+ * indirect -> indirect. The two defrag passes need opposite compression PAT >+ * settings, which is why they cannot be combined. >+ */ >+enum xe_migrate_copy_mode { >+ XE_MIGRATE_COPY_NORMAL, >+ XE_MIGRATE_COPY_CCS_ONLY, >+ XE_MIGRATE_COPY_VRAM_RESOLVE, >+ XE_MIGRATE_COPY_DEFRAG_DATA, >+ XE_MIGRATE_COPY_DEFRAG_CCS, >+}; > > static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m, > struct xe_bo *src_bo, > struct xe_bo *dst_bo, > struct ttm_resource *src, > struct ttm_resource *dst, >- bool copy_only_ccs, >- bool is_vram_resolve, >+ struct sg_table *src_sg, >+ enum xe_migrate_copy_mode mode, > bool intr) > { >+ bool copy_only_ccs = mode == XE_MIGRATE_COPY_CCS_ONLY; >+ bool is_vram_resolve = mode == XE_MIGRATE_COPY_VRAM_RESOLVE; >+ bool defrag_copy = mode == XE_MIGRATE_COPY_DEFRAG_DATA; >+ bool defrag_ccs = mode == XE_MIGRATE_COPY_DEFRAG_CCS; > struct xe_gt *gt = m->tile->primary_gt; > struct xe_device *xe = gt_to_xe(gt); > struct dma_fence *fence = NULL; >@@ -1317,10 +1351,13 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m, > bool src_is_vram = is_devmem(src_bo, src); > bool dst_is_vram = is_devmem(dst_bo, dst); > bool type_device = src_bo->ttm.type == ttm_bo_type_device; >- bool needs_ccs_emit = type_device && xe_migrate_needs_ccs_emit(xe); >+ bool needs_ccs_emit = type_device && xe_migrate_needs_ccs_emit(xe) && >+ !defrag_copy; > bool copy_ccs = xe_device_has_flat_ccs(xe) && >- xe_bo_needs_ccs_pages(src_bo) && xe_bo_needs_ccs_pages(dst_bo); >- bool copy_system_ccs = copy_ccs && (!src_is_vram || !dst_is_vram); >+ xe_bo_needs_ccs_pages(src_bo) && xe_bo_needs_ccs_pages(dst_bo) && >+ !defrag_copy; >+ bool copy_system_ccs = copy_ccs && (!src_is_vram || !dst_is_vram) && >+ !defrag_ccs && !defrag_copy; > > /* > * For decompression operation, always use the compression PAT index. >@@ -1331,6 +1368,12 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m, > xe_device_has_flat_ccs(xe) && > GRAPHICS_VER(xe) >= 20 && src_is_vram && !dst_is_vram); > >+ /* >+ * The defrag CCS pass migrates the aux state from the old pages >+ * (@src_sg) to the new pages with both sides accessed indirectly, so >+ * keep both src_is_pltt and dst_is_pltt set (no direct staging side). >+ */ >+ > /* Copying CCS between two different BOs is not supported yet. */ > if (XE_WARN_ON(copy_ccs && src_bo != dst_bo)) > return ERR_PTR(-EINVAL); >@@ -1339,7 +1382,7 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m, > return ERR_PTR(-EINVAL); > > if (!src_is_vram && src->mem_type != XE_PL_STOLEN) >- xe_res_first_sg(xe_bo_sg(src_bo), 0, size, &src_it); >+ xe_res_first_sg(src_sg ? src_sg : xe_bo_sg(src_bo), 0, size, &src_it); > else > xe_res_first(src, 0, size, &src_it); > if (!dst_is_vram && dst->mem_type != XE_PL_STOLEN) >@@ -1348,7 +1391,8 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m, > xe_res_first(dst, 0, size, &dst_it); > > if (copy_system_ccs) >- xe_res_first_sg(xe_bo_sg(src_bo), xe_bo_ccs_pages_start(src_bo), >+ xe_res_first_sg(src_sg ? src_sg : xe_bo_sg(src_bo), >+ xe_bo_ccs_pages_start(src_bo), > PAGE_ALIGN(xe_device_ccs_bytes(xe, size)), > &ccs_it); > >@@ -1399,7 +1443,8 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m, > } > > /* Add copy commands size here */ >- batch_size += ((copy_only_ccs) ? 0 : emit_copy_cmd_len(xe)) + >+ batch_size += ((copy_only_ccs || defrag_ccs) ? 0 : >+ emit_copy_cmd_len(xe)) + > ((needs_ccs_emit ? EMIT_COPY_CCS_DW : 0)); > > bb = __xe_bb_new(gt, batch_size, usm, !fence && intr); >@@ -1411,13 +1456,15 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m, > if (src_is_vram && xe_migrate_allow_identity(src_L0, &src_it)) > xe_res_next(&src_it, src_L0); > else >- emit_pte(m, bb, src_L0_pt, src_is_vram, copy_system_ccs || use_comp_pat, >+ emit_pte(m, bb, src_L0_pt, src_is_vram, >+ copy_system_ccs || use_comp_pat || defrag_ccs, > &src_it, src_L0, src); > > if (dst_is_vram && xe_migrate_allow_identity(src_L0, &dst_it)) > xe_res_next(&dst_it, src_L0); > else if (!copy_only_ccs) >- emit_pte(m, bb, dst_L0_pt, dst_is_vram, copy_system_ccs, >+ emit_pte(m, bb, dst_L0_pt, dst_is_vram, >+ copy_system_ccs || defrag_ccs, > &dst_it, src_L0, dst); > > if (copy_system_ccs) >@@ -1426,7 +1473,7 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m, > bb->cs[bb->len++] = MI_BATCH_BUFFER_END; > update_idx = bb->len; > >- if (!copy_only_ccs) >+ if (!copy_only_ccs && !defrag_ccs) > emit_copy(gt, bb, src_L0_ofs, dst_L0_ofs, src_L0, XE_PAGE_SIZE); > > if (needs_ccs_emit) >@@ -1513,7 +1560,64 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m, > bool copy_only_ccs, > bool intr) > { >- return __xe_migrate_copy(m, src_bo, dst_bo, src, dst, copy_only_ccs, false, intr); >+ return __xe_migrate_copy(m, src_bo, dst_bo, src, dst, NULL, >+ copy_only_ccs ? XE_MIGRATE_COPY_CCS_ONLY : >+ XE_MIGRATE_COPY_NORMAL, intr); >+} >+ >+/** >+ * xe_migrate_copy_defrag() - Migrate a BO's backing to a reallocated page set. >+ * @m: The migration context. >+ * @bo: The buffer object being defragmented. Both @src and @dst belong to @bo. >+ * @src: The source TTM resource (the old backing). >+ * @dst: The dst TTM resource (the freshly reallocated backing). >+ * @src_sg: Scatter-gather table of the source (old) backing pages. >+ * @need_ccs: Whether the BO has CCS aux state that must be migrated too. >+ * >+ * Used by the defrag path where a single BO has its backing reallocated at a >+ * more beneficial page order. The contents are relocated from the old pages >+ * (@src_sg) to the new pages (the BO's current backing) entirely on the GPU, >+ * in up to two passes: >+ * >+ * - Data pass (always): copy the data pages verbatim. The pages are mapped >+ * without the compression PAT, so the (possibly compressed) bytes are copied >+ * as-is rather than being decompressed and recompressed, and no CCS aux copy >+ * is appended. >+ * >+ * - CCS pass (@need_ccs): copy the CCS aux (compression) state. Both the old >+ * and new data pages are mapped with the compression PAT so the copy engine >+ * accesses the aux state indirectly, issuing one indirect -> indirect >+ * XY_CTRL_SURF_COPY_BLT; the data blit is skipped. >+ * >+ * The two passes are issued separately because they require opposite >+ * compression PAT settings on the data page mappings (cleared for the verbatim >+ * data copy, set for the indirect CCS access), which a single mapping cannot >+ * satisfy. Both passes run in order on the same migrate queue. >+ * >+ * Return: Pointer to a dma_fence representing the last copy batch, or an error >+ * pointer on failure. >+ */ >+struct dma_fence *xe_migrate_copy_defrag(struct xe_migrate *m, >+ struct xe_bo *bo, >+ struct ttm_resource *src, >+ struct ttm_resource *dst, >+ struct sg_table *src_sg, >+ bool need_ccs) >+{ >+ struct dma_fence *fence2, *fence = >+ __xe_migrate_copy(m, bo, bo, src, dst, src_sg, >+ XE_MIGRATE_COPY_DEFRAG_DATA, false); NIT...Passing false to 'intr' here and below is fine, given defrag worker context can't be interrupted. May be add a line of documentation just in case tomorrow if someone tries to defragment from a interruptible context? In anycase, Reviewed-by: Niranjana Vishwanathapura >+ >+ if (IS_ERR(fence) || !need_ccs) >+ return fence; >+ >+ fence2 = __xe_migrate_copy(m, bo, bo, src, dst, src_sg, >+ XE_MIGRATE_COPY_DEFRAG_CCS, false); >+ if (IS_ERR(fence2)) >+ dma_fence_wait(fence, false); >+ dma_fence_put(fence); >+ >+ return fence2; > } > > /** >@@ -1522,7 +1626,7 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m, > * @bo: The buffer object to resolve > * @res: The reservation object > * >- * Wrapper around __xe_migrate_copy() with is_vram_resolve set to true >+ * Wrapper around __xe_migrate_copy() with XE_MIGRATE_COPY_VRAM_RESOLVE > * to trigger decompression if needed. > * > * Return: A dma_fence that signals on completion, or an ERR_PTR on failure. >@@ -1531,7 +1635,8 @@ struct dma_fence *xe_migrate_resolve(struct xe_migrate *m, > struct xe_bo *bo, > struct ttm_resource *res) > { >- return __xe_migrate_copy(m, bo, bo, res, res, false, true, true); >+ return __xe_migrate_copy(m, bo, bo, res, res, NULL, >+ XE_MIGRATE_COPY_VRAM_RESOLVE, true); > } > > /** >diff --git a/drivers/gpu/drm/xe/xe_migrate.h b/drivers/gpu/drm/xe/xe_migrate.h >index 0bf94f5b388d..70451392e0a7 100644 >--- a/drivers/gpu/drm/xe/xe_migrate.h >+++ b/drivers/gpu/drm/xe/xe_migrate.h >@@ -11,6 +11,7 @@ > struct dma_fence; > struct drm_pagemap_addr; > struct iosys_map; >+struct sg_table; > struct ttm_resource; > > struct xe_bo; >@@ -59,6 +60,13 @@ struct dma_fence *xe_migrate_copy(struct xe_migrate *m, > bool copy_only_ccs, > bool intr); > >+struct dma_fence *xe_migrate_copy_defrag(struct xe_migrate *m, >+ struct xe_bo *bo, >+ struct ttm_resource *src, >+ struct ttm_resource *dst, >+ struct sg_table *src_sg, >+ bool need_ccs); >+ > struct dma_fence *xe_migrate_resolve(struct xe_migrate *m, > struct xe_bo *bo, > struct ttm_resource *res); >-- >2.34.1 >