From: Matthew Brost <matthew.brost@intel.com>
To: Maarten Lankhorst <dev@lankhorst.se>
Cc: <intel-xe@lists.freedesktop.org>, Tomasz Lis <tomasz.lis@intel.com>
Subject: Re: [PATCH v3 2/6] drm/mm: Introduce address space shifting
Date: Wed, 8 Oct 2025 14:58:11 -0700 [thread overview]
Message-ID: <aObec3FqsasCQfbU@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20250819101119.511705-10-dev@lankhorst.se>
On Tue, Aug 19, 2025 at 12:11:20PM +0200, Maarten Lankhorst wrote:
> From: Tomasz Lis <tomasz.lis@intel.com>
>
> Due to resource reprovisioning, sometimes a need arises to move
> a living address space to a new area, preserving all the nodes
> and holes stored within.
>
> It is possible to do that by removing all nodes to a temporary list,
> reiniting the drm_mm instance and re-adding everything while applying
> a shift to each node. But that is a lot of extra work for a task
> which could be done internally without any node shuffle operations.
>
> This change introduces an interface which allows to shift the range
> without pruning the whole drm_mm instance.
>
> Having a drm_mm interface for such shift significantly simplifies
> the code required to adjust a KMD for a change in base address
> of a space managed by drm_mm instance.
>
> Signed-off-by: Tomasz Lis <tomasz.lis@intel.com>
> Link: https://lore.kernel.org/r/20250204224136.3183710-2-tomasz.lis@intel.com
> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/drm_mm.c | 24 ++++++++++++++++++++++++
> include/drm/drm_mm.h | 1 +
> 2 files changed, 25 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
> index ca254611b3823..ce3bd8b5e41f0 100644
> --- a/drivers/gpu/drm/drm_mm.c
> +++ b/drivers/gpu/drm/drm_mm.c
> @@ -917,6 +917,30 @@ struct drm_mm_node *drm_mm_scan_color_evict(struct drm_mm_scan *scan)
> }
> EXPORT_SYMBOL(drm_mm_scan_color_evict);
>
> +/**
> + * drm_mm_shift - move the range of addresses managed by this @mm
> + * @mm: the drm_mm structure instance to shift
> + * @shift: the shift value to be added to addresses of all nodes
> + *
> + * The function shifts all nodes by given offset, moving the address space
> + * range managed by this @mm.
> + */
> +void drm_mm_shift(struct drm_mm *mm, s64 shift)
> +{
> + struct drm_mm_node *node;
> +
> + /*
> + * Head node represents a hole, with negative size and start at the end
> + * of addressable area. This means it is never present within nodes
> + * list - needs to be shifted separately.
> + */
> + mm->head_node.start += shift;
> +
> + drm_mm_for_each_node(node, mm)
> + node->start += shift;
> +}
> +EXPORT_SYMBOL(drm_mm_shift);
> +
> /**
> * drm_mm_init - initialize a drm-mm allocator
> * @mm: the drm_mm structure to initialize
> diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
> index f654874c4ce67..798e5a4f07add 100644
> --- a/include/drm/drm_mm.h
> +++ b/include/drm/drm_mm.h
> @@ -465,6 +465,7 @@ static inline int drm_mm_insert_node(struct drm_mm *mm,
> void drm_mm_remove_node(struct drm_mm_node *node);
> void drm_mm_init(struct drm_mm *mm, u64 start, u64 size);
> void drm_mm_takedown(struct drm_mm *mm);
> +void drm_mm_shift(struct drm_mm *mm, s64 shift);
>
> /**
> * drm_mm_clean - checks whether an allocator is clean
> --
> 2.50.0
>
next prev parent reply other threads:[~2025-10-08 21:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-19 10:11 [PATCH v3 0/6] drm/xe: Make struct xe_ggtt private Maarten Lankhorst
2025-08-19 10:11 ` [PATCH v3 1/6] drm/xe: Only have a single drmm release action Maarten Lankhorst
2025-08-22 20:25 ` Rodrigo Vivi
2025-08-22 20:38 ` Michal Wajdeczko
2025-08-19 10:11 ` [PATCH v3 2/6] drm/mm: Introduce address space shifting Maarten Lankhorst
2025-10-08 21:58 ` Matthew Brost [this message]
2025-08-19 10:11 ` [PATCH v3 3/6] drm/xe: Start using ggtt->start in preparation of balloon removal Maarten Lankhorst
2025-08-19 10:11 ` [PATCH v3 4/6] drm/xe: Rewrite GGTT VF initialisation Maarten Lankhorst
2025-10-08 22:00 ` Matthew Brost
2025-08-19 10:11 ` [PATCH v3 5/6] drm/xe: Convert xe_fb_pin to use a callback for insertion into GGTT Maarten Lankhorst
2025-08-19 10:11 ` [PATCH v3 6/6] drm/xe: Move struct xe_ggtt to xe_ggtt.c Maarten Lankhorst
2025-08-19 14:29 ` ✗ CI.checkpatch: warning for drm/xe: Make struct xe_ggtt private. (rev3) Patchwork
2025-08-19 14:30 ` ✓ CI.KUnit: success " Patchwork
2025-08-19 14:45 ` ✗ CI.checksparse: warning " Patchwork
2025-08-19 15:37 ` ✓ Xe.CI.BAT: success " Patchwork
2025-08-20 10:06 ` ✗ Xe.CI.Full: failure " 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=aObec3FqsasCQfbU@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=dev@lankhorst.se \
--cc=intel-xe@lists.freedesktop.org \
--cc=tomasz.lis@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox