From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 83D20C4452D for ; Mon, 20 Jul 2026 16:07:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0002210E9C2; Mon, 20 Jul 2026 16:07:17 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=lankhorst.se header.i=@lankhorst.se header.b="UNW3mfve"; dkim-atps=neutral Received: from lankhorst.se (unknown [141.105.120.124]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5804D10E9BC; Mon, 20 Jul 2026 16:07:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lankhorst.se; s=default; t=1784563636; bh=J+dO8qqHWc64WGG6JZVa7qd8cRI/2zZRat+e2Y2DYhQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UNW3mfveRxxgr8C1+gk8ShBQufLENu6RnEdn+Iv+sUXMbfGbBwIaIHvcxE1KB4Vvg 07KjY79sLBVaqufX9Btlxc8AdzV0tA6e+Evr9AAzZccdxDJUrKnElQXE94dR+2LR5C foTMGizCx9JGGls/cSJP7JTWcGF2h9B5js9XRSnp8tqHpNtZ0zE3XGDbjRgrrvK3Wc w81frSKTg6uMeBKzA4S5QlmCcW8o/wwPZh+2TKEjhUYZ6vn+nFxtkkoFeAHJ1LZJqP uCIeIY18kmMHpYXHPEFeQO0+C5GlNm5A4i2T93gyNmPLq6mUsR0WAWAgkbZEWPNl4y z9xZ148veVKYA== From: Maarten Lankhorst To: intel-xe@lists.freedesktop.org Cc: intel-gfx@lists.freedesktop.org, Maarten Lankhorst , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= Subject: [PATCH v3 2/6] drm/xe/ggtt: Add xe_ggtt_node_remove_noclear Date: Mon, 20 Jul 2026 18:08:08 +0200 Message-ID: <20260720160805.380356-10-dev@lankhorst.se> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260720160805.380356-8-dev@lankhorst.se> References: <20260720160805.380356-8-dev@lankhorst.se> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" The last bit required for handling fb takeover is ensuring we can release the old live framebuffer without keeping track. The display code can then safely perform the flip. It's unfortunately a workaround for how display is structured through callbacks instead of being a midlayer. Signed-off-by: Maarten Lankhorst Reviewed-by: Ville Syrjälä --- drivers/gpu/drm/xe/xe_ggtt.c | 30 +++++++++++++++++++++++------- drivers/gpu/drm/xe/xe_ggtt.h | 1 + 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c index 50e5b174c7960..225e6378b2bfc 100644 --- a/drivers/gpu/drm/xe/xe_ggtt.c +++ b/drivers/gpu/drm/xe/xe_ggtt.c @@ -470,24 +470,40 @@ static void ggtt_node_fini(struct xe_ggtt_node *node) kfree(node); } -static void ggtt_node_remove(struct xe_ggtt_node *node) +static void ggtt_node_remove(struct xe_ggtt_node *node, bool clear) { struct xe_ggtt *ggtt = node->ggtt; - bool bound; mutex_lock(&ggtt->lock); - bound = ggtt->flags & XE_GGTT_FLAGS_ONLINE; - if (bound) + if (clear) + clear = ggtt->flags & XE_GGTT_FLAGS_ONLINE; + if (clear) xe_ggtt_clear(ggtt, xe_ggtt_node_addr(node), xe_ggtt_node_size(node)); drm_mm_remove_node(&node->base); node->base.size = 0; - if (bound && node->invalidate_on_remove) + if (clear && node->invalidate_on_remove) xe_ggtt_invalidate(ggtt); mutex_unlock(&ggtt->lock); ggtt_node_fini(node); } +/** + * xe_ggtt_node_remove_noclear - Remove a &xe_ggtt_node from the GGTT without clearing entries + * @node: the &xe_ggtt_node to be removed + * + * This function is similar to xe_ggtt_node_remove(), but doesn't clear + * the entries. It's used to release the live FB mapping without + * clearing it. + * + * This function should only be called before xe_ggtt_init() in + * the bios FB takeover code. + */ +void xe_ggtt_node_remove_noclear(struct xe_ggtt_node *node) +{ + ggtt_node_remove(node, false); +} + static void ggtt_node_remove_work_func(struct work_struct *work) { struct xe_ggtt_node *node = container_of(work, typeof(*node), @@ -495,7 +511,7 @@ static void ggtt_node_remove_work_func(struct work_struct *work) struct xe_device *xe = tile_to_xe(node->ggtt->tile); guard(xe_pm_runtime)(xe); - ggtt_node_remove(node); + ggtt_node_remove(node, true); } /** @@ -517,7 +533,7 @@ void xe_ggtt_node_remove(struct xe_ggtt_node *node, bool invalidate) node->invalidate_on_remove = invalidate; if (xe_pm_runtime_get_if_active(xe)) { - ggtt_node_remove(node); + ggtt_node_remove(node, true); xe_pm_runtime_put(xe); } else { queue_work(ggtt->wq, &node->delayed_removal_work); diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h index 15e62ecec2287..7cd8b45ed5cd8 100644 --- a/drivers/gpu/drm/xe/xe_ggtt.h +++ b/drivers/gpu/drm/xe/xe_ggtt.h @@ -32,6 +32,7 @@ xe_ggtt_insert_node_transform(struct xe_ggtt *ggtt, u64 size, u32 align, xe_ggtt_transform_cb transform, void *arg); void xe_ggtt_node_remove(struct xe_ggtt_node *node, bool invalidate); +void xe_ggtt_node_remove_noclear(struct xe_ggtt_node *node); size_t xe_ggtt_node_pt_size(const struct xe_ggtt_node *node); void xe_ggtt_map_bo_unlocked(struct xe_ggtt *ggtt, struct xe_bo *bo); int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo, struct drm_exec *exec); -- 2.53.0