Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=198.175.65.20 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796329447; b=gNh7uePLdrAdGQF+mbq9UQAZt64uSLifZO+sfeoP6ViY76M0jKwMRVHfUZApCnw/Iq1z xwv7OhB/piwyWkfkbi81kbCGd8DQFYcSAv5k2oH/b+3veRgRC2FiosXcqXUoBb6T6MpTG rlSphUmHl+LemBRQOw3R/0Fad1VvWVnImYJy5hNb1uYbspgrfJ7tAbO3aOdp6a62QTtcT 6afpGaO+pBoXMojNuMq3ZLm+4IEj+VBNb6+PbQe4IPI/CUh8tvQXvizUNCbIDnsiQVIxH uxcTKCWAIM5G/8Icb7W109Ge2qZ2snRZTpDuROccLX5yne54ej7Jp4BqLGpyVa4FD7g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796329447; 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:From:To:Cc:Subject: Date:Message-Id:X-Mailer:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=sbxCVIdHxv6eF+oMmh8fMJdT+SNVTOGIZa5lJzjrDbk=; b=wlsq82+lj497VniVvaRjLMomq/675I0kq10SL5L7kmL2Ag6IBWBJWdE4pPDuGtfJVqml wmvqmOMwPK4mW5p354+Zhd7W4YOHF1zA7lwLqRFzJT1Wk6vyS0yV1Jjk24XGcqJ6/3xYr 2j8g9XpqQHwWErqh5ALLeh8P6OXAqWWr4+ZO2K/vmo//eG+CrMYZv5Ahjh8abFJlrDnXN hoBe4UsNV3ofUQf/uFxygANkhV/+3Sb67C2Z+MYbnboMxNb4/5fl4sGI356RS4XxIJOn2 KZoFPSm0kbKB7WZaCmbN9C9gdPvieCxEVFM4nHeaRVSCtgmI3hSiuTr+pGXDY0FVCPg== ARC-Authentication-Results: i=1; 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=PAJ2bO7k; arc=none smtp.remote-ip=198.175.65.20 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 000536072CC6 for ; Thu, 3 Dec 2026 20:24:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 000536072CC6 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=PAJ2bO7k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1796329448; x=1827865448; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sbxCVIdHxv6eF+oMmh8fMJdT+SNVTOGIZa5lJzjrDbk=; b=PAJ2bO7kP3V8Q9C1XAkRVtfwIQibJn6riJHmq2RLNecIQwFbYtCy3eVZ 2M7Ls73OxVEnBYb9sKmz4aqqzYURYWyOEHmxVoDcefQ0UNLdvEx67kPym C93fPcYqy3r5hkYAABij5ZgzHXB4XNe6yUc3kNe0lUEkGweo+iVqoOYSF u9l4Ooi1eAgiaBta8D7G0pcEEh3YTOYIvOAwHH/uVbDn/hmEUlOAL8aVs pgSlLfHlB3HqF22AKpi14BfXavyqng+Fl5D1VuT2+Jgs9i/e5tQo1LuuS 2RWNyJsF3IcVn4C6QFrY2SlsYhUnUpmw0Y7Ige8PzwsfPpn01+pRZwMLr Q==; X-CSE-ConnectionGUID: U2NUvo6/SAGUBH1ycGZtlw== X-CSE-MsgGUID: ZxO82t77Q8uPnK5sdx1J6Q== X-IronPort-AV: E=McAfee;i="6800,10657,11985"; a="5351222" X-IronPort-AV: E=Sophos;i="6.29,77,1794902400"; d="scan'208";a="5351222" 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-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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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