From: Matthew Brost <matthew.brost@intel.com>
To: Maarten Lankhorst <dev@lankhorst.se>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH 10/10] drm/xe: Do not rely on GGTT internals in xe_guc_buf kunit tests
Date: Thu, 5 Jun 2025 08:12:03 -0700 [thread overview]
Message-ID: <aEGzw/Rl96CX9tLH@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250505121924.921544-11-dev@lankhorst.se>
On Mon, May 05, 2025 at 02:19:23PM +0200, Maarten Lankhorst wrote:
> Add a function to init ggtt for kunit, and use the GGTT function for
> initialising the GGTT node without populating it. This
> prevents the test from ever knowing about struct xe_ggtt.
>
> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c | 11 +++++-----
> drivers/gpu/drm/xe/xe_ggtt.c | 23 ++++++++++++++++-----
> drivers/gpu/drm/xe/xe_ggtt.h | 1 +
> 3 files changed, 24 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c b/drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c
> index 6faffcd748694..537766cdd882e 100644
> --- a/drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c
> +++ b/drivers/gpu/drm/xe/tests/xe_guc_buf_kunit.c
> @@ -42,10 +42,8 @@ static struct xe_bo *replacement_xe_managed_bo_create_pin_map(struct xe_device *
> KUNIT_ASSERT_NOT_ERR_OR_NULL(test, bo->ggtt_node[tile->id]);
>
> KUNIT_ASSERT_EQ(test, 0,
> - drm_mm_insert_node_in_range(&ggtt->mm,
> - &bo->ggtt_node[tile->id]->base,
> - bo->size, SZ_4K,
> - 0, 0, U64_MAX, 0));
> + xe_ggtt_node_insert(bo->ggtt_node[tile->id],
> + bo->size, SZ_4K));
> }
>
> return bo;
> @@ -67,8 +65,9 @@ static int guc_buf_test_init(struct kunit *test)
> ggtt = xe_device_get_root_tile(test->priv)->mem.ggtt;
> guc = &xe_device_get_gt(test->priv, 0)->uc.guc;
>
> - drm_mm_init(&ggtt->mm, DUT_GGTT_START, DUT_GGTT_SIZE);
> - mutex_init(&ggtt->lock);
> + KUNIT_ASSERT_EQ(test, 0,
> + xe_ggtt_init_kunit(ggtt, DUT_GGTT_START,
> + DUT_GGTT_START + DUT_GGTT_SIZE));
>
> kunit_activate_static_stub(test, xe_managed_bo_create_pin_map,
> replacement_xe_managed_bo_create_pin_map);
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 2316f3a74d9c3..d019466649881 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -5,6 +5,7 @@
>
> #include "xe_ggtt.h"
>
> +#include <kunit/visibility.h>
> #include <linux/fault-inject.h>
> #include <linux/io-64-nonatomic-lo-hi.h>
> #include <linux/sizes.h>
> @@ -221,6 +222,22 @@ static const struct xe_ggtt_pt_ops xelpg_pt_wa_ops = {
> .ggtt_set_pte = xe_ggtt_set_pte_and_flush,
> };
>
> +static void __xe_ggtt_init_early(struct xe_ggtt *ggtt, u32 reserved)
> +{
> + drm_mm_init(&ggtt->mm, reserved,
> + ggtt->size - reserved);
> + mutex_init(&ggtt->lock);
> + primelockdep(ggtt);
> +}
> +
> +int xe_ggtt_init_kunit(struct xe_ggtt *ggtt, u32 reserved, u32 size)
> +{
> + ggtt->size = size;
> + __xe_ggtt_init_early(ggtt, reserved);
> + return 0;
> +}
> +EXPORT_SYMBOL_IF_KUNIT(xe_ggtt_init_kunit);
> +
> /**
> * xe_ggtt_init_early - Early GGTT initialization
> * @ggtt: the &xe_ggtt to be initialized
> @@ -267,11 +284,7 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
> ggtt->pt_ops = &xelp_pt_ops;
>
> ggtt->wq = alloc_workqueue("xe-ggtt-wq", 0, WQ_MEM_RECLAIM);
> -
> - drm_mm_init(&ggtt->mm, xe_wopcm_size(xe),
> - ggtt->size - xe_wopcm_size(xe));
> - mutex_init(&ggtt->lock);
> - primelockdep(ggtt);
> + __xe_ggtt_init_early(ggtt, xe_wopcm_size(xe));
>
> err = drmm_add_action_or_reset(&xe->drm, ggtt_fini_early, ggtt);
> if (err)
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 600a76526cf34..9a11872e16d80 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -13,6 +13,7 @@ struct xe_tile;
>
> struct xe_ggtt *xe_ggtt_alloc(struct xe_tile *tile);
> int xe_ggtt_init_early(struct xe_ggtt *ggtt);
> +int xe_ggtt_init_kunit(struct xe_ggtt *ggtt, u32 reserved, u32 size);
> int xe_ggtt_init(struct xe_ggtt *ggtt);
>
> struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt);
> --
> 2.45.2
>
next prev parent reply other threads:[~2025-06-05 15:10 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 12:19 [PATCH 00/10] drm/xe/ggtt: Stop relying on GGTT internals Maarten Lankhorst
2025-05-05 12:19 ` [PATCH 01/10] drm/xe: Use xe_ggtt_map_bo_unlocked for resume Maarten Lankhorst
2025-05-05 12:19 ` [PATCH 02/10] drm/xe: Add xe_ggtt_might_lock Maarten Lankhorst
2025-05-05 12:19 ` [PATCH 03/10] drm/xe: Add xe_ggtt_alloc Maarten Lankhorst
2025-05-05 12:19 ` [PATCH 04/10] drm/xe/display: Remove dereferences of ggtt for tile id Maarten Lankhorst
2025-05-12 22:51 ` Matthew Brost
2025-05-05 12:19 ` [PATCH 05/10] drm/xe/ggtt: Seperate flags and address in PTE encoding Maarten Lankhorst
2025-06-05 15:10 ` Matthew Brost
2025-06-05 16:57 ` Maarten Lankhorst
2025-06-05 18:30 ` Matthew Brost
2025-05-05 12:19 ` [PATCH 06/10] drm/xe/display: Dont poke into GGTT internals to fill a DPT Maarten Lankhorst
2025-05-20 13:06 ` Juha-Pekka Heikkilä
2025-05-05 12:19 ` [PATCH 07/10] drm/xe/display: Convert GGTT mapping to use pte_encode_flags Maarten Lankhorst
2025-05-20 13:20 ` Juha-Pekka Heikkilä
2025-05-05 12:19 ` [PATCH 08/10] drm/xe: Remove pte_encode_bo callback Maarten Lankhorst
2025-05-20 13:23 ` Juha-Pekka Heikkilä
2025-05-05 12:19 ` [PATCH 09/10] drm/xe: Implement a helper for reading out a GGTT PTE at a specified offset Maarten Lankhorst
2025-05-20 13:28 ` Juha-Pekka Heikkilä
2025-05-05 12:19 ` [PATCH 10/10] drm/xe: Do not rely on GGTT internals in xe_guc_buf kunit tests Maarten Lankhorst
2025-06-05 15:12 ` Matthew Brost [this message]
2025-05-06 21:48 ` ✓ CI.Patch_applied: success for drm/xe/ggtt: Stop relying on GGTT internals. (rev2) Patchwork
2025-05-06 21:48 ` ✗ CI.checkpatch: warning " Patchwork
2025-05-06 21:49 ` ✓ CI.KUnit: success " Patchwork
2025-05-06 21:58 ` ✓ CI.Build: " Patchwork
2025-05-06 22:00 ` ✓ CI.Hooks: " Patchwork
2025-05-06 22:01 ` ✓ CI.checksparse: " Patchwork
2025-05-06 22:27 ` ✓ Xe.CI.BAT: " Patchwork
2025-05-07 1:52 ` ✗ Xe.CI.Full: failure " Patchwork
2025-05-26 16:29 ` ✓ CI.Patch_applied: success " Patchwork
2025-05-26 16:29 ` ✗ CI.checkpatch: warning " Patchwork
2025-05-26 16:30 ` ✓ CI.KUnit: success " Patchwork
2025-05-26 16:41 ` ✓ CI.Build: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aEGzw/Rl96CX9tLH@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=dev@lankhorst.se \
--cc=intel-xe@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.