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 B56E5606A32D for ; Thu, 3 Dec 2026 20:24:49 +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=lKO+zuCi Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 31D6E112BD8; Thu, 3 Dec 2026 20:24:44 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) by gabe.freedesktop.org (Postfix) with ESMTPS id C53AB112BCF; Thu, 3 Dec 2026 20:24:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796329470; x=1827865470; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sbxCVIdHxv6eF+oMmh8fMJdT+SNVTOGIZa5lJzjrDbk=; b=lKO+zuCiXQ2eP0CndMX5mgNzNvxJecNAAeIdsH+Uz5FjucEYQF5q/tnG xQWBB/P176F9a5Y8A9w6NAHOnIb+QHUdCex4oH5jngFMsv2NDjcmrcTa7 iyRFdWd1Tjiv1Y5VhEbskC0+42ggahlMSQMZC3RfYe61EehLimoCNRO5V 3nSGcAhr7HBmvScc8Y67tODIWEbQhxNiVDQAk8kT9FbyLV7hj16nm6vcG qhlIHULP/j2tWOAcZWhTeuE5DsG1iRv4rHLb9mpUGwVIRHqAyoyv/Tik5 Mw4/XWvAJQNq+oyTeB9nTDWbCdXwbBh576lnRzBDwPQeU40h8n3j+VMx5 g==; X-CSE-ConnectionGUID: gt9yg5DCT1a4epXCW+kyjw== X-CSE-MsgGUID: HgCo0tRET/+iMm7NIqYZQw== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5351217" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5351217" Received: from fmviesa013.fm.intel.com ([10.60.135.153]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 12:24:07 -0800 X-CSE-ConnectionGUID: ioqH76D0RzOOhlP6TZpaOQ== X-CSE-MsgGUID: V38VtY0+S828dAj3Tv4LYA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="15862524" Received: from gsse-cloud1.jf.intel.com ([10.54.39.91]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 Dec 2026 12:24:07 -0800 From: Matthew Brost To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: Carlos Santa , Ryan Neph , Natalie Vock , Arun Pravin , Matthew Auld , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org, =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , Niranjana Vishwanathapura Subject: [PATCH v6 29/35] drm/xe: Add per-device dependency scheduler for IOVA defrag finalize Date: Thu, 3 Dec 2026 12:23:46 -0800 Message-Id: <20261203202352.4153159-30-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261203202352.4153159-1-matthew.brost@intel.com> References: <20261203202352.4153159-1-matthew.brost@intel.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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=-18.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT 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 A future patch performs the destination DMA mapping of a defrag move in two stages when the BO is IOVA mapped: a temporary contiguous mapping of just that changed pages used for the GPU copy, followed by a post-copy finalize step that tears that mapping down and links the new backing into the (transferred) IOVA reservation. The finalize step must run only after the GPU copy it depends on has completed, so it is dispatched as an xe_dep_job. Add a per-device xe_dep_scheduler dedicated to these finalize jobs, created in xe_bo_defrag_init() (after the migrate contexts are up) and torn down in xe_bo_defrag_fini(). No users yet; the job itself is added in a later patch. v4: -Gate dep scheduler creation on use_dma_iommu (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 Signed-off-by: Matthew Brost Reviewed-by: Niranjana Vishwanathapura --- drivers/gpu/drm/xe/xe_bo.c | 18 ++++++++++++++++++ drivers/gpu/drm/xe/xe_device_types.h | 10 ++++++++++ 2 files changed, 28 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c index 06922c386c28..aeb633c2bdf5 100644 --- a/drivers/gpu/drm/xe/xe_bo.c +++ b/drivers/gpu/drm/xe/xe_bo.c @@ -28,6 +28,7 @@ #include #include "xe_device.h" +#include "xe_dep_scheduler.h" #include "xe_dma_buf.h" #include "xe_drm_client.h" #include "xe_ggtt.h" @@ -1539,6 +1540,10 @@ static void xe_bo_defrag_fini(void *arg) struct xe_device *xe = arg; disable_delayed_work_sync(&xe->mem.defrag.worker); + if (xe->mem.defrag.iova_sched) { + xe_dep_scheduler_fini(xe->mem.defrag.iova_sched); + xe->mem.defrag.iova_sched = NULL; + } } /** @@ -1578,6 +1583,19 @@ int xe_bo_defrag_init_early(struct xe_device *xe) */ int xe_bo_defrag_init(struct xe_device *xe) { + if (use_dma_iommu(xe->drm.dev)) { + struct xe_dep_scheduler *iova_sched; + +#define XE_BO_MAX_IOVA_DEFRAG_JOBS 16 /* Picking a reasonable value */ + iova_sched = xe_dep_scheduler_create(xe, NULL, "xe_iova_defrag", + XE_BO_MAX_IOVA_DEFRAG_JOBS); +#undef XE_BO_MAX_IOVA_DEFRAG_JOBS + if (IS_ERR(iova_sched)) + return PTR_ERR(iova_sched); + + xe->mem.defrag.iova_sched = iova_sched; + } + return devm_add_action_or_reset(xe->drm.dev, xe_bo_defrag_fini, xe); } diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h index 1c3f4b5c9232..90ab7288f8fe 100644 --- a/drivers/gpu/drm/xe/xe_device_types.h +++ b/drivers/gpu/drm/xe/xe_device_types.h @@ -42,6 +42,7 @@ struct drm_pagemap_shrinker; struct intel_display; +struct xe_dep_scheduler; struct intel_dg_nvm_dev; struct xe_cpu_bind; struct xe_ggtt; @@ -356,6 +357,15 @@ struct xe_device { * not be queued. Protected by @mem.defrag.lock. */ bool suspended; + /** + * @mem.defrag.iova_sched: Dependency scheduler used to + * run the post-copy IOVA finalize job for defrag moves + * of IOVA-mapped BOs. The job tears down the temporary + * copy-step IOVA mapping and links the new backing into + * the (transferred) reservation once the GPU copy that + * its dependencies gate has completed. + */ + struct xe_dep_scheduler *iova_sched; } defrag; } mem; -- 2.34.1