Unverified Commit 6062ea93 authored by Rodrigo Vivi's avatar Rodrigo Vivi
Browse files

drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node



The xe_ggtt component uses drm_mm to manage the GGTT.
The drm_mm_node is just a node inside drm_mm, but in Xe we use that
only in the GGTT context. So, this patch encapsulates the drm_mm_node
into a xe_ggtt's new struct.

This is the first step towards limiting all the drm_mm access
through xe_ggtt. The ultimate goal is to have a better control of
the node insertion and removal, so the removal can be delegated
to a delayed workqueue.

v2: Fix includes and typos (Michal and Brost)

Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240821193842.352557-5-rodrigo.vivi@intel.com


Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 6dbd43dc
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -7,7 +7,8 @@
#define I915_VMA_H

#include <uapi/drm/i915_drm.h>
#include <drm/drm_mm.h>

#include "xe_ggtt_types.h"

/* We don't want these from i915_drm.h in case of Xe */
#undef I915_TILING_X
@@ -19,7 +20,7 @@ struct xe_bo;

struct i915_vma {
	struct xe_bo *bo, *dpt;
	struct drm_mm_node node;
	struct xe_ggtt_node node;
};

#define i915_ggtt_clear_scanout(bo) do { } while (0)
@@ -28,7 +29,7 @@ struct i915_vma {

static inline u32 i915_ggtt_offset(const struct i915_vma *vma)
{
	return vma->node.start;
	return vma->node.base.start;
}

#endif
+5 −5
Original line number Diff line number Diff line
@@ -204,7 +204,7 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
	if (xe_bo_is_vram(bo) && ggtt->flags & XE_GGTT_FLAGS_64K)
		align = max_t(u32, align, SZ_64K);

	if (bo->ggtt_node.size && view->type == I915_GTT_VIEW_NORMAL) {
	if (bo->ggtt_node.base.size && view->type == I915_GTT_VIEW_NORMAL) {
		vma->node = bo->ggtt_node;
	} else if (view->type == I915_GTT_VIEW_NORMAL) {
		u32 x, size = bo->ttm.base.size;
@@ -218,7 +218,7 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
			u64 pte = ggtt->pt_ops->pte_encode_bo(bo, x,
							      xe->pat.idx[XE_CACHE_NONE]);

			ggtt->pt_ops->ggtt_set_pte(ggtt, vma->node.start + x, pte);
			ggtt->pt_ops->ggtt_set_pte(ggtt, vma->node.base.start + x, pte);
		}
	} else {
		u32 i, ggtt_ofs;
@@ -232,7 +232,7 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
		if (ret)
			goto out_unlock;

		ggtt_ofs = vma->node.start;
		ggtt_ofs = vma->node.base.start;

		for (i = 0; i < ARRAY_SIZE(rot_info->plane); i++)
			write_ggtt_rotated(bo, ggtt, &ggtt_ofs,
@@ -325,8 +325,8 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)

	if (vma->dpt)
		xe_bo_unpin_map_no_vm(vma->dpt);
	else if (!drm_mm_node_allocated(&vma->bo->ggtt_node) ||
		 vma->bo->ggtt_node.start != vma->node.start)
	else if (!drm_mm_node_allocated(&vma->bo->ggtt_node.base) ||
		 vma->bo->ggtt_node.base.start != vma->node.base.start)
		xe_ggtt_remove_node(ggtt, &vma->node, false);

	ttm_bo_reserve(&vma->bo->ttm, false, false, NULL);
+1 −1
Original line number Diff line number Diff line
@@ -1120,7 +1120,7 @@ static void xe_ttm_bo_destroy(struct ttm_buffer_object *ttm_bo)

	xe_assert(xe, list_empty(&ttm_bo->base.gpuva.list));

	if (bo->ggtt_node.size)
	if (bo->ggtt_node.base.size)
		xe_ggtt_remove_bo(bo->tile->mem.ggtt, bo);

#ifdef CONFIG_PROC_FS
+3 −3
Original line number Diff line number Diff line
@@ -194,9 +194,9 @@ xe_bo_main_addr(struct xe_bo *bo, size_t page_size)
static inline u32
xe_bo_ggtt_addr(struct xe_bo *bo)
{
	XE_WARN_ON(bo->ggtt_node.size > bo->size);
	XE_WARN_ON(bo->ggtt_node.start + bo->ggtt_node.size > (1ull << 32));
	return bo->ggtt_node.start;
	XE_WARN_ON(bo->ggtt_node.base.size > bo->size);
	XE_WARN_ON(bo->ggtt_node.base.start + bo->ggtt_node.base.size > (1ull << 32));
	return bo->ggtt_node.base.start;
}

int xe_bo_vmap(struct xe_bo *bo);
+3 −2
Original line number Diff line number Diff line
@@ -8,12 +8,13 @@

#include <linux/iosys-map.h>

#include <drm/drm_mm.h>
#include <drm/ttm/ttm_bo.h>
#include <drm/ttm/ttm_device.h>
#include <drm/ttm/ttm_execbuf_util.h>
#include <drm/ttm/ttm_placement.h>

#include "xe_ggtt_types.h"

struct xe_device;
struct xe_vm;

@@ -39,7 +40,7 @@ struct xe_bo {
	/** @placement: current placement for this BO */
	struct ttm_placement placement;
	/** @ggtt_node: GGTT node if this BO is mapped in the GGTT */
	struct drm_mm_node ggtt_node;
	struct xe_ggtt_node ggtt_node;
	/** @vmap: iosys map of this buffer */
	struct iosys_map vmap;
	/** @ttm_kmap: TTM bo kmap object for internal use only. Keep off. */
Loading