* [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk
@ 2024-07-11 17:11 Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 02/12] drm/xe: Introduce GGTT documentation Rodrigo Vivi
` (14 more replies)
0 siblings, 15 replies; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe; +Cc: Rodrigo Vivi, Himal Prasad Ghimiray
Apparently this was only useful when enabling ggtt support
for the very first time and never used again.
It is also not useful now that we have the ggtt_dump available
through debugfs.
Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 20 --------------------
drivers/gpu/drm/xe/xe_ggtt.h | 1 -
2 files changed, 21 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 0cdbc1296e88..add14f3dea1f 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -314,26 +314,6 @@ static void xe_ggtt_invalidate(struct xe_ggtt *ggtt)
ggtt_invalidate_gt_tlb(ggtt->tile->media_gt);
}
-void xe_ggtt_printk(struct xe_ggtt *ggtt, const char *prefix)
-{
- u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[XE_CACHE_WB];
- u64 addr, scratch_pte;
-
- scratch_pte = ggtt->pt_ops->pte_encode_bo(ggtt->scratch, 0, pat_index);
-
- printk("%sGlobal GTT:", prefix);
- for (addr = 0; addr < ggtt->size; addr += XE_PAGE_SIZE) {
- unsigned int i = addr / XE_PAGE_SIZE;
-
- xe_tile_assert(ggtt->tile, addr <= U32_MAX);
- if (ggtt->gsm[i] == scratch_pte)
- continue;
-
- printk("%s ggtt[0x%08x] = 0x%016llx",
- prefix, (u32)addr, ggtt->gsm[i]);
- }
-}
-
static void xe_ggtt_dump_node(struct xe_ggtt *ggtt,
const struct drm_mm_node *node, const char *description)
{
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 6a96fd54bf60..2546bab97507 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -12,7 +12,6 @@ struct drm_printer;
int xe_ggtt_init_early(struct xe_ggtt *ggtt);
int xe_ggtt_init(struct xe_ggtt *ggtt);
-void xe_ggtt_printk(struct xe_ggtt *ggtt, const char *prefix);
int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct drm_mm_node *node);
void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node);
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 02/12] drm/xe: Introduce GGTT documentation
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-11 19:41 ` Michal Wajdeczko
2024-07-11 17:11 ` [PATCH 03/12] drm/xe: Remove unnecessary drm_mm.h includes Rodrigo Vivi
` (13 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe
Cc: Rodrigo Vivi, Matthew Brost, Michal Wajdeczko,
Himal Prasad Ghimiray
Document xe_ggtt and ensure it is part of the built kernel docs.
v2: - Accepted all Michal's suggestions
- Rebased on top of new set_pte per platform/wa function pointer
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com> #v1
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
Documentation/gpu/xe/xe_mm.rst | 15 ++++
drivers/gpu/drm/xe/xe_ggtt.c | 136 +++++++++++++++++++++++------
drivers/gpu/drm/xe/xe_ggtt_types.h | 32 +++++--
3 files changed, 148 insertions(+), 35 deletions(-)
diff --git a/Documentation/gpu/xe/xe_mm.rst b/Documentation/gpu/xe/xe_mm.rst
index 6c8fd8b4a466..95864a4502dd 100644
--- a/Documentation/gpu/xe/xe_mm.rst
+++ b/Documentation/gpu/xe/xe_mm.rst
@@ -7,6 +7,21 @@ Memory Management
.. kernel-doc:: drivers/gpu/drm/xe/xe_bo_doc.h
:doc: Buffer Objects (BO)
+GGTT
+====
+
+.. kernel-doc:: drivers/gpu/drm/xe/xe_ggtt.c
+ :doc: Global Graphics Translation Table (GGTT)
+
+GGTT Internal API
+-----------------
+
+.. kernel-doc:: drivers/gpu/drm/xe/xe_ggtt_types.h
+ :internal:
+
+.. kernel-doc:: drivers/gpu/drm/xe/xe_ggtt.c
+ :internal:
+
Pagetable building
==================
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index add14f3dea1f..709ef48f2fdb 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -30,6 +30,39 @@
#include "xe_wa.h"
#include "xe_wopcm.h"
+/**
+ * DOC: Global Graphics Translation Table (GGTT)
+ *
+ * Xe GGTT implements the support for a Global Virtual Address space that is used
+ * for resources that are accessible to privileged (i.e. kernel-mode) processes,
+ * and not tied to a specific user-level process. For example, the Graphics
+ * micro-Controller (GuC) and Display Engine (if present) utilize this Global
+ * address space.
+ *
+ * The Global GTT (GGTT) translates from the Global virtual address to a physical
+ * address that can be accessed by HW. The GGTT is a flat, single-level table.
+ *
+ * Xe implements a simplified version of the GGTT specifically managing only a
+ * certain range of it that goes from the WOPCM (Write-Once Power Control Module)
+ * to a predefined GUC_GGTT_TOP. This approach avoids complications related to
+ * the GuC (Graphics Microcontroller) hardware limitations. The GuC address space
+ * is limited on both ends of the GGTT, because the GuC shim HW redirects
+ * accesses to those addresses to other HW areas instead of going through the
+ * GGTT. On the bottom end, the GuC can't access offsets below the WOPCM size,
+ * while on the top side the limit is fixed at GUC_GGTT_TOP. To keep things
+ * simple, instead of checking each object to see if they are accessed by GuC or
+ * not, we just exclude those areas from the allocator. Additionally, to simplify
+ * the driver load, we use the maximum WOPCM size in this logic instead of the
+ * programmed one, so we don't need to wait until the actual size to be
+ * programmed is determined (which requires FW fetch) before initializing the
+ * GGTT. These simplifications might waste space in the GGTT (about 20-25 MBs
+ * depending on the platform) but we can live with this. Another benifit of this
+ * is the GuC bootrom can't access anything below the WOPCM max size so anything
+ * the bootom needs to access (e.g. a RSA key) needs to be placed in the GGTT
+ * above the WOPCM max size. Starting the GGTT allocations above the WOPCM max
+ * give us the correct placement for free.
+ */
+
static u64 xelp_ggtt_pte_encode_bo(struct xe_bo *bo, u64 bo_offset,
u16 pat_index)
{
@@ -164,12 +197,16 @@ static const struct xe_ggtt_pt_ops xelpg_pt_wa_ops = {
.ggtt_set_pte = xe_ggtt_set_pte_and_flush,
};
-/*
- * Early GGTT initialization, which allows to create new mappings usable by the
- * GuC.
- * Mappings are not usable by the HW engines, as it doesn't have scratch /
+/**
+ * xe_ggtt_init_early - Early GGTT initialization
+ * @ggtt: the &xe_ggtt to be initialized
+ *
+ * It allows to create new mappings usable by the GuC.
+ * Mappings are not usable by the HW engines, as it doesn't have scratch nor
* initial clear done to it yet. That will happen in the regular, non-early
- * GGTT init.
+ * GGTT initialization.
+ *
+ * Return: 0 on success or a negative error code on failure.
*/
int xe_ggtt_init_early(struct xe_ggtt *ggtt)
{
@@ -194,29 +231,6 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
if (IS_DGFX(xe) && xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K)
ggtt->flags |= XE_GGTT_FLAGS_64K;
- /*
- * 8B per entry, each points to a 4KB page.
- *
- * The GuC address space is limited on both ends of the GGTT, because
- * the GuC shim HW redirects accesses to those addresses to other HW
- * areas instead of going through the GGTT. On the bottom end, the GuC
- * can't access offsets below the WOPCM size, while on the top side the
- * limit is fixed at GUC_GGTT_TOP. To keep things simple, instead of
- * checking each object to see if they are accessed by GuC or not, we
- * just exclude those areas from the allocator. Additionally, to
- * simplify the driver load, we use the maximum WOPCM size in this logic
- * instead of the programmed one, so we don't need to wait until the
- * actual size to be programmed is determined (which requires FW fetch)
- * before initializing the GGTT. These simplifications might waste space
- * in the GGTT (about 20-25 MBs depending on the platform) but we can
- * live with this.
- *
- * Another benifit of this is the GuC bootrom can't access anything
- * below the WOPCM max size so anything the bootom needs to access (e.g.
- * a RSA key) needs to be placed in the GGTT above the WOPCM max size.
- * Starting the GGTT allocations above the WOPCM max give us the correct
- * placement for free.
- */
if (ggtt->size > GUC_GGTT_TOP)
ggtt->size = GUC_GGTT_TOP;
@@ -262,6 +276,12 @@ static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt)
mutex_unlock(&ggtt->lock);
}
+/**
+ * xe_ggtt_init - Regular non-early GGTT initialization
+ * @ggtt: the &xe_ggtt to be initialized
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
int xe_ggtt_init(struct xe_ggtt *ggtt)
{
struct xe_device *xe = tile_to_xe(ggtt->tile);
@@ -382,6 +402,18 @@ void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node)
mutex_unlock(&ggtt->lock);
}
+/**
+ * xe_ggtt_insert_special_node_locked - Locked version to insert a &drm_mm_node into the GGTT
+ * @ggtt: the &xe_ggtt where node will be inserted
+ * @node: the &drm_mm_node to be inserted
+ * @size: size of the node
+ * @align: alignment constrain of the node
+ * @mm_flags: flags to control the node behavior
+ *
+ * To be used in cases where ggtt->lock is already taken.
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct drm_mm_node *node,
u32 size, u32 align, u32 mm_flags)
{
@@ -389,6 +421,15 @@ int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct drm_mm_node
mm_flags);
}
+/**
+ * xe_ggtt_insert_special_node - Insert a &drm_mm_node into the GGTT
+ * @ggtt: the &xe_ggtt where node will be inserted
+ * @node: the &drm_mm_node to be inserted
+ * @size: size of the node
+ * @align: alignment constrain of the node
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
u32 size, u32 align)
{
@@ -402,6 +443,11 @@ int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
return ret;
}
+/**
+ * xe_ggtt_map_bo - Map the BO into GGTT
+ * @ggtt: the &xe_ggtt where node will be mapped
+ * @bo: the &xe_bo to be mapped
+ */
void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
{
u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
@@ -449,17 +495,39 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
return err;
}
+/**
+ * xe_ggtt_insert_bo_at - Insert BO at a specific GGTT space
+ * @ggtt: the &xe_ggtt where bo will be inserted
+ * @bo: the &xe_bo to be inserted
+ * @start: address where it will be inserted
+ * @end: end of the range where it will be inserted
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u64 start, u64 end)
{
return __xe_ggtt_insert_bo_at(ggtt, bo, start, end);
}
+/**
+ * xe_ggtt_insert_bo - Insert BO into GGTT
+ * @ggtt: the &xe_ggtt where bo will be inserted
+ * @bo: the &xe_bo to be inserted
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
{
return __xe_ggtt_insert_bo_at(ggtt, bo, 0, U64_MAX);
}
+/**
+ * xe_ggtt_remove_node - Remove a &drm_mm_node from the GGTT
+ * @ggtt: the &xe_ggtt where node will be removed
+ * @node: the &drm_mm_node to be removed
+ * @invalidate: if node needs invalidation upon removal
+ */
void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
bool invalidate)
{
@@ -488,6 +556,11 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
drm_dev_exit(idx);
}
+/**
+ * xe_ggtt_remove_bo - Remove a BO from the GGTT
+ * @ggtt: the &xe_ggtt where node will be removed
+ * @bo: the &xe_bo to be removed
+ */
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
{
if (XE_WARN_ON(!bo->ggtt_node.size))
@@ -544,6 +617,13 @@ void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vf
}
#endif
+/**
+ * xe_ggtt_dump - Dump GGTT for debug
+ * @ggtt: the &xe_ggtt to be dumped
+ * @p: the &drm_mm_printer helper handle to be used to dump the information
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p)
{
int err;
diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
index 2245d88d8f39..4e2114201b35 100644
--- a/drivers/gpu/drm/xe/xe_ggtt_types.h
+++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
@@ -13,30 +13,48 @@
struct xe_bo;
struct xe_gt;
+/**
+ * struct xe_ggtt - Main GGTT struct
+ * In general, each tile can contains its own GGTT instance.
+ */
struct xe_ggtt {
+ /** @tile: Back pointer to tile where this GGTT belongs */
struct xe_tile *tile;
-
+ /** @size: Total size of this GGTT */
u64 size;
#define XE_GGTT_FLAGS_64K BIT(0)
+ /**
+ * @flags: Flags for this GGTT
+ * Acceptable flags:
+ * - %XE_GGTT_FLAGS_64K - if PTE size is 64K. Otherwise, regular is 4K.
+ */
unsigned int flags;
-
+ /** @scratch: Internal object allocation used as a scratch page */
struct xe_bo *scratch;
-
+ /** @lock: Mutex lock to protect GGTT data */
struct mutex lock;
-
+ /**
+ * @gsm: The iomem pointer to the actual location of the translation
+ * table located in the GSM for easy PTE manipulation
+ */
u64 __iomem *gsm;
-
+ /** @pt_ops: Page Table operations per platform */
const struct xe_ggtt_pt_ops *pt_ops;
-
+ /** @mm: The memory manager used to manage individual GGTT allocations */
struct drm_mm mm;
-
/** @access_count: counts GGTT writes */
unsigned int access_count;
};
+/**
+ * struct xe_ggtt_pt_ops - GGTT Page table operations
+ * Which can vary from platform to platform.
+ */
struct xe_ggtt_pt_ops {
+ /** @pte_encode_bo: Encode PTE address for a given BO */
u64 (*pte_encode_bo)(struct xe_bo *bo, u64 bo_offset, u16 pat_index);
+ /** @ggtt_set_pte: Directly write into GGTT's PTE */
void (*ggtt_set_pte)(struct xe_ggtt *ggtt, u64 addr, u64 pte);
};
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 03/12] drm/xe: Remove unnecessary drm_mm.h includes
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 02/12] drm/xe: Introduce GGTT documentation Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-11 18:35 ` Cavitt, Jonathan
2024-07-11 17:11 ` [PATCH 04/12] drm/{i915, xe}: Avoid direct inspection of dpt_vma from outside dpt Rodrigo Vivi
` (12 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe; +Cc: Rodrigo Vivi
These includes are no longer necessary, and where appropriate
replace by the linux/types.h one.
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_migrate.h | 2 +-
drivers/gpu/drm/xe/xe_res_cursor.h | 1 -
drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 1 -
3 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_migrate.h b/drivers/gpu/drm/xe/xe_migrate.h
index 453e0ecf5034..f2af9355c051 100644
--- a/drivers/gpu/drm/xe/xe_migrate.h
+++ b/drivers/gpu/drm/xe/xe_migrate.h
@@ -6,7 +6,7 @@
#ifndef _XE_MIGRATE_
#define _XE_MIGRATE_
-#include <drm/drm_mm.h>
+#include <linux/types.h>
struct dma_fence;
struct iosys_map;
diff --git a/drivers/gpu/drm/xe/xe_res_cursor.h b/drivers/gpu/drm/xe/xe_res_cursor.h
index 655af89b31a9..dca374b6521c 100644
--- a/drivers/gpu/drm/xe/xe_res_cursor.h
+++ b/drivers/gpu/drm/xe/xe_res_cursor.h
@@ -26,7 +26,6 @@
#include <linux/scatterlist.h>
-#include <drm/drm_mm.h>
#include <drm/ttm/ttm_placement.h>
#include <drm/ttm/ttm_range_manager.h>
#include <drm/ttm/ttm_resource.h>
diff --git a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
index f46fd2df84de..f7113cf6109d 100644
--- a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
+++ b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
@@ -5,7 +5,6 @@
*/
#include <drm/drm_managed.h>
-#include <drm/drm_mm.h>
#include <drm/ttm/ttm_device.h>
#include <drm/ttm/ttm_placement.h>
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 04/12] drm/{i915, xe}: Avoid direct inspection of dpt_vma from outside dpt
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 02/12] drm/xe: Introduce GGTT documentation Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 03/12] drm/xe: Remove unnecessary drm_mm.h includes Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-11 18:38 ` Cavitt, Jonathan
2024-07-11 17:11 ` [PATCH 05/12] drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node Rodrigo Vivi
` (11 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe
Cc: Rodrigo Vivi, Matthew Brost, Maarten Lankhorst,
Juha-Pekka Heikkila
DPT code is so dependent on i915 vma implementation and it is not
ported yet to Xe.
This patch limits inspection to DPT's VMA struct to intel_dpt
component only, so the Xe GGTT code can evolve.
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/i915/display/intel_dpt.c | 4 ++++
drivers/gpu/drm/i915/display/intel_dpt.h | 1 +
drivers/gpu/drm/i915/display/skl_universal_plane.c | 3 ++-
drivers/gpu/drm/xe/display/xe_fb_pin.c | 9 +++++++--
4 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_dpt.c b/drivers/gpu/drm/i915/display/intel_dpt.c
index 73a1918e2537..3a6d99044828 100644
--- a/drivers/gpu/drm/i915/display/intel_dpt.c
+++ b/drivers/gpu/drm/i915/display/intel_dpt.c
@@ -317,3 +317,7 @@ void intel_dpt_destroy(struct i915_address_space *vm)
i915_vm_put(&dpt->vm);
}
+u64 intel_dpt_offset(struct i915_vma *dpt_vma)
+{
+ return dpt_vma->node.start;
+}
diff --git a/drivers/gpu/drm/i915/display/intel_dpt.h b/drivers/gpu/drm/i915/display/intel_dpt.h
index ff18a525bfbe..7336e905142d 100644
--- a/drivers/gpu/drm/i915/display/intel_dpt.h
+++ b/drivers/gpu/drm/i915/display/intel_dpt.h
@@ -20,5 +20,6 @@ void intel_dpt_suspend(struct drm_i915_private *i915);
void intel_dpt_resume(struct drm_i915_private *i915);
struct i915_address_space *
intel_dpt_create(struct intel_framebuffer *fb);
+u64 intel_dpt_offset(struct i915_vma *dpt_vma);
#endif /* __INTEL_DPT_H__ */
diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
index ba5a628b4757..1cf1d5c8b9dc 100644
--- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
+++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
@@ -14,6 +14,7 @@
#include "intel_de.h"
#include "intel_display_irq.h"
#include "intel_display_types.h"
+#include "intel_dpt.h"
#include "intel_fb.h"
#include "intel_fbc.h"
#include "intel_frontbuffer.h"
@@ -1162,7 +1163,7 @@ static u32 skl_surf_address(const struct intel_plane_state *plane_state,
* within the DPT is always 0.
*/
drm_WARN_ON(&i915->drm, plane_state->dpt_vma &&
- plane_state->dpt_vma->node.start);
+ intel_dpt_offset(plane_state->dpt_vma));
drm_WARN_ON(&i915->drm, offset & 0x1fffff);
return offset >> 9;
} else {
diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index d7db44e79eaf..42d431ff14e7 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -377,8 +377,8 @@ void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
}
/*
- * For Xe introduce dummy intel_dpt_create which just return NULL and
- * intel_dpt_destroy which does nothing.
+ * For Xe introduce dummy intel_dpt_create which just return NULL,
+ * intel_dpt_destroy which does nothing, and fake intel_dpt_ofsset returning 0;
*/
struct i915_address_space *intel_dpt_create(struct intel_framebuffer *fb)
{
@@ -389,3 +389,8 @@ void intel_dpt_destroy(struct i915_address_space *vm)
{
return;
}
+
+u64 intel_dpt_offset(struct i915_vma *dpt_vma)
+{
+ return 0;
+}
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 05/12] drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (2 preceding siblings ...)
2024-07-11 17:11 ` [PATCH 04/12] drm/{i915, xe}: Avoid direct inspection of dpt_vma from outside dpt Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-11 19:51 ` Michal Wajdeczko
2024-07-16 17:16 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 06/12] drm/xe: Rename xe_ggtt_node related functions Rodrigo Vivi
` (10 subsequent siblings)
14 siblings, 2 replies; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe; +Cc: Rodrigo Vivi, Matthew Brost
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 delagated
to a delayed workqueue.
Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
| 7 +-
drivers/gpu/drm/xe/display/xe_fb_pin.c | 10 +--
drivers/gpu/drm/xe/xe_bo.c | 2 +-
drivers/gpu/drm/xe/xe_bo.h | 6 +-
drivers/gpu/drm/xe/xe_bo_types.h | 5 +-
drivers/gpu/drm/xe/xe_device_types.h | 2 +-
drivers/gpu/drm/xe/xe_ggtt.c | 72 +++++++++----------
drivers/gpu/drm/xe/xe_ggtt.h | 12 ++--
drivers/gpu/drm/xe/xe_ggtt_types.h | 8 +++
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 39 +++++-----
.../gpu/drm/xe/xe_gt_sriov_pf_config_types.h | 4 +-
11 files changed, 90 insertions(+), 77 deletions(-)
--git a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
index a20d2638ea7a..97193e660f6c 100644
--- a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
+++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
@@ -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
diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index 42d431ff14e7..a93923fb8721 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -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);
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 31192d983d9e..3501a5871069 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -1090,7 +1090,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
diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
index 6de894c728f5..7c95133cc32b 100644
--- a/drivers/gpu/drm/xe/xe_bo.h
+++ b/drivers/gpu/drm/xe/xe_bo.h
@@ -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);
diff --git a/drivers/gpu/drm/xe/xe_bo_types.h b/drivers/gpu/drm/xe/xe_bo_types.h
index ebc8abf7930a..3ba96a93623c 100644
--- a/drivers/gpu/drm/xe/xe_bo_types.h
+++ b/drivers/gpu/drm/xe/xe_bo_types.h
@@ -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. */
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index f0cf9020e463..30f9c58932bb 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -203,7 +203,7 @@ struct xe_tile {
struct xe_memirq memirq;
/** @sriov.vf.ggtt_balloon: GGTT regions excluded from use. */
- struct drm_mm_node ggtt_balloon[2];
+ struct xe_ggtt_node ggtt_balloon[2];
} vf;
} sriov;
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 709ef48f2fdb..ea55c7eabee4 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -351,61 +351,61 @@ static void xe_ggtt_dump_node(struct xe_ggtt *ggtt,
* @ggtt: the &xe_ggtt where we want to make reservation
* @start: the starting GGTT address of the reserved region
* @end: then end GGTT address of the reserved region
- * @node: the &drm_mm_node to hold reserved GGTT node
+ * @node: the &xe_ggtt_node to hold reserved GGTT node
*
* Use xe_ggtt_deballoon() to release a reserved GGTT node.
*
* Return: 0 on success or a negative error code on failure.
*/
-int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct drm_mm_node *node)
+int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_node *node)
{
int err;
xe_tile_assert(ggtt->tile, start < end);
xe_tile_assert(ggtt->tile, IS_ALIGNED(start, XE_PAGE_SIZE));
xe_tile_assert(ggtt->tile, IS_ALIGNED(end, XE_PAGE_SIZE));
- xe_tile_assert(ggtt->tile, !drm_mm_node_allocated(node));
+ xe_tile_assert(ggtt->tile, !drm_mm_node_allocated(&node->base));
- node->color = 0;
- node->start = start;
- node->size = end - start;
+ node->base.color = 0;
+ node->base.start = start;
+ node->base.size = end - start;
mutex_lock(&ggtt->lock);
- err = drm_mm_reserve_node(&ggtt->mm, node);
+ err = drm_mm_reserve_node(&ggtt->mm, &node->base);
mutex_unlock(&ggtt->lock);
if (xe_gt_WARN(ggtt->tile->primary_gt, err,
"Failed to balloon GGTT %#llx-%#llx (%pe)\n",
- node->start, node->start + node->size, ERR_PTR(err)))
+ node->base.start, node->base.start + node->base.size, ERR_PTR(err)))
return err;
- xe_ggtt_dump_node(ggtt, node, "balloon");
+ xe_ggtt_dump_node(ggtt, &node->base, "balloon");
return 0;
}
/**
* xe_ggtt_deballoon - release a reserved GGTT region
* @ggtt: the &xe_ggtt where reserved node belongs
- * @node: the &drm_mm_node with reserved GGTT region
+ * @node: the &xe_ggtt_node with reserved GGTT region
*
* See xe_ggtt_balloon() for details.
*/
-void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node)
+void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
{
- if (!drm_mm_node_allocated(node))
+ if (!drm_mm_node_allocated(&node->base))
return;
- xe_ggtt_dump_node(ggtt, node, "deballoon");
+ xe_ggtt_dump_node(ggtt, &node->base, "deballoon");
mutex_lock(&ggtt->lock);
- drm_mm_remove_node(node);
+ drm_mm_remove_node(&node->base);
mutex_unlock(&ggtt->lock);
}
/**
- * xe_ggtt_insert_special_node_locked - Locked version to insert a &drm_mm_node into the GGTT
+ * xe_ggtt_insert_special_node_locked - Locked version to insert a &xe_ggtt_node into the GGTT
* @ggtt: the &xe_ggtt where node will be inserted
- * @node: the &drm_mm_node to be inserted
+ * @node: the &xe_ggtt_node to be inserted
* @size: size of the node
* @align: alignment constrain of the node
* @mm_flags: flags to control the node behavior
@@ -414,23 +414,23 @@ void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node)
*
* Return: 0 on success or a negative error code on failure.
*/
-int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct drm_mm_node *node,
+int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
u32 size, u32 align, u32 mm_flags)
{
- return drm_mm_insert_node_generic(&ggtt->mm, node, size, align, 0,
+ return drm_mm_insert_node_generic(&ggtt->mm, &node->base, size, align, 0,
mm_flags);
}
/**
- * xe_ggtt_insert_special_node - Insert a &drm_mm_node into the GGTT
+ * xe_ggtt_insert_special_node - Insert a &xe_ggtt_node into the GGTT
* @ggtt: the &xe_ggtt where node will be inserted
- * @node: the &drm_mm_node to be inserted
+ * @node: the &xe_ggtt_node to be inserted
* @size: size of the node
* @align: alignment constrain of the node
*
* Return: 0 on success or a negative error code on failure.
*/
-int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
+int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
u32 size, u32 align)
{
int ret;
@@ -452,7 +452,7 @@ void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
{
u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
- u64 start = bo->ggtt_node.start;
+ u64 start = bo->ggtt_node.base.start;
u64 offset, pte;
for (offset = 0; offset < bo->size; offset += XE_PAGE_SIZE) {
@@ -470,9 +470,9 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
if (xe_bo_is_vram(bo) && ggtt->flags & XE_GGTT_FLAGS_64K)
alignment = SZ_64K;
- if (XE_WARN_ON(bo->ggtt_node.size)) {
+ if (XE_WARN_ON(bo->ggtt_node.base.size)) {
/* Someone's already inserted this BO in the GGTT */
- xe_tile_assert(ggtt->tile, bo->ggtt_node.size == bo->size);
+ xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
return 0;
}
@@ -482,7 +482,7 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
xe_pm_runtime_get_noresume(tile_to_xe(ggtt->tile));
mutex_lock(&ggtt->lock);
- err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node, bo->size,
+ err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node.base, bo->size,
alignment, 0, start, end, 0);
if (!err)
xe_ggtt_map_bo(ggtt, bo);
@@ -523,12 +523,12 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
}
/**
- * xe_ggtt_remove_node - Remove a &drm_mm_node from the GGTT
+ * xe_ggtt_remove_node - Remove a &xe_ggtt_node from the GGTT
* @ggtt: the &xe_ggtt where node will be removed
- * @node: the &drm_mm_node to be removed
+ * @node: the &xe_ggtt_node to be removed
* @invalidate: if node needs invalidation upon removal
*/
-void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
+void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
bool invalidate)
{
struct xe_device *xe = tile_to_xe(ggtt->tile);
@@ -541,9 +541,9 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
mutex_lock(&ggtt->lock);
if (bound)
- xe_ggtt_clear(ggtt, node->start, node->size);
- drm_mm_remove_node(node);
- node->size = 0;
+ xe_ggtt_clear(ggtt, node->base.start, node->base.size);
+ drm_mm_remove_node(&node->base);
+ node->base.size = 0;
mutex_unlock(&ggtt->lock);
if (!bound)
@@ -563,11 +563,11 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
*/
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
{
- if (XE_WARN_ON(!bo->ggtt_node.size))
+ if (XE_WARN_ON(!bo->ggtt_node.base.size))
return;
/* This BO is not currently in the GGTT */
- xe_tile_assert(ggtt->tile, bo->ggtt_node.size == bo->size);
+ xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
xe_ggtt_remove_node(ggtt, &bo->ggtt_node,
bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
@@ -602,17 +602,17 @@ static void xe_ggtt_assign_locked(struct xe_ggtt *ggtt, const struct drm_mm_node
/**
* xe_ggtt_assign - assign a GGTT region to the VF
* @ggtt: the &xe_ggtt where the node belongs
- * @node: the &drm_mm_node to update
+ * @node: the &xe_ggtt_node to update
* @vfid: the VF identifier
*
* This function is used by the PF driver to assign a GGTT region to the VF.
* In addition to PTE's VFID bits 11:2 also PRESENT bit 0 is set as on some
* platforms VFs can't modify that either.
*/
-void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vfid)
+void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct xe_ggtt_node *node, u16 vfid)
{
mutex_lock(&ggtt->lock);
- xe_ggtt_assign_locked(ggtt, node, vfid);
+ xe_ggtt_assign_locked(ggtt, &node->base, vfid);
mutex_unlock(&ggtt->lock);
}
#endif
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 2546bab97507..30a521f7b075 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -13,15 +13,15 @@ struct drm_printer;
int xe_ggtt_init_early(struct xe_ggtt *ggtt);
int xe_ggtt_init(struct xe_ggtt *ggtt);
-int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct drm_mm_node *node);
-void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node);
+int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
+void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
-int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
+int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
u32 size, u32 align);
int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt,
- struct drm_mm_node *node,
+ struct xe_ggtt_node *node,
u32 size, u32 align, u32 mm_flags);
-void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
+void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
bool invalidate);
void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
@@ -32,7 +32,7 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
#ifdef CONFIG_PCI_IOV
-void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vfid);
+void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct xe_ggtt_node *node, u16 vfid);
#endif
#endif
diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
index 4e2114201b35..f3292e6c3873 100644
--- a/drivers/gpu/drm/xe/xe_ggtt_types.h
+++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
@@ -47,6 +47,14 @@ struct xe_ggtt {
unsigned int access_count;
};
+/**
+ * struct xe_ggtt_node - A node in GGTT
+ */
+struct xe_ggtt_node {
+ /** @base: A drm_mm_node */
+ struct drm_mm_node base;
+};
+
/**
* struct xe_ggtt_pt_ops - GGTT Page table operations
* Which can vary from platform to platform.
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index db6c213da847..3600468da013 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -6,6 +6,9 @@
#include <linux/string_choices.h>
#include <linux/wordpart.h>
+/* FIXME: remove this after encapsulating all drm_mm_node access into xe_ggtt */
+#include <drm/drm_mm.h>
+
#include "abi/guc_actions_sriov_abi.h"
#include "abi/guc_klvs_abi.h"
@@ -232,14 +235,14 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config)
{
u32 n = 0;
- if (drm_mm_node_allocated(&config->ggtt_region)) {
+ if (drm_mm_node_allocated(&config->ggtt_region.base)) {
cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_START);
- cfg[n++] = lower_32_bits(config->ggtt_region.start);
- cfg[n++] = upper_32_bits(config->ggtt_region.start);
+ cfg[n++] = lower_32_bits(config->ggtt_region.base.start);
+ cfg[n++] = upper_32_bits(config->ggtt_region.base.start);
cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_SIZE);
- cfg[n++] = lower_32_bits(config->ggtt_region.size);
- cfg[n++] = upper_32_bits(config->ggtt_region.size);
+ cfg[n++] = lower_32_bits(config->ggtt_region.base.size);
+ cfg[n++] = upper_32_bits(config->ggtt_region.base.size);
}
return n;
@@ -369,11 +372,11 @@ static int pf_distribute_config_ggtt(struct xe_tile *tile, unsigned int vfid, u6
return err ?: err2;
}
-static void pf_release_ggtt(struct xe_tile *tile, struct drm_mm_node *node)
+static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
{
struct xe_ggtt *ggtt = tile->mem.ggtt;
- if (drm_mm_node_allocated(node)) {
+ if (drm_mm_node_allocated(&node->base)) {
/*
* explicit GGTT PTE assignment to the PF using xe_ggtt_assign()
* is redundant, as PTE will be implicitly re-assigned to PF by
@@ -391,7 +394,7 @@ static void pf_release_vf_config_ggtt(struct xe_gt *gt, struct xe_gt_sriov_confi
static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
{
struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
- struct drm_mm_node *node = &config->ggtt_region;
+ struct xe_ggtt_node *node = &config->ggtt_region;
struct xe_tile *tile = gt_to_tile(gt);
struct xe_ggtt *ggtt = tile->mem.ggtt;
u64 alignment = pf_get_ggtt_alignment(gt);
@@ -403,14 +406,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
size = round_up(size, alignment);
- if (drm_mm_node_allocated(node)) {
+ if (drm_mm_node_allocated(&node->base)) {
err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
if (unlikely(err))
return err;
pf_release_ggtt(tile, node);
}
- xe_gt_assert(gt, !drm_mm_node_allocated(node));
+ xe_gt_assert(gt, !drm_mm_node_allocated(&node->base));
if (!size)
return 0;
@@ -421,9 +424,9 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
xe_ggtt_assign(ggtt, node, vfid);
xe_gt_sriov_dbg_verbose(gt, "VF%u assigned GGTT %llx-%llx\n",
- vfid, node->start, node->start + node->size - 1);
+ vfid, node->base.start, node->base.start + node->base.size - 1);
- err = pf_distribute_config_ggtt(gt->tile, vfid, node->start, node->size);
+ err = pf_distribute_config_ggtt(gt->tile, vfid, node->base.start, node->base.size);
if (unlikely(err))
return err;
@@ -433,10 +436,10 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
{
struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
- struct drm_mm_node *node = &config->ggtt_region;
+ struct xe_ggtt_node *node = &config->ggtt_region;
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
- return drm_mm_node_allocated(node) ? node->size : 0;
+ return drm_mm_node_allocated(&node->base) ? node->base.size : 0;
}
/**
@@ -2018,13 +2021,13 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
for (n = 1; n <= total_vfs; n++) {
config = >->sriov.pf.vfs[n].config;
- if (!drm_mm_node_allocated(&config->ggtt_region))
+ if (!drm_mm_node_allocated(&config->ggtt_region.base))
continue;
- string_get_size(config->ggtt_region.size, 1, STRING_UNITS_2, buf, sizeof(buf));
+ string_get_size(config->ggtt_region.base.size, 1, STRING_UNITS_2, buf, sizeof(buf));
drm_printf(p, "VF%u:\t%#0llx-%#llx\t(%s)\n",
- n, config->ggtt_region.start,
- config->ggtt_region.start + config->ggtt_region.size - 1, buf);
+ n, config->ggtt_region.base.start,
+ config->ggtt_region.base.start + config->ggtt_region.base.size - 1, buf);
}
return 0;
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
index 7bc66656fcc7..6d0d9299bafa 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
@@ -6,7 +6,7 @@
#ifndef _XE_GT_SRIOV_PF_CONFIG_TYPES_H_
#define _XE_GT_SRIOV_PF_CONFIG_TYPES_H_
-#include <drm/drm_mm.h>
+#include <xe_ggtt_types.h>
#include "xe_guc_klv_thresholds_set_types.h"
@@ -19,7 +19,7 @@ struct xe_bo;
*/
struct xe_gt_sriov_config {
/** @ggtt_region: GGTT region assigned to the VF. */
- struct drm_mm_node ggtt_region;
+ struct xe_ggtt_node ggtt_region;
/** @lmem_obj: LMEM allocation for use by the VF. */
struct xe_bo *lmem_obj;
/** @num_ctxs: number of GuC contexts IDs. */
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 06/12] drm/xe: Rename xe_ggtt_node related functions
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (3 preceding siblings ...)
2024-07-11 17:11 ` [PATCH 05/12] drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-16 17:24 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 07/12] drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node Rodrigo Vivi
` (9 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe; +Cc: Rodrigo Vivi
Bring some consistency and prepare for more xe_ggtt_node related
functions to be introduced.
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/display/xe_fb_pin.c | 8 +-
drivers/gpu/drm/xe/xe_ggtt.c | 86 +++++++++++-----------
drivers/gpu/drm/xe/xe_ggtt.h | 12 +--
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 4 +-
4 files changed, 54 insertions(+), 56 deletions(-)
diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index a93923fb8721..db74c3395ef8 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -209,8 +209,7 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
} else if (view->type == I915_GTT_VIEW_NORMAL) {
u32 x, size = bo->ttm.base.size;
- ret = xe_ggtt_insert_special_node_locked(ggtt, &vma->node, size,
- align, 0);
+ ret = xe_ggtt_node_insert_locked(ggtt, &vma->node, size, align, 0);
if (ret)
goto out_unlock;
@@ -227,8 +226,7 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
/* display seems to use tiles instead of bytes here, so convert it back.. */
u32 size = intel_rotation_info_size(rot_info) * XE_PAGE_SIZE;
- ret = xe_ggtt_insert_special_node_locked(ggtt, &vma->node, size,
- align, 0);
+ ret = xe_ggtt_node_insert_locked(ggtt, &vma->node, size, align, 0);
if (ret)
goto out_unlock;
@@ -327,7 +325,7 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)
xe_bo_unpin_map_no_vm(vma->dpt);
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);
+ xe_ggtt_node_remove(ggtt, &vma->node, false);
ttm_bo_reserve(&vma->bo->ttm, false, false, NULL);
ttm_bo_unpin(&vma->bo->ttm);
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index ea55c7eabee4..3ab29588a068 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -403,7 +403,7 @@ void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
}
/**
- * xe_ggtt_insert_special_node_locked - Locked version to insert a &xe_ggtt_node into the GGTT
+ * xe_ggtt_node_insert_locked - Locked version to insert a &xe_ggtt_node into the GGTT
* @ggtt: the &xe_ggtt where node will be inserted
* @node: the &xe_ggtt_node to be inserted
* @size: size of the node
@@ -414,15 +414,15 @@ void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
*
* Return: 0 on success or a negative error code on failure.
*/
-int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
- u32 size, u32 align, u32 mm_flags)
+int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ u32 size, u32 align, u32 mm_flags)
{
return drm_mm_insert_node_generic(&ggtt->mm, &node->base, size, align, 0,
mm_flags);
}
/**
- * xe_ggtt_insert_special_node - Insert a &xe_ggtt_node into the GGTT
+ * xe_ggtt_node_insert - Insert a &xe_ggtt_node into the GGTT
* @ggtt: the &xe_ggtt where node will be inserted
* @node: the &xe_ggtt_node to be inserted
* @size: size of the node
@@ -430,19 +430,53 @@ int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node
*
* Return: 0 on success or a negative error code on failure.
*/
-int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
- u32 size, u32 align)
+int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ u32 size, u32 align)
{
int ret;
mutex_lock(&ggtt->lock);
- ret = xe_ggtt_insert_special_node_locked(ggtt, node, size,
- align, DRM_MM_INSERT_HIGH);
+ ret = xe_ggtt_node_insert_locked(ggtt, node, size,
+ align, DRM_MM_INSERT_HIGH);
mutex_unlock(&ggtt->lock);
return ret;
}
+/**
+ * xe_ggtt_node_remove - Remove a &xe_ggtt_node from the GGTT
+ * @ggtt: the &xe_ggtt where node will be removed
+ * @node: the &xe_ggtt_node to be removed
+ * @invalidate: if node needs invalidation upon removal
+ */
+void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ bool invalidate)
+{
+ struct xe_device *xe = tile_to_xe(ggtt->tile);
+ bool bound;
+ int idx;
+
+ bound = drm_dev_enter(&xe->drm, &idx);
+ if (bound)
+ xe_pm_runtime_get_noresume(xe);
+
+ mutex_lock(&ggtt->lock);
+ if (bound)
+ xe_ggtt_clear(ggtt, node->base.start, node->base.size);
+ drm_mm_remove_node(&node->base);
+ node->base.size = 0;
+ mutex_unlock(&ggtt->lock);
+
+ if (!bound)
+ return;
+
+ if (invalidate)
+ xe_ggtt_invalidate(ggtt);
+
+ xe_pm_runtime_put(xe);
+ drm_dev_exit(idx);
+}
+
/**
* xe_ggtt_map_bo - Map the BO into GGTT
* @ggtt: the &xe_ggtt where node will be mapped
@@ -522,40 +556,6 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
return __xe_ggtt_insert_bo_at(ggtt, bo, 0, U64_MAX);
}
-/**
- * xe_ggtt_remove_node - Remove a &xe_ggtt_node from the GGTT
- * @ggtt: the &xe_ggtt where node will be removed
- * @node: the &xe_ggtt_node to be removed
- * @invalidate: if node needs invalidation upon removal
- */
-void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
- bool invalidate)
-{
- struct xe_device *xe = tile_to_xe(ggtt->tile);
- bool bound;
- int idx;
-
- bound = drm_dev_enter(&xe->drm, &idx);
- if (bound)
- xe_pm_runtime_get_noresume(xe);
-
- mutex_lock(&ggtt->lock);
- if (bound)
- xe_ggtt_clear(ggtt, node->base.start, node->base.size);
- drm_mm_remove_node(&node->base);
- node->base.size = 0;
- mutex_unlock(&ggtt->lock);
-
- if (!bound)
- return;
-
- if (invalidate)
- xe_ggtt_invalidate(ggtt);
-
- xe_pm_runtime_put(xe);
- drm_dev_exit(idx);
-}
-
/**
* xe_ggtt_remove_bo - Remove a BO from the GGTT
* @ggtt: the &xe_ggtt where node will be removed
@@ -569,7 +569,7 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
/* This BO is not currently in the GGTT */
xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
- xe_ggtt_remove_node(ggtt, &bo->ggtt_node,
+ xe_ggtt_node_remove(ggtt, &bo->ggtt_node,
bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
}
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 30a521f7b075..5147930357de 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -16,12 +16,12 @@ int xe_ggtt_init(struct xe_ggtt *ggtt);
int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
-int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
- u32 size, u32 align);
-int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt,
- struct xe_ggtt_node *node,
- u32 size, u32 align, u32 mm_flags);
-void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ u32 size, u32 align);
+int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt,
+ struct xe_ggtt_node *node,
+ u32 size, u32 align, u32 mm_flags);
+void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
bool invalidate);
void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index 3600468da013..dfa71bcd0f56 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -382,7 +382,7 @@ static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
* is redundant, as PTE will be implicitly re-assigned to PF by
* the xe_ggtt_clear() called by below xe_ggtt_remove_node().
*/
- xe_ggtt_remove_node(ggtt, node, false);
+ xe_ggtt_node_remove(ggtt, node, false);
}
}
@@ -418,7 +418,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
if (!size)
return 0;
- err = xe_ggtt_insert_special_node(ggtt, node, size, alignment);
+ err = xe_ggtt_node_insert(ggtt, node, size, alignment);
if (unlikely(err))
return err;
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 07/12] drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (4 preceding siblings ...)
2024-07-11 17:11 ` [PATCH 06/12] drm/xe: Rename xe_ggtt_node related functions Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-17 23:27 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
` (8 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe; +Cc: Rodrigo Vivi, Michal Wajdeczko
Continue with the encapsulation of drm_mm_node inside xe_ggtt.
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/display/xe_fb_pin.c | 2 +-
drivers/gpu/drm/xe/xe_ggtt.c | 11 +++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 1 +
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 12 ++++++------
4 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index db74c3395ef8..de4930b67a29 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -323,7 +323,7 @@ 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.base) ||
+ else if (!xe_ggtt_node_allocated(&vma->bo->ggtt_node) ||
vma->bo->ggtt_node.base.start != vma->node.base.start)
xe_ggtt_node_remove(ggtt, &vma->node, false);
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 3ab29588a068..67337bfeb81e 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -477,6 +477,17 @@ void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
drm_dev_exit(idx);
}
+/**
+ * xe_ggtt_node_allocated - Check if node is allocated
+ * @node: the &xe_ggtt_node to be inspected
+ *
+ * Return: True if allocated, False otherwise.
+ */
+bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
+{
+ return drm_mm_node_allocated(&node->base);
+}
+
/**
* xe_ggtt_map_bo - Map the BO into GGTT
* @ggtt: the &xe_ggtt where node will be mapped
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 5147930357de..f816b3c0732b 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -23,6 +23,7 @@ int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt,
u32 size, u32 align, u32 mm_flags);
void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
bool invalidate);
+bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node);
void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index dfa71bcd0f56..efaf188290ea 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -235,7 +235,7 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config)
{
u32 n = 0;
- if (drm_mm_node_allocated(&config->ggtt_region.base)) {
+ if (xe_ggtt_node_allocated(&config->ggtt_region)) {
cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_START);
cfg[n++] = lower_32_bits(config->ggtt_region.base.start);
cfg[n++] = upper_32_bits(config->ggtt_region.base.start);
@@ -376,7 +376,7 @@ static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
{
struct xe_ggtt *ggtt = tile->mem.ggtt;
- if (drm_mm_node_allocated(&node->base)) {
+ if (xe_ggtt_node_allocated(node)) {
/*
* explicit GGTT PTE assignment to the PF using xe_ggtt_assign()
* is redundant, as PTE will be implicitly re-assigned to PF by
@@ -406,14 +406,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
size = round_up(size, alignment);
- if (drm_mm_node_allocated(&node->base)) {
+ if (xe_ggtt_node_allocated(node)) {
err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
if (unlikely(err))
return err;
pf_release_ggtt(tile, node);
}
- xe_gt_assert(gt, !drm_mm_node_allocated(&node->base));
+ xe_gt_assert(gt, !xe_ggtt_node_allocated(node));
if (!size)
return 0;
@@ -439,7 +439,7 @@ static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
struct xe_ggtt_node *node = &config->ggtt_region;
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
- return drm_mm_node_allocated(&node->base) ? node->base.size : 0;
+ return xe_ggtt_node_allocated(node) ? node->base.size : 0;
}
/**
@@ -2021,7 +2021,7 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
for (n = 1; n <= total_vfs; n++) {
config = >->sriov.pf.vfs[n].config;
- if (!drm_mm_node_allocated(&config->ggtt_region.base))
+ if (!xe_ggtt_node_allocated(&config->ggtt_region))
continue;
string_get_size(config->ggtt_region.base.size, 1, STRING_UNITS_2, buf, sizeof(buf));
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (5 preceding siblings ...)
2024-07-11 17:11 ` [PATCH 07/12] drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-11 20:00 ` Michal Wajdeczko
2024-07-11 17:11 ` [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes Rodrigo Vivi
` (7 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe; +Cc: Rodrigo Vivi, Michal Wajdeczko
Introduce a new xe_ggtt_largest_hole helper that attends the SRIOV
demand and continue with the goal of limiting drm_mm access to xe_ggtt.
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 35 ++++++++++++++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 1 +
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 23 ++------------
3 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 67337bfeb81e..dbaf1ce87fb4 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -584,6 +584,41 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
}
+/**
+ * xe_ggtt_largest_hole - Largest GGTT hole
+ * @ggtt: the &xe_ggtt that will be inspected
+ * @alignment: mininum alignment
+ * @spare: If not NULL: in: desired memory size to be spared / out: Adjusted possible spare
+ *
+ * Return: size of the largest continuous GGTT region
+ */
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare)
+{
+ const struct drm_mm *mm = &ggtt->mm;
+ const struct drm_mm_node *entry;
+ u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
+ u64 hole_start, hole_end, hole_size;
+ u64 max_hole = 0;
+
+ mutex_lock(&ggtt->lock);
+
+ drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
+ hole_start = max(hole_start, hole_min_start);
+ hole_start = ALIGN(hole_start, alignment);
+ hole_end = ALIGN_DOWN(hole_end, alignment);
+ if (hole_start >= hole_end)
+ continue;
+ hole_size = hole_end - hole_start;
+ if (spare)
+ *spare -= min3(*spare, hole_size, max_hole);
+ max_hole = max(max_hole, hole_size);
+ }
+
+ mutex_unlock(&ggtt->lock);
+
+ return max_hole;
+}
+
#ifdef CONFIG_PCI_IOV
static u64 xe_encode_vfid_pte(u16 vfid)
{
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index f816b3c0732b..31060fe7644b 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -29,6 +29,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u64 start, u64 end);
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index efaf188290ea..1d17c34fe5a4 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -590,30 +590,11 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
static u64 pf_get_max_ggtt(struct xe_gt *gt)
{
struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
- const struct drm_mm *mm = &ggtt->mm;
- const struct drm_mm_node *entry;
u64 alignment = pf_get_ggtt_alignment(gt);
u64 spare = pf_get_spare_ggtt(gt);
- u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
- u64 hole_start, hole_end, hole_size;
- u64 max_hole = 0;
-
- mutex_lock(&ggtt->lock);
-
- drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
- hole_start = max(hole_start, hole_min_start);
- hole_start = ALIGN(hole_start, alignment);
- hole_end = ALIGN_DOWN(hole_end, alignment);
- if (hole_start >= hole_end)
- continue;
- hole_size = hole_end - hole_start;
- xe_gt_sriov_dbg_verbose(gt, "HOLE start %llx size %lluK\n",
- hole_start, hole_size / SZ_1K);
- spare -= min3(spare, hole_size, max_hole);
- max_hole = max(max_hole, hole_size);
- }
+ u64 max_hole;
- mutex_unlock(&ggtt->lock);
+ max_hole = xe_ggtt_largest_hole(ggtt, alignment, &spare);
xe_gt_sriov_dbg_verbose(gt, "HOLE max %lluK reserved %lluK\n",
max_hole / SZ_1K, spare / SZ_1K);
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (6 preceding siblings ...)
2024-07-11 17:11 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-11 18:43 ` Cavitt, Jonathan
2024-07-11 20:09 ` Michal Wajdeczko
2024-07-11 17:11 ` [PATCH 10/12] drm/xe: Rename xe_ggtt balloon functions to make the node clear Rodrigo Vivi
` (6 subsequent siblings)
14 siblings, 2 replies; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe; +Cc: Rodrigo Vivi, Michal Wajdeczko
Introduce a new xe_ggtt_print_holes helper that attends the SRIOV
demand and finishes the goal of limiting drm_mm access to xe_ggtt.
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 40 ++++++++++++++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 1 +
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 25 +-------------
3 files changed, 42 insertions(+), 24 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index dbaf1ce87fb4..5b51753fe1ba 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -682,3 +682,43 @@ int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p)
mutex_unlock(&ggtt->lock);
return err;
}
+
+/**
+ * xe_ggtt_print_holes - Print holes
+ * @ggtt: the &xe_ggtt to be inspected
+ * @alignment: min alignment
+ * @p: the &drm_printer
+ *
+ * Print GGTT ranges that are available and return total size available.
+ *
+ * Return: Total available size.
+ */
+u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer *p)
+{
+ const struct drm_mm *mm = &ggtt->mm;
+ const struct drm_mm_node *entry;
+ u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
+ u64 hole_start, hole_end, hole_size;
+ u64 total;
+ char buf[10];
+
+ mutex_lock(&ggtt->lock);
+
+ drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
+ hole_start = max(hole_start, hole_min_start);
+ hole_start = ALIGN(hole_start, alignment);
+ hole_end = ALIGN_DOWN(hole_end, alignment);
+ if (hole_start >= hole_end)
+ continue;
+ hole_size = hole_end - hole_start;
+ total += hole_size;
+
+ string_get_size(hole_size, 1, STRING_UNITS_2, buf, sizeof(buf));
+ drm_printf(p, "range:\t%#llx-%#llx\t(%s)\n",
+ hole_start, hole_end - 1, buf);
+ }
+
+ mutex_unlock(&ggtt->lock);
+
+ return total;
+}
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 31060fe7644b..67ae5f1602a3 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -32,6 +32,7 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
+u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer *p);
#ifdef CONFIG_PCI_IOV
void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct xe_ggtt_node *node, u16 vfid);
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index 1d17c34fe5a4..d0995680f53f 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -6,9 +6,6 @@
#include <linux/string_choices.h>
#include <linux/wordpart.h>
-/* FIXME: remove this after encapsulating all drm_mm_node access into xe_ggtt */
-#include <drm/drm_mm.h>
-
#include "abi/guc_actions_sriov_abi.h"
#include "abi/guc_klvs_abi.h"
@@ -2096,11 +2093,7 @@ int xe_gt_sriov_pf_config_print_dbs(struct xe_gt *gt, struct drm_printer *p)
int xe_gt_sriov_pf_config_print_available_ggtt(struct xe_gt *gt, struct drm_printer *p)
{
struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
- const struct drm_mm *mm = &ggtt->mm;
- const struct drm_mm_node *entry;
u64 alignment = pf_get_ggtt_alignment(gt);
- u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
- u64 hole_start, hole_end, hole_size;
u64 spare, avail, total = 0;
char buf[10];
@@ -2109,24 +2102,8 @@ int xe_gt_sriov_pf_config_print_available_ggtt(struct xe_gt *gt, struct drm_prin
mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
spare = pf_get_spare_ggtt(gt);
+ total = xe_ggtt_print_holes(ggtt, alignment, p);
- mutex_lock(&ggtt->lock);
-
- drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
- hole_start = max(hole_start, hole_min_start);
- hole_start = ALIGN(hole_start, alignment);
- hole_end = ALIGN_DOWN(hole_end, alignment);
- if (hole_start >= hole_end)
- continue;
- hole_size = hole_end - hole_start;
- total += hole_size;
-
- string_get_size(hole_size, 1, STRING_UNITS_2, buf, sizeof(buf));
- drm_printf(p, "range:\t%#llx-%#llx\t(%s)\n",
- hole_start, hole_end - 1, buf);
- }
-
- mutex_unlock(&ggtt->lock);
mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
string_get_size(total, 1, STRING_UNITS_2, buf, sizeof(buf));
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 10/12] drm/xe: Rename xe_ggtt balloon functions to make the node clear
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (7 preceding siblings ...)
2024-07-11 17:11 ` [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-11 20:17 ` Michal Wajdeczko
2024-07-11 17:11 ` [PATCH 11/12] drm/xe: Make xe_ggtt_node struct independent Rodrigo Vivi
` (5 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe; +Cc: Rodrigo Vivi, Michal Wajdeczko
These operations are related to node. Convert them to the
new appropriate name space xe_ggtt_node.
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 12 ++++++------
drivers/gpu/drm/xe/xe_ggtt.h | 4 ++--
drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 10 +++++-----
3 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 5b51753fe1ba..928c01f9e212 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -347,17 +347,17 @@ static void xe_ggtt_dump_node(struct xe_ggtt *ggtt,
}
/**
- * xe_ggtt_balloon - prevent allocation of specified GGTT addresses
+ * xe_ggtt_node_balloon - prevent allocation of specified GGTT addresses
* @ggtt: the &xe_ggtt where we want to make reservation
* @start: the starting GGTT address of the reserved region
* @end: then end GGTT address of the reserved region
* @node: the &xe_ggtt_node to hold reserved GGTT node
*
- * Use xe_ggtt_deballoon() to release a reserved GGTT node.
+ * Use xe_ggtt_node_deballoon() to release a reserved GGTT node.
*
* Return: 0 on success or a negative error code on failure.
*/
-int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_node *node)
+int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_node *node)
{
int err;
@@ -384,13 +384,13 @@ int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_nod
}
/**
- * xe_ggtt_deballoon - release a reserved GGTT region
+ * xe_ggtt_node_deballoon - release a reserved GGTT region
* @ggtt: the &xe_ggtt where reserved node belongs
* @node: the &xe_ggtt_node with reserved GGTT region
*
- * See xe_ggtt_balloon() for details.
+ * See xe_ggtt_node_balloon() for details.
*/
-void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
+void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
{
if (!drm_mm_node_allocated(&node->base))
return;
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index 67ae5f1602a3..e68cede2e6b5 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -13,8 +13,8 @@ struct drm_printer;
int xe_ggtt_init_early(struct xe_ggtt *ggtt);
int xe_ggtt_init(struct xe_ggtt *ggtt);
-int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
-void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
+int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
+void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
u32 size, u32 align);
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
index 41e46a00c01e..a478e6e1b20e 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
@@ -528,7 +528,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
start = xe_wopcm_size(xe);
end = config->ggtt_base;
if (end != start) {
- err = xe_ggtt_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[0]);
+ err = xe_ggtt_node_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[0]);
if (err)
goto failed;
}
@@ -536,7 +536,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
start = config->ggtt_base + config->ggtt_size;
end = GUC_GGTT_TOP;
if (end != start) {
- err = xe_ggtt_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[1]);
+ err = xe_ggtt_node_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[1]);
if (err)
goto deballoon;
}
@@ -544,7 +544,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
return 0;
deballoon:
- xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
+ xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
failed:
return err;
}
@@ -555,8 +555,8 @@ static void deballoon_ggtt(struct drm_device *drm, void *arg)
struct xe_ggtt *ggtt = tile->mem.ggtt;
xe_tile_assert(tile, IS_SRIOV_VF(tile_to_xe(tile)));
- xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[1]);
- xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
+ xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[1]);
+ xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
}
/**
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 11/12] drm/xe: Make xe_ggtt_node struct independent
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (8 preceding siblings ...)
2024-07-11 17:11 ` [PATCH 10/12] drm/xe: Rename xe_ggtt balloon functions to make the node clear Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-17 23:50 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 12/12] drm/xe: Fix missing runtime outer protection for ggtt_remove_node Rodrigo Vivi
` (4 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe; +Cc: Rodrigo Vivi, Matthew Auld, Michal Wajdeczko, Matthew Brost
In some rare cases, the drm_mm node cannot be removed synchronously
due to runtime PM conditions. In this situation, the node removal will
be delegated to a workqueue that will be able to wake up the device
before removing the node.
However, in this situation, the lifetime of the xe_ggtt_node cannot
be restricted to the lifetime of the parent object. So, this patch
introduces the infrastructure so the xe_ggtt_node struct can be
allocated in advance and freed when needed.
By having the ggtt backpointer, it also ensure that the init function
is always called before any attempt to insert or reserve the node
in the GGTT.
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
| 4 +-
drivers/gpu/drm/xe/display/xe_fb_pin.c | 36 ++++--
drivers/gpu/drm/xe/xe_bo.c | 2 +-
drivers/gpu/drm/xe/xe_bo.h | 9 +-
drivers/gpu/drm/xe/xe_bo_types.h | 2 +-
drivers/gpu/drm/xe/xe_device_types.h | 2 +-
drivers/gpu/drm/xe/xe_ggtt.c | 103 ++++++++++++++++--
drivers/gpu/drm/xe/xe_ggtt.h | 2 +
drivers/gpu/drm/xe/xe_ggtt_types.h | 8 +-
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 34 +++---
.../gpu/drm/xe/xe_gt_sriov_pf_config_types.h | 2 +-
drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 26 ++++-
12 files changed, 181 insertions(+), 49 deletions(-)
--git a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
index 97193e660f6c..ac860414b91f 100644
--- a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
+++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
@@ -20,7 +20,7 @@ struct xe_bo;
struct i915_vma {
struct xe_bo *bo, *dpt;
- struct xe_ggtt_node node;
+ struct xe_ggtt_node *node;
};
#define i915_ggtt_clear_scanout(bo) do { } while (0)
@@ -29,7 +29,7 @@ struct i915_vma {
static inline u32 i915_ggtt_offset(const struct i915_vma *vma)
{
- return vma->node.base.start;
+ return vma->node->base.start;
}
#endif
diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
index de4930b67a29..e871957d7565 100644
--- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
+++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
@@ -204,20 +204,28 @@ 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.base.size && view->type == I915_GTT_VIEW_NORMAL) {
+ if (bo->ggtt_node && 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;
- ret = xe_ggtt_node_insert_locked(ggtt, &vma->node, size, align, 0);
- if (ret)
+ vma->node = xe_ggtt_node_init(ggtt);
+ if (IS_ERR(vma->node)) {
+ ret = PTR_ERR(vma->node);
goto out_unlock;
+ }
+
+ ret = xe_ggtt_node_insert_locked(ggtt, vma->node, size, align, 0);
+ if (ret) {
+ xe_ggtt_node_force_fini(vma->node);
+ goto out_unlock;
+ }
for (x = 0; x < size; x += XE_PAGE_SIZE) {
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.base.start + x, pte);
+ ggtt->pt_ops->ggtt_set_pte(ggtt, vma->node->base.start + x, pte);
}
} else {
u32 i, ggtt_ofs;
@@ -226,11 +234,19 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
/* display seems to use tiles instead of bytes here, so convert it back.. */
u32 size = intel_rotation_info_size(rot_info) * XE_PAGE_SIZE;
- ret = xe_ggtt_node_insert_locked(ggtt, &vma->node, size, align, 0);
- if (ret)
+ vma->node = xe_ggtt_node_init(ggtt);
+ if (IS_ERR(vma->node)) {
+ ret = PTR_ERR(vma->node);
goto out_unlock;
+ }
+
+ ret = xe_ggtt_node_insert_locked(ggtt, vma->node, size, align, 0);
+ if (ret) {
+ xe_ggtt_node_force_fini(vma->node);
+ goto out_unlock;
+ }
- ggtt_ofs = vma->node.base.start;
+ ggtt_ofs = vma->node->base.start;
for (i = 0; i < ARRAY_SIZE(rot_info->plane); i++)
write_ggtt_rotated(bo, ggtt, &ggtt_ofs,
@@ -323,9 +339,9 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)
if (vma->dpt)
xe_bo_unpin_map_no_vm(vma->dpt);
- else if (!xe_ggtt_node_allocated(&vma->bo->ggtt_node) ||
- vma->bo->ggtt_node.base.start != vma->node.base.start)
- xe_ggtt_node_remove(ggtt, &vma->node, false);
+ else if (!xe_ggtt_node_allocated(vma->bo->ggtt_node) ||
+ vma->bo->ggtt_node->base.start != vma->node->base.start)
+ xe_ggtt_node_remove(ggtt, vma->node, false);
ttm_bo_reserve(&vma->bo->ttm, false, false, NULL);
ttm_bo_unpin(&vma->bo->ttm);
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 3501a5871069..7e277ac0cd8d 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -1090,7 +1090,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.base.size)
+ if (bo->ggtt_node)
xe_ggtt_remove_bo(bo->tile->mem.ggtt, bo);
#ifdef CONFIG_PROC_FS
diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
index 7c95133cc32b..c8a90e5bbd6b 100644
--- a/drivers/gpu/drm/xe/xe_bo.h
+++ b/drivers/gpu/drm/xe/xe_bo.h
@@ -194,9 +194,12 @@ 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.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;
+ if (XE_WARN_ON(!bo->ggtt_node))
+ return -ENOENT;
+
+ 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);
diff --git a/drivers/gpu/drm/xe/xe_bo_types.h b/drivers/gpu/drm/xe/xe_bo_types.h
index 3ba96a93623c..0ec6172cc8ba 100644
--- a/drivers/gpu/drm/xe/xe_bo_types.h
+++ b/drivers/gpu/drm/xe/xe_bo_types.h
@@ -40,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 xe_ggtt_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. */
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 30f9c58932bb..706872711ebf 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -203,7 +203,7 @@ struct xe_tile {
struct xe_memirq memirq;
/** @sriov.vf.ggtt_balloon: GGTT regions excluded from use. */
- struct xe_ggtt_node ggtt_balloon[2];
+ struct xe_ggtt_node *ggtt_balloon[2];
} vf;
} sriov;
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 928c01f9e212..fe0bfd8c26cd 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -353,6 +353,7 @@ static void xe_ggtt_dump_node(struct xe_ggtt *ggtt,
* @end: then end GGTT address of the reserved region
* @node: the &xe_ggtt_node to hold reserved GGTT node
*
+ * It cannot be called without first having called xe_ggtt_init().
* Use xe_ggtt_node_deballoon() to release a reserved GGTT node.
*
* Return: 0 on success or a negative error code on failure.
@@ -361,6 +362,9 @@ int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggt
{
int err;
+ if (!node || !node->ggtt)
+ return -ENOENT;
+
xe_tile_assert(ggtt->tile, start < end);
xe_tile_assert(ggtt->tile, IS_ALIGNED(start, XE_PAGE_SIZE));
xe_tile_assert(ggtt->tile, IS_ALIGNED(end, XE_PAGE_SIZE));
@@ -392,14 +396,20 @@ int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggt
*/
void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
{
- if (!drm_mm_node_allocated(&node->base))
+ if (!node || !node->ggtt)
return;
+ if (!drm_mm_node_allocated(&node->base))
+ goto free_node;
+
xe_ggtt_dump_node(ggtt, &node->base, "deballoon");
mutex_lock(&ggtt->lock);
drm_mm_remove_node(&node->base);
mutex_unlock(&ggtt->lock);
+
+free_node:
+ kfree(node);
}
/**
@@ -410,6 +420,7 @@ void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
* @align: alignment constrain of the node
* @mm_flags: flags to control the node behavior
*
+ * It cannot be called without first having called xe_ggtt_init() once.
* To be used in cases where ggtt->lock is already taken.
*
* Return: 0 on success or a negative error code on failure.
@@ -417,6 +428,9 @@ void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
u32 size, u32 align, u32 mm_flags)
{
+ if (!node || !node->ggtt)
+ return -ENOENT;
+
return drm_mm_insert_node_generic(&ggtt->mm, &node->base, size, align, 0,
mm_flags);
}
@@ -428,6 +442,8 @@ int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
* @size: size of the node
* @align: alignment constrain of the node
*
+ * It cannot be called without first having called xe_ggtt_init() once.
+ *
* Return: 0 on success or a negative error code on failure.
*/
int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
@@ -435,6 +451,9 @@ int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
{
int ret;
+ if (!node || !node->ggtt)
+ return -ENOENT;
+
mutex_lock(&ggtt->lock);
ret = xe_ggtt_node_insert_locked(ggtt, node, size,
align, DRM_MM_INSERT_HIGH);
@@ -443,6 +462,43 @@ int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
return ret;
}
+/**
+ * xe_ggtt_node_init - Initialize %xe_ggtt_node struct
+ * @ggtt: the &xe_ggtt where the new node will later be inserted/reserved.
+ *
+ * This function will allocated the struct %xe_ggtt_node and return it's pointer.
+ * This struct will then be freed after the node removal upon xe_ggtt_node_remove()
+ * or xe_ggtt_node_deballoon().
+ * Having %xe_ggtt_node struct allocated doesn't mean that the node is already allocated
+ * in GGTT. Only the xe_ggtt_node_insert(), xe_ggtt_node_insert_locked(),
+ * xe_ggtt_node_balloon() will ensure the node is inserted or reserved in GGTT.
+ *
+ * Return: A pointer to %xe_ggtt_node struct on success. An ERR_PTR otherwise.
+ **/
+struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt)
+{
+ struct xe_ggtt_node *node = kzalloc(sizeof(*node), GFP_KERNEL);
+
+ if (!node)
+ return ERR_PTR(-ENOMEM);
+
+ node->ggtt = ggtt;
+ return node;
+}
+
+/**
+ * xe_ggtt_node_force_fini - Forcebly finalize %xe_ggtt_node struct
+ * @node: the &xe_ggtt_node to be freed
+ *
+ * If anything went wrong with either xe_ggtt_node_insert(), xe_ggtt_node_insert_locked(),
+ * or xe_ggtt_node_balloon(); and this @node is not going to be reused, then,
+ * this function needs to be called to free the %xe_ggtt_node struct
+ **/
+void xe_ggtt_node_force_fini(struct xe_ggtt_node *node)
+{
+ kfree(node);
+}
+
/**
* xe_ggtt_node_remove - Remove a &xe_ggtt_node from the GGTT
* @ggtt: the &xe_ggtt where node will be removed
@@ -456,6 +512,9 @@ void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
bool bound;
int idx;
+ if (!node || !node->ggtt)
+ return;
+
bound = drm_dev_enter(&xe->drm, &idx);
if (bound)
xe_pm_runtime_get_noresume(xe);
@@ -468,23 +527,29 @@ void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
mutex_unlock(&ggtt->lock);
if (!bound)
- return;
+ goto free_node;
if (invalidate)
xe_ggtt_invalidate(ggtt);
xe_pm_runtime_put(xe);
drm_dev_exit(idx);
+
+free_node:
+ kfree(node);
}
/**
- * xe_ggtt_node_allocated - Check if node is allocated
+ * xe_ggtt_node_allocated - Check if node is allocated in GGTT
* @node: the &xe_ggtt_node to be inspected
*
* Return: True if allocated, False otherwise.
*/
bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
{
+ if (!node || !node->ggtt)
+ return false;
+
return drm_mm_node_allocated(&node->base);
}
@@ -497,9 +562,14 @@ void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
{
u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
- u64 start = bo->ggtt_node.base.start;
+ u64 start;
u64 offset, pte;
+ if (XE_WARN_ON(!bo->ggtt_node))
+ return;
+
+ start = bo->ggtt_node->base.start;
+
for (offset = 0; offset < bo->size; offset += XE_PAGE_SIZE) {
pte = ggtt->pt_ops->pte_encode_bo(bo, offset, pat_index);
ggtt->pt_ops->ggtt_set_pte(ggtt, start + offset, pte);
@@ -515,9 +585,9 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
if (xe_bo_is_vram(bo) && ggtt->flags & XE_GGTT_FLAGS_64K)
alignment = SZ_64K;
- if (XE_WARN_ON(bo->ggtt_node.base.size)) {
+ if (XE_WARN_ON(bo->ggtt_node)) {
/* Someone's already inserted this BO in the GGTT */
- xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
+ xe_tile_assert(ggtt->tile, bo->ggtt_node->base.size == bo->size);
return 0;
}
@@ -526,15 +596,26 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
return err;
xe_pm_runtime_get_noresume(tile_to_xe(ggtt->tile));
+
+ bo->ggtt_node = xe_ggtt_node_init(ggtt);
+ if (IS_ERR(bo->ggtt_node)) {
+ err = PTR_ERR(bo->ggtt_node);
+ goto out;
+ }
+
mutex_lock(&ggtt->lock);
- err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node.base, bo->size,
+ err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node->base, bo->size,
alignment, 0, start, end, 0);
- if (!err)
+ if (err)
+ xe_ggtt_node_force_fini(bo->ggtt_node);
+ else
xe_ggtt_map_bo(ggtt, bo);
mutex_unlock(&ggtt->lock);
if (!err && bo->flags & XE_BO_FLAG_GGTT_INVALIDATE)
xe_ggtt_invalidate(ggtt);
+
+out:
xe_pm_runtime_put(tile_to_xe(ggtt->tile));
return err;
@@ -574,13 +655,13 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
*/
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
{
- if (XE_WARN_ON(!bo->ggtt_node.base.size))
+ if (XE_WARN_ON(!bo->ggtt_node))
return;
/* This BO is not currently in the GGTT */
- xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
+ xe_tile_assert(ggtt->tile, bo->ggtt_node->base.size == bo->size);
- xe_ggtt_node_remove(ggtt, &bo->ggtt_node,
+ xe_ggtt_node_remove(ggtt, bo->ggtt_node,
bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
}
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index e68cede2e6b5..9ca0a3da8903 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -13,6 +13,8 @@ struct drm_printer;
int xe_ggtt_init_early(struct xe_ggtt *ggtt);
int xe_ggtt_init(struct xe_ggtt *ggtt);
+struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt);
+void xe_ggtt_node_force_fini(struct xe_ggtt_node *node);
int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
index f3292e6c3873..60cbce3170d1 100644
--- a/drivers/gpu/drm/xe/xe_ggtt_types.h
+++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
@@ -48,9 +48,15 @@ struct xe_ggtt {
};
/**
- * struct xe_ggtt_node - A node in GGTT
+ * struct xe_ggtt_node - A node in GGTT.
+ *
+ * This struct needs to be initialized (only-once) with xe_ggtt_node_init() before any node
+ * insertion, reservation, or 'ballooning'.
+ * It will, then, be finalized by either xe_ggtt_node_remove() or xe_ggtt_node_deballoon().
*/
struct xe_ggtt_node {
+ /** @ggtt: Back pointer to xe_ggtt where this region will be inserted at */
+ struct xe_ggtt *ggtt;
/** @base: A drm_mm_node */
struct drm_mm_node base;
};
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index d0995680f53f..ac292351483c 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -232,14 +232,14 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config)
{
u32 n = 0;
- if (xe_ggtt_node_allocated(&config->ggtt_region)) {
+ if (xe_ggtt_node_allocated(config->ggtt_region)) {
cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_START);
- cfg[n++] = lower_32_bits(config->ggtt_region.base.start);
- cfg[n++] = upper_32_bits(config->ggtt_region.base.start);
+ cfg[n++] = lower_32_bits(config->ggtt_region->base.start);
+ cfg[n++] = upper_32_bits(config->ggtt_region->base.start);
cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_SIZE);
- cfg[n++] = lower_32_bits(config->ggtt_region.base.size);
- cfg[n++] = upper_32_bits(config->ggtt_region.base.size);
+ cfg[n++] = lower_32_bits(config->ggtt_region->base.size);
+ cfg[n++] = upper_32_bits(config->ggtt_region->base.size);
}
return n;
@@ -385,13 +385,13 @@ static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
static void pf_release_vf_config_ggtt(struct xe_gt *gt, struct xe_gt_sriov_config *config)
{
- pf_release_ggtt(gt_to_tile(gt), &config->ggtt_region);
+ pf_release_ggtt(gt_to_tile(gt), config->ggtt_region);
}
static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
{
struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
- struct xe_ggtt_node *node = &config->ggtt_region;
+ struct xe_ggtt_node *node = config->ggtt_region;
struct xe_tile *tile = gt_to_tile(gt);
struct xe_ggtt *ggtt = tile->mem.ggtt;
u64 alignment = pf_get_ggtt_alignment(gt);
@@ -415,9 +415,15 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
if (!size)
return 0;
+ node = xe_ggtt_node_init(ggtt);
+ if (IS_ERR(node))
+ return PTR_ERR(node);
+
err = xe_ggtt_node_insert(ggtt, node, size, alignment);
- if (unlikely(err))
+ if (unlikely(err)) {
+ xe_ggtt_node_force_fini(node);
return err;
+ }
xe_ggtt_assign(ggtt, node, vfid);
xe_gt_sriov_dbg_verbose(gt, "VF%u assigned GGTT %llx-%llx\n",
@@ -433,7 +439,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
{
struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
- struct xe_ggtt_node *node = &config->ggtt_region;
+ struct xe_ggtt_node *node = config->ggtt_region;
xe_gt_assert(gt, !xe_gt_is_media_type(gt));
return xe_ggtt_node_allocated(node) ? node->base.size : 0;
@@ -1999,13 +2005,15 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
for (n = 1; n <= total_vfs; n++) {
config = >->sriov.pf.vfs[n].config;
- if (!xe_ggtt_node_allocated(&config->ggtt_region))
+ if (!xe_ggtt_node_allocated(config->ggtt_region))
continue;
- string_get_size(config->ggtt_region.base.size, 1, STRING_UNITS_2, buf, sizeof(buf));
+ string_get_size(config->ggtt_region->base.size, 1, STRING_UNITS_2,
+ buf, sizeof(buf));
drm_printf(p, "VF%u:\t%#0llx-%#llx\t(%s)\n",
- n, config->ggtt_region.base.start,
- config->ggtt_region.base.start + config->ggtt_region.base.size - 1, buf);
+ n, config->ggtt_region->base.start,
+ config->ggtt_region->base.start + config->ggtt_region->base.size - 1,
+ buf);
}
return 0;
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
index 6d0d9299bafa..44dc0a6e90d1 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
@@ -19,7 +19,7 @@ struct xe_bo;
*/
struct xe_gt_sriov_config {
/** @ggtt_region: GGTT region assigned to the VF. */
- struct xe_ggtt_node ggtt_region;
+ struct xe_ggtt_node *ggtt_region;
/** @lmem_obj: LMEM allocation for use by the VF. */
struct xe_bo *lmem_obj;
/** @num_ctxs: number of GuC contexts IDs. */
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
index a478e6e1b20e..5c540e20c785 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
@@ -495,6 +495,22 @@ u64 xe_gt_sriov_vf_lmem(struct xe_gt *gt)
return gt->sriov.vf.self_config.lmem_size;
}
+static int vf_balloon_ggtt_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ u64 start, u64 end)
+{
+ int err;
+
+ node = xe_ggtt_node_init(ggtt);
+ if (IS_ERR(node))
+ return PTR_ERR(node);
+
+ err = xe_ggtt_node_balloon(ggtt, start, end, node);
+ if (err)
+ xe_ggtt_node_force_fini(node);
+
+ return err;
+}
+
static int vf_balloon_ggtt(struct xe_gt *gt)
{
struct xe_gt_sriov_vf_selfconfig *config = >->sriov.vf.self_config;
@@ -528,7 +544,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
start = xe_wopcm_size(xe);
end = config->ggtt_base;
if (end != start) {
- err = xe_ggtt_node_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[0]);
+ err = vf_balloon_ggtt_node(ggtt, tile->sriov.vf.ggtt_balloon[0], start, end);
if (err)
goto failed;
}
@@ -536,7 +552,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
start = config->ggtt_base + config->ggtt_size;
end = GUC_GGTT_TOP;
if (end != start) {
- err = xe_ggtt_node_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[1]);
+ err = vf_balloon_ggtt_node(ggtt, tile->sriov.vf.ggtt_balloon[1], start, end);
if (err)
goto deballoon;
}
@@ -544,7 +560,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
return 0;
deballoon:
- xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
+ xe_ggtt_node_deballoon(ggtt, tile->sriov.vf.ggtt_balloon[0]);
failed:
return err;
}
@@ -555,8 +571,8 @@ static void deballoon_ggtt(struct drm_device *drm, void *arg)
struct xe_ggtt *ggtt = tile->mem.ggtt;
xe_tile_assert(tile, IS_SRIOV_VF(tile_to_xe(tile)));
- xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[1]);
- xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
+ xe_ggtt_node_deballoon(ggtt, tile->sriov.vf.ggtt_balloon[1]);
+ xe_ggtt_node_deballoon(ggtt, tile->sriov.vf.ggtt_balloon[0]);
}
/**
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 12/12] drm/xe: Fix missing runtime outer protection for ggtt_remove_node
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (9 preceding siblings ...)
2024-07-11 17:11 ` [PATCH 11/12] drm/xe: Make xe_ggtt_node struct independent Rodrigo Vivi
@ 2024-07-11 17:11 ` Rodrigo Vivi
2024-07-16 17:32 ` Matthew Brost
2024-07-11 17:25 ` ✓ CI.Patch_applied: success for series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk Patchwork
` (3 subsequent siblings)
14 siblings, 1 reply; 38+ messages in thread
From: Rodrigo Vivi @ 2024-07-11 17:11 UTC (permalink / raw)
To: intel-xe
Cc: Rodrigo Vivi, Matthew Auld, Paulo Zanoni, Francois Dugast,
Thomas Hellström, Matthew Brost
Defer the ggtt node removal to a thread if runtime_pm is not active.
The ggtt node removal can be called from multiple places, including
places where we cannot protect with outer callers and places we are
within other locks. So, try to grab the runtime reference if the
device is already active, otherwise defer the removal to a separate
thread from where we are sure we can wake the device up.
v2: - use xe wq instead of system wq (Matt and CI)
- Avoid GFP_KERNEL to be future proof since this removal can
be called from outside our drivers and we don't want to block
if atomic is needed. (Brost)
v3: amend forgot chunk declaring xe_device.
v4: Use a xe_ggtt_region to encapsulate the node and remova info,
wihtout the need for any memory allocation at runtime.
v5: Actually fill the delayed_removal.invalidate (Brost)
v6: - Ensure that ggtt_region is not freed before work finishes (Auld)
- Own wq to ensures that the queued works are flushed before
ggtt_fini (Brost)
v7: also free ggtt_region on early !bound return (Auld)
v8: Address the null deref (CI)
v9: Based on the new xe_ggtt_node for the proper care of the lifetime
of the object.
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 106 ++++++++++++++++++-----------
drivers/gpu/drm/xe/xe_ggtt_types.h | 12 ++++
2 files changed, 78 insertions(+), 40 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index fe0bfd8c26cd..b57a71d54b1c 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -161,6 +161,7 @@ static void ggtt_fini_early(struct drm_device *drm, void *arg)
{
struct xe_ggtt *ggtt = arg;
+ destroy_workqueue(ggtt->wq);
mutex_destroy(&ggtt->lock);
drm_mm_takedown(&ggtt->mm);
}
@@ -242,6 +243,8 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
else
ggtt->pt_ops = &xelp_pt_ops;
+ ggtt->wq = alloc_workqueue("xe-ggtt-wq", 0, 0);
+
drm_mm_init(&ggtt->mm, xe_wopcm_size(xe),
ggtt->size - xe_wopcm_size(xe));
mutex_init(&ggtt->lock);
@@ -276,6 +279,67 @@ static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt)
mutex_unlock(&ggtt->lock);
}
+static void ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ bool invalidate)
+{
+ struct xe_device *xe = tile_to_xe(ggtt->tile);
+ bool bound;
+ int idx;
+
+ if (!node || !node->ggtt)
+ return;
+
+ bound = drm_dev_enter(&xe->drm, &idx);
+
+ mutex_lock(&ggtt->lock);
+ if (bound)
+ xe_ggtt_clear(ggtt, node->base.start, node->base.size);
+ drm_mm_remove_node(&node->base);
+ node->base.size = 0;
+ mutex_unlock(&ggtt->lock);
+
+ if (!bound)
+ goto free_node;
+
+ if (invalidate)
+ xe_ggtt_invalidate(ggtt);
+
+ drm_dev_exit(idx);
+
+free_node:
+ kfree(node);
+}
+
+static void ggtt_node_remove_work_func(struct work_struct *work)
+{
+ struct xe_ggtt_node *node = container_of(work, typeof(*node),
+ delayed_removal.work);
+ struct xe_device *xe = tile_to_xe(node->ggtt->tile);
+
+ xe_pm_runtime_get(xe);
+ ggtt_node_remove(node->ggtt, node, node->delayed_removal.invalidate);
+ xe_pm_runtime_put(xe);
+}
+
+/**
+ * xe_ggtt_node_remove - Remove a &xe_ggtt_node from the GGTT
+ * @ggtt: the &xe_ggtt where node will be removed
+ * @node: the &xe_ggtt_node to be removed
+ * @invalidate: if node needs invalidation upon removal
+ */
+void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
+ bool invalidate)
+{
+ struct xe_device *xe = tile_to_xe(ggtt->tile);
+
+ if (xe_pm_runtime_get_if_active(xe)) {
+ ggtt_node_remove(ggtt, node, invalidate);
+ xe_pm_runtime_put(xe);
+ } else {
+ queue_work(ggtt->wq, &node->delayed_removal.work);
+ }
+}
+
/**
* xe_ggtt_init - Regular non-early GGTT initialization
* @ggtt: the &xe_ggtt to be initialized
@@ -482,7 +546,9 @@ struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt)
if (!node)
return ERR_PTR(-ENOMEM);
+ INIT_WORK(&node->delayed_removal.work, ggtt_node_remove_work_func);
node->ggtt = ggtt;
+
return node;
}
@@ -499,46 +565,6 @@ void xe_ggtt_node_force_fini(struct xe_ggtt_node *node)
kfree(node);
}
-/**
- * xe_ggtt_node_remove - Remove a &xe_ggtt_node from the GGTT
- * @ggtt: the &xe_ggtt where node will be removed
- * @node: the &xe_ggtt_node to be removed
- * @invalidate: if node needs invalidation upon removal
- */
-void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
- bool invalidate)
-{
- struct xe_device *xe = tile_to_xe(ggtt->tile);
- bool bound;
- int idx;
-
- if (!node || !node->ggtt)
- return;
-
- bound = drm_dev_enter(&xe->drm, &idx);
- if (bound)
- xe_pm_runtime_get_noresume(xe);
-
- mutex_lock(&ggtt->lock);
- if (bound)
- xe_ggtt_clear(ggtt, node->base.start, node->base.size);
- drm_mm_remove_node(&node->base);
- node->base.size = 0;
- mutex_unlock(&ggtt->lock);
-
- if (!bound)
- goto free_node;
-
- if (invalidate)
- xe_ggtt_invalidate(ggtt);
-
- xe_pm_runtime_put(xe);
- drm_dev_exit(idx);
-
-free_node:
- kfree(node);
-}
-
/**
* xe_ggtt_node_allocated - Check if node is allocated in GGTT
* @node: the &xe_ggtt_node to be inspected
diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
index 60cbce3170d1..5ea12ea30a4d 100644
--- a/drivers/gpu/drm/xe/xe_ggtt_types.h
+++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
@@ -45,6 +45,8 @@ struct xe_ggtt {
struct drm_mm mm;
/** @access_count: counts GGTT writes */
unsigned int access_count;
+ /** @wq: Dedicated unordered work queue to process node removals */
+ struct workqueue_struct *wq;
};
/**
@@ -59,6 +61,16 @@ struct xe_ggtt_node {
struct xe_ggtt *ggtt;
/** @base: A drm_mm_node */
struct drm_mm_node base;
+ /**
+ * @delayed_removal: Information for removal through work thread when
+ * device runtime_pm is suspended
+ */
+ struct {
+ /** @delayed_removal.work: The work struct for the delayed removal */
+ struct work_struct work;
+ /** @delayed_removal.invalidate: If it needs invalidation upon removal */
+ bool invalidate;
+ } delayed_removal;
};
/**
--
2.45.2
^ permalink raw reply related [flat|nested] 38+ messages in thread
* ✓ CI.Patch_applied: success for series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (10 preceding siblings ...)
2024-07-11 17:11 ` [PATCH 12/12] drm/xe: Fix missing runtime outer protection for ggtt_remove_node Rodrigo Vivi
@ 2024-07-11 17:25 ` Patchwork
2024-07-11 17:26 ` ✓ CI.checkpatch: " Patchwork
` (2 subsequent siblings)
14 siblings, 0 replies; 38+ messages in thread
From: Patchwork @ 2024-07-11 17:25 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: intel-xe
== Series Details ==
Series: series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk
URL : https://patchwork.freedesktop.org/series/136004/
State : success
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 3bcdb3f9a537 drm-tip: 2024y-07m-11d-17h-00m-04s UTC integration manifest
=== git am output follows ===
Applying: drm/xe: Removed unused xe_ggtt_printk
Applying: drm/xe: Introduce GGTT documentation
Applying: drm/xe: Remove unnecessary drm_mm.h includes
Applying: drm/{i915, xe}: Avoid direct inspection of dpt_vma from outside dpt
Applying: drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node
Applying: drm/xe: Rename xe_ggtt_node related functions
Applying: drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node
Applying: drm/xe: Introduce xe_ggtt_largest_hole
Applying: drm/xe: Introduce xe_ggtt_print_holes
Applying: drm/xe: Rename xe_ggtt balloon functions to make the node clear
Applying: drm/xe: Make xe_ggtt_node struct independent
Applying: drm/xe: Fix missing runtime outer protection for ggtt_remove_node
^ permalink raw reply [flat|nested] 38+ messages in thread
* ✓ CI.checkpatch: success for series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (11 preceding siblings ...)
2024-07-11 17:25 ` ✓ CI.Patch_applied: success for series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk Patchwork
@ 2024-07-11 17:26 ` Patchwork
2024-07-11 17:28 ` ✓ CI.KUnit: " Patchwork
2024-07-11 17:34 ` ✗ CI.Build: failure " Patchwork
14 siblings, 0 replies; 38+ messages in thread
From: Patchwork @ 2024-07-11 17:26 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: intel-xe
== Series Details ==
Series: series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk
URL : https://patchwork.freedesktop.org/series/136004/
State : success
== Summary ==
+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt
Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master
51ce9f6cd981d42d7467409d7dbc559a450abc1e
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit e0eb7ea2a023c816a0eb0dbe4d569614aad5d297
Author: Rodrigo Vivi <rodrigo.vivi@intel.com>
Date: Thu Jul 11 13:11:55 2024 -0400
drm/xe: Fix missing runtime outer protection for ggtt_remove_node
Defer the ggtt node removal to a thread if runtime_pm is not active.
The ggtt node removal can be called from multiple places, including
places where we cannot protect with outer callers and places we are
within other locks. So, try to grab the runtime reference if the
device is already active, otherwise defer the removal to a separate
thread from where we are sure we can wake the device up.
v2: - use xe wq instead of system wq (Matt and CI)
- Avoid GFP_KERNEL to be future proof since this removal can
be called from outside our drivers and we don't want to block
if atomic is needed. (Brost)
v3: amend forgot chunk declaring xe_device.
v4: Use a xe_ggtt_region to encapsulate the node and remova info,
wihtout the need for any memory allocation at runtime.
v5: Actually fill the delayed_removal.invalidate (Brost)
v6: - Ensure that ggtt_region is not freed before work finishes (Auld)
- Own wq to ensures that the queued works are flushed before
ggtt_fini (Brost)
v7: also free ggtt_region on early !bound return (Auld)
v8: Address the null deref (CI)
v9: Based on the new xe_ggtt_node for the proper care of the lifetime
of the object.
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
Cc: Francois Dugast <francois.dugast@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
+ /mt/dim checkpatch 3bcdb3f9a5370e29bc971883307487527c3e6a65 drm-intel
231091d7b36c drm/xe: Removed unused xe_ggtt_printk
9d3ef5591632 drm/xe: Introduce GGTT documentation
415f64d26ed8 drm/xe: Remove unnecessary drm_mm.h includes
560b3ec054df drm/{i915, xe}: Avoid direct inspection of dpt_vma from outside dpt
f5df4e46ced1 drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node
d63ac0078d7e drm/xe: Rename xe_ggtt_node related functions
22cb7472e06a drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node
0354aef1ba26 drm/xe: Introduce xe_ggtt_largest_hole
b9c292a45ce5 drm/xe: Introduce xe_ggtt_print_holes
1601f6c013c7 drm/xe: Rename xe_ggtt balloon functions to make the node clear
bf8d89bf2034 drm/xe: Make xe_ggtt_node struct independent
e0eb7ea2a023 drm/xe: Fix missing runtime outer protection for ggtt_remove_node
^ permalink raw reply [flat|nested] 38+ messages in thread
* ✓ CI.KUnit: success for series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (12 preceding siblings ...)
2024-07-11 17:26 ` ✓ CI.checkpatch: " Patchwork
@ 2024-07-11 17:28 ` Patchwork
2024-07-11 17:34 ` ✗ CI.Build: failure " Patchwork
14 siblings, 0 replies; 38+ messages in thread
From: Patchwork @ 2024-07-11 17:28 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: intel-xe
== Series Details ==
Series: series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk
URL : https://patchwork.freedesktop.org/series/136004/
State : success
== Summary ==
+ trap cleanup EXIT
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/xe/.kunitconfig
[17:26:31] Configuring KUnit Kernel ...
Generating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[17:26:38] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
156 | u64 ioread64_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
163 | u64 ioread64_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
170 | u64 ioread64be_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
178 | u64 ioread64be_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
[17:27:35] Starting KUnit Kernel (1/1)...
[17:27:35] ============================================================
Running tests with:
$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt
[17:27:35] =================== guc_dbm (7 subtests) ===================
[17:27:35] [PASSED] test_empty
[17:27:35] [PASSED] test_default
[17:27:35] ======================== test_size ========================
[17:27:35] [PASSED] 4
[17:27:35] [PASSED] 8
[17:27:35] [PASSED] 32
[17:27:35] [PASSED] 256
[17:27:35] ==================== [PASSED] test_size ====================
[17:27:35] ======================= test_reuse ========================
[17:27:35] [PASSED] 4
[17:27:35] [PASSED] 8
[17:27:35] [PASSED] 32
[17:27:35] [PASSED] 256
[17:27:35] =================== [PASSED] test_reuse ====================
[17:27:35] =================== test_range_overlap ====================
[17:27:35] [PASSED] 4
[17:27:35] [PASSED] 8
[17:27:35] [PASSED] 32
[17:27:35] [PASSED] 256
[17:27:35] =============== [PASSED] test_range_overlap ================
[17:27:35] =================== test_range_compact ====================
[17:27:35] [PASSED] 4
[17:27:35] [PASSED] 8
[17:27:35] [PASSED] 32
[17:27:35] [PASSED] 256
[17:27:35] =============== [PASSED] test_range_compact ================
[17:27:35] ==================== test_range_spare =====================
[17:27:35] [PASSED] 4
[17:27:35] [PASSED] 8
[17:27:35] [PASSED] 32
[17:27:35] [PASSED] 256
[17:27:35] ================ [PASSED] test_range_spare =================
[17:27:35] ===================== [PASSED] guc_dbm =====================
[17:27:35] =================== guc_idm (6 subtests) ===================
[17:27:35] [PASSED] bad_init
[17:27:35] [PASSED] no_init
[17:27:35] [PASSED] init_fini
[17:27:35] [PASSED] check_used
[17:27:35] [PASSED] check_quota
[17:27:35] [PASSED] check_all
[17:27:35] ===================== [PASSED] guc_idm =====================
[17:27:35] ================== no_relay (3 subtests) ===================
[17:27:35] [PASSED] xe_drops_guc2pf_if_not_ready
[17:27:35] [PASSED] xe_drops_guc2vf_if_not_ready
[17:27:35] [PASSED] xe_rejects_send_if_not_ready
[17:27:35] ==================== [PASSED] no_relay =====================
[17:27:35] ================== pf_relay (14 subtests) ==================
[17:27:35] [PASSED] pf_rejects_guc2pf_too_short
[17:27:35] [PASSED] pf_rejects_guc2pf_too_long
[17:27:35] [PASSED] pf_rejects_guc2pf_no_payload
[17:27:35] [PASSED] pf_fails_no_payload
[17:27:35] [PASSED] pf_fails_bad_origin
[17:27:35] [PASSED] pf_fails_bad_type
[17:27:35] [PASSED] pf_txn_reports_error
[17:27:35] [PASSED] pf_txn_sends_pf2guc
[17:27:35] [PASSED] pf_sends_pf2guc
[17:27:35] [SKIPPED] pf_loopback_nop
[17:27:35] [SKIPPED] pf_loopback_echo
[17:27:35] [SKIPPED] pf_loopback_fail
[17:27:35] [SKIPPED] pf_loopback_busy
[17:27:35] [SKIPPED] pf_loopback_retry
[17:27:35] ==================== [PASSED] pf_relay =====================
[17:27:35] ================== vf_relay (3 subtests) ===================
[17:27:35] [PASSED] vf_rejects_guc2vf_too_short
[17:27:35] [PASSED] vf_rejects_guc2vf_too_long
[17:27:35] [PASSED] vf_rejects_guc2vf_no_payload
[17:27:35] ==================== [PASSED] vf_relay =====================
[17:27:35] ================= pf_service (11 subtests) =================
[17:27:35] [PASSED] pf_negotiate_any
[17:27:35] [PASSED] pf_negotiate_base_match
[17:27:35] [PASSED] pf_negotiate_base_newer
[17:27:35] [PASSED] pf_negotiate_base_next
[17:27:35] [SKIPPED] pf_negotiate_base_older
[17:27:35] [PASSED] pf_negotiate_base_prev
[17:27:35] [PASSED] pf_negotiate_latest_match
[17:27:35] [PASSED] pf_negotiate_latest_newer
[17:27:35] [PASSED] pf_negotiate_latest_next
[17:27:35] [SKIPPED] pf_negotiate_latest_older
[17:27:35] [SKIPPED] pf_negotiate_latest_prev
[17:27:35] =================== [PASSED] pf_service ====================
[17:27:35] ===================== lmtt (1 subtest) =====================
[17:27:35] ======================== test_ops =========================
[17:27:35] [PASSED] 2-level
[17:27:35] [PASSED] multi-level
[17:27:35] ==================== [PASSED] test_ops =====================
[17:27:35] ====================== [PASSED] lmtt =======================
[17:27:35] ==================== xe_bo (2 subtests) ====================
[17:27:35] [SKIPPED] xe_ccs_migrate_kunit
[17:27:35] [SKIPPED] xe_bo_evict_kunit
[17:27:35] ===================== [SKIPPED] xe_bo ======================
[17:27:35] ================== xe_dma_buf (1 subtest) ==================
[17:27:35] [SKIPPED] xe_dma_buf_kunit
[17:27:35] =================== [SKIPPED] xe_dma_buf ===================
[17:27:35] ================== xe_migrate (1 subtest) ==================
[17:27:35] [SKIPPED] xe_migrate_sanity_kunit
[17:27:35] =================== [SKIPPED] xe_migrate ===================
[17:27:35] =================== xe_mocs (2 subtests) ===================
[17:27:35] [SKIPPED] xe_live_mocs_kernel_kunit
[17:27:35] [SKIPPED] xe_live_mocs_reset_kunit
[17:27:35] ==================== [SKIPPED] xe_mocs =====================
[17:27:35] ==================== args (11 subtests) ====================
[17:27:35] [PASSED] count_args_test
[17:27:35] [PASSED] call_args_example
[17:27:35] [PASSED] call_args_test
[17:27:35] [PASSED] drop_first_arg_example
[17:27:35] [PASSED] drop_first_arg_test
[17:27:35] [PASSED] first_arg_example
[17:27:35] [PASSED] first_arg_test
[17:27:35] [PASSED] last_arg_example
[17:27:35] [PASSED] last_arg_test
[17:27:35] [PASSED] pick_arg_example
[17:27:35] [PASSED] sep_comma_example
[17:27:35] ====================== [PASSED] args =======================
[17:27:35] =================== xe_pci (2 subtests) ====================
[17:27:35] [PASSED] xe_gmdid_graphics_ip
[17:27:35] [PASSED] xe_gmdid_media_ip
[17:27:35] ===================== [PASSED] xe_pci ======================
[17:27:35] ==================== xe_rtp (1 subtest) ====================
[17:27:35] ================== xe_rtp_process_tests ===================
[17:27:35] [PASSED] coalesce-same-reg
[17:27:35] [PASSED] no-match-no-add
[17:27:35] [PASSED] match-or
[17:27:35] [PASSED] match-or-xfail
[17:27:35] [PASSED] no-match-no-add-multiple-rules
[17:27:35] [PASSED] two-regs-two-entries
[17:27:35] [PASSED] clr-one-set-other
[17:27:35] [PASSED] set-field
[17:27:35] [PASSED] conflict-duplicate
[17:27:35] [PASSED] conflict-not-disjoint
[17:27:35] [PASSED] conflict-reg-type
stty: 'standard input': Inappropriate ioctl for device
[17:27:35] ============== [PASSED] xe_rtp_process_tests ===============
[17:27:35] ===================== [PASSED] xe_rtp ======================
[17:27:35] ==================== xe_wa (1 subtest) =====================
[17:27:35] ======================== xe_wa_gt =========================
[17:27:35] [PASSED] TIGERLAKE (B0)
[17:27:35] [PASSED] DG1 (A0)
[17:27:35] [PASSED] DG1 (B0)
[17:27:35] [PASSED] ALDERLAKE_S (A0)
[17:27:35] [PASSED] ALDERLAKE_S (B0)
[17:27:35] [PASSED] ALDERLAKE_S (C0)
[17:27:35] [PASSED] ALDERLAKE_S (D0)
[17:27:35] [PASSED] ALDERLAKE_P (A0)
[17:27:35] [PASSED] ALDERLAKE_P (B0)
[17:27:35] [PASSED] ALDERLAKE_P (C0)
[17:27:35] [PASSED] ALDERLAKE_S_RPLS (D0)
[17:27:35] [PASSED] ALDERLAKE_P_RPLU (E0)
[17:27:35] [PASSED] DG2_G10 (C0)
[17:27:35] [PASSED] DG2_G11 (B1)
[17:27:35] [PASSED] DG2_G12 (A1)
[17:27:35] [PASSED] METEORLAKE (g:A0, m:A0)
[17:27:35] [PASSED] METEORLAKE (g:A0, m:A0)
[17:27:35] [PASSED] METEORLAKE (g:A0, m:A0)
[17:27:35] [PASSED] LUNARLAKE (g:A0, m:A0)
[17:27:35] [PASSED] LUNARLAKE (g:B0, m:A0)
[17:27:35] ==================== [PASSED] xe_wa_gt =====================
[17:27:35] ====================== [PASSED] xe_wa ======================
[17:27:35] ============================================================
[17:27:35] Testing complete. Ran 111 tests: passed: 97, skipped: 14
[17:27:35] Elapsed time: 64.073s total, 6.870s configuring, 56.884s building, 0.287s running
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/tests/.kunitconfig
[17:27:35] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[17:27:38] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
../lib/iomap.c:156:5: warning: no previous prototype for ‘ioread64_lo_hi’ [-Wmissing-prototypes]
156 | u64 ioread64_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:163:5: warning: no previous prototype for ‘ioread64_hi_lo’ [-Wmissing-prototypes]
163 | u64 ioread64_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~
../lib/iomap.c:170:5: warning: no previous prototype for ‘ioread64be_lo_hi’ [-Wmissing-prototypes]
170 | u64 ioread64be_lo_hi(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:178:5: warning: no previous prototype for ‘ioread64be_hi_lo’ [-Wmissing-prototypes]
178 | u64 ioread64be_hi_lo(const void __iomem *addr)
| ^~~~~~~~~~~~~~~~
../lib/iomap.c:264:6: warning: no previous prototype for ‘iowrite64_lo_hi’ [-Wmissing-prototypes]
264 | void iowrite64_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:272:6: warning: no previous prototype for ‘iowrite64_hi_lo’ [-Wmissing-prototypes]
272 | void iowrite64_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~
../lib/iomap.c:280:6: warning: no previous prototype for ‘iowrite64be_lo_hi’ [-Wmissing-prototypes]
280 | void iowrite64be_lo_hi(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
../lib/iomap.c:288:6: warning: no previous prototype for ‘iowrite64be_hi_lo’ [-Wmissing-prototypes]
288 | void iowrite64be_hi_lo(u64 val, void __iomem *addr)
| ^~~~~~~~~~~~~~~~~
[17:28:18] Starting KUnit Kernel (1/1)...
[17:28:18] ============================================================
Running tests with:
$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt
[17:28:18] ============ drm_test_pick_cmdline (2 subtests) ============
[17:28:18] [PASSED] drm_test_pick_cmdline_res_1920_1080_60
[17:28:18] =============== drm_test_pick_cmdline_named ===============
[17:28:18] [PASSED] NTSC
[17:28:18] [PASSED] NTSC-J
[17:28:18] [PASSED] PAL
[17:28:18] [PASSED] PAL-M
[17:28:18] =========== [PASSED] drm_test_pick_cmdline_named ===========
[17:28:18] ============== [PASSED] drm_test_pick_cmdline ==============
[17:28:18] ================== drm_buddy (7 subtests) ==================
[17:28:18] [PASSED] drm_test_buddy_alloc_limit
[17:28:18] [PASSED] drm_test_buddy_alloc_optimistic
[17:28:18] [PASSED] drm_test_buddy_alloc_pessimistic
[17:28:18] [PASSED] drm_test_buddy_alloc_pathological
[17:28:18] [PASSED] drm_test_buddy_alloc_contiguous
[17:28:18] [PASSED] drm_test_buddy_alloc_clear
[17:28:18] [PASSED] drm_test_buddy_alloc_range_bias
[17:28:18] ==================== [PASSED] drm_buddy ====================
[17:28:18] ============= drm_cmdline_parser (40 subtests) =============
[17:28:18] [PASSED] drm_test_cmdline_force_d_only
[17:28:18] [PASSED] drm_test_cmdline_force_D_only_dvi
[17:28:18] [PASSED] drm_test_cmdline_force_D_only_hdmi
[17:28:18] [PASSED] drm_test_cmdline_force_D_only_not_digital
[17:28:18] [PASSED] drm_test_cmdline_force_e_only
[17:28:18] [PASSED] drm_test_cmdline_res
[17:28:18] [PASSED] drm_test_cmdline_res_vesa
[17:28:18] [PASSED] drm_test_cmdline_res_vesa_rblank
[17:28:18] [PASSED] drm_test_cmdline_res_rblank
[17:28:18] [PASSED] drm_test_cmdline_res_bpp
[17:28:18] [PASSED] drm_test_cmdline_res_refresh
[17:28:18] [PASSED] drm_test_cmdline_res_bpp_refresh
[17:28:18] [PASSED] drm_test_cmdline_res_bpp_refresh_interlaced
[17:28:18] [PASSED] drm_test_cmdline_res_bpp_refresh_margins
[17:28:18] [PASSED] drm_test_cmdline_res_bpp_refresh_force_off
[17:28:18] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on
[17:28:18] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on_analog
[17:28:18] [PASSED] drm_test_cmdline_res_bpp_refresh_force_on_digital
[17:28:18] [PASSED] drm_test_cmdline_res_bpp_refresh_interlaced_margins_force_on
[17:28:18] [PASSED] drm_test_cmdline_res_margins_force_on
[17:28:18] [PASSED] drm_test_cmdline_res_vesa_margins
[17:28:18] [PASSED] drm_test_cmdline_name
[17:28:18] [PASSED] drm_test_cmdline_name_bpp
[17:28:18] [PASSED] drm_test_cmdline_name_option
[17:28:18] [PASSED] drm_test_cmdline_name_bpp_option
[17:28:18] [PASSED] drm_test_cmdline_rotate_0
[17:28:18] [PASSED] drm_test_cmdline_rotate_90
[17:28:18] [PASSED] drm_test_cmdline_rotate_180
[17:28:18] [PASSED] drm_test_cmdline_rotate_270
[17:28:18] [PASSED] drm_test_cmdline_hmirror
[17:28:18] [PASSED] drm_test_cmdline_vmirror
[17:28:18] [PASSED] drm_test_cmdline_margin_options
[17:28:18] [PASSED] drm_test_cmdline_multiple_options
[17:28:18] [PASSED] drm_test_cmdline_bpp_extra_and_option
[17:28:18] [PASSED] drm_test_cmdline_extra_and_option
[17:28:18] [PASSED] drm_test_cmdline_freestanding_options
[17:28:18] [PASSED] drm_test_cmdline_freestanding_force_e_and_options
[17:28:18] [PASSED] drm_test_cmdline_panel_orientation
[17:28:18] ================ drm_test_cmdline_invalid =================
[17:28:18] [PASSED] margin_only
[17:28:18] [PASSED] interlace_only
[17:28:18] [PASSED] res_missing_x
[17:28:18] [PASSED] res_missing_y
[17:28:18] [PASSED] res_bad_y
[17:28:18] [PASSED] res_missing_y_bpp
[17:28:18] [PASSED] res_bad_bpp
[17:28:18] [PASSED] res_bad_refresh
[17:28:18] [PASSED] res_bpp_refresh_force_on_off
[17:28:18] [PASSED] res_invalid_mode
[17:28:18] [PASSED] res_bpp_wrong_place_mode
[17:28:18] [PASSED] name_bpp_refresh
[17:28:18] [PASSED] name_refresh
[17:28:18] [PASSED] name_refresh_wrong_mode
[17:28:18] [PASSED] name_refresh_invalid_mode
[17:28:18] [PASSED] rotate_multiple
[17:28:18] [PASSED] rotate_invalid_val
[17:28:18] [PASSED] rotate_truncated
[17:28:18] [PASSED] invalid_option
[17:28:18] [PASSED] invalid_tv_option
[17:28:18] [PASSED] truncated_tv_option
[17:28:18] ============ [PASSED] drm_test_cmdline_invalid =============
[17:28:18] =============== drm_test_cmdline_tv_options ===============
[17:28:18] [PASSED] NTSC
[17:28:18] [PASSED] NTSC_443
[17:28:18] [PASSED] NTSC_J
[17:28:18] [PASSED] PAL
[17:28:18] [PASSED] PAL_M
[17:28:18] [PASSED] PAL_N
[17:28:18] [PASSED] SECAM
[17:28:18] [PASSED] MONO_525
[17:28:18] [PASSED] MONO_625
[17:28:18] =========== [PASSED] drm_test_cmdline_tv_options ===========
[17:28:18] =============== [PASSED] drm_cmdline_parser ================
[17:28:18] ========== drmm_connector_hdmi_init (19 subtests) ==========
[17:28:18] [PASSED] drm_test_connector_hdmi_init_valid
[17:28:18] [PASSED] drm_test_connector_hdmi_init_bpc_8
[17:28:18] [PASSED] drm_test_connector_hdmi_init_bpc_10
[17:28:18] [PASSED] drm_test_connector_hdmi_init_bpc_12
[17:28:18] [PASSED] drm_test_connector_hdmi_init_bpc_invalid
[17:28:18] [PASSED] drm_test_connector_hdmi_init_bpc_null
[17:28:18] [PASSED] drm_test_connector_hdmi_init_formats_empty
[17:28:18] [PASSED] drm_test_connector_hdmi_init_formats_no_rgb
[17:28:18] [PASSED] drm_test_connector_hdmi_init_null_ddc
[17:28:18] [PASSED] drm_test_connector_hdmi_init_null_product
[17:28:18] [PASSED] drm_test_connector_hdmi_init_null_vendor
[17:28:18] [PASSED] drm_test_connector_hdmi_init_product_length_exact
[17:28:18] [PASSED] drm_test_connector_hdmi_init_product_length_too_long
[17:28:18] [PASSED] drm_test_connector_hdmi_init_product_valid
[17:28:18] [PASSED] drm_test_connector_hdmi_init_vendor_length_exact
[17:28:18] [PASSED] drm_test_connector_hdmi_init_vendor_length_too_long
[17:28:18] [PASSED] drm_test_connector_hdmi_init_vendor_valid
[17:28:18] ========= drm_test_connector_hdmi_init_type_valid =========
[17:28:18] [PASSED] HDMI-A
[17:28:18] [PASSED] HDMI-B
[17:28:18] ===== [PASSED] drm_test_connector_hdmi_init_type_valid =====
[17:28:18] ======== drm_test_connector_hdmi_init_type_invalid ========
[17:28:18] [PASSED] Unknown
[17:28:18] [PASSED] VGA
[17:28:18] [PASSED] DVI-I
[17:28:18] [PASSED] DVI-D
[17:28:18] [PASSED] DVI-A
[17:28:18] [PASSED] Composite
[17:28:18] [PASSED] SVIDEO
[17:28:18] [PASSED] LVDS
[17:28:18] [PASSED] Component
[17:28:18] [PASSED] DIN
[17:28:18] [PASSED] DP
[17:28:18] [PASSED] TV
[17:28:18] [PASSED] eDP
[17:28:18] [PASSED] Virtual
[17:28:18] [PASSED] DSI
[17:28:18] [PASSED] DPI
[17:28:18] [PASSED] Writeback
[17:28:18] [PASSED] SPI
[17:28:18] [PASSED] USB
[17:28:18] ==== [PASSED] drm_test_connector_hdmi_init_type_invalid ====
[17:28:18] ============ [PASSED] drmm_connector_hdmi_init =============
[17:28:18] ============= drmm_connector_init (3 subtests) =============
[17:28:18] [PASSED] drm_test_drmm_connector_init
[17:28:18] [PASSED] drm_test_drmm_connector_init_null_ddc
[17:28:18] ========= drm_test_drmm_connector_init_type_valid =========
[17:28:18] [PASSED] Unknown
[17:28:18] [PASSED] VGA
[17:28:18] [PASSED] DVI-I
[17:28:18] [PASSED] DVI-D
[17:28:18] [PASSED] DVI-A
[17:28:18] [PASSED] Composite
[17:28:18] [PASSED] SVIDEO
[17:28:18] [PASSED] LVDS
[17:28:18] [PASSED] Component
[17:28:18] [PASSED] DIN
[17:28:18] [PASSED] DP
[17:28:18] [PASSED] HDMI-A
[17:28:18] [PASSED] HDMI-B
[17:28:18] [PASSED] TV
[17:28:18] [PASSED] eDP
[17:28:18] [PASSED] Virtual
[17:28:18] [PASSED] DSI
[17:28:18] [PASSED] DPI
[17:28:18] [PASSED] Writeback
[17:28:18] [PASSED] SPI
[17:28:18] [PASSED] USB
[17:28:18] ===== [PASSED] drm_test_drmm_connector_init_type_valid =====
[17:28:18] =============== [PASSED] drmm_connector_init ===============
[17:28:18] = drm_connector_attach_broadcast_rgb_property (2 subtests) =
[17:28:18] [PASSED] drm_test_drm_connector_attach_broadcast_rgb_property
[17:28:18] [PASSED] drm_test_drm_connector_attach_broadcast_rgb_property_hdmi_connector
[17:28:18] === [PASSED] drm_connector_attach_broadcast_rgb_property ===
[17:28:18] ========== drm_get_tv_mode_from_name (2 subtests) ==========
[17:28:18] ========== drm_test_get_tv_mode_from_name_valid ===========
[17:28:18] [PASSED] NTSC
[17:28:18] [PASSED] NTSC-443
[17:28:18] [PASSED] NTSC-J
[17:28:18] [PASSED] PAL
[17:28:18] [PASSED] PAL-M
[17:28:18] [PASSED] PAL-N
[17:28:18] [PASSED] SECAM
[17:28:18] [PASSED] Mono
[17:28:18] ====== [PASSED] drm_test_get_tv_mode_from_name_valid =======
[17:28:18] [PASSED] drm_test_get_tv_mode_from_name_truncated
[17:28:18] ============ [PASSED] drm_get_tv_mode_from_name ============
[17:28:18] = drm_test_connector_hdmi_compute_mode_clock (12 subtests) =
[17:28:18] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb
[17:28:18] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_10bpc
[17:28:18] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_10bpc_vic_1
[17:28:18] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_12bpc
[17:28:18] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_12bpc_vic_1
[17:28:18] [PASSED] drm_test_drm_hdmi_compute_mode_clock_rgb_double
[17:28:18] = drm_test_connector_hdmi_compute_mode_clock_yuv420_valid =
[17:28:18] [PASSED] VIC 96
[17:28:18] [PASSED] VIC 97
[17:28:18] [PASSED] VIC 101
[17:28:18] [PASSED] VIC 102
[17:28:18] [PASSED] VIC 106
[17:28:18] [PASSED] VIC 107
[17:28:18] === [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv420_valid ===
[17:28:18] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv420_10_bpc
[17:28:18] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv420_12_bpc
[17:28:18] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv422_8_bpc
[17:28:18] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv422_10_bpc
[17:28:18] [PASSED] drm_test_connector_hdmi_compute_mode_clock_yuv422_12_bpc
[17:28:18] === [PASSED] drm_test_connector_hdmi_compute_mode_clock ====
[17:28:18] == drm_hdmi_connector_get_broadcast_rgb_name (2 subtests) ==
[17:28:18] === drm_test_drm_hdmi_connector_get_broadcast_rgb_name ====
[17:28:18] [PASSED] Automatic
[17:28:18] [PASSED] Full
[17:28:18] [PASSED] Limited 16:235
[17:28:18] === [PASSED] drm_test_drm_hdmi_connector_get_broadcast_rgb_name ===
[17:28:18] [PASSED] drm_test_drm_hdmi_connector_get_broadcast_rgb_name_invalid
[17:28:18] ==== [PASSED] drm_hdmi_connector_get_broadcast_rgb_name ====
[17:28:18] == drm_hdmi_connector_get_output_format_name (2 subtests) ==
[17:28:18] === drm_test_drm_hdmi_connector_get_output_format_name ====
[17:28:18] [PASSED] RGB
[17:28:18] [PASSED] YUV 4:2:0
[17:28:18] [PASSED] YUV 4:2:2
[17:28:18] [PASSED] YUV 4:4:4
[17:28:18] === [PASSED] drm_test_drm_hdmi_connector_get_output_format_name ===
[17:28:18] [PASSED] drm_test_drm_hdmi_connector_get_output_format_name_invalid
[17:28:18] ==== [PASSED] drm_hdmi_connector_get_output_format_name ====
[17:28:18] ============= drm_damage_helper (21 subtests) ==============
[17:28:18] [PASSED] drm_test_damage_iter_no_damage
[17:28:18] [PASSED] drm_test_damage_iter_no_damage_fractional_src
[17:28:18] [PASSED] drm_test_damage_iter_no_damage_src_moved
[17:28:18] [PASSED] drm_test_damage_iter_no_damage_fractional_src_moved
[17:28:18] [PASSED] drm_test_damage_iter_no_damage_not_visible
[17:28:18] [PASSED] drm_test_damage_iter_no_damage_no_crtc
[17:28:18] [PASSED] drm_test_damage_iter_no_damage_no_fb
[17:28:18] [PASSED] drm_test_damage_iter_simple_damage
[17:28:18] [PASSED] drm_test_damage_iter_single_damage
[17:28:18] [PASSED] drm_test_damage_iter_single_damage_intersect_src
[17:28:18] [PASSED] drm_test_damage_iter_single_damage_outside_src
[17:28:18] [PASSED] drm_test_damage_iter_single_damage_fractional_src
[17:28:18] [PASSED] drm_test_damage_iter_single_damage_intersect_fractional_src
[17:28:18] [PASSED] drm_test_damage_iter_single_damage_outside_fractional_src
[17:28:18] [PASSED] drm_test_damage_iter_single_damage_src_moved
[17:28:18] [PASSED] drm_test_damage_iter_single_damage_fractional_src_moved
[17:28:18] [PASSED] drm_test_damage_iter_damage
[17:28:18] [PASSED] drm_test_damage_iter_damage_one_intersect
[17:28:18] [PASSED] drm_test_damage_iter_damage_one_outside
[17:28:18] [PASSED] drm_test_damage_iter_damage_src_moved
[17:28:18] [PASSED] drm_test_damage_iter_damage_not_visible
[17:28:18] ================ [PASSED] drm_damage_helper ================
[17:28:18] ============== drm_dp_mst_helper (3 subtests) ==============
[17:28:18] ============== drm_test_dp_mst_calc_pbn_mode ==============
[17:28:18] [PASSED] Clock 154000 BPP 30 DSC disabled
[17:28:18] [PASSED] Clock 234000 BPP 30 DSC disabled
[17:28:18] [PASSED] Clock 297000 BPP 24 DSC disabled
[17:28:18] [PASSED] Clock 332880 BPP 24 DSC enabled
[17:28:18] [PASSED] Clock 324540 BPP 24 DSC enabled
[17:28:18] ========== [PASSED] drm_test_dp_mst_calc_pbn_mode ==========
[17:28:18] ============== drm_test_dp_mst_calc_pbn_div ===============
[17:28:18] [PASSED] Link rate 2000000 lane count 4
[17:28:18] [PASSED] Link rate 2000000 lane count 2
[17:28:18] [PASSED] Link rate 2000000 lane count 1
[17:28:18] [PASSED] Link rate 1350000 lane count 4
[17:28:18] [PASSED] Link rate 1350000 lane count 2
[17:28:18] [PASSED] Link rate 1350000 lane count 1
[17:28:18] [PASSED] Link rate 1000000 lane count 4
[17:28:18] [PASSED] Link rate 1000000 lane count 2
[17:28:18] [PASSED] Link rate 1000000 lane count 1
[17:28:18] [PASSED] Link rate 810000 lane count 4
[17:28:18] [PASSED] Link rate 810000 lane count 2
[17:28:18] [PASSED] Link rate 810000 lane count 1
[17:28:18] [PASSED] Link rate 540000 lane count 4
[17:28:18] [PASSED] Link rate 540000 lane count 2
[17:28:18] [PASSED] Link rate 540000 lane count 1
[17:28:18] [PASSED] Link rate 270000 lane count 4
[17:28:18] [PASSED] Link rate 270000 lane count 2
[17:28:18] [PASSED] Link rate 270000 lane count 1
[17:28:18] [PASSED] Link rate 162000 lane count 4
[17:28:18] [PASSED] Link rate 162000 lane count 2
[17:28:18] [PASSED] Link rate 162000 lane count 1
[17:28:18] ========== [PASSED] drm_test_dp_mst_calc_pbn_div ===========
[17:28:18] ========= drm_test_dp_mst_sideband_msg_req_decode =========
[17:28:18] [PASSED] DP_ENUM_PATH_RESOURCES with port number
[17:28:18] [PASSED] DP_POWER_UP_PHY with port number
[17:28:18] [PASSED] DP_POWER_DOWN_PHY with port number
[17:28:18] [PASSED] DP_ALLOCATE_PAYLOAD with SDP stream sinks
[17:28:18] [PASSED] DP_ALLOCATE_PAYLOAD with port number
[17:28:18] [PASSED] DP_ALLOCATE_PAYLOAD with VCPI
[17:28:18] [PASSED] DP_ALLOCATE_PAYLOAD with PBN
[17:28:18] [PASSED] DP_QUERY_PAYLOAD with port number
[17:28:18] [PASSED] DP_QUERY_PAYLOAD with VCPI
[17:28:18] [PASSED] DP_REMOTE_DPCD_READ with port number
[17:28:18] [PASSED] DP_REMOTE_DPCD_READ with DPCD address
[17:28:18] [PASSED] DP_REMOTE_DPCD_READ with max number of bytes
[17:28:18] [PASSED] DP_REMOTE_DPCD_WRITE with port number
[17:28:18] [PASSED] DP_REMOTE_DPCD_WRITE with DPCD address
[17:28:18] [PASSED] DP_REMOTE_DPCD_WRITE with data array
[17:28:18] [PASSED] DP_REMOTE_I2C_READ with port number
[17:28:18] [PASSED] DP_REMOTE_I2C_READ with I2C device ID
[17:28:18] [PASSED] DP_REMOTE_I2C_READ with transactions array
[17:28:18] [PASSED] DP_REMOTE_I2C_WRITE with port number
[17:28:18] [PASSED] DP_REMOTE_I2C_WRITE with I2C device ID
[17:28:18] [PASSED] DP_REMOTE_I2C_WRITE with data array
[17:28:18] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream ID
[17:28:18] [PASSED] DP_QUERY_STREAM_ENC_STATUS with client ID
[17:28:18] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream event
[17:28:18] [PASSED] DP_QUERY_STREAM_ENC_STATUS with valid stream event
[17:28:18] [PASSED] DP_QUERY_STREAM_ENC_STATUS with stream behavior
[17:28:18] [PASSED] DP_QUERY_STREAM_ENC_STATUS with a valid stream behavior
[17:28:18] ===== [PASSED] drm_test_dp_mst_sideband_msg_req_decode =====
[17:28:18] ================ [PASSED] drm_dp_mst_helper ================
[17:28:18] ================== drm_exec (7 subtests) ===================
[17:28:18] [PASSED] sanitycheck
[17:28:18] [PASSED] test_lock
[17:28:18] [PASSED] test_lock_unlock
[17:28:18] [PASSED] test_duplicates
[17:28:18] [PASSED] test_prepare
[17:28:18] [PASSED] test_prepare_array
[17:28:18] [PASSED] test_multiple_loops
[17:28:18] ==================== [PASSED] drm_exec =====================
[17:28:18] =========== drm_format_helper_test (17 subtests) ===========
[17:28:18] ============== drm_test_fb_xrgb8888_to_gray8 ==============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ========== [PASSED] drm_test_fb_xrgb8888_to_gray8 ==========
[17:28:18] ============= drm_test_fb_xrgb8888_to_rgb332 ==============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb332 ==========
[17:28:18] ============= drm_test_fb_xrgb8888_to_rgb565 ==============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb565 ==========
[17:28:18] ============ drm_test_fb_xrgb8888_to_xrgb1555 =============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ======== [PASSED] drm_test_fb_xrgb8888_to_xrgb1555 =========
[17:28:18] ============ drm_test_fb_xrgb8888_to_argb1555 =============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ======== [PASSED] drm_test_fb_xrgb8888_to_argb1555 =========
[17:28:18] ============ drm_test_fb_xrgb8888_to_rgba5551 =============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ======== [PASSED] drm_test_fb_xrgb8888_to_rgba5551 =========
[17:28:18] ============= drm_test_fb_xrgb8888_to_rgb888 ==============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ========= [PASSED] drm_test_fb_xrgb8888_to_rgb888 ==========
[17:28:18] ============ drm_test_fb_xrgb8888_to_argb8888 =============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ======== [PASSED] drm_test_fb_xrgb8888_to_argb8888 =========
[17:28:18] =========== drm_test_fb_xrgb8888_to_xrgb2101010 ===========
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ======= [PASSED] drm_test_fb_xrgb8888_to_xrgb2101010 =======
[17:28:18] =========== drm_test_fb_xrgb8888_to_argb2101010 ===========
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ======= [PASSED] drm_test_fb_xrgb8888_to_argb2101010 =======
[17:28:18] ============== drm_test_fb_xrgb8888_to_mono ===============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ========== [PASSED] drm_test_fb_xrgb8888_to_mono ===========
[17:28:18] ==================== drm_test_fb_swab =====================
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ================ [PASSED] drm_test_fb_swab =================
[17:28:18] ============ drm_test_fb_xrgb8888_to_xbgr8888 =============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ======== [PASSED] drm_test_fb_xrgb8888_to_xbgr8888 =========
[17:28:18] ============ drm_test_fb_xrgb8888_to_abgr8888 =============
[17:28:18] [PASSED] single_pixel_source_buffer
[17:28:18] [PASSED] single_pixel_clip_rectangle
[17:28:18] [PASSED] well_known_colors
[17:28:18] [PASSED] destination_pitch
[17:28:18] ======== [PASSED] drm_test_fb_xrgb8888_to_abgr8888 =========
[17:28:18] ================= drm_test_fb_clip_offset =================
[17:28:18] [PASSED] pass through
[17:28:18] [PASSED] horizontal offset
[17:28:18] [PASSED] vertical offset
[17:28:18] [PASSED] horizontal and vertical offset
[17:28:18] [PASSED] horizontal offset (custom pitch)
[17:28:18] [PASSED] vertical offset (custom pitch)
[17:28:18] [PASSED] horizontal and vertical offset (custom pitch)
[17:28:18] ============= [PASSED] drm_test_fb_clip_offset =============
[17:28:18] ============== drm_test_fb_build_fourcc_list ==============
[17:28:18] [PASSED] no native formats
[17:28:18] [PASSED] XRGB8888 as native format
[17:28:18] [PASSED] remove duplicates
[17:28:18] [PASSED] convert alpha formats
[17:28:18] [PASSED] random formats
[17:28:18] ========== [PASSED] drm_test_fb_build_fourcc_list ==========
[17:28:18] =================== drm_test_fb_memcpy ====================
[17:28:18] [PASSED] single_pixel_source_buffer: XR24 little-endian (0x34325258)
[17:28:18] [PASSED] single_pixel_source_buffer: XRA8 little-endian (0x38415258)
[17:28:18] [PASSED] single_pixel_source_buffer: YU24 little-endian (0x34325559)
[17:28:18] [PASSED] single_pixel_clip_rectangle: XB24 little-endian (0x34324258)
[17:28:18] [PASSED] single_pixel_clip_rectangle: XRA8 little-endian (0x38415258)
[17:28:18] [PASSED] single_pixel_clip_rectangle: YU24 little-endian (0x34325559)
[17:28:18] [PASSED] well_known_colors: XB24 little-endian (0x34324258)
[17:28:18] [PASSED] well_known_colors: XRA8 little-endian (0x38415258)
[17:28:18] [PASSED] well_known_colors: YU24 little-endian (0x34325559)
[17:28:18] [PASSED] destination_pitch: XB24 little-endian (0x34324258)
[17:28:18] [PASSED] destination_pitch: XRA8 little-endian (0x38415258)
[17:28:18] [PASSED] destination_pitch: YU24 little-endian (0x34325559)
[17:28:18] =============== [PASSED] drm_test_fb_memcpy ================
[17:28:18] ============= [PASSED] drm_format_helper_test ==============
[17:28:18] ================= drm_format (18 subtests) =================
[17:28:18] [PASSED] drm_test_format_block_width_invalid
[17:28:18] [PASSED] drm_test_format_block_width_one_plane
[17:28:18] [PASSED] drm_test_format_block_width_two_plane
[17:28:18] [PASSED] drm_test_format_block_width_three_plane
[17:28:18] [PASSED] drm_test_format_block_width_tiled
[17:28:18] [PASSED] drm_test_format_block_height_invalid
[17:28:18] [PASSED] drm_test_format_block_height_one_plane
[17:28:18] [PASSED] drm_test_format_block_height_two_plane
[17:28:18] [PASSED] drm_test_format_block_height_three_plane
[17:28:18] [PASSED] drm_test_format_block_height_tiled
[17:28:18] [PASSED] drm_test_format_min_pitch_invalid
[17:28:18] [PASSED] drm_test_format_min_pitch_one_plane_8bpp
[17:28:18] [PASSED] drm_test_format_min_pitch_one_plane_16bpp
[17:28:18] [PASSED] drm_test_format_min_pitch_one_plane_24bpp
[17:28:18] [PASSED] drm_test_format_min_pitch_one_plane_32bpp
[17:28:18] [PASSED] drm_test_format_min_pitch_two_plane
[17:28:18] [PASSED] drm_test_format_min_pitch_three_plane_8bpp
[17:28:18] [PASSED] drm_test_format_min_pitch_tiled
[17:28:18] =================== [PASSED] drm_format ====================
[17:28:18] =============== drm_framebuffer (1 subtest) ================
[17:28:18] =============== drm_test_framebuffer_create ===============
[17:28:18] [PASSED] ABGR8888 normal sizes
[17:28:18] [PASSED] ABGR8888 max sizes
[17:28:18] [PASSED] ABGR8888 pitch greater than min required
[17:28:18] [PASSED] ABGR8888 pitch less than min required
[17:28:18] [PASSED] ABGR8888 Invalid width
[17:28:18] [PASSED] ABGR8888 Invalid buffer handle
[17:28:18] [PASSED] No pixel format
[17:28:18] [PASSED] ABGR8888 Width 0
[17:28:18] [PASSED] ABGR8888 Height 0
[17:28:18] [PASSED] ABGR8888 Out of bound height * pitch combination
[17:28:18] [PASSED] ABGR8888 Large buffer offset
[17:28:18] [PASSED] ABGR8888 Set DRM_MODE_FB_MODIFIERS without modifiers
[17:28:18] [PASSED] ABGR8888 Valid buffer modifier
[17:28:18] [PASSED] ABGR8888 Invalid buffer modifier(DRM_FORMAT_MOD_SAMSUNG_64_32_TILE)
[17:28:18] [PASSED] ABGR8888 Extra pitches without DRM_MODE_FB_MODIFIERS
[17:28:18] [PASSED] ABGR8888 Extra pitches with DRM_MODE_FB_MODIFIERS
[17:28:18] [PASSED] NV12 Normal sizes
[17:28:18] [PASSED] NV12 Max sizes
[17:28:18] [PASSED] NV12 Invalid pitch
[17:28:18] [PASSED] NV12 Invalid modifier/missing DRM_MODE_FB_MODIFIERS flag
[17:28:18] [PASSED] NV12 different modifier per-plane
[17:28:18] [PASSED] NV12 with DRM_FORMAT_MOD_SAMSUNG_64_32_TILE
[17:28:18] [PASSED] NV12 Valid modifiers without DRM_MODE_FB_MODIFIERS
[17:28:18] [PASSED] NV12 Modifier for inexistent plane
[17:28:18] [PASSED] NV12 Handle for inexistent plane
[17:28:18] [PASSED] NV12 Handle for inexistent plane without DRM_MODE_FB_MODIFIERS
[17:28:18] [PASSED] YVU420 DRM_MODE_FB_MODIFIERS set without modifier
[17:28:18] [PASSED] YVU420 Normal sizes
[17:28:18] [PASSED] YVU420 Max sizes
[17:28:18] [PASSED] YVU420 Invalid pitch
[17:28:18] [PASSED] YVU420 Different pitches
[17:28:18] [PASSED] YVU420 Different buffer offsets/pitches
[17:28:18] [PASSED] YVU420 Modifier set just for plane 0, without DRM_MODE_FB_MODIFIERS
[17:28:18] [PASSED] YVU420 Modifier set just for planes 0, 1, without DRM_MODE_FB_MODIFIERS
[17:28:18] [PASSED] YVU420 Modifier set just for plane 0, 1, with DRM_MODE_FB_MODIFIERS
[17:28:18] [PASSED] YVU420 Valid modifier
[17:28:18] [PASSED] YVU420 Different modifiers per plane
[17:28:18] [PASSED] YVU420 Modifier for inexistent plane
[17:28:18] [PASSED] X0L2 Normal sizes
[17:28:18] [PASSED] X0L2 Max sizes
[17:28:18] [PASSED] X0L2 Invalid pitch
[17:28:18] [PASSED] X0L2 Pitch greater than minimum required
[17:28:18] [PASSED] X0L2 Handle for inexistent plane
[17:28:18] [PASSED] X0L2 Offset for inexistent plane, without DRM_MODE_FB_MODIFIERS set
[17:28:18] [PASSED] X0L2 Modifier without DRM_MODE_FB_MODIFIERS set
[17:28:18] [PASSED] X0L2 Valid modifier
[17:28:18] [PASSED] X0L2 Modifier for inexistent plane
[17:28:18] =========== [PASSED] drm_test_framebuffer_create ===========
[17:28:18] ================= [PASSED] drm_framebuffer =================
[17:28:18] ================ drm_gem_shmem (8 subtests) ================
[17:28:18] [PASSED] drm_gem_shmem_test_obj_create
[17:28:18] [PASSED] drm_gem_shmem_test_obj_create_private
[17:28:18] [PASSED] drm_gem_shmem_test_pin_pages
[17:28:18] [PASSED] drm_gem_shmem_test_vmap
[17:28:18] [PASSED] drm_gem_shmem_test_get_pages_sgt
[17:28:18] [PASSED] drm_gem_shmem_test_get_sg_table
[17:28:18] [PASSED] drm_gem_shmem_test_madvise
[17:28:18] [PASSED] drm_gem_shmem_test_purge
[17:28:18] ================== [PASSED] drm_gem_shmem ==================
[17:28:18] === drm_atomic_helper_connector_hdmi_check (22 subtests) ===
[17:28:18] [PASSED] drm_test_check_broadcast_rgb_auto_cea_mode
[17:28:18] [PASSED] drm_test_check_broadcast_rgb_auto_cea_mode_vic_1
[17:28:18] [PASSED] drm_test_check_broadcast_rgb_full_cea_mode
[17:28:18] [PASSED] drm_test_check_broadcast_rgb_full_cea_mode_vic_1
[17:28:18] [PASSED] drm_test_check_broadcast_rgb_limited_cea_mode
[17:28:18] [PASSED] drm_test_check_broadcast_rgb_limited_cea_mode_vic_1
[17:28:18] [PASSED] drm_test_check_broadcast_rgb_crtc_mode_changed
[17:28:18] [PASSED] drm_test_check_broadcast_rgb_crtc_mode_not_changed
[17:28:18] [PASSED] drm_test_check_hdmi_funcs_reject_rate
[17:28:18] [PASSED] drm_test_check_max_tmds_rate_bpc_fallback
[17:28:18] [PASSED] drm_test_check_max_tmds_rate_format_fallback
[17:28:18] [PASSED] drm_test_check_output_bpc_crtc_mode_changed
[17:28:18] [PASSED] drm_test_check_output_bpc_crtc_mode_not_changed
[17:28:18] [PASSED] drm_test_check_output_bpc_dvi
[17:28:18] [PASSED] drm_test_check_output_bpc_format_vic_1
[17:28:18] [PASSED] drm_test_check_output_bpc_format_display_8bpc_only
[17:28:18] [PASSED] drm_test_check_output_bpc_format_display_rgb_only
[17:28:18] [PASSED] drm_test_check_output_bpc_format_driver_8bpc_only
[17:28:18] [PASSED] drm_test_check_output_bpc_format_driver_rgb_only
[17:28:18] [PASSED] drm_test_check_tmds_char_rate_rgb_8bpc
[17:28:18] [PASSED] drm_test_check_tmds_char_rate_rgb_10bpc
[17:28:18] [PASSED] drm_test_check_tmds_char_rate_rgb_12bpc
[17:28:18] ===== [PASSED] drm_atomic_helper_connector_hdmi_check ======
[17:28:18] === drm_atomic_helper_connector_hdmi_reset (6 subtests) ====
[17:28:18] [PASSED] drm_test_check_broadcast_rgb_value
[17:28:18] [PASSED] drm_test_check_bpc_8_value
[17:28:18] [PASSED] drm_test_check_bpc_10_value
[17:28:18] [PASSED] drm_test_check_bpc_12_value
[17:28:18] [PASSED] drm_test_check_format_value
[17:28:18] [PASSED] drm_test_check_tmds_char_value
[17:28:18] ===== [PASSED] drm_atomic_helper_connector_hdmi_reset ======
[17:28:18] ================= drm_managed (2 subtests) =================
[17:28:18] [PASSED] drm_test_managed_release_action
[17:28:18] [PASSED] drm_test_managed_run_action
[17:28:18] =================== [PASSED] drm_managed ===================
[17:28:18] =================== drm_mm (6 subtests) ====================
[17:28:18] [PASSED] drm_test_mm_init
[17:28:18] [PASSED] drm_test_mm_debug
[17:28:18] [PASSED] drm_test_mm_align32
[17:28:18] [PASSED] drm_test_mm_align64
[17:28:18] [PASSED] drm_test_mm_lowest
[17:28:18] [PASSED] drm_test_mm_highest
[17:28:18] ===================== [PASSED] drm_mm ======================
[17:28:18] ============= drm_modes_analog_tv (5 subtests) =============
[17:28:18] [PASSED] drm_test_modes_analog_tv_mono_576i
[17:28:18] [PASSED] drm_test_modes_analog_tv_ntsc_480i
[17:28:18] [PASSED] drm_test_modes_analog_tv_ntsc_480i_inlined
[17:28:18] [PASSED] drm_test_modes_analog_tv_pal_576i
[17:28:18] [PASSED] drm_test_modes_analog_tv_pal_576i_inlined
[17:28:18] =============== [PASSED] drm_modes_analog_tv ===============
[17:28:18] ============== drm_plane_helper (2 subtests) ===============
[17:28:18] =============== drm_test_check_plane_state ================
[17:28:18] [PASSED] clipping_simple
[17:28:18] [PASSED] clipping_rotate_reflect
[17:28:18] [PASSED] positioning_simple
[17:28:18] [PASSED] upscaling
[17:28:18] [PASSED] downscaling
[17:28:18] [PASSED] rounding1
[17:28:18] [PASSED] rounding2
[17:28:18] [PASSED] rounding3
[17:28:18] [PASSED] rounding4
[17:28:18] =========== [PASSED] drm_test_check_plane_state ============
[17:28:18] =========== drm_test_check_invalid_plane_state ============
[17:28:18] [PASSED] positioning_invalid
[17:28:18] [PASSED] upscaling_invalid
stty: 'standard input': Inappropriate ioctl for device
[17:28:18] [PASSED] downscaling_invalid
[17:28:18] ======= [PASSED] drm_test_check_invalid_plane_state ========
[17:28:18] ================ [PASSED] drm_plane_helper =================
[17:28:18] ====== drm_connector_helper_tv_get_modes (1 subtest) =======
[17:28:18] ====== drm_test_connector_helper_tv_get_modes_check =======
[17:28:18] [PASSED] None
[17:28:18] [PASSED] PAL
[17:28:18] [PASSED] NTSC
[17:28:18] [PASSED] Both, NTSC Default
[17:28:18] [PASSED] Both, PAL Default
[17:28:18] [PASSED] Both, NTSC Default, with PAL on command-line
[17:28:18] [PASSED] Both, PAL Default, with NTSC on command-line
[17:28:18] == [PASSED] drm_test_connector_helper_tv_get_modes_check ===
[17:28:18] ======== [PASSED] drm_connector_helper_tv_get_modes ========
[17:28:18] ================== drm_rect (9 subtests) ===================
[17:28:18] [PASSED] drm_test_rect_clip_scaled_div_by_zero
[17:28:18] [PASSED] drm_test_rect_clip_scaled_not_clipped
[17:28:18] [PASSED] drm_test_rect_clip_scaled_clipped
[17:28:18] [PASSED] drm_test_rect_clip_scaled_signed_vs_unsigned
[17:28:18] ================= drm_test_rect_intersect =================
[17:28:18] [PASSED] top-left x bottom-right: 2x2+1+1 x 2x2+0+0
[17:28:18] [PASSED] top-right x bottom-left: 2x2+0+0 x 2x2+1-1
[17:28:18] [PASSED] bottom-left x top-right: 2x2+1-1 x 2x2+0+0
[17:28:18] [PASSED] bottom-right x top-left: 2x2+0+0 x 2x2+1+1
[17:28:18] [PASSED] right x left: 2x1+0+0 x 3x1+1+0
[17:28:18] [PASSED] left x right: 3x1+1+0 x 2x1+0+0
[17:28:18] [PASSED] up x bottom: 1x2+0+0 x 1x3+0-1
[17:28:18] [PASSED] bottom x up: 1x3+0-1 x 1x2+0+0
[17:28:18] [PASSED] touching corner: 1x1+0+0 x 2x2+1+1
[17:28:18] [PASSED] touching side: 1x1+0+0 x 1x1+1+0
[17:28:18] [PASSED] equal rects: 2x2+0+0 x 2x2+0+0
[17:28:18] [PASSED] inside another: 2x2+0+0 x 1x1+1+1
[17:28:18] [PASSED] far away: 1x1+0+0 x 1x1+3+6
[17:28:18] [PASSED] points intersecting: 0x0+5+10 x 0x0+5+10
[17:28:18] [PASSED] points not intersecting: 0x0+0+0 x 0x0+5+10
[17:28:18] ============= [PASSED] drm_test_rect_intersect =============
[17:28:18] ================ drm_test_rect_calc_hscale ================
[17:28:18] [PASSED] normal use
[17:28:18] [PASSED] out of max range
[17:28:18] [PASSED] out of min range
[17:28:18] [PASSED] zero dst
[17:28:18] [PASSED] negative src
[17:28:18] [PASSED] negative dst
[17:28:18] ============ [PASSED] drm_test_rect_calc_hscale ============
[17:28:18] ================ drm_test_rect_calc_vscale ================
[17:28:18] [PASSED] normal use
[17:28:18] [PASSED] out of max range
[17:28:18] [PASSED] out of min range
[17:28:18] [PASSED] zero dst
[17:28:18] [PASSED] negative src
[17:28:18] [PASSED] negative dst
[17:28:18] ============ [PASSED] drm_test_rect_calc_vscale ============
[17:28:18] ================== drm_test_rect_rotate ===================
[17:28:18] [PASSED] reflect-x
[17:28:18] [PASSED] reflect-y
[17:28:18] [PASSED] rotate-0
[17:28:18] [PASSED] rotate-90
[17:28:18] [PASSED] rotate-180
[17:28:18] [PASSED] rotate-270
[17:28:18] ============== [PASSED] drm_test_rect_rotate ===============
[17:28:18] ================ drm_test_rect_rotate_inv =================
[17:28:18] [PASSED] reflect-x
[17:28:18] [PASSED] reflect-y
[17:28:18] [PASSED] rotate-0
[17:28:18] [PASSED] rotate-90
[17:28:18] [PASSED] rotate-180
[17:28:18] [PASSED] rotate-270
[17:28:18] ============ [PASSED] drm_test_rect_rotate_inv =============
[17:28:18] ==================== [PASSED] drm_rect =====================
[17:28:18] ============================================================
[17:28:18] Testing complete. Ran 515 tests: passed: 515
[17:28:18] Elapsed time: 43.131s total, 2.891s configuring, 39.963s building, 0.246s running
+ /kernel/tools/testing/kunit/kunit.py run --kunitconfig /kernel/drivers/gpu/drm/ttm/tests/.kunitconfig
[17:28:18] Configuring KUnit Kernel ...
Regenerating .config ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
[17:28:21] Building KUnit Kernel ...
Populating config with:
$ make ARCH=um O=.kunit olddefconfig
Building with:
$ make ARCH=um O=.kunit --jobs=48
[17:28:35] Starting KUnit Kernel (1/1)...
[17:28:35] ============================================================
Running tests with:
$ .kunit/linux kunit.enable=1 mem=1G console=tty kunit_shutdown=halt
[17:28:35] ================= ttm_device (5 subtests) ==================
[17:28:35] [PASSED] ttm_device_init_basic
[17:28:35] [PASSED] ttm_device_init_multiple
[17:28:35] [PASSED] ttm_device_fini_basic
[17:28:35] [PASSED] ttm_device_init_no_vma_man
[17:28:35] ================== ttm_device_init_pools ==================
[17:28:35] [PASSED] No DMA allocations, no DMA32 required
[17:28:35] [PASSED] DMA allocations, DMA32 required
[17:28:35] [PASSED] No DMA allocations, DMA32 required
[17:28:35] [PASSED] DMA allocations, no DMA32 required
[17:28:35] ============== [PASSED] ttm_device_init_pools ==============
[17:28:35] =================== [PASSED] ttm_device ====================
[17:28:35] ================== ttm_pool (8 subtests) ===================
[17:28:35] ================== ttm_pool_alloc_basic ===================
[17:28:35] [PASSED] One page
[17:28:35] [PASSED] More than one page
[17:28:35] [PASSED] Above the allocation limit
[17:28:35] [PASSED] One page, with coherent DMA mappings enabled
[17:28:35] [PASSED] Above the allocation limit, with coherent DMA mappings enabled
[17:28:35] ============== [PASSED] ttm_pool_alloc_basic ===============
[17:28:35] ============== ttm_pool_alloc_basic_dma_addr ==============
[17:28:35] [PASSED] One page
[17:28:35] [PASSED] More than one page
[17:28:35] [PASSED] Above the allocation limit
[17:28:35] [PASSED] One page, with coherent DMA mappings enabled
[17:28:35] [PASSED] Above the allocation limit, with coherent DMA mappings enabled
[17:28:35] ========== [PASSED] ttm_pool_alloc_basic_dma_addr ==========
[17:28:35] [PASSED] ttm_pool_alloc_order_caching_match
[17:28:35] [PASSED] ttm_pool_alloc_caching_mismatch
[17:28:35] [PASSED] ttm_pool_alloc_order_mismatch
[17:28:35] [PASSED] ttm_pool_free_dma_alloc
[17:28:35] [PASSED] ttm_pool_free_no_dma_alloc
[17:28:35] [PASSED] ttm_pool_fini_basic
[17:28:35] ==================== [PASSED] ttm_pool =====================
[17:28:35] ================ ttm_resource (8 subtests) =================
[17:28:35] ================= ttm_resource_init_basic =================
[17:28:35] [PASSED] Init resource in TTM_PL_SYSTEM
[17:28:35] [PASSED] Init resource in TTM_PL_VRAM
[17:28:35] [PASSED] Init resource in a private placement
[17:28:35] [PASSED] Init resource in TTM_PL_SYSTEM, set placement flags
[17:28:35] ============= [PASSED] ttm_resource_init_basic =============
[17:28:35] [PASSED] ttm_resource_init_pinned
[17:28:35] [PASSED] ttm_resource_fini_basic
[17:28:35] [PASSED] ttm_resource_manager_init_basic
[17:28:35] [PASSED] ttm_resource_manager_usage_basic
[17:28:35] [PASSED] ttm_resource_manager_set_used_basic
[17:28:35] [PASSED] ttm_sys_man_alloc_basic
[17:28:35] [PASSED] ttm_sys_man_free_basic
[17:28:35] ================== [PASSED] ttm_resource ===================
[17:28:35] =================== ttm_tt (15 subtests) ===================
[17:28:35] ==================== ttm_tt_init_basic ====================
[17:28:35] [PASSED] Page-aligned size
[17:28:35] [PASSED] Extra pages requested
[17:28:35] ================ [PASSED] ttm_tt_init_basic ================
[17:28:35] [PASSED] ttm_tt_init_misaligned
[17:28:35] [PASSED] ttm_tt_fini_basic
[17:28:35] [PASSED] ttm_tt_fini_sg
[17:28:35] [PASSED] ttm_tt_fini_shmem
[17:28:35] [PASSED] ttm_tt_create_basic
[17:28:35] [PASSED] ttm_tt_create_invalid_bo_type
[17:28:35] [PASSED] ttm_tt_create_ttm_exists
[17:28:35] [PASSED] ttm_tt_create_failed
[17:28:35] [PASSED] ttm_tt_destroy_basic
[17:28:35] [PASSED] ttm_tt_populate_null_ttm
[17:28:35] [PASSED] ttm_tt_populate_populated_ttm
[17:28:35] [PASSED] ttm_tt_unpopulate_basic
[17:28:35] [PASSED] ttm_tt_unpopulate_empty_ttm
[17:28:35] [PASSED] ttm_tt_swapin_basic
[17:28:35] ===================== [PASSED] ttm_tt ======================
[17:28:35] =================== ttm_bo (14 subtests) ===================
[17:28:35] =========== ttm_bo_reserve_optimistic_no_ticket ===========
[17:28:35] [PASSED] Cannot be interrupted and sleeps
[17:28:35] [PASSED] Cannot be interrupted, locks straight away
[17:28:35] [PASSED] Can be interrupted, sleeps
[17:28:35] ======= [PASSED] ttm_bo_reserve_optimistic_no_ticket =======
[17:28:35] [PASSED] ttm_bo_reserve_locked_no_sleep
[17:28:35] [PASSED] ttm_bo_reserve_no_wait_ticket
[17:28:35] [PASSED] ttm_bo_reserve_double_resv
[17:28:35] [PASSED] ttm_bo_reserve_interrupted
[17:28:35] [PASSED] ttm_bo_reserve_deadlock
[17:28:35] [PASSED] ttm_bo_unreserve_basic
[17:28:35] [PASSED] ttm_bo_unreserve_pinned
[17:28:35] [PASSED] ttm_bo_unreserve_bulk
[17:28:35] [PASSED] ttm_bo_put_basic
[17:28:35] [PASSED] ttm_bo_put_shared_resv
[17:28:35] [PASSED] ttm_bo_pin_basic
[17:28:35] [PASSED] ttm_bo_pin_unpin_resource
[17:28:35] [PASSED] ttm_bo_multiple_pin_one_unpin
[17:28:35] ===================== [PASSED] ttm_bo ======================
[17:28:35] ============== ttm_bo_validate (22 subtests) ===============
[17:28:35] ============== ttm_bo_init_reserved_sys_man ===============
[17:28:35] [PASSED] Buffer object for userspace
[17:28:35] [PASSED] Kernel buffer object
[17:28:35] [PASSED] Shared buffer object
[17:28:35] ========== [PASSED] ttm_bo_init_reserved_sys_man ===========
[17:28:35] ============== ttm_bo_init_reserved_mock_man ==============
[17:28:35] [PASSED] Buffer object for userspace
[17:28:35] [PASSED] Kernel buffer object
[17:28:35] [PASSED] Shared buffer object
[17:28:35] ========== [PASSED] ttm_bo_init_reserved_mock_man ==========
[17:28:35] [PASSED] ttm_bo_init_reserved_resv
[17:28:35] ================== ttm_bo_validate_basic ==================
[17:28:35] [PASSED] Buffer object for userspace
[17:28:35] [PASSED] Kernel buffer object
[17:28:35] [PASSED] Shared buffer object
[17:28:35] ============== [PASSED] ttm_bo_validate_basic ==============
[17:28:35] [PASSED] ttm_bo_validate_invalid_placement
[17:28:35] ============= ttm_bo_validate_same_placement ==============
[17:28:35] [PASSED] System manager
[17:28:35] [PASSED] VRAM manager
[17:28:35] ========= [PASSED] ttm_bo_validate_same_placement ==========
[17:28:35] [PASSED] ttm_bo_validate_failed_alloc
[17:28:35] [PASSED] ttm_bo_validate_pinned
[17:28:35] [PASSED] ttm_bo_validate_busy_placement
[17:28:35] ================ ttm_bo_validate_multihop =================
[17:28:35] [PASSED] Buffer object for userspace
[17:28:35] [PASSED] Kernel buffer object
[17:28:35] [PASSED] Shared buffer object
[17:28:35] ============ [PASSED] ttm_bo_validate_multihop =============
[17:28:35] ========== ttm_bo_validate_no_placement_signaled ==========
[17:28:35] [PASSED] Buffer object in system domain, no page vector
[17:28:35] [PASSED] Buffer object in system domain with an existing page vector
[17:28:35] ====== [PASSED] ttm_bo_validate_no_placement_signaled ======
[17:28:35] ======== ttm_bo_validate_no_placement_not_signaled ========
[17:28:35] [PASSED] Buffer object for userspace
[17:28:35] [PASSED] Kernel buffer object
[17:28:35] [PASSED] Shared buffer object
[17:28:35] ==== [PASSED] ttm_bo_validate_no_placement_not_signaled ====
[17:28:35] [PASSED] ttm_bo_validate_move_fence_signaled
[17:28:35] ========= ttm_bo_validate_move_fence_not_signaled =========
[17:28:35] [PASSED] Waits for GPU
[17:28:35] [PASSED] Tries to lock straight away
[17:28:36] ===== [PASSED] ttm_bo_validate_move_fence_not_signaled =====
[17:28:36] [PASSED] ttm_bo_validate_swapout
[17:28:36] [PASSED] ttm_bo_validate_happy_evict
[17:28:36] [PASSED] ttm_bo_validate_all_pinned_evict
[17:28:36] [PASSED] ttm_bo_validate_allowed_only_evict
[17:28:36] [PASSED] ttm_bo_validate_deleted_evict
[17:28:36] [PASSED] ttm_bo_validate_busy_domain_evict
[17:28:36] [PASSED] ttm_bo_validate_evict_gutting
[17:28:36] [PASSED] ttm_bo_validate_recrusive_evict
stty: 'standard input': Inappropriate ioctl for device
[17:28:36] ================= [PASSED] ttm_bo_validate =================
[17:28:36] ============================================================
[17:28:36] Testing complete. Ran 102 tests: passed: 102
[17:28:36] Elapsed time: 17.482s total, 2.571s configuring, 14.138s building, 0.670s running
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel
^ permalink raw reply [flat|nested] 38+ messages in thread
* ✗ CI.Build: failure for series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
` (13 preceding siblings ...)
2024-07-11 17:28 ` ✓ CI.KUnit: " Patchwork
@ 2024-07-11 17:34 ` Patchwork
14 siblings, 0 replies; 38+ messages in thread
From: Patchwork @ 2024-07-11 17:34 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: intel-xe
== Series Details ==
Series: series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk
URL : https://patchwork.freedesktop.org/series/136004/
State : failure
== Summary ==
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml2_policy.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml2_translation_helper.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml2_dc_resource_mgmt.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml2_mall_phantom.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml_display_rq_dlg_calc.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_top/dml_top.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_top/dml_top_mcache.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_top/dml2_top_optimization.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/inc/dml2_debug.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_core/dml2_core_factory.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_core/dml2_core_dcn4_calcs.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_core/dml2_core_shared.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_dpmm/dml2_dpmm_dcn4.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_dpmm/dml2_dpmm_factory.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_mcg/dml2_mcg_dcn4.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_mcg/dml2_mcg_factory.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn3.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_factory.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_pmo/dml2_pmo_dcn4_fams2.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/src/dml2_standalone_libraries/lib_float_math.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/dml21_translation_helper.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/dml21_wrapper.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dml2/dml21/dml21_utils.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce120/dce120_timing_generator.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce112/dce112_compressor.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_timing_generator.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_compressor.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_opp_regamma_v.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_opp_csc_v.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_timing_generator_v.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_mem_input_v.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_opp_v.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce110/dce110_transform_v.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce80/dce80_timing_generator.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce60/dce60_timing_generator.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce60/dce60_hw_sequencer.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dce60/dce60_resource.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/hdcp/hdcp_msg.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/spl/dc_spl.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/spl/dc_spl_scl_filters.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/spl/dc_spl_isharp_filters.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stat.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_resource.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_hw_sequencer.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_sink.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_surface.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_debug.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_stream.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link_enc_cfg.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_link_exports.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_state.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_vm_helper.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dc_helper.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dc_dmub_srv.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dc_edid_parser.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dc/dc_spl_translate.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/freesync/freesync.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/color/color_gamma.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/color/color_table.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/info_packet/info_packet.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/power/power_helpers.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_srv.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_srv_stat.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_reg.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn20.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn21.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn30.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn301.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn302.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn303.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn31.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn314.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn315.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn316.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn32.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn35.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn351.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/dmub/src/dmub_dcn401.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp_ddc.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp_log.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp_psp.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp1_execution.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp1_transition.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp2_execution.o
CC [M] drivers/gpu/drm/amd/amdgpu/../display/modules/hdcp/hdcp2_transition.o
LD [M] drivers/gpu/drm/amd/amdgpu/amdgpu.o
make[5]: *** [../scripts/Makefile.build:485: drivers/gpu/drm] Error 2
make[4]: *** [../scripts/Makefile.build:485: drivers/gpu] Error 2
make[3]: *** [../scripts/Makefile.build:485: drivers] Error 2
make[2]: *** [/kernel/Makefile:1934: .] Error 2
make[1]: *** [/kernel/Makefile:240: __sub-make] Error 2
make[1]: Leaving directory '/kernel/build64-default'
make: *** [Makefile:240: __sub-make] Error 2
+ cleanup
++ stat -c %u:%g /kernel
+ chown -R 1003:1003 /kernel
^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: [PATCH 03/12] drm/xe: Remove unnecessary drm_mm.h includes
2024-07-11 17:11 ` [PATCH 03/12] drm/xe: Remove unnecessary drm_mm.h includes Rodrigo Vivi
@ 2024-07-11 18:35 ` Cavitt, Jonathan
0 siblings, 0 replies; 38+ messages in thread
From: Cavitt, Jonathan @ 2024-07-11 18:35 UTC (permalink / raw)
To: Vivi, Rodrigo, intel-xe@lists.freedesktop.org
Cc: Vivi, Rodrigo, Cavitt, Jonathan
-----Original Message-----
From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Rodrigo Vivi
Sent: Thursday, July 11, 2024 10:12 AM
To: intel-xe@lists.freedesktop.org
Cc: Vivi, Rodrigo <rodrigo.vivi@intel.com>
Subject: [PATCH 03/12] drm/xe: Remove unnecessary drm_mm.h includes
>
> These includes are no longer necessary, and where appropriate
> replace by the linux/types.h one.
s/replace/are replaced/
But otherwise:
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
-Jonathan Cavitt
>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_migrate.h | 2 +-
> drivers/gpu/drm/xe/xe_res_cursor.h | 1 -
> drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c | 1 -
> 3 files changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_migrate.h b/drivers/gpu/drm/xe/xe_migrate.h
> index 453e0ecf5034..f2af9355c051 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.h
> +++ b/drivers/gpu/drm/xe/xe_migrate.h
> @@ -6,7 +6,7 @@
> #ifndef _XE_MIGRATE_
> #define _XE_MIGRATE_
>
> -#include <drm/drm_mm.h>
> +#include <linux/types.h>
>
> struct dma_fence;
> struct iosys_map;
> diff --git a/drivers/gpu/drm/xe/xe_res_cursor.h b/drivers/gpu/drm/xe/xe_res_cursor.h
> index 655af89b31a9..dca374b6521c 100644
> --- a/drivers/gpu/drm/xe/xe_res_cursor.h
> +++ b/drivers/gpu/drm/xe/xe_res_cursor.h
> @@ -26,7 +26,6 @@
>
> #include <linux/scatterlist.h>
>
> -#include <drm/drm_mm.h>
> #include <drm/ttm/ttm_placement.h>
> #include <drm/ttm/ttm_range_manager.h>
> #include <drm/ttm/ttm_resource.h>
> diff --git a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
> index f46fd2df84de..f7113cf6109d 100644
> --- a/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
> +++ b/drivers/gpu/drm/xe/xe_ttm_stolen_mgr.c
> @@ -5,7 +5,6 @@
> */
>
> #include <drm/drm_managed.h>
> -#include <drm/drm_mm.h>
>
> #include <drm/ttm/ttm_device.h>
> #include <drm/ttm/ttm_placement.h>
> --
> 2.45.2
>
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: [PATCH 04/12] drm/{i915, xe}: Avoid direct inspection of dpt_vma from outside dpt
2024-07-11 17:11 ` [PATCH 04/12] drm/{i915, xe}: Avoid direct inspection of dpt_vma from outside dpt Rodrigo Vivi
@ 2024-07-11 18:38 ` Cavitt, Jonathan
0 siblings, 0 replies; 38+ messages in thread
From: Cavitt, Jonathan @ 2024-07-11 18:38 UTC (permalink / raw)
To: Vivi, Rodrigo, intel-xe@lists.freedesktop.org
Cc: Vivi, Rodrigo, Brost, Matthew, Maarten Lankhorst,
Juha-Pekka Heikkila, Cavitt, Jonathan
-----Original Message-----
From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Rodrigo Vivi
Sent: Thursday, July 11, 2024 10:12 AM
To: intel-xe@lists.freedesktop.org
Cc: Vivi, Rodrigo <rodrigo.vivi@intel.com>; Brost, Matthew <matthew.brost@intel.com>; Maarten Lankhorst <maarten.lankhorst@linux.intel.com>; Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
Subject: [PATCH 04/12] drm/{i915, xe}: Avoid direct inspection of dpt_vma from outside dpt
>
> DPT code is so dependent on i915 vma implementation and it is not
> ported yet to Xe.
>
> This patch limits inspection to DPT's VMA struct to intel_dpt
> component only, so the Xe GGTT code can evolve.
>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
LGTM.
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
-Jonathan Cavitt
> ---
> drivers/gpu/drm/i915/display/intel_dpt.c | 4 ++++
> drivers/gpu/drm/i915/display/intel_dpt.h | 1 +
> drivers/gpu/drm/i915/display/skl_universal_plane.c | 3 ++-
> drivers/gpu/drm/xe/display/xe_fb_pin.c | 9 +++++++--
> 4 files changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_dpt.c b/drivers/gpu/drm/i915/display/intel_dpt.c
> index 73a1918e2537..3a6d99044828 100644
> --- a/drivers/gpu/drm/i915/display/intel_dpt.c
> +++ b/drivers/gpu/drm/i915/display/intel_dpt.c
> @@ -317,3 +317,7 @@ void intel_dpt_destroy(struct i915_address_space *vm)
> i915_vm_put(&dpt->vm);
> }
>
> +u64 intel_dpt_offset(struct i915_vma *dpt_vma)
> +{
> + return dpt_vma->node.start;
> +}
> diff --git a/drivers/gpu/drm/i915/display/intel_dpt.h b/drivers/gpu/drm/i915/display/intel_dpt.h
> index ff18a525bfbe..7336e905142d 100644
> --- a/drivers/gpu/drm/i915/display/intel_dpt.h
> +++ b/drivers/gpu/drm/i915/display/intel_dpt.h
> @@ -20,5 +20,6 @@ void intel_dpt_suspend(struct drm_i915_private *i915);
> void intel_dpt_resume(struct drm_i915_private *i915);
> struct i915_address_space *
> intel_dpt_create(struct intel_framebuffer *fb);
> +u64 intel_dpt_offset(struct i915_vma *dpt_vma);
>
> #endif /* __INTEL_DPT_H__ */
> diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> index ba5a628b4757..1cf1d5c8b9dc 100644
> --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
> +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
> @@ -14,6 +14,7 @@
> #include "intel_de.h"
> #include "intel_display_irq.h"
> #include "intel_display_types.h"
> +#include "intel_dpt.h"
> #include "intel_fb.h"
> #include "intel_fbc.h"
> #include "intel_frontbuffer.h"
> @@ -1162,7 +1163,7 @@ static u32 skl_surf_address(const struct intel_plane_state *plane_state,
> * within the DPT is always 0.
> */
> drm_WARN_ON(&i915->drm, plane_state->dpt_vma &&
> - plane_state->dpt_vma->node.start);
> + intel_dpt_offset(plane_state->dpt_vma));
> drm_WARN_ON(&i915->drm, offset & 0x1fffff);
> return offset >> 9;
> } else {
> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> index d7db44e79eaf..42d431ff14e7 100644
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -377,8 +377,8 @@ void intel_plane_unpin_fb(struct intel_plane_state *old_plane_state)
> }
>
> /*
> - * For Xe introduce dummy intel_dpt_create which just return NULL and
> - * intel_dpt_destroy which does nothing.
> + * For Xe introduce dummy intel_dpt_create which just return NULL,
> + * intel_dpt_destroy which does nothing, and fake intel_dpt_ofsset returning 0;
> */
> struct i915_address_space *intel_dpt_create(struct intel_framebuffer *fb)
> {
> @@ -389,3 +389,8 @@ void intel_dpt_destroy(struct i915_address_space *vm)
> {
> return;
> }
> +
> +u64 intel_dpt_offset(struct i915_vma *dpt_vma)
> +{
> + return 0;
> +}
> --
> 2.45.2
>
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* RE: [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes
2024-07-11 17:11 ` [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes Rodrigo Vivi
@ 2024-07-11 18:43 ` Cavitt, Jonathan
2024-07-11 20:09 ` Michal Wajdeczko
1 sibling, 0 replies; 38+ messages in thread
From: Cavitt, Jonathan @ 2024-07-11 18:43 UTC (permalink / raw)
To: Vivi, Rodrigo, intel-xe@lists.freedesktop.org
Cc: Vivi, Rodrigo, Wajdeczko, Michal, Cavitt, Jonathan
-----Original Message-----
From: Intel-xe <intel-xe-bounces@lists.freedesktop.org> On Behalf Of Rodrigo Vivi
Sent: Thursday, July 11, 2024 10:12 AM
To: intel-xe@lists.freedesktop.org
Cc: Vivi, Rodrigo <rodrigo.vivi@intel.com>; Wajdeczko, Michal <Michal.Wajdeczko@intel.com>
Subject: [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes
>
> Introduce a new xe_ggtt_print_holes helper that attends the SRIOV
> demand and finishes the goal of limiting drm_mm access to xe_ggtt.
>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
LGTM.
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
-Jonathan Cavitt
> ---
> drivers/gpu/drm/xe/xe_ggtt.c | 40 ++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_ggtt.h | 1 +
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 25 +-------------
> 3 files changed, 42 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index dbaf1ce87fb4..5b51753fe1ba 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -682,3 +682,43 @@ int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p)
> mutex_unlock(&ggtt->lock);
> return err;
> }
> +
> +/**
> + * xe_ggtt_print_holes - Print holes
> + * @ggtt: the &xe_ggtt to be inspected
> + * @alignment: min alignment
> + * @p: the &drm_printer
> + *
> + * Print GGTT ranges that are available and return total size available.
> + *
> + * Return: Total available size.
> + */
> +u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer *p)
> +{
> + const struct drm_mm *mm = &ggtt->mm;
> + const struct drm_mm_node *entry;
> + u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
> + u64 hole_start, hole_end, hole_size;
> + u64 total;
> + char buf[10];
> +
> + mutex_lock(&ggtt->lock);
> +
> + drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> + hole_start = max(hole_start, hole_min_start);
> + hole_start = ALIGN(hole_start, alignment);
> + hole_end = ALIGN_DOWN(hole_end, alignment);
> + if (hole_start >= hole_end)
> + continue;
> + hole_size = hole_end - hole_start;
> + total += hole_size;
> +
> + string_get_size(hole_size, 1, STRING_UNITS_2, buf, sizeof(buf));
> + drm_printf(p, "range:\t%#llx-%#llx\t(%s)\n",
> + hole_start, hole_end - 1, buf);
> + }
> +
> + mutex_unlock(&ggtt->lock);
> +
> + return total;
> +}
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 31060fe7644b..67ae5f1602a3 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -32,6 +32,7 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
>
> int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
> +u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer *p);
>
> #ifdef CONFIG_PCI_IOV
> void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct xe_ggtt_node *node, u16 vfid);
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index 1d17c34fe5a4..d0995680f53f 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -6,9 +6,6 @@
> #include <linux/string_choices.h>
> #include <linux/wordpart.h>
>
> -/* FIXME: remove this after encapsulating all drm_mm_node access into xe_ggtt */
> -#include <drm/drm_mm.h>
> -
> #include "abi/guc_actions_sriov_abi.h"
> #include "abi/guc_klvs_abi.h"
>
> @@ -2096,11 +2093,7 @@ int xe_gt_sriov_pf_config_print_dbs(struct xe_gt *gt, struct drm_printer *p)
> int xe_gt_sriov_pf_config_print_available_ggtt(struct xe_gt *gt, struct drm_printer *p)
> {
> struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
> - const struct drm_mm *mm = &ggtt->mm;
> - const struct drm_mm_node *entry;
> u64 alignment = pf_get_ggtt_alignment(gt);
> - u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
> - u64 hole_start, hole_end, hole_size;
> u64 spare, avail, total = 0;
> char buf[10];
>
> @@ -2109,24 +2102,8 @@ int xe_gt_sriov_pf_config_print_available_ggtt(struct xe_gt *gt, struct drm_prin
> mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
>
> spare = pf_get_spare_ggtt(gt);
> + total = xe_ggtt_print_holes(ggtt, alignment, p);
>
> - mutex_lock(&ggtt->lock);
> -
> - drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> - hole_start = max(hole_start, hole_min_start);
> - hole_start = ALIGN(hole_start, alignment);
> - hole_end = ALIGN_DOWN(hole_end, alignment);
> - if (hole_start >= hole_end)
> - continue;
> - hole_size = hole_end - hole_start;
> - total += hole_size;
> -
> - string_get_size(hole_size, 1, STRING_UNITS_2, buf, sizeof(buf));
> - drm_printf(p, "range:\t%#llx-%#llx\t(%s)\n",
> - hole_start, hole_end - 1, buf);
> - }
> -
> - mutex_unlock(&ggtt->lock);
> mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
>
> string_get_size(total, 1, STRING_UNITS_2, buf, sizeof(buf));
> --
> 2.45.2
>
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 02/12] drm/xe: Introduce GGTT documentation
2024-07-11 17:11 ` [PATCH 02/12] drm/xe: Introduce GGTT documentation Rodrigo Vivi
@ 2024-07-11 19:41 ` Michal Wajdeczko
0 siblings, 0 replies; 38+ messages in thread
From: Michal Wajdeczko @ 2024-07-11 19:41 UTC (permalink / raw)
To: Rodrigo Vivi, intel-xe; +Cc: Matthew Brost, Himal Prasad Ghimiray
On 11.07.2024 19:11, Rodrigo Vivi wrote:
> Document xe_ggtt and ensure it is part of the built kernel docs.
>
> v2: - Accepted all Michal's suggestions
> - Rebased on top of new set_pte per platform/wa function pointer
>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com> #v1
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> Documentation/gpu/xe/xe_mm.rst | 15 ++++
> drivers/gpu/drm/xe/xe_ggtt.c | 136 +++++++++++++++++++++++------
> drivers/gpu/drm/xe/xe_ggtt_types.h | 32 +++++--
> 3 files changed, 148 insertions(+), 35 deletions(-)
>
> diff --git a/Documentation/gpu/xe/xe_mm.rst b/Documentation/gpu/xe/xe_mm.rst
> index 6c8fd8b4a466..95864a4502dd 100644
> --- a/Documentation/gpu/xe/xe_mm.rst
> +++ b/Documentation/gpu/xe/xe_mm.rst
> @@ -7,6 +7,21 @@ Memory Management
> .. kernel-doc:: drivers/gpu/drm/xe/xe_bo_doc.h
> :doc: Buffer Objects (BO)
>
> +GGTT
> +====
> +
> +.. kernel-doc:: drivers/gpu/drm/xe/xe_ggtt.c
> + :doc: Global Graphics Translation Table (GGTT)
> +
> +GGTT Internal API
> +-----------------
> +
> +.. kernel-doc:: drivers/gpu/drm/xe/xe_ggtt_types.h
> + :internal:
> +
> +.. kernel-doc:: drivers/gpu/drm/xe/xe_ggtt.c
> + :internal:
> +
> Pagetable building
> ==================
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index add14f3dea1f..709ef48f2fdb 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -30,6 +30,39 @@
> #include "xe_wa.h"
> #include "xe_wopcm.h"
>
> +/**
> + * DOC: Global Graphics Translation Table (GGTT)
> + *
> + * Xe GGTT implements the support for a Global Virtual Address space that is used
> + * for resources that are accessible to privileged (i.e. kernel-mode) processes,
> + * and not tied to a specific user-level process. For example, the Graphics
> + * micro-Controller (GuC) and Display Engine (if present) utilize this Global
> + * address space.
> + *
> + * The Global GTT (GGTT) translates from the Global virtual address to a physical
> + * address that can be accessed by HW. The GGTT is a flat, single-level table.
> + *
> + * Xe implements a simplified version of the GGTT specifically managing only a
> + * certain range of it that goes from the WOPCM (Write-Once Power Control Module)
this is "Write Once Protected Content Memory"
and if we ever include xe_wopcm.c to the doc then we can link with
"Write Once Protected Content Memory (WOPCM) Layout"
> + * to a predefined GUC_GGTT_TOP. This approach avoids complications related to
> + * the GuC (Graphics Microcontroller) hardware limitations. The GuC address space
> + * is limited on both ends of the GGTT, because the GuC shim HW redirects
> + * accesses to those addresses to other HW areas instead of going through the
> + * GGTT. On the bottom end, the GuC can't access offsets below the WOPCM size,
> + * while on the top side the limit is fixed at GUC_GGTT_TOP. To keep things
> + * simple, instead of checking each object to see if they are accessed by GuC or
> + * not, we just exclude those areas from the allocator. Additionally, to simplify
> + * the driver load, we use the maximum WOPCM size in this logic instead of the
> + * programmed one, so we don't need to wait until the actual size to be
> + * programmed is determined (which requires FW fetch) before initializing the
> + * GGTT. These simplifications might waste space in the GGTT (about 20-25 MBs
> + * depending on the platform) but we can live with this. Another benifit of this
typo: benefit
> + * is the GuC bootrom can't access anything below the WOPCM max size so anything
> + * the bootom needs to access (e.g. a RSA key) needs to be placed in the GGTT
typo: bootrom
> + * above the WOPCM max size. Starting the GGTT allocations above the WOPCM max
> + * give us the correct placement for free.
> + */
> +
> static u64 xelp_ggtt_pte_encode_bo(struct xe_bo *bo, u64 bo_offset,
> u16 pat_index)
> {
> @@ -164,12 +197,16 @@ static const struct xe_ggtt_pt_ops xelpg_pt_wa_ops = {
> .ggtt_set_pte = xe_ggtt_set_pte_and_flush,
> };
>
> -/*
> - * Early GGTT initialization, which allows to create new mappings usable by the
> - * GuC.
> - * Mappings are not usable by the HW engines, as it doesn't have scratch /
> +/**
> + * xe_ggtt_init_early - Early GGTT initialization
> + * @ggtt: the &xe_ggtt to be initialized
> + *
> + * It allows to create new mappings usable by the GuC.
> + * Mappings are not usable by the HW engines, as it doesn't have scratch nor
> * initial clear done to it yet. That will happen in the regular, non-early
> - * GGTT init.
> + * GGTT initialization.
> + *
> + * Return: 0 on success or a negative error code on failure.
> */
> int xe_ggtt_init_early(struct xe_ggtt *ggtt)
> {
> @@ -194,29 +231,6 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
> if (IS_DGFX(xe) && xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K)
> ggtt->flags |= XE_GGTT_FLAGS_64K;
>
> - /*
> - * 8B per entry, each points to a 4KB page.
> - *
> - * The GuC address space is limited on both ends of the GGTT, because
> - * the GuC shim HW redirects accesses to those addresses to other HW
> - * areas instead of going through the GGTT. On the bottom end, the GuC
> - * can't access offsets below the WOPCM size, while on the top side the
> - * limit is fixed at GUC_GGTT_TOP. To keep things simple, instead of
> - * checking each object to see if they are accessed by GuC or not, we
> - * just exclude those areas from the allocator. Additionally, to
> - * simplify the driver load, we use the maximum WOPCM size in this logic
> - * instead of the programmed one, so we don't need to wait until the
> - * actual size to be programmed is determined (which requires FW fetch)
> - * before initializing the GGTT. These simplifications might waste space
> - * in the GGTT (about 20-25 MBs depending on the platform) but we can
> - * live with this.
> - *
> - * Another benifit of this is the GuC bootrom can't access anything
> - * below the WOPCM max size so anything the bootom needs to access (e.g.
> - * a RSA key) needs to be placed in the GGTT above the WOPCM max size.
> - * Starting the GGTT allocations above the WOPCM max give us the correct
> - * placement for free.
> - */
> if (ggtt->size > GUC_GGTT_TOP)
> ggtt->size = GUC_GGTT_TOP;
>
> @@ -262,6 +276,12 @@ static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt)
> mutex_unlock(&ggtt->lock);
> }
>
> +/**
> + * xe_ggtt_init - Regular non-early GGTT initialization
> + * @ggtt: the &xe_ggtt to be initialized
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> int xe_ggtt_init(struct xe_ggtt *ggtt)
> {
> struct xe_device *xe = tile_to_xe(ggtt->tile);
> @@ -382,6 +402,18 @@ void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node)
> mutex_unlock(&ggtt->lock);
> }
>
> +/**
> + * xe_ggtt_insert_special_node_locked - Locked version to insert a &drm_mm_node into the GGTT
> + * @ggtt: the &xe_ggtt where node will be inserted
> + * @node: the &drm_mm_node to be inserted
> + * @size: size of the node
> + * @align: alignment constrain of the node
> + * @mm_flags: flags to control the node behavior
> + *
> + * To be used in cases where ggtt->lock is already taken.
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> u32 size, u32 align, u32 mm_flags)
> {
> @@ -389,6 +421,15 @@ int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct drm_mm_node
> mm_flags);
> }
>
> +/**
> + * xe_ggtt_insert_special_node - Insert a &drm_mm_node into the GGTT
> + * @ggtt: the &xe_ggtt where node will be inserted
> + * @node: the &drm_mm_node to be inserted
> + * @size: size of the node
> + * @align: alignment constrain of the node
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> u32 size, u32 align)
> {
> @@ -402,6 +443,11 @@ int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> return ret;
> }
>
> +/**
> + * xe_ggtt_map_bo - Map the BO into GGTT
> + * @ggtt: the &xe_ggtt where node will be mapped
> + * @bo: the &xe_bo to be mapped
> + */
> void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> {
> u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
> @@ -449,17 +495,39 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> return err;
> }
>
> +/**
> + * xe_ggtt_insert_bo_at - Insert BO at a specific GGTT space
> + * @ggtt: the &xe_ggtt where bo will be inserted
> + * @bo: the &xe_bo to be inserted
> + * @start: address where it will be inserted
> + * @end: end of the range where it will be inserted
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> u64 start, u64 end)
> {
> return __xe_ggtt_insert_bo_at(ggtt, bo, start, end);
> }
>
> +/**
> + * xe_ggtt_insert_bo - Insert BO into GGTT
> + * @ggtt: the &xe_ggtt where bo will be inserted
> + * @bo: the &xe_bo to be inserted
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> {
> return __xe_ggtt_insert_bo_at(ggtt, bo, 0, U64_MAX);
> }
>
> +/**
> + * xe_ggtt_remove_node - Remove a &drm_mm_node from the GGTT
> + * @ggtt: the &xe_ggtt where node will be removed
> + * @node: the &drm_mm_node to be removed
> + * @invalidate: if node needs invalidation upon removal
> + */
> void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> bool invalidate)
> {
> @@ -488,6 +556,11 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> drm_dev_exit(idx);
> }
>
> +/**
> + * xe_ggtt_remove_bo - Remove a BO from the GGTT
> + * @ggtt: the &xe_ggtt where node will be removed
> + * @bo: the &xe_bo to be removed
> + */
> void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> {
> if (XE_WARN_ON(!bo->ggtt_node.size))
> @@ -544,6 +617,13 @@ void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vf
> }
> #endif
>
> +/**
> + * xe_ggtt_dump - Dump GGTT for debug
> + * @ggtt: the &xe_ggtt to be dumped
> + * @p: the &drm_mm_printer helper handle to be used to dump the information
> + *
> + * Return: 0 on success or a negative error code on failure.
> + */
> int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p)
> {
> int err;
> diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
> index 2245d88d8f39..4e2114201b35 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt_types.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
> @@ -13,30 +13,48 @@
> struct xe_bo;
> struct xe_gt;
>
> +/**
> + * struct xe_ggtt - Main GGTT struct
separation line?
> + * In general, each tile can contains its own GGTT instance.
maybe worth to link with "Global Graphics Translation Table (GGTT)"
> + */
> struct xe_ggtt {
> + /** @tile: Back pointer to tile where this GGTT belongs */
> struct xe_tile *tile;
> -
> + /** @size: Total size of this GGTT */
> u64 size;
>
> #define XE_GGTT_FLAGS_64K BIT(0)
> + /**
> + * @flags: Flags for this GGTT
> + * Acceptable flags:
> + * - %XE_GGTT_FLAGS_64K - if PTE size is 64K. Otherwise, regular is 4K.
> + */
> unsigned int flags;
> -
> + /** @scratch: Internal object allocation used as a scratch page */
> struct xe_bo *scratch;
> -
> + /** @lock: Mutex lock to protect GGTT data */
> struct mutex lock;
> -
> + /**
> + * @gsm: The iomem pointer to the actual location of the translation
> + * table located in the GSM for easy PTE manipulation
> + */
> u64 __iomem *gsm;
> -
> + /** @pt_ops: Page Table operations per platform */
> const struct xe_ggtt_pt_ops *pt_ops;
> -
> + /** @mm: The memory manager used to manage individual GGTT allocations */
> struct drm_mm mm;
> -
> /** @access_count: counts GGTT writes */
> unsigned int access_count;
> };
>
> +/**
> + * struct xe_ggtt_pt_ops - GGTT Page table operations
> + * Which can vary from platform to platform.
> + */
> struct xe_ggtt_pt_ops {
> + /** @pte_encode_bo: Encode PTE address for a given BO */
> u64 (*pte_encode_bo)(struct xe_bo *bo, u64 bo_offset, u16 pat_index);
> + /** @ggtt_set_pte: Directly write into GGTT's PTE */
> void (*ggtt_set_pte)(struct xe_ggtt *ggtt, u64 addr, u64 pte);
> };
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 05/12] drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node
2024-07-11 17:11 ` [PATCH 05/12] drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node Rodrigo Vivi
@ 2024-07-11 19:51 ` Michal Wajdeczko
2024-07-16 17:16 ` Matthew Brost
1 sibling, 0 replies; 38+ messages in thread
From: Michal Wajdeczko @ 2024-07-11 19:51 UTC (permalink / raw)
To: Rodrigo Vivi, intel-xe; +Cc: Matthew Brost
On 11.07.2024 19:11, Rodrigo Vivi wrote:
> 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 delagated
typo: delegated
> to a delayed workqueue.
>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> .../gpu/drm/xe/compat-i915-headers/i915_vma.h | 7 +-
> drivers/gpu/drm/xe/display/xe_fb_pin.c | 10 +--
> drivers/gpu/drm/xe/xe_bo.c | 2 +-
> drivers/gpu/drm/xe/xe_bo.h | 6 +-
> drivers/gpu/drm/xe/xe_bo_types.h | 5 +-
> drivers/gpu/drm/xe/xe_device_types.h | 2 +-
> drivers/gpu/drm/xe/xe_ggtt.c | 72 +++++++++----------
> drivers/gpu/drm/xe/xe_ggtt.h | 12 ++--
> drivers/gpu/drm/xe/xe_ggtt_types.h | 8 +++
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 39 +++++-----
> .../gpu/drm/xe/xe_gt_sriov_pf_config_types.h | 4 +-
> 11 files changed, 90 insertions(+), 77 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
> index a20d2638ea7a..97193e660f6c 100644
> --- a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
> +++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
> @@ -7,7 +7,8 @@
> #define I915_VMA_H
>
> #include <uapi/drm/i915_drm.h>
> -#include <drm/drm_mm.h>
> +
> +#include <xe_ggtt_types.h>
this should be ""
>
> /* 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
> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> index 42d431ff14e7..a93923fb8721 100644
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -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);
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index 31192d983d9e..3501a5871069 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -1090,7 +1090,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
> diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
> index 6de894c728f5..7c95133cc32b 100644
> --- a/drivers/gpu/drm/xe/xe_bo.h
> +++ b/drivers/gpu/drm/xe/xe_bo.h
> @@ -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);
> diff --git a/drivers/gpu/drm/xe/xe_bo_types.h b/drivers/gpu/drm/xe/xe_bo_types.h
> index ebc8abf7930a..3ba96a93623c 100644
> --- a/drivers/gpu/drm/xe/xe_bo_types.h
> +++ b/drivers/gpu/drm/xe/xe_bo_types.h
> @@ -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>
use ""
> +
> 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. */
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
> index f0cf9020e463..30f9c58932bb 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -203,7 +203,7 @@ struct xe_tile {
> struct xe_memirq memirq;
>
> /** @sriov.vf.ggtt_balloon: GGTT regions excluded from use. */
> - struct drm_mm_node ggtt_balloon[2];
> + struct xe_ggtt_node ggtt_balloon[2];
> } vf;
> } sriov;
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 709ef48f2fdb..ea55c7eabee4 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -351,61 +351,61 @@ static void xe_ggtt_dump_node(struct xe_ggtt *ggtt,
> * @ggtt: the &xe_ggtt where we want to make reservation
> * @start: the starting GGTT address of the reserved region
> * @end: then end GGTT address of the reserved region
> - * @node: the &drm_mm_node to hold reserved GGTT node
> + * @node: the &xe_ggtt_node to hold reserved GGTT node
> *
> * Use xe_ggtt_deballoon() to release a reserved GGTT node.
> *
> * Return: 0 on success or a negative error code on failure.
> */
> -int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct drm_mm_node *node)
> +int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_node *node)
> {
> int err;
>
> xe_tile_assert(ggtt->tile, start < end);
> xe_tile_assert(ggtt->tile, IS_ALIGNED(start, XE_PAGE_SIZE));
> xe_tile_assert(ggtt->tile, IS_ALIGNED(end, XE_PAGE_SIZE));
> - xe_tile_assert(ggtt->tile, !drm_mm_node_allocated(node));
> + xe_tile_assert(ggtt->tile, !drm_mm_node_allocated(&node->base));
>
> - node->color = 0;
> - node->start = start;
> - node->size = end - start;
> + node->base.color = 0;
> + node->base.start = start;
> + node->base.size = end - start;
>
> mutex_lock(&ggtt->lock);
> - err = drm_mm_reserve_node(&ggtt->mm, node);
> + err = drm_mm_reserve_node(&ggtt->mm, &node->base);
> mutex_unlock(&ggtt->lock);
>
> if (xe_gt_WARN(ggtt->tile->primary_gt, err,
> "Failed to balloon GGTT %#llx-%#llx (%pe)\n",
> - node->start, node->start + node->size, ERR_PTR(err)))
> + node->base.start, node->base.start + node->base.size, ERR_PTR(err)))
> return err;
>
> - xe_ggtt_dump_node(ggtt, node, "balloon");
> + xe_ggtt_dump_node(ggtt, &node->base, "balloon");
> return 0;
> }
>
> /**
> * xe_ggtt_deballoon - release a reserved GGTT region
> * @ggtt: the &xe_ggtt where reserved node belongs
> - * @node: the &drm_mm_node with reserved GGTT region
> + * @node: the &xe_ggtt_node with reserved GGTT region
> *
> * See xe_ggtt_balloon() for details.
> */
> -void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node)
> +void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> {
> - if (!drm_mm_node_allocated(node))
> + if (!drm_mm_node_allocated(&node->base))
> return;
>
> - xe_ggtt_dump_node(ggtt, node, "deballoon");
> + xe_ggtt_dump_node(ggtt, &node->base, "deballoon");
>
> mutex_lock(&ggtt->lock);
> - drm_mm_remove_node(node);
> + drm_mm_remove_node(&node->base);
> mutex_unlock(&ggtt->lock);
> }
>
> /**
> - * xe_ggtt_insert_special_node_locked - Locked version to insert a &drm_mm_node into the GGTT
> + * xe_ggtt_insert_special_node_locked - Locked version to insert a &xe_ggtt_node into the GGTT
> * @ggtt: the &xe_ggtt where node will be inserted
> - * @node: the &drm_mm_node to be inserted
> + * @node: the &xe_ggtt_node to be inserted
> * @size: size of the node
> * @align: alignment constrain of the node
> * @mm_flags: flags to control the node behavior
> @@ -414,23 +414,23 @@ void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node)
> *
> * Return: 0 on success or a negative error code on failure.
> */
> -int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> +int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> u32 size, u32 align, u32 mm_flags)
> {
> - return drm_mm_insert_node_generic(&ggtt->mm, node, size, align, 0,
> + return drm_mm_insert_node_generic(&ggtt->mm, &node->base, size, align, 0,
> mm_flags);
> }
>
> /**
> - * xe_ggtt_insert_special_node - Insert a &drm_mm_node into the GGTT
> + * xe_ggtt_insert_special_node - Insert a &xe_ggtt_node into the GGTT
> * @ggtt: the &xe_ggtt where node will be inserted
> - * @node: the &drm_mm_node to be inserted
> + * @node: the &xe_ggtt_node to be inserted
> * @size: size of the node
> * @align: alignment constrain of the node
> *
> * Return: 0 on success or a negative error code on failure.
> */
> -int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> +int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> u32 size, u32 align)
> {
> int ret;
> @@ -452,7 +452,7 @@ void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> {
> u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
> u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
> - u64 start = bo->ggtt_node.start;
> + u64 start = bo->ggtt_node.base.start;
> u64 offset, pte;
>
> for (offset = 0; offset < bo->size; offset += XE_PAGE_SIZE) {
> @@ -470,9 +470,9 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> if (xe_bo_is_vram(bo) && ggtt->flags & XE_GGTT_FLAGS_64K)
> alignment = SZ_64K;
>
> - if (XE_WARN_ON(bo->ggtt_node.size)) {
> + if (XE_WARN_ON(bo->ggtt_node.base.size)) {
> /* Someone's already inserted this BO in the GGTT */
> - xe_tile_assert(ggtt->tile, bo->ggtt_node.size == bo->size);
> + xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
> return 0;
> }
>
> @@ -482,7 +482,7 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
>
> xe_pm_runtime_get_noresume(tile_to_xe(ggtt->tile));
> mutex_lock(&ggtt->lock);
> - err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node, bo->size,
> + err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node.base, bo->size,
> alignment, 0, start, end, 0);
> if (!err)
> xe_ggtt_map_bo(ggtt, bo);
> @@ -523,12 +523,12 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> }
>
> /**
> - * xe_ggtt_remove_node - Remove a &drm_mm_node from the GGTT
> + * xe_ggtt_remove_node - Remove a &xe_ggtt_node from the GGTT
> * @ggtt: the &xe_ggtt where node will be removed
> - * @node: the &drm_mm_node to be removed
> + * @node: the &xe_ggtt_node to be removed
> * @invalidate: if node needs invalidation upon removal
> */
> -void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> +void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> bool invalidate)
> {
> struct xe_device *xe = tile_to_xe(ggtt->tile);
> @@ -541,9 +541,9 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
>
> mutex_lock(&ggtt->lock);
> if (bound)
> - xe_ggtt_clear(ggtt, node->start, node->size);
> - drm_mm_remove_node(node);
> - node->size = 0;
> + xe_ggtt_clear(ggtt, node->base.start, node->base.size);
> + drm_mm_remove_node(&node->base);
> + node->base.size = 0;
> mutex_unlock(&ggtt->lock);
>
> if (!bound)
> @@ -563,11 +563,11 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> */
> void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> {
> - if (XE_WARN_ON(!bo->ggtt_node.size))
> + if (XE_WARN_ON(!bo->ggtt_node.base.size))
> return;
>
> /* This BO is not currently in the GGTT */
> - xe_tile_assert(ggtt->tile, bo->ggtt_node.size == bo->size);
> + xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
>
> xe_ggtt_remove_node(ggtt, &bo->ggtt_node,
> bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
> @@ -602,17 +602,17 @@ static void xe_ggtt_assign_locked(struct xe_ggtt *ggtt, const struct drm_mm_node
> /**
> * xe_ggtt_assign - assign a GGTT region to the VF
> * @ggtt: the &xe_ggtt where the node belongs
> - * @node: the &drm_mm_node to update
> + * @node: the &xe_ggtt_node to update
> * @vfid: the VF identifier
> *
> * This function is used by the PF driver to assign a GGTT region to the VF.
> * In addition to PTE's VFID bits 11:2 also PRESENT bit 0 is set as on some
> * platforms VFs can't modify that either.
> */
> -void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vfid)
> +void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct xe_ggtt_node *node, u16 vfid)
> {
> mutex_lock(&ggtt->lock);
> - xe_ggtt_assign_locked(ggtt, node, vfid);
> + xe_ggtt_assign_locked(ggtt, &node->base, vfid);
> mutex_unlock(&ggtt->lock);
> }
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 2546bab97507..30a521f7b075 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -13,15 +13,15 @@ struct drm_printer;
> int xe_ggtt_init_early(struct xe_ggtt *ggtt);
> int xe_ggtt_init(struct xe_ggtt *ggtt);
>
> -int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct drm_mm_node *node);
> -void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node);
> +int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
> +void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
>
> -int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> +int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> u32 size, u32 align);
> int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt,
> - struct drm_mm_node *node,
> + struct xe_ggtt_node *node,
> u32 size, u32 align, u32 mm_flags);
> -void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> +void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> bool invalidate);
> void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> @@ -32,7 +32,7 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
>
> #ifdef CONFIG_PCI_IOV
> -void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vfid);
> +void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct xe_ggtt_node *node, u16 vfid);
> #endif
>
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
> index 4e2114201b35..f3292e6c3873 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt_types.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
> @@ -47,6 +47,14 @@ struct xe_ggtt {
> unsigned int access_count;
> };
>
> +/**
> + * struct xe_ggtt_node - A node in GGTT
> + */
> +struct xe_ggtt_node {
> + /** @base: A drm_mm_node */
> + struct drm_mm_node base;
> +};
> +
> /**
> * struct xe_ggtt_pt_ops - GGTT Page table operations
> * Which can vary from platform to platform.
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index db6c213da847..3600468da013 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -6,6 +6,9 @@
> #include <linux/string_choices.h>
> #include <linux/wordpart.h>
>
> +/* FIXME: remove this after encapsulating all drm_mm_node access into xe_ggtt */
> +#include <drm/drm_mm.h>
> +
> #include "abi/guc_actions_sriov_abi.h"
> #include "abi/guc_klvs_abi.h"
>
> @@ -232,14 +235,14 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config)
> {
> u32 n = 0;
>
> - if (drm_mm_node_allocated(&config->ggtt_region)) {
> + if (drm_mm_node_allocated(&config->ggtt_region.base)) {
> cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_START);
> - cfg[n++] = lower_32_bits(config->ggtt_region.start);
> - cfg[n++] = upper_32_bits(config->ggtt_region.start);
> + cfg[n++] = lower_32_bits(config->ggtt_region.base.start);
> + cfg[n++] = upper_32_bits(config->ggtt_region.base.start);
>
> cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_SIZE);
> - cfg[n++] = lower_32_bits(config->ggtt_region.size);
> - cfg[n++] = upper_32_bits(config->ggtt_region.size);
> + cfg[n++] = lower_32_bits(config->ggtt_region.base.size);
> + cfg[n++] = upper_32_bits(config->ggtt_region.base.size);
> }
>
> return n;
> @@ -369,11 +372,11 @@ static int pf_distribute_config_ggtt(struct xe_tile *tile, unsigned int vfid, u6
> return err ?: err2;
> }
>
> -static void pf_release_ggtt(struct xe_tile *tile, struct drm_mm_node *node)
> +static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
> {
> struct xe_ggtt *ggtt = tile->mem.ggtt;
>
> - if (drm_mm_node_allocated(node)) {
> + if (drm_mm_node_allocated(&node->base)) {
> /*
> * explicit GGTT PTE assignment to the PF using xe_ggtt_assign()
> * is redundant, as PTE will be implicitly re-assigned to PF by
> @@ -391,7 +394,7 @@ static void pf_release_vf_config_ggtt(struct xe_gt *gt, struct xe_gt_sriov_confi
> static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
> {
> struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
> - struct drm_mm_node *node = &config->ggtt_region;
> + struct xe_ggtt_node *node = &config->ggtt_region;
> struct xe_tile *tile = gt_to_tile(gt);
> struct xe_ggtt *ggtt = tile->mem.ggtt;
> u64 alignment = pf_get_ggtt_alignment(gt);
> @@ -403,14 +406,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
>
> size = round_up(size, alignment);
>
> - if (drm_mm_node_allocated(node)) {
> + if (drm_mm_node_allocated(&node->base)) {
> err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
> if (unlikely(err))
> return err;
>
> pf_release_ggtt(tile, node);
> }
> - xe_gt_assert(gt, !drm_mm_node_allocated(node));
> + xe_gt_assert(gt, !drm_mm_node_allocated(&node->base));
>
> if (!size)
> return 0;
> @@ -421,9 +424,9 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
>
> xe_ggtt_assign(ggtt, node, vfid);
> xe_gt_sriov_dbg_verbose(gt, "VF%u assigned GGTT %llx-%llx\n",
> - vfid, node->start, node->start + node->size - 1);
> + vfid, node->base.start, node->base.start + node->base.size - 1);
>
> - err = pf_distribute_config_ggtt(gt->tile, vfid, node->start, node->size);
> + err = pf_distribute_config_ggtt(gt->tile, vfid, node->base.start, node->base.size);
> if (unlikely(err))
> return err;
>
> @@ -433,10 +436,10 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
> static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
> {
> struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
> - struct drm_mm_node *node = &config->ggtt_region;
> + struct xe_ggtt_node *node = &config->ggtt_region;
>
> xe_gt_assert(gt, !xe_gt_is_media_type(gt));
> - return drm_mm_node_allocated(node) ? node->size : 0;
> + return drm_mm_node_allocated(&node->base) ? node->base.size : 0;
> }
>
> /**
> @@ -2018,13 +2021,13 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
>
> for (n = 1; n <= total_vfs; n++) {
> config = >->sriov.pf.vfs[n].config;
> - if (!drm_mm_node_allocated(&config->ggtt_region))
> + if (!drm_mm_node_allocated(&config->ggtt_region.base))
> continue;
>
> - string_get_size(config->ggtt_region.size, 1, STRING_UNITS_2, buf, sizeof(buf));
> + string_get_size(config->ggtt_region.base.size, 1, STRING_UNITS_2, buf, sizeof(buf));
> drm_printf(p, "VF%u:\t%#0llx-%#llx\t(%s)\n",
> - n, config->ggtt_region.start,
> - config->ggtt_region.start + config->ggtt_region.size - 1, buf);
> + n, config->ggtt_region.base.start,
> + config->ggtt_region.base.start + config->ggtt_region.base.size - 1, buf);
> }
>
> return 0;
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> index 7bc66656fcc7..6d0d9299bafa 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> @@ -6,7 +6,7 @@
> #ifndef _XE_GT_SRIOV_PF_CONFIG_TYPES_H_
> #define _XE_GT_SRIOV_PF_CONFIG_TYPES_H_
>
> -#include <drm/drm_mm.h>
> +#include <xe_ggtt_types.h>
use "" and put together with other "xe" headers
>
> #include "xe_guc_klv_thresholds_set_types.h"
>
> @@ -19,7 +19,7 @@ struct xe_bo;
> */
> struct xe_gt_sriov_config {
> /** @ggtt_region: GGTT region assigned to the VF. */
> - struct drm_mm_node ggtt_region;
> + struct xe_ggtt_node ggtt_region;
> /** @lmem_obj: LMEM allocation for use by the VF. */
> struct xe_bo *lmem_obj;
> /** @num_ctxs: number of GuC contexts IDs. */
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole
2024-07-11 17:11 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
@ 2024-07-11 20:00 ` Michal Wajdeczko
2024-08-09 21:33 ` Rodrigo Vivi
0 siblings, 1 reply; 38+ messages in thread
From: Michal Wajdeczko @ 2024-07-11 20:00 UTC (permalink / raw)
To: Rodrigo Vivi, intel-xe
On 11.07.2024 19:11, Rodrigo Vivi wrote:
> Introduce a new xe_ggtt_largest_hole helper that attends the SRIOV
> demand and continue with the goal of limiting drm_mm access to xe_ggtt.
>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_ggtt.c | 35 ++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_ggtt.h | 1 +
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 23 ++------------
> 3 files changed, 38 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 67337bfeb81e..dbaf1ce87fb4 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -584,6 +584,41 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
> }
>
> +/**
> + * xe_ggtt_largest_hole - Largest GGTT hole
> + * @ggtt: the &xe_ggtt that will be inspected
> + * @alignment: mininum alignment
typo: minimum
> + * @spare: If not NULL: in: desired memory size to be spared / out: Adjusted possible spare
> + *
> + * Return: size of the largest continuous GGTT region
> + */
> +u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare)
> +{
> + const struct drm_mm *mm = &ggtt->mm;
> + const struct drm_mm_node *entry;
> + u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
this is likely not needed any more as xe_ggtt is always above WOPCM
(unlikely to previous driver ;)
> + u64 hole_start, hole_end, hole_size;
> + u64 max_hole = 0;
> +
> + mutex_lock(&ggtt->lock);
> +
> + drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> + hole_start = max(hole_start, hole_min_start);
> + hole_start = ALIGN(hole_start, alignment);
> + hole_end = ALIGN_DOWN(hole_end, alignment);
> + if (hole_start >= hole_end)
> + continue;
> + hole_size = hole_end - hole_start;
> + if (spare)
> + *spare -= min3(*spare, hole_size, max_hole);
> + max_hole = max(max_hole, hole_size);
> + }
> +
> + mutex_unlock(&ggtt->lock);
> +
> + return max_hole;
> +}
> +
> #ifdef CONFIG_PCI_IOV
> static u64 xe_encode_vfid_pte(u16 vfid)
> {
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index f816b3c0732b..31060fe7644b 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -29,6 +29,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> u64 start, u64 end);
> void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> +u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
>
> int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
>
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index efaf188290ea..1d17c34fe5a4 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -590,30 +590,11 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
> static u64 pf_get_max_ggtt(struct xe_gt *gt)
> {
> struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
> - const struct drm_mm *mm = &ggtt->mm;
> - const struct drm_mm_node *entry;
> u64 alignment = pf_get_ggtt_alignment(gt);
> u64 spare = pf_get_spare_ggtt(gt);
> - u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
> - u64 hole_start, hole_end, hole_size;
> - u64 max_hole = 0;
> -
> - mutex_lock(&ggtt->lock);
> -
> - drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> - hole_start = max(hole_start, hole_min_start);
> - hole_start = ALIGN(hole_start, alignment);
> - hole_end = ALIGN_DOWN(hole_end, alignment);
> - if (hole_start >= hole_end)
> - continue;
> - hole_size = hole_end - hole_start;
> - xe_gt_sriov_dbg_verbose(gt, "HOLE start %llx size %lluK\n",
> - hole_start, hole_size / SZ_1K);
> - spare -= min3(spare, hole_size, max_hole);
> - max_hole = max(max_hole, hole_size);
> - }
> + u64 max_hole;
>
> - mutex_unlock(&ggtt->lock);
> + max_hole = xe_ggtt_largest_hole(ggtt, alignment, &spare);
>
> xe_gt_sriov_dbg_verbose(gt, "HOLE max %lluK reserved %lluK\n",
> max_hole / SZ_1K, spare / SZ_1K);
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes
2024-07-11 17:11 ` [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes Rodrigo Vivi
2024-07-11 18:43 ` Cavitt, Jonathan
@ 2024-07-11 20:09 ` Michal Wajdeczko
2024-08-09 21:38 ` Rodrigo Vivi
1 sibling, 1 reply; 38+ messages in thread
From: Michal Wajdeczko @ 2024-07-11 20:09 UTC (permalink / raw)
To: Rodrigo Vivi, intel-xe
On 11.07.2024 19:11, Rodrigo Vivi wrote:
> Introduce a new xe_ggtt_print_holes helper that attends the SRIOV
> demand and finishes the goal of limiting drm_mm access to xe_ggtt.
>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_ggtt.c | 40 ++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_ggtt.h | 1 +
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 25 +-------------
> 3 files changed, 42 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index dbaf1ce87fb4..5b51753fe1ba 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -682,3 +682,43 @@ int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p)
> mutex_unlock(&ggtt->lock);
> return err;
> }
> +
> +/**
> + * xe_ggtt_print_holes - Print holes
> + * @ggtt: the &xe_ggtt to be inspected
> + * @alignment: min alignment
> + * @p: the &drm_printer
> + *
> + * Print GGTT ranges that are available and return total size available.
> + *
> + * Return: Total available size.
I would rather prefer to lost that info than make the 'print' function
return some real value (which may be immediately stale as it will be out
of mutex)
> + */
> +u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer *p)
> +{
> + const struct drm_mm *mm = &ggtt->mm;
> + const struct drm_mm_node *entry;
> + u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
> + u64 hole_start, hole_end, hole_size;
> + u64 total;
> + char buf[10];
> +
> + mutex_lock(&ggtt->lock);
> +
> + drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> + hole_start = max(hole_start, hole_min_start);
> + hole_start = ALIGN(hole_start, alignment);
> + hole_end = ALIGN_DOWN(hole_end, alignment);
> + if (hole_start >= hole_end)
> + continue;
> + hole_size = hole_end - hole_start;
> + total += hole_size;
> +
> + string_get_size(hole_size, 1, STRING_UNITS_2, buf, sizeof(buf));
> + drm_printf(p, "range:\t%#llx-%#llx\t(%s)\n",
> + hole_start, hole_end - 1, buf);
> + }
or we can print that 'total' here, as it is still kind of related since
it is "sum of all holes" ;)
> +
> + mutex_unlock(&ggtt->lock);
> +
> + return total;
> +}
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 31060fe7644b..67ae5f1602a3 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -32,6 +32,7 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
>
> int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
hmm, maybe xe_ggtt_dump() from prev patch should be xe_ggtt_print() ?
> +u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer *p);
>
> #ifdef CONFIG_PCI_IOV
> void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct xe_ggtt_node *node, u16 vfid);
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index 1d17c34fe5a4..d0995680f53f 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -6,9 +6,6 @@
> #include <linux/string_choices.h>
> #include <linux/wordpart.h>
>
> -/* FIXME: remove this after encapsulating all drm_mm_node access into xe_ggtt */
> -#include <drm/drm_mm.h>
> -
> #include "abi/guc_actions_sriov_abi.h"
> #include "abi/guc_klvs_abi.h"
>
> @@ -2096,11 +2093,7 @@ int xe_gt_sriov_pf_config_print_dbs(struct xe_gt *gt, struct drm_printer *p)
> int xe_gt_sriov_pf_config_print_available_ggtt(struct xe_gt *gt, struct drm_printer *p)
> {
> struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
> - const struct drm_mm *mm = &ggtt->mm;
> - const struct drm_mm_node *entry;
> u64 alignment = pf_get_ggtt_alignment(gt);
> - u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
> - u64 hole_start, hole_end, hole_size;
> u64 spare, avail, total = 0;
> char buf[10];
>
> @@ -2109,24 +2102,8 @@ int xe_gt_sriov_pf_config_print_available_ggtt(struct xe_gt *gt, struct drm_prin
> mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
>
> spare = pf_get_spare_ggtt(gt);
> + total = xe_ggtt_print_holes(ggtt, alignment, p);
>
> - mutex_lock(&ggtt->lock);
> -
> - drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> - hole_start = max(hole_start, hole_min_start);
> - hole_start = ALIGN(hole_start, alignment);
> - hole_end = ALIGN_DOWN(hole_end, alignment);
> - if (hole_start >= hole_end)
> - continue;
> - hole_size = hole_end - hole_start;
> - total += hole_size;
> -
> - string_get_size(hole_size, 1, STRING_UNITS_2, buf, sizeof(buf));
> - drm_printf(p, "range:\t%#llx-%#llx\t(%s)\n",
> - hole_start, hole_end - 1, buf);
> - }
> -
> - mutex_unlock(&ggtt->lock);
> mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
>
> string_get_size(total, 1, STRING_UNITS_2, buf, sizeof(buf));
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 10/12] drm/xe: Rename xe_ggtt balloon functions to make the node clear
2024-07-11 17:11 ` [PATCH 10/12] drm/xe: Rename xe_ggtt balloon functions to make the node clear Rodrigo Vivi
@ 2024-07-11 20:17 ` Michal Wajdeczko
2024-08-09 21:42 ` Rodrigo Vivi
0 siblings, 1 reply; 38+ messages in thread
From: Michal Wajdeczko @ 2024-07-11 20:17 UTC (permalink / raw)
To: Rodrigo Vivi, intel-xe
On 11.07.2024 19:11, Rodrigo Vivi wrote:
> These operations are related to node. Convert them to the
> new appropriate name space xe_ggtt_node.
hmm, actually these operations were meant to be GGTT related [1], but it
was suggested that it would be better to keep required nodes on the
client side
[1] https://patchwork.freedesktop.org/patch/341977/?series=69844&rev=1
but maybe we can return to this idea and on the Xe driver lets hide
balloon nodes inside the xe_ggtt ?
and later on we may want to add xe_ggtt_reballoon() to shift the range
>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_ggtt.c | 12 ++++++------
> drivers/gpu/drm/xe/xe_ggtt.h | 4 ++--
> drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 10 +++++-----
> 3 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 5b51753fe1ba..928c01f9e212 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -347,17 +347,17 @@ static void xe_ggtt_dump_node(struct xe_ggtt *ggtt,
> }
>
> /**
> - * xe_ggtt_balloon - prevent allocation of specified GGTT addresses
> + * xe_ggtt_node_balloon - prevent allocation of specified GGTT addresses
> * @ggtt: the &xe_ggtt where we want to make reservation
> * @start: the starting GGTT address of the reserved region
> * @end: then end GGTT address of the reserved region
> * @node: the &xe_ggtt_node to hold reserved GGTT node
> *
> - * Use xe_ggtt_deballoon() to release a reserved GGTT node.
> + * Use xe_ggtt_node_deballoon() to release a reserved GGTT node.
> *
> * Return: 0 on success or a negative error code on failure.
> */
> -int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_node *node)
> +int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_node *node)
> {
> int err;
>
> @@ -384,13 +384,13 @@ int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_nod
> }
>
> /**
> - * xe_ggtt_deballoon - release a reserved GGTT region
> + * xe_ggtt_node_deballoon - release a reserved GGTT region
> * @ggtt: the &xe_ggtt where reserved node belongs
> * @node: the &xe_ggtt_node with reserved GGTT region
> *
> - * See xe_ggtt_balloon() for details.
> + * See xe_ggtt_node_balloon() for details.
> */
> -void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> +void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> {
> if (!drm_mm_node_allocated(&node->base))
> return;
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 67ae5f1602a3..e68cede2e6b5 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -13,8 +13,8 @@ struct drm_printer;
> int xe_ggtt_init_early(struct xe_ggtt *ggtt);
> int xe_ggtt_init(struct xe_ggtt *ggtt);
>
> -int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
> -void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
> +int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
> +void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
>
> int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> u32 size, u32 align);
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> index 41e46a00c01e..a478e6e1b20e 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> @@ -528,7 +528,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
> start = xe_wopcm_size(xe);
> end = config->ggtt_base;
> if (end != start) {
> - err = xe_ggtt_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[0]);
> + err = xe_ggtt_node_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[0]);
> if (err)
> goto failed;
> }
> @@ -536,7 +536,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
> start = config->ggtt_base + config->ggtt_size;
> end = GUC_GGTT_TOP;
> if (end != start) {
> - err = xe_ggtt_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[1]);
> + err = xe_ggtt_node_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[1]);
> if (err)
> goto deballoon;
> }
> @@ -544,7 +544,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
> return 0;
>
> deballoon:
> - xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
> + xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
> failed:
> return err;
> }
> @@ -555,8 +555,8 @@ static void deballoon_ggtt(struct drm_device *drm, void *arg)
> struct xe_ggtt *ggtt = tile->mem.ggtt;
>
> xe_tile_assert(tile, IS_SRIOV_VF(tile_to_xe(tile)));
> - xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[1]);
> - xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
> + xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[1]);
> + xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
> }
>
> /**
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 05/12] drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node
2024-07-11 17:11 ` [PATCH 05/12] drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node Rodrigo Vivi
2024-07-11 19:51 ` Michal Wajdeczko
@ 2024-07-16 17:16 ` Matthew Brost
1 sibling, 0 replies; 38+ messages in thread
From: Matthew Brost @ 2024-07-16 17:16 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: intel-xe
On Thu, Jul 11, 2024 at 01:11:48PM -0400, Rodrigo Vivi wrote:
> 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 delagated
> to a delayed workqueue.
>
> Cc: Matthew Brost <matthew.brost@intel.com>
Agree with Michal's nits, but the changes in this patch LGTM.
With Michal's comments addressed:
Reviewed-by: Matthew Brost <matthew.brost@intel.com.
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> .../gpu/drm/xe/compat-i915-headers/i915_vma.h | 7 +-
> drivers/gpu/drm/xe/display/xe_fb_pin.c | 10 +--
> drivers/gpu/drm/xe/xe_bo.c | 2 +-
> drivers/gpu/drm/xe/xe_bo.h | 6 +-
> drivers/gpu/drm/xe/xe_bo_types.h | 5 +-
> drivers/gpu/drm/xe/xe_device_types.h | 2 +-
> drivers/gpu/drm/xe/xe_ggtt.c | 72 +++++++++----------
> drivers/gpu/drm/xe/xe_ggtt.h | 12 ++--
> drivers/gpu/drm/xe/xe_ggtt_types.h | 8 +++
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 39 +++++-----
> .../gpu/drm/xe/xe_gt_sriov_pf_config_types.h | 4 +-
> 11 files changed, 90 insertions(+), 77 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
> index a20d2638ea7a..97193e660f6c 100644
> --- a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
> +++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
> @@ -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
> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> index 42d431ff14e7..a93923fb8721 100644
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -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);
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index 31192d983d9e..3501a5871069 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -1090,7 +1090,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
> diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
> index 6de894c728f5..7c95133cc32b 100644
> --- a/drivers/gpu/drm/xe/xe_bo.h
> +++ b/drivers/gpu/drm/xe/xe_bo.h
> @@ -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);
> diff --git a/drivers/gpu/drm/xe/xe_bo_types.h b/drivers/gpu/drm/xe/xe_bo_types.h
> index ebc8abf7930a..3ba96a93623c 100644
> --- a/drivers/gpu/drm/xe/xe_bo_types.h
> +++ b/drivers/gpu/drm/xe/xe_bo_types.h
> @@ -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. */
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
> index f0cf9020e463..30f9c58932bb 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -203,7 +203,7 @@ struct xe_tile {
> struct xe_memirq memirq;
>
> /** @sriov.vf.ggtt_balloon: GGTT regions excluded from use. */
> - struct drm_mm_node ggtt_balloon[2];
> + struct xe_ggtt_node ggtt_balloon[2];
> } vf;
> } sriov;
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 709ef48f2fdb..ea55c7eabee4 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -351,61 +351,61 @@ static void xe_ggtt_dump_node(struct xe_ggtt *ggtt,
> * @ggtt: the &xe_ggtt where we want to make reservation
> * @start: the starting GGTT address of the reserved region
> * @end: then end GGTT address of the reserved region
> - * @node: the &drm_mm_node to hold reserved GGTT node
> + * @node: the &xe_ggtt_node to hold reserved GGTT node
> *
> * Use xe_ggtt_deballoon() to release a reserved GGTT node.
> *
> * Return: 0 on success or a negative error code on failure.
> */
> -int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct drm_mm_node *node)
> +int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_node *node)
> {
> int err;
>
> xe_tile_assert(ggtt->tile, start < end);
> xe_tile_assert(ggtt->tile, IS_ALIGNED(start, XE_PAGE_SIZE));
> xe_tile_assert(ggtt->tile, IS_ALIGNED(end, XE_PAGE_SIZE));
> - xe_tile_assert(ggtt->tile, !drm_mm_node_allocated(node));
> + xe_tile_assert(ggtt->tile, !drm_mm_node_allocated(&node->base));
>
> - node->color = 0;
> - node->start = start;
> - node->size = end - start;
> + node->base.color = 0;
> + node->base.start = start;
> + node->base.size = end - start;
>
> mutex_lock(&ggtt->lock);
> - err = drm_mm_reserve_node(&ggtt->mm, node);
> + err = drm_mm_reserve_node(&ggtt->mm, &node->base);
> mutex_unlock(&ggtt->lock);
>
> if (xe_gt_WARN(ggtt->tile->primary_gt, err,
> "Failed to balloon GGTT %#llx-%#llx (%pe)\n",
> - node->start, node->start + node->size, ERR_PTR(err)))
> + node->base.start, node->base.start + node->base.size, ERR_PTR(err)))
> return err;
>
> - xe_ggtt_dump_node(ggtt, node, "balloon");
> + xe_ggtt_dump_node(ggtt, &node->base, "balloon");
> return 0;
> }
>
> /**
> * xe_ggtt_deballoon - release a reserved GGTT region
> * @ggtt: the &xe_ggtt where reserved node belongs
> - * @node: the &drm_mm_node with reserved GGTT region
> + * @node: the &xe_ggtt_node with reserved GGTT region
> *
> * See xe_ggtt_balloon() for details.
> */
> -void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node)
> +void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> {
> - if (!drm_mm_node_allocated(node))
> + if (!drm_mm_node_allocated(&node->base))
> return;
>
> - xe_ggtt_dump_node(ggtt, node, "deballoon");
> + xe_ggtt_dump_node(ggtt, &node->base, "deballoon");
>
> mutex_lock(&ggtt->lock);
> - drm_mm_remove_node(node);
> + drm_mm_remove_node(&node->base);
> mutex_unlock(&ggtt->lock);
> }
>
> /**
> - * xe_ggtt_insert_special_node_locked - Locked version to insert a &drm_mm_node into the GGTT
> + * xe_ggtt_insert_special_node_locked - Locked version to insert a &xe_ggtt_node into the GGTT
> * @ggtt: the &xe_ggtt where node will be inserted
> - * @node: the &drm_mm_node to be inserted
> + * @node: the &xe_ggtt_node to be inserted
> * @size: size of the node
> * @align: alignment constrain of the node
> * @mm_flags: flags to control the node behavior
> @@ -414,23 +414,23 @@ void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node)
> *
> * Return: 0 on success or a negative error code on failure.
> */
> -int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> +int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> u32 size, u32 align, u32 mm_flags)
> {
> - return drm_mm_insert_node_generic(&ggtt->mm, node, size, align, 0,
> + return drm_mm_insert_node_generic(&ggtt->mm, &node->base, size, align, 0,
> mm_flags);
> }
>
> /**
> - * xe_ggtt_insert_special_node - Insert a &drm_mm_node into the GGTT
> + * xe_ggtt_insert_special_node - Insert a &xe_ggtt_node into the GGTT
> * @ggtt: the &xe_ggtt where node will be inserted
> - * @node: the &drm_mm_node to be inserted
> + * @node: the &xe_ggtt_node to be inserted
> * @size: size of the node
> * @align: alignment constrain of the node
> *
> * Return: 0 on success or a negative error code on failure.
> */
> -int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> +int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> u32 size, u32 align)
> {
> int ret;
> @@ -452,7 +452,7 @@ void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> {
> u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
> u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
> - u64 start = bo->ggtt_node.start;
> + u64 start = bo->ggtt_node.base.start;
> u64 offset, pte;
>
> for (offset = 0; offset < bo->size; offset += XE_PAGE_SIZE) {
> @@ -470,9 +470,9 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> if (xe_bo_is_vram(bo) && ggtt->flags & XE_GGTT_FLAGS_64K)
> alignment = SZ_64K;
>
> - if (XE_WARN_ON(bo->ggtt_node.size)) {
> + if (XE_WARN_ON(bo->ggtt_node.base.size)) {
> /* Someone's already inserted this BO in the GGTT */
> - xe_tile_assert(ggtt->tile, bo->ggtt_node.size == bo->size);
> + xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
> return 0;
> }
>
> @@ -482,7 +482,7 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
>
> xe_pm_runtime_get_noresume(tile_to_xe(ggtt->tile));
> mutex_lock(&ggtt->lock);
> - err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node, bo->size,
> + err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node.base, bo->size,
> alignment, 0, start, end, 0);
> if (!err)
> xe_ggtt_map_bo(ggtt, bo);
> @@ -523,12 +523,12 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> }
>
> /**
> - * xe_ggtt_remove_node - Remove a &drm_mm_node from the GGTT
> + * xe_ggtt_remove_node - Remove a &xe_ggtt_node from the GGTT
> * @ggtt: the &xe_ggtt where node will be removed
> - * @node: the &drm_mm_node to be removed
> + * @node: the &xe_ggtt_node to be removed
> * @invalidate: if node needs invalidation upon removal
> */
> -void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> +void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> bool invalidate)
> {
> struct xe_device *xe = tile_to_xe(ggtt->tile);
> @@ -541,9 +541,9 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
>
> mutex_lock(&ggtt->lock);
> if (bound)
> - xe_ggtt_clear(ggtt, node->start, node->size);
> - drm_mm_remove_node(node);
> - node->size = 0;
> + xe_ggtt_clear(ggtt, node->base.start, node->base.size);
> + drm_mm_remove_node(&node->base);
> + node->base.size = 0;
> mutex_unlock(&ggtt->lock);
>
> if (!bound)
> @@ -563,11 +563,11 @@ void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> */
> void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> {
> - if (XE_WARN_ON(!bo->ggtt_node.size))
> + if (XE_WARN_ON(!bo->ggtt_node.base.size))
> return;
>
> /* This BO is not currently in the GGTT */
> - xe_tile_assert(ggtt->tile, bo->ggtt_node.size == bo->size);
> + xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
>
> xe_ggtt_remove_node(ggtt, &bo->ggtt_node,
> bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
> @@ -602,17 +602,17 @@ static void xe_ggtt_assign_locked(struct xe_ggtt *ggtt, const struct drm_mm_node
> /**
> * xe_ggtt_assign - assign a GGTT region to the VF
> * @ggtt: the &xe_ggtt where the node belongs
> - * @node: the &drm_mm_node to update
> + * @node: the &xe_ggtt_node to update
> * @vfid: the VF identifier
> *
> * This function is used by the PF driver to assign a GGTT region to the VF.
> * In addition to PTE's VFID bits 11:2 also PRESENT bit 0 is set as on some
> * platforms VFs can't modify that either.
> */
> -void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vfid)
> +void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct xe_ggtt_node *node, u16 vfid)
> {
> mutex_lock(&ggtt->lock);
> - xe_ggtt_assign_locked(ggtt, node, vfid);
> + xe_ggtt_assign_locked(ggtt, &node->base, vfid);
> mutex_unlock(&ggtt->lock);
> }
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 2546bab97507..30a521f7b075 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -13,15 +13,15 @@ struct drm_printer;
> int xe_ggtt_init_early(struct xe_ggtt *ggtt);
> int xe_ggtt_init(struct xe_ggtt *ggtt);
>
> -int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct drm_mm_node *node);
> -void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct drm_mm_node *node);
> +int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
> +void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
>
> -int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> +int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> u32 size, u32 align);
> int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt,
> - struct drm_mm_node *node,
> + struct xe_ggtt_node *node,
> u32 size, u32 align, u32 mm_flags);
> -void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct drm_mm_node *node,
> +void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> bool invalidate);
> void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> @@ -32,7 +32,7 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
>
> #ifdef CONFIG_PCI_IOV
> -void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct drm_mm_node *node, u16 vfid);
> +void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct xe_ggtt_node *node, u16 vfid);
> #endif
>
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
> index 4e2114201b35..f3292e6c3873 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt_types.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
> @@ -47,6 +47,14 @@ struct xe_ggtt {
> unsigned int access_count;
> };
>
> +/**
> + * struct xe_ggtt_node - A node in GGTT
> + */
> +struct xe_ggtt_node {
> + /** @base: A drm_mm_node */
> + struct drm_mm_node base;
> +};
> +
> /**
> * struct xe_ggtt_pt_ops - GGTT Page table operations
> * Which can vary from platform to platform.
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index db6c213da847..3600468da013 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -6,6 +6,9 @@
> #include <linux/string_choices.h>
> #include <linux/wordpart.h>
>
> +/* FIXME: remove this after encapsulating all drm_mm_node access into xe_ggtt */
> +#include <drm/drm_mm.h>
> +
> #include "abi/guc_actions_sriov_abi.h"
> #include "abi/guc_klvs_abi.h"
>
> @@ -232,14 +235,14 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config)
> {
> u32 n = 0;
>
> - if (drm_mm_node_allocated(&config->ggtt_region)) {
> + if (drm_mm_node_allocated(&config->ggtt_region.base)) {
> cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_START);
> - cfg[n++] = lower_32_bits(config->ggtt_region.start);
> - cfg[n++] = upper_32_bits(config->ggtt_region.start);
> + cfg[n++] = lower_32_bits(config->ggtt_region.base.start);
> + cfg[n++] = upper_32_bits(config->ggtt_region.base.start);
>
> cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_SIZE);
> - cfg[n++] = lower_32_bits(config->ggtt_region.size);
> - cfg[n++] = upper_32_bits(config->ggtt_region.size);
> + cfg[n++] = lower_32_bits(config->ggtt_region.base.size);
> + cfg[n++] = upper_32_bits(config->ggtt_region.base.size);
> }
>
> return n;
> @@ -369,11 +372,11 @@ static int pf_distribute_config_ggtt(struct xe_tile *tile, unsigned int vfid, u6
> return err ?: err2;
> }
>
> -static void pf_release_ggtt(struct xe_tile *tile, struct drm_mm_node *node)
> +static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
> {
> struct xe_ggtt *ggtt = tile->mem.ggtt;
>
> - if (drm_mm_node_allocated(node)) {
> + if (drm_mm_node_allocated(&node->base)) {
> /*
> * explicit GGTT PTE assignment to the PF using xe_ggtt_assign()
> * is redundant, as PTE will be implicitly re-assigned to PF by
> @@ -391,7 +394,7 @@ static void pf_release_vf_config_ggtt(struct xe_gt *gt, struct xe_gt_sriov_confi
> static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
> {
> struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
> - struct drm_mm_node *node = &config->ggtt_region;
> + struct xe_ggtt_node *node = &config->ggtt_region;
> struct xe_tile *tile = gt_to_tile(gt);
> struct xe_ggtt *ggtt = tile->mem.ggtt;
> u64 alignment = pf_get_ggtt_alignment(gt);
> @@ -403,14 +406,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
>
> size = round_up(size, alignment);
>
> - if (drm_mm_node_allocated(node)) {
> + if (drm_mm_node_allocated(&node->base)) {
> err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
> if (unlikely(err))
> return err;
>
> pf_release_ggtt(tile, node);
> }
> - xe_gt_assert(gt, !drm_mm_node_allocated(node));
> + xe_gt_assert(gt, !drm_mm_node_allocated(&node->base));
>
> if (!size)
> return 0;
> @@ -421,9 +424,9 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
>
> xe_ggtt_assign(ggtt, node, vfid);
> xe_gt_sriov_dbg_verbose(gt, "VF%u assigned GGTT %llx-%llx\n",
> - vfid, node->start, node->start + node->size - 1);
> + vfid, node->base.start, node->base.start + node->base.size - 1);
>
> - err = pf_distribute_config_ggtt(gt->tile, vfid, node->start, node->size);
> + err = pf_distribute_config_ggtt(gt->tile, vfid, node->base.start, node->base.size);
> if (unlikely(err))
> return err;
>
> @@ -433,10 +436,10 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
> static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
> {
> struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
> - struct drm_mm_node *node = &config->ggtt_region;
> + struct xe_ggtt_node *node = &config->ggtt_region;
>
> xe_gt_assert(gt, !xe_gt_is_media_type(gt));
> - return drm_mm_node_allocated(node) ? node->size : 0;
> + return drm_mm_node_allocated(&node->base) ? node->base.size : 0;
> }
>
> /**
> @@ -2018,13 +2021,13 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
>
> for (n = 1; n <= total_vfs; n++) {
> config = >->sriov.pf.vfs[n].config;
> - if (!drm_mm_node_allocated(&config->ggtt_region))
> + if (!drm_mm_node_allocated(&config->ggtt_region.base))
> continue;
>
> - string_get_size(config->ggtt_region.size, 1, STRING_UNITS_2, buf, sizeof(buf));
> + string_get_size(config->ggtt_region.base.size, 1, STRING_UNITS_2, buf, sizeof(buf));
> drm_printf(p, "VF%u:\t%#0llx-%#llx\t(%s)\n",
> - n, config->ggtt_region.start,
> - config->ggtt_region.start + config->ggtt_region.size - 1, buf);
> + n, config->ggtt_region.base.start,
> + config->ggtt_region.base.start + config->ggtt_region.base.size - 1, buf);
> }
>
> return 0;
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> index 7bc66656fcc7..6d0d9299bafa 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> @@ -6,7 +6,7 @@
> #ifndef _XE_GT_SRIOV_PF_CONFIG_TYPES_H_
> #define _XE_GT_SRIOV_PF_CONFIG_TYPES_H_
>
> -#include <drm/drm_mm.h>
> +#include <xe_ggtt_types.h>
>
> #include "xe_guc_klv_thresholds_set_types.h"
>
> @@ -19,7 +19,7 @@ struct xe_bo;
> */
> struct xe_gt_sriov_config {
> /** @ggtt_region: GGTT region assigned to the VF. */
> - struct drm_mm_node ggtt_region;
> + struct xe_ggtt_node ggtt_region;
> /** @lmem_obj: LMEM allocation for use by the VF. */
> struct xe_bo *lmem_obj;
> /** @num_ctxs: number of GuC contexts IDs. */
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 06/12] drm/xe: Rename xe_ggtt_node related functions
2024-07-11 17:11 ` [PATCH 06/12] drm/xe: Rename xe_ggtt_node related functions Rodrigo Vivi
@ 2024-07-16 17:24 ` Matthew Brost
0 siblings, 0 replies; 38+ messages in thread
From: Matthew Brost @ 2024-07-16 17:24 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: intel-xe
On Thu, Jul 11, 2024 at 01:11:49PM -0400, Rodrigo Vivi wrote:
> Bring some consistency and prepare for more xe_ggtt_node related
> functions to be introduced.
>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/display/xe_fb_pin.c | 8 +-
> drivers/gpu/drm/xe/xe_ggtt.c | 86 +++++++++++-----------
> drivers/gpu/drm/xe/xe_ggtt.h | 12 +--
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 4 +-
> 4 files changed, 54 insertions(+), 56 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> index a93923fb8721..db74c3395ef8 100644
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -209,8 +209,7 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
> } else if (view->type == I915_GTT_VIEW_NORMAL) {
> u32 x, size = bo->ttm.base.size;
>
> - ret = xe_ggtt_insert_special_node_locked(ggtt, &vma->node, size,
> - align, 0);
> + ret = xe_ggtt_node_insert_locked(ggtt, &vma->node, size, align, 0);
> if (ret)
> goto out_unlock;
>
> @@ -227,8 +226,7 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
> /* display seems to use tiles instead of bytes here, so convert it back.. */
> u32 size = intel_rotation_info_size(rot_info) * XE_PAGE_SIZE;
>
> - ret = xe_ggtt_insert_special_node_locked(ggtt, &vma->node, size,
> - align, 0);
> + ret = xe_ggtt_node_insert_locked(ggtt, &vma->node, size, align, 0);
> if (ret)
> goto out_unlock;
>
> @@ -327,7 +325,7 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)
> xe_bo_unpin_map_no_vm(vma->dpt);
> 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);
> + xe_ggtt_node_remove(ggtt, &vma->node, false);
>
> ttm_bo_reserve(&vma->bo->ttm, false, false, NULL);
> ttm_bo_unpin(&vma->bo->ttm);
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index ea55c7eabee4..3ab29588a068 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -403,7 +403,7 @@ void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> }
>
> /**
> - * xe_ggtt_insert_special_node_locked - Locked version to insert a &xe_ggtt_node into the GGTT
> + * xe_ggtt_node_insert_locked - Locked version to insert a &xe_ggtt_node into the GGTT
> * @ggtt: the &xe_ggtt where node will be inserted
> * @node: the &xe_ggtt_node to be inserted
> * @size: size of the node
> @@ -414,15 +414,15 @@ void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> *
> * Return: 0 on success or a negative error code on failure.
> */
> -int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> - u32 size, u32 align, u32 mm_flags)
> +int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> + u32 size, u32 align, u32 mm_flags)
> {
> return drm_mm_insert_node_generic(&ggtt->mm, &node->base, size, align, 0,
> mm_flags);
> }
>
> /**
> - * xe_ggtt_insert_special_node - Insert a &xe_ggtt_node into the GGTT
> + * xe_ggtt_node_insert - Insert a &xe_ggtt_node into the GGTT
> * @ggtt: the &xe_ggtt where node will be inserted
> * @node: the &xe_ggtt_node to be inserted
> * @size: size of the node
> @@ -430,19 +430,53 @@ int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node
> *
> * Return: 0 on success or a negative error code on failure.
> */
> -int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> - u32 size, u32 align)
> +int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> + u32 size, u32 align)
> {
> int ret;
>
> mutex_lock(&ggtt->lock);
> - ret = xe_ggtt_insert_special_node_locked(ggtt, node, size,
> - align, DRM_MM_INSERT_HIGH);
> + ret = xe_ggtt_node_insert_locked(ggtt, node, size,
> + align, DRM_MM_INSERT_HIGH);
> mutex_unlock(&ggtt->lock);
>
> return ret;
> }
>
> +/**
> + * xe_ggtt_node_remove - Remove a &xe_ggtt_node from the GGTT
> + * @ggtt: the &xe_ggtt where node will be removed
> + * @node: the &xe_ggtt_node to be removed
> + * @invalidate: if node needs invalidation upon removal
> + */
> +void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> + bool invalidate)
> +{
> + struct xe_device *xe = tile_to_xe(ggtt->tile);
> + bool bound;
> + int idx;
> +
> + bound = drm_dev_enter(&xe->drm, &idx);
> + if (bound)
> + xe_pm_runtime_get_noresume(xe);
> +
> + mutex_lock(&ggtt->lock);
> + if (bound)
> + xe_ggtt_clear(ggtt, node->base.start, node->base.size);
> + drm_mm_remove_node(&node->base);
> + node->base.size = 0;
> + mutex_unlock(&ggtt->lock);
> +
> + if (!bound)
> + return;
> +
> + if (invalidate)
> + xe_ggtt_invalidate(ggtt);
> +
> + xe_pm_runtime_put(xe);
> + drm_dev_exit(idx);
> +}
> +
> /**
> * xe_ggtt_map_bo - Map the BO into GGTT
> * @ggtt: the &xe_ggtt where node will be mapped
> @@ -522,40 +556,6 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> return __xe_ggtt_insert_bo_at(ggtt, bo, 0, U64_MAX);
> }
>
> -/**
> - * xe_ggtt_remove_node - Remove a &xe_ggtt_node from the GGTT
> - * @ggtt: the &xe_ggtt where node will be removed
> - * @node: the &xe_ggtt_node to be removed
> - * @invalidate: if node needs invalidation upon removal
> - */
> -void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> - bool invalidate)
> -{
> - struct xe_device *xe = tile_to_xe(ggtt->tile);
> - bool bound;
> - int idx;
> -
> - bound = drm_dev_enter(&xe->drm, &idx);
> - if (bound)
> - xe_pm_runtime_get_noresume(xe);
> -
> - mutex_lock(&ggtt->lock);
> - if (bound)
> - xe_ggtt_clear(ggtt, node->base.start, node->base.size);
> - drm_mm_remove_node(&node->base);
> - node->base.size = 0;
> - mutex_unlock(&ggtt->lock);
> -
> - if (!bound)
> - return;
> -
> - if (invalidate)
> - xe_ggtt_invalidate(ggtt);
> -
> - xe_pm_runtime_put(xe);
> - drm_dev_exit(idx);
> -}
> -
> /**
> * xe_ggtt_remove_bo - Remove a BO from the GGTT
> * @ggtt: the &xe_ggtt where node will be removed
> @@ -569,7 +569,7 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> /* This BO is not currently in the GGTT */
> xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
>
> - xe_ggtt_remove_node(ggtt, &bo->ggtt_node,
> + xe_ggtt_node_remove(ggtt, &bo->ggtt_node,
> bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
> }
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 30a521f7b075..5147930357de 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -16,12 +16,12 @@ int xe_ggtt_init(struct xe_ggtt *ggtt);
> int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
> void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
>
> -int xe_ggtt_insert_special_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> - u32 size, u32 align);
> -int xe_ggtt_insert_special_node_locked(struct xe_ggtt *ggtt,
> - struct xe_ggtt_node *node,
> - u32 size, u32 align, u32 mm_flags);
> -void xe_ggtt_remove_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> +int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> + u32 size, u32 align);
> +int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt,
> + struct xe_ggtt_node *node,
> + u32 size, u32 align, u32 mm_flags);
> +void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> bool invalidate);
> void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index 3600468da013..dfa71bcd0f56 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -382,7 +382,7 @@ static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
> * is redundant, as PTE will be implicitly re-assigned to PF by
> * the xe_ggtt_clear() called by below xe_ggtt_remove_node().
> */
> - xe_ggtt_remove_node(ggtt, node, false);
> + xe_ggtt_node_remove(ggtt, node, false);
> }
> }
>
> @@ -418,7 +418,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
> if (!size)
> return 0;
>
> - err = xe_ggtt_insert_special_node(ggtt, node, size, alignment);
> + err = xe_ggtt_node_insert(ggtt, node, size, alignment);
> if (unlikely(err))
> return err;
>
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 12/12] drm/xe: Fix missing runtime outer protection for ggtt_remove_node
2024-07-11 17:11 ` [PATCH 12/12] drm/xe: Fix missing runtime outer protection for ggtt_remove_node Rodrigo Vivi
@ 2024-07-16 17:32 ` Matthew Brost
0 siblings, 0 replies; 38+ messages in thread
From: Matthew Brost @ 2024-07-16 17:32 UTC (permalink / raw)
To: Rodrigo Vivi
Cc: intel-xe, Matthew Auld, Paulo Zanoni, Francois Dugast,
Thomas Hellström
On Thu, Jul 11, 2024 at 01:11:55PM -0400, Rodrigo Vivi wrote:
> Defer the ggtt node removal to a thread if runtime_pm is not active.
>
> The ggtt node removal can be called from multiple places, including
> places where we cannot protect with outer callers and places we are
> within other locks. So, try to grab the runtime reference if the
> device is already active, otherwise defer the removal to a separate
> thread from where we are sure we can wake the device up.
>
> v2: - use xe wq instead of system wq (Matt and CI)
> - Avoid GFP_KERNEL to be future proof since this removal can
> be called from outside our drivers and we don't want to block
> if atomic is needed. (Brost)
> v3: amend forgot chunk declaring xe_device.
> v4: Use a xe_ggtt_region to encapsulate the node and remova info,
> wihtout the need for any memory allocation at runtime.
> v5: Actually fill the delayed_removal.invalidate (Brost)
I think you lost this change in a rebase as delayed_removal.invalidate
doesn't appear to be set in this patch.
Matt
> v6: - Ensure that ggtt_region is not freed before work finishes (Auld)
> - Own wq to ensures that the queued works are flushed before
> ggtt_fini (Brost)
> v7: also free ggtt_region on early !bound return (Auld)
> v8: Address the null deref (CI)
> v9: Based on the new xe_ggtt_node for the proper care of the lifetime
> of the object.
>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Paulo Zanoni <paulo.r.zanoni@intel.com>
> Cc: Francois Dugast <francois.dugast@intel.com>
> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> drivers/gpu/drm/xe/xe_ggtt.c | 106 ++++++++++++++++++-----------
> drivers/gpu/drm/xe/xe_ggtt_types.h | 12 ++++
> 2 files changed, 78 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index fe0bfd8c26cd..b57a71d54b1c 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -161,6 +161,7 @@ static void ggtt_fini_early(struct drm_device *drm, void *arg)
> {
> struct xe_ggtt *ggtt = arg;
>
> + destroy_workqueue(ggtt->wq);
> mutex_destroy(&ggtt->lock);
> drm_mm_takedown(&ggtt->mm);
> }
> @@ -242,6 +243,8 @@ int xe_ggtt_init_early(struct xe_ggtt *ggtt)
> else
> ggtt->pt_ops = &xelp_pt_ops;
>
> + ggtt->wq = alloc_workqueue("xe-ggtt-wq", 0, 0);
> +
> drm_mm_init(&ggtt->mm, xe_wopcm_size(xe),
> ggtt->size - xe_wopcm_size(xe));
> mutex_init(&ggtt->lock);
> @@ -276,6 +279,67 @@ static void xe_ggtt_initial_clear(struct xe_ggtt *ggtt)
> mutex_unlock(&ggtt->lock);
> }
>
> +static void ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> + bool invalidate)
> +{
> + struct xe_device *xe = tile_to_xe(ggtt->tile);
> + bool bound;
> + int idx;
> +
> + if (!node || !node->ggtt)
> + return;
> +
> + bound = drm_dev_enter(&xe->drm, &idx);
> +
> + mutex_lock(&ggtt->lock);
> + if (bound)
> + xe_ggtt_clear(ggtt, node->base.start, node->base.size);
> + drm_mm_remove_node(&node->base);
> + node->base.size = 0;
> + mutex_unlock(&ggtt->lock);
> +
> + if (!bound)
> + goto free_node;
> +
> + if (invalidate)
> + xe_ggtt_invalidate(ggtt);
> +
> + drm_dev_exit(idx);
> +
> +free_node:
> + kfree(node);
> +}
> +
> +static void ggtt_node_remove_work_func(struct work_struct *work)
> +{
> + struct xe_ggtt_node *node = container_of(work, typeof(*node),
> + delayed_removal.work);
> + struct xe_device *xe = tile_to_xe(node->ggtt->tile);
> +
> + xe_pm_runtime_get(xe);
> + ggtt_node_remove(node->ggtt, node, node->delayed_removal.invalidate);
> + xe_pm_runtime_put(xe);
> +}
> +
> +/**
> + * xe_ggtt_node_remove - Remove a &xe_ggtt_node from the GGTT
> + * @ggtt: the &xe_ggtt where node will be removed
> + * @node: the &xe_ggtt_node to be removed
> + * @invalidate: if node needs invalidation upon removal
> + */
> +void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> + bool invalidate)
> +{
> + struct xe_device *xe = tile_to_xe(ggtt->tile);
> +
> + if (xe_pm_runtime_get_if_active(xe)) {
> + ggtt_node_remove(ggtt, node, invalidate);
> + xe_pm_runtime_put(xe);
> + } else {
> + queue_work(ggtt->wq, &node->delayed_removal.work);
> + }
> +}
> +
> /**
> * xe_ggtt_init - Regular non-early GGTT initialization
> * @ggtt: the &xe_ggtt to be initialized
> @@ -482,7 +546,9 @@ struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt)
> if (!node)
> return ERR_PTR(-ENOMEM);
>
> + INIT_WORK(&node->delayed_removal.work, ggtt_node_remove_work_func);
> node->ggtt = ggtt;
> +
> return node;
> }
>
> @@ -499,46 +565,6 @@ void xe_ggtt_node_force_fini(struct xe_ggtt_node *node)
> kfree(node);
> }
>
> -/**
> - * xe_ggtt_node_remove - Remove a &xe_ggtt_node from the GGTT
> - * @ggtt: the &xe_ggtt where node will be removed
> - * @node: the &xe_ggtt_node to be removed
> - * @invalidate: if node needs invalidation upon removal
> - */
> -void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> - bool invalidate)
> -{
> - struct xe_device *xe = tile_to_xe(ggtt->tile);
> - bool bound;
> - int idx;
> -
> - if (!node || !node->ggtt)
> - return;
> -
> - bound = drm_dev_enter(&xe->drm, &idx);
> - if (bound)
> - xe_pm_runtime_get_noresume(xe);
> -
> - mutex_lock(&ggtt->lock);
> - if (bound)
> - xe_ggtt_clear(ggtt, node->base.start, node->base.size);
> - drm_mm_remove_node(&node->base);
> - node->base.size = 0;
> - mutex_unlock(&ggtt->lock);
> -
> - if (!bound)
> - goto free_node;
> -
> - if (invalidate)
> - xe_ggtt_invalidate(ggtt);
> -
> - xe_pm_runtime_put(xe);
> - drm_dev_exit(idx);
> -
> -free_node:
> - kfree(node);
> -}
> -
> /**
> * xe_ggtt_node_allocated - Check if node is allocated in GGTT
> * @node: the &xe_ggtt_node to be inspected
> diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
> index 60cbce3170d1..5ea12ea30a4d 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt_types.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
> @@ -45,6 +45,8 @@ struct xe_ggtt {
> struct drm_mm mm;
> /** @access_count: counts GGTT writes */
> unsigned int access_count;
> + /** @wq: Dedicated unordered work queue to process node removals */
> + struct workqueue_struct *wq;
> };
>
> /**
> @@ -59,6 +61,16 @@ struct xe_ggtt_node {
> struct xe_ggtt *ggtt;
> /** @base: A drm_mm_node */
> struct drm_mm_node base;
> + /**
> + * @delayed_removal: Information for removal through work thread when
> + * device runtime_pm is suspended
> + */
> + struct {
> + /** @delayed_removal.work: The work struct for the delayed removal */
> + struct work_struct work;
> + /** @delayed_removal.invalidate: If it needs invalidation upon removal */
> + bool invalidate;
> + } delayed_removal;
> };
>
> /**
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 07/12] drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node
2024-07-11 17:11 ` [PATCH 07/12] drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node Rodrigo Vivi
@ 2024-07-17 23:27 ` Matthew Brost
0 siblings, 0 replies; 38+ messages in thread
From: Matthew Brost @ 2024-07-17 23:27 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: intel-xe, Michal Wajdeczko
On Thu, Jul 11, 2024 at 01:11:50PM -0400, Rodrigo Vivi wrote:
> Continue with the encapsulation of drm_mm_node inside xe_ggtt.
>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/xe/display/xe_fb_pin.c | 2 +-
> drivers/gpu/drm/xe/xe_ggtt.c | 11 +++++++++++
> drivers/gpu/drm/xe/xe_ggtt.h | 1 +
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 12 ++++++------
> 4 files changed, 19 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> index db74c3395ef8..de4930b67a29 100644
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -323,7 +323,7 @@ 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.base) ||
> + else if (!xe_ggtt_node_allocated(&vma->bo->ggtt_node) ||
> vma->bo->ggtt_node.base.start != vma->node.base.start)
> xe_ggtt_node_remove(ggtt, &vma->node, false);
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 3ab29588a068..67337bfeb81e 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -477,6 +477,17 @@ void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> drm_dev_exit(idx);
> }
>
> +/**
> + * xe_ggtt_node_allocated - Check if node is allocated
> + * @node: the &xe_ggtt_node to be inspected
> + *
> + * Return: True if allocated, False otherwise.
> + */
> +bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
> +{
> + return drm_mm_node_allocated(&node->base);
> +}
> +
> /**
> * xe_ggtt_map_bo - Map the BO into GGTT
> * @ggtt: the &xe_ggtt where node will be mapped
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index 5147930357de..f816b3c0732b 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -23,6 +23,7 @@ int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt,
> u32 size, u32 align, u32 mm_flags);
> void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> bool invalidate);
> +bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node);
> void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index dfa71bcd0f56..efaf188290ea 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -235,7 +235,7 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config)
> {
> u32 n = 0;
>
> - if (drm_mm_node_allocated(&config->ggtt_region.base)) {
> + if (xe_ggtt_node_allocated(&config->ggtt_region)) {
> cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_START);
> cfg[n++] = lower_32_bits(config->ggtt_region.base.start);
> cfg[n++] = upper_32_bits(config->ggtt_region.base.start);
> @@ -376,7 +376,7 @@ static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
> {
> struct xe_ggtt *ggtt = tile->mem.ggtt;
>
> - if (drm_mm_node_allocated(&node->base)) {
> + if (xe_ggtt_node_allocated(node)) {
> /*
> * explicit GGTT PTE assignment to the PF using xe_ggtt_assign()
> * is redundant, as PTE will be implicitly re-assigned to PF by
> @@ -406,14 +406,14 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
>
> size = round_up(size, alignment);
>
> - if (drm_mm_node_allocated(&node->base)) {
> + if (xe_ggtt_node_allocated(node)) {
> err = pf_distribute_config_ggtt(tile, vfid, 0, 0);
> if (unlikely(err))
> return err;
>
> pf_release_ggtt(tile, node);
> }
> - xe_gt_assert(gt, !drm_mm_node_allocated(&node->base));
> + xe_gt_assert(gt, !xe_ggtt_node_allocated(node));
>
> if (!size)
> return 0;
> @@ -439,7 +439,7 @@ static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
> struct xe_ggtt_node *node = &config->ggtt_region;
>
> xe_gt_assert(gt, !xe_gt_is_media_type(gt));
> - return drm_mm_node_allocated(&node->base) ? node->base.size : 0;
> + return xe_ggtt_node_allocated(node) ? node->base.size : 0;
> }
>
> /**
> @@ -2021,7 +2021,7 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
>
> for (n = 1; n <= total_vfs; n++) {
> config = >->sriov.pf.vfs[n].config;
> - if (!drm_mm_node_allocated(&config->ggtt_region.base))
> + if (!xe_ggtt_node_allocated(&config->ggtt_region))
> continue;
>
> string_get_size(config->ggtt_region.base.size, 1, STRING_UNITS_2, buf, sizeof(buf));
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 11/12] drm/xe: Make xe_ggtt_node struct independent
2024-07-11 17:11 ` [PATCH 11/12] drm/xe: Make xe_ggtt_node struct independent Rodrigo Vivi
@ 2024-07-17 23:50 ` Matthew Brost
0 siblings, 0 replies; 38+ messages in thread
From: Matthew Brost @ 2024-07-17 23:50 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: intel-xe, Matthew Auld, Michal Wajdeczko
On Thu, Jul 11, 2024 at 01:11:54PM -0400, Rodrigo Vivi wrote:
> In some rare cases, the drm_mm node cannot be removed synchronously
> due to runtime PM conditions. In this situation, the node removal will
> be delegated to a workqueue that will be able to wake up the device
> before removing the node.
>
> However, in this situation, the lifetime of the xe_ggtt_node cannot
> be restricted to the lifetime of the parent object. So, this patch
> introduces the infrastructure so the xe_ggtt_node struct can be
> allocated in advance and freed when needed.
>
> By having the ggtt backpointer, it also ensure that the init function
> is always called before any attempt to insert or reserve the node
> in the GGTT.
>
A couple of nits below, but...
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> ---
> .../gpu/drm/xe/compat-i915-headers/i915_vma.h | 4 +-
> drivers/gpu/drm/xe/display/xe_fb_pin.c | 36 ++++--
> drivers/gpu/drm/xe/xe_bo.c | 2 +-
> drivers/gpu/drm/xe/xe_bo.h | 9 +-
> drivers/gpu/drm/xe/xe_bo_types.h | 2 +-
> drivers/gpu/drm/xe/xe_device_types.h | 2 +-
> drivers/gpu/drm/xe/xe_ggtt.c | 103 ++++++++++++++++--
> drivers/gpu/drm/xe/xe_ggtt.h | 2 +
> drivers/gpu/drm/xe/xe_ggtt_types.h | 8 +-
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 34 +++---
> .../gpu/drm/xe/xe_gt_sriov_pf_config_types.h | 2 +-
> drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 26 ++++-
> 12 files changed, 181 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
> index 97193e660f6c..ac860414b91f 100644
> --- a/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
> +++ b/drivers/gpu/drm/xe/compat-i915-headers/i915_vma.h
> @@ -20,7 +20,7 @@ struct xe_bo;
>
> struct i915_vma {
> struct xe_bo *bo, *dpt;
> - struct xe_ggtt_node node;
> + struct xe_ggtt_node *node;
> };
>
> #define i915_ggtt_clear_scanout(bo) do { } while (0)
> @@ -29,7 +29,7 @@ struct i915_vma {
>
> static inline u32 i915_ggtt_offset(const struct i915_vma *vma)
> {
> - return vma->node.base.start;
> + return vma->node->base.start;
> }
>
> #endif
> diff --git a/drivers/gpu/drm/xe/display/xe_fb_pin.c b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> index de4930b67a29..e871957d7565 100644
> --- a/drivers/gpu/drm/xe/display/xe_fb_pin.c
> +++ b/drivers/gpu/drm/xe/display/xe_fb_pin.c
> @@ -204,20 +204,28 @@ 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.base.size && view->type == I915_GTT_VIEW_NORMAL) {
> + if (bo->ggtt_node && 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;
>
> - ret = xe_ggtt_node_insert_locked(ggtt, &vma->node, size, align, 0);
> - if (ret)
> + vma->node = xe_ggtt_node_init(ggtt);
> + if (IS_ERR(vma->node)) {
> + ret = PTR_ERR(vma->node);
> goto out_unlock;
> + }
> +
> + ret = xe_ggtt_node_insert_locked(ggtt, vma->node, size, align, 0);
> + if (ret) {
> + xe_ggtt_node_force_fini(vma->node);
> + goto out_unlock;
> + }
>
> for (x = 0; x < size; x += XE_PAGE_SIZE) {
> 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.base.start + x, pte);
> + ggtt->pt_ops->ggtt_set_pte(ggtt, vma->node->base.start + x, pte);
> }
> } else {
> u32 i, ggtt_ofs;
> @@ -226,11 +234,19 @@ static int __xe_pin_fb_vma_ggtt(const struct intel_framebuffer *fb,
> /* display seems to use tiles instead of bytes here, so convert it back.. */
> u32 size = intel_rotation_info_size(rot_info) * XE_PAGE_SIZE;
>
> - ret = xe_ggtt_node_insert_locked(ggtt, &vma->node, size, align, 0);
> - if (ret)
> + vma->node = xe_ggtt_node_init(ggtt);
> + if (IS_ERR(vma->node)) {
> + ret = PTR_ERR(vma->node);
> goto out_unlock;
> + }
> +
> + ret = xe_ggtt_node_insert_locked(ggtt, vma->node, size, align, 0);
> + if (ret) {
> + xe_ggtt_node_force_fini(vma->node);
> + goto out_unlock;
> + }
>
> - ggtt_ofs = vma->node.base.start;
> + ggtt_ofs = vma->node->base.start;
>
> for (i = 0; i < ARRAY_SIZE(rot_info->plane); i++)
> write_ggtt_rotated(bo, ggtt, &ggtt_ofs,
> @@ -323,9 +339,9 @@ static void __xe_unpin_fb_vma(struct i915_vma *vma)
>
> if (vma->dpt)
> xe_bo_unpin_map_no_vm(vma->dpt);
> - else if (!xe_ggtt_node_allocated(&vma->bo->ggtt_node) ||
> - vma->bo->ggtt_node.base.start != vma->node.base.start)
> - xe_ggtt_node_remove(ggtt, &vma->node, false);
> + else if (!xe_ggtt_node_allocated(vma->bo->ggtt_node) ||
> + vma->bo->ggtt_node->base.start != vma->node->base.start)
> + xe_ggtt_node_remove(ggtt, vma->node, false);
>
> ttm_bo_reserve(&vma->bo->ttm, false, false, NULL);
> ttm_bo_unpin(&vma->bo->ttm);
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index 3501a5871069..7e277ac0cd8d 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -1090,7 +1090,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.base.size)
> + if (bo->ggtt_node)
> xe_ggtt_remove_bo(bo->tile->mem.ggtt, bo);
>
> #ifdef CONFIG_PROC_FS
> diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
> index 7c95133cc32b..c8a90e5bbd6b 100644
> --- a/drivers/gpu/drm/xe/xe_bo.h
> +++ b/drivers/gpu/drm/xe/xe_bo.h
> @@ -194,9 +194,12 @@ 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.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;
> + if (XE_WARN_ON(!bo->ggtt_node))
> + return -ENOENT;
> +
> + 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);
> diff --git a/drivers/gpu/drm/xe/xe_bo_types.h b/drivers/gpu/drm/xe/xe_bo_types.h
> index 3ba96a93623c..0ec6172cc8ba 100644
> --- a/drivers/gpu/drm/xe/xe_bo_types.h
> +++ b/drivers/gpu/drm/xe/xe_bo_types.h
> @@ -40,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 xe_ggtt_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. */
> diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
> index 30f9c58932bb..706872711ebf 100644
> --- a/drivers/gpu/drm/xe/xe_device_types.h
> +++ b/drivers/gpu/drm/xe/xe_device_types.h
> @@ -203,7 +203,7 @@ struct xe_tile {
> struct xe_memirq memirq;
>
> /** @sriov.vf.ggtt_balloon: GGTT regions excluded from use. */
> - struct xe_ggtt_node ggtt_balloon[2];
> + struct xe_ggtt_node *ggtt_balloon[2];
> } vf;
> } sriov;
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> index 928c01f9e212..fe0bfd8c26cd 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.c
> +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> @@ -353,6 +353,7 @@ static void xe_ggtt_dump_node(struct xe_ggtt *ggtt,
> * @end: then end GGTT address of the reserved region
> * @node: the &xe_ggtt_node to hold reserved GGTT node
> *
> + * It cannot be called without first having called xe_ggtt_init().
> * Use xe_ggtt_node_deballoon() to release a reserved GGTT node.
> *
> * Return: 0 on success or a negative error code on failure.
> @@ -361,6 +362,9 @@ int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggt
> {
> int err;
>
> + if (!node || !node->ggtt)
> + return -ENOENT;
> +
> xe_tile_assert(ggtt->tile, start < end);
> xe_tile_assert(ggtt->tile, IS_ALIGNED(start, XE_PAGE_SIZE));
> xe_tile_assert(ggtt->tile, IS_ALIGNED(end, XE_PAGE_SIZE));
> @@ -392,14 +396,20 @@ int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggt
> */
> void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> {
> - if (!drm_mm_node_allocated(&node->base))
> + if (!node || !node->ggtt)
> return;
>
> + if (!drm_mm_node_allocated(&node->base))
> + goto free_node;
> +
> xe_ggtt_dump_node(ggtt, &node->base, "deballoon");
>
> mutex_lock(&ggtt->lock);
> drm_mm_remove_node(&node->base);
> mutex_unlock(&ggtt->lock);
> +
> +free_node:
> + kfree(node);
xe_ggtt_node_fini
Matt
> }
>
> /**
> @@ -410,6 +420,7 @@ void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> * @align: alignment constrain of the node
> * @mm_flags: flags to control the node behavior
> *
> + * It cannot be called without first having called xe_ggtt_init() once.
> * To be used in cases where ggtt->lock is already taken.
> *
> * Return: 0 on success or a negative error code on failure.
> @@ -417,6 +428,9 @@ void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> u32 size, u32 align, u32 mm_flags)
> {
> + if (!node || !node->ggtt)
> + return -ENOENT;
> +
> return drm_mm_insert_node_generic(&ggtt->mm, &node->base, size, align, 0,
> mm_flags);
> }
> @@ -428,6 +442,8 @@ int xe_ggtt_node_insert_locked(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> * @size: size of the node
> * @align: alignment constrain of the node
> *
> + * It cannot be called without first having called xe_ggtt_init() once.
> + *
> * Return: 0 on success or a negative error code on failure.
> */
> int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> @@ -435,6 +451,9 @@ int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> {
> int ret;
>
> + if (!node || !node->ggtt)
> + return -ENOENT;
> +
> mutex_lock(&ggtt->lock);
> ret = xe_ggtt_node_insert_locked(ggtt, node, size,
> align, DRM_MM_INSERT_HIGH);
> @@ -443,6 +462,43 @@ int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> return ret;
> }
>
> +/**
> + * xe_ggtt_node_init - Initialize %xe_ggtt_node struct
> + * @ggtt: the &xe_ggtt where the new node will later be inserted/reserved.
> + *
> + * This function will allocated the struct %xe_ggtt_node and return it's pointer.
> + * This struct will then be freed after the node removal upon xe_ggtt_node_remove()
> + * or xe_ggtt_node_deballoon().
> + * Having %xe_ggtt_node struct allocated doesn't mean that the node is already allocated
> + * in GGTT. Only the xe_ggtt_node_insert(), xe_ggtt_node_insert_locked(),
> + * xe_ggtt_node_balloon() will ensure the node is inserted or reserved in GGTT.
> + *
> + * Return: A pointer to %xe_ggtt_node struct on success. An ERR_PTR otherwise.
> + **/
> +struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt)
> +{
> + struct xe_ggtt_node *node = kzalloc(sizeof(*node), GFP_KERNEL);
> +
> + if (!node)
> + return ERR_PTR(-ENOMEM);
> +
> + node->ggtt = ggtt;
> + return node;
> +}
> +
> +/**
> + * xe_ggtt_node_force_fini - Forcebly finalize %xe_ggtt_node struct
> + * @node: the &xe_ggtt_node to be freed
> + *
> + * If anything went wrong with either xe_ggtt_node_insert(), xe_ggtt_node_insert_locked(),
> + * or xe_ggtt_node_balloon(); and this @node is not going to be reused, then,
> + * this function needs to be called to free the %xe_ggtt_node struct
> + **/
> +void xe_ggtt_node_force_fini(struct xe_ggtt_node *node)
s/xe_ggtt_node_force_fini/xe_ggtt_node_fini
> +{
> + kfree(node);
> +}
> +
> /**
> * xe_ggtt_node_remove - Remove a &xe_ggtt_node from the GGTT
> * @ggtt: the &xe_ggtt where node will be removed
> @@ -456,6 +512,9 @@ void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> bool bound;
> int idx;
>
> + if (!node || !node->ggtt)
> + return;
> +
> bound = drm_dev_enter(&xe->drm, &idx);
> if (bound)
> xe_pm_runtime_get_noresume(xe);
> @@ -468,23 +527,29 @@ void xe_ggtt_node_remove(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> mutex_unlock(&ggtt->lock);
>
> if (!bound)
> - return;
> + goto free_node;
>
> if (invalidate)
> xe_ggtt_invalidate(ggtt);
>
> xe_pm_runtime_put(xe);
> drm_dev_exit(idx);
> +
> +free_node:
> + kfree(node);
xe_ggtt_node_fini
> }
>
> /**
> - * xe_ggtt_node_allocated - Check if node is allocated
> + * xe_ggtt_node_allocated - Check if node is allocated in GGTT
> * @node: the &xe_ggtt_node to be inspected
> *
> * Return: True if allocated, False otherwise.
> */
> bool xe_ggtt_node_allocated(const struct xe_ggtt_node *node)
> {
> + if (!node || !node->ggtt)
> + return false;
> +
> return drm_mm_node_allocated(&node->base);
> }
>
> @@ -497,9 +562,14 @@ void xe_ggtt_map_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> {
> u16 cache_mode = bo->flags & XE_BO_FLAG_NEEDS_UC ? XE_CACHE_NONE : XE_CACHE_WB;
> u16 pat_index = tile_to_xe(ggtt->tile)->pat.idx[cache_mode];
> - u64 start = bo->ggtt_node.base.start;
> + u64 start;
> u64 offset, pte;
>
> + if (XE_WARN_ON(!bo->ggtt_node))
> + return;
> +
> + start = bo->ggtt_node->base.start;
> +
> for (offset = 0; offset < bo->size; offset += XE_PAGE_SIZE) {
> pte = ggtt->pt_ops->pte_encode_bo(bo, offset, pat_index);
> ggtt->pt_ops->ggtt_set_pte(ggtt, start + offset, pte);
> @@ -515,9 +585,9 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> if (xe_bo_is_vram(bo) && ggtt->flags & XE_GGTT_FLAGS_64K)
> alignment = SZ_64K;
>
> - if (XE_WARN_ON(bo->ggtt_node.base.size)) {
> + if (XE_WARN_ON(bo->ggtt_node)) {
> /* Someone's already inserted this BO in the GGTT */
> - xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
> + xe_tile_assert(ggtt->tile, bo->ggtt_node->base.size == bo->size);
> return 0;
> }
>
> @@ -526,15 +596,26 @@ static int __xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> return err;
>
> xe_pm_runtime_get_noresume(tile_to_xe(ggtt->tile));
> +
> + bo->ggtt_node = xe_ggtt_node_init(ggtt);
> + if (IS_ERR(bo->ggtt_node)) {
> + err = PTR_ERR(bo->ggtt_node);
> + goto out;
> + }
> +
> mutex_lock(&ggtt->lock);
> - err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node.base, bo->size,
> + err = drm_mm_insert_node_in_range(&ggtt->mm, &bo->ggtt_node->base, bo->size,
> alignment, 0, start, end, 0);
> - if (!err)
> + if (err)
> + xe_ggtt_node_force_fini(bo->ggtt_node);
> + else
> xe_ggtt_map_bo(ggtt, bo);
> mutex_unlock(&ggtt->lock);
>
> if (!err && bo->flags & XE_BO_FLAG_GGTT_INVALIDATE)
> xe_ggtt_invalidate(ggtt);
> +
> +out:
> xe_pm_runtime_put(tile_to_xe(ggtt->tile));
>
> return err;
> @@ -574,13 +655,13 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> */
> void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> {
> - if (XE_WARN_ON(!bo->ggtt_node.base.size))
> + if (XE_WARN_ON(!bo->ggtt_node))
> return;
>
> /* This BO is not currently in the GGTT */
> - xe_tile_assert(ggtt->tile, bo->ggtt_node.base.size == bo->size);
> + xe_tile_assert(ggtt->tile, bo->ggtt_node->base.size == bo->size);
>
> - xe_ggtt_node_remove(ggtt, &bo->ggtt_node,
> + xe_ggtt_node_remove(ggtt, bo->ggtt_node,
> bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
> }
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> index e68cede2e6b5..9ca0a3da8903 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> @@ -13,6 +13,8 @@ struct drm_printer;
> int xe_ggtt_init_early(struct xe_ggtt *ggtt);
> int xe_ggtt_init(struct xe_ggtt *ggtt);
>
> +struct xe_ggtt_node *xe_ggtt_node_init(struct xe_ggtt *ggtt);
> +void xe_ggtt_node_force_fini(struct xe_ggtt_node *node);
> int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
> void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
>
> diff --git a/drivers/gpu/drm/xe/xe_ggtt_types.h b/drivers/gpu/drm/xe/xe_ggtt_types.h
> index f3292e6c3873..60cbce3170d1 100644
> --- a/drivers/gpu/drm/xe/xe_ggtt_types.h
> +++ b/drivers/gpu/drm/xe/xe_ggtt_types.h
> @@ -48,9 +48,15 @@ struct xe_ggtt {
> };
>
> /**
> - * struct xe_ggtt_node - A node in GGTT
> + * struct xe_ggtt_node - A node in GGTT.
> + *
> + * This struct needs to be initialized (only-once) with xe_ggtt_node_init() before any node
> + * insertion, reservation, or 'ballooning'.
> + * It will, then, be finalized by either xe_ggtt_node_remove() or xe_ggtt_node_deballoon().
> */
> struct xe_ggtt_node {
> + /** @ggtt: Back pointer to xe_ggtt where this region will be inserted at */
> + struct xe_ggtt *ggtt;
> /** @base: A drm_mm_node */
> struct drm_mm_node base;
> };
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index d0995680f53f..ac292351483c 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -232,14 +232,14 @@ static u32 encode_config_ggtt(u32 *cfg, const struct xe_gt_sriov_config *config)
> {
> u32 n = 0;
>
> - if (xe_ggtt_node_allocated(&config->ggtt_region)) {
> + if (xe_ggtt_node_allocated(config->ggtt_region)) {
> cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_START);
> - cfg[n++] = lower_32_bits(config->ggtt_region.base.start);
> - cfg[n++] = upper_32_bits(config->ggtt_region.base.start);
> + cfg[n++] = lower_32_bits(config->ggtt_region->base.start);
> + cfg[n++] = upper_32_bits(config->ggtt_region->base.start);
>
> cfg[n++] = PREP_GUC_KLV_TAG(VF_CFG_GGTT_SIZE);
> - cfg[n++] = lower_32_bits(config->ggtt_region.base.size);
> - cfg[n++] = upper_32_bits(config->ggtt_region.base.size);
> + cfg[n++] = lower_32_bits(config->ggtt_region->base.size);
> + cfg[n++] = upper_32_bits(config->ggtt_region->base.size);
> }
>
> return n;
> @@ -385,13 +385,13 @@ static void pf_release_ggtt(struct xe_tile *tile, struct xe_ggtt_node *node)
>
> static void pf_release_vf_config_ggtt(struct xe_gt *gt, struct xe_gt_sriov_config *config)
> {
> - pf_release_ggtt(gt_to_tile(gt), &config->ggtt_region);
> + pf_release_ggtt(gt_to_tile(gt), config->ggtt_region);
> }
>
> static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
> {
> struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
> - struct xe_ggtt_node *node = &config->ggtt_region;
> + struct xe_ggtt_node *node = config->ggtt_region;
> struct xe_tile *tile = gt_to_tile(gt);
> struct xe_ggtt *ggtt = tile->mem.ggtt;
> u64 alignment = pf_get_ggtt_alignment(gt);
> @@ -415,9 +415,15 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
> if (!size)
> return 0;
>
> + node = xe_ggtt_node_init(ggtt);
> + if (IS_ERR(node))
> + return PTR_ERR(node);
> +
> err = xe_ggtt_node_insert(ggtt, node, size, alignment);
> - if (unlikely(err))
> + if (unlikely(err)) {
> + xe_ggtt_node_force_fini(node);
> return err;
> + }
>
> xe_ggtt_assign(ggtt, node, vfid);
> xe_gt_sriov_dbg_verbose(gt, "VF%u assigned GGTT %llx-%llx\n",
> @@ -433,7 +439,7 @@ static int pf_provision_vf_ggtt(struct xe_gt *gt, unsigned int vfid, u64 size)
> static u64 pf_get_vf_config_ggtt(struct xe_gt *gt, unsigned int vfid)
> {
> struct xe_gt_sriov_config *config = pf_pick_vf_config(gt, vfid);
> - struct xe_ggtt_node *node = &config->ggtt_region;
> + struct xe_ggtt_node *node = config->ggtt_region;
>
> xe_gt_assert(gt, !xe_gt_is_media_type(gt));
> return xe_ggtt_node_allocated(node) ? node->base.size : 0;
> @@ -1999,13 +2005,15 @@ int xe_gt_sriov_pf_config_print_ggtt(struct xe_gt *gt, struct drm_printer *p)
>
> for (n = 1; n <= total_vfs; n++) {
> config = >->sriov.pf.vfs[n].config;
> - if (!xe_ggtt_node_allocated(&config->ggtt_region))
> + if (!xe_ggtt_node_allocated(config->ggtt_region))
> continue;
>
> - string_get_size(config->ggtt_region.base.size, 1, STRING_UNITS_2, buf, sizeof(buf));
> + string_get_size(config->ggtt_region->base.size, 1, STRING_UNITS_2,
> + buf, sizeof(buf));
> drm_printf(p, "VF%u:\t%#0llx-%#llx\t(%s)\n",
> - n, config->ggtt_region.base.start,
> - config->ggtt_region.base.start + config->ggtt_region.base.size - 1, buf);
> + n, config->ggtt_region->base.start,
> + config->ggtt_region->base.start + config->ggtt_region->base.size - 1,
> + buf);
> }
>
> return 0;
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> index 6d0d9299bafa..44dc0a6e90d1 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config_types.h
> @@ -19,7 +19,7 @@ struct xe_bo;
> */
> struct xe_gt_sriov_config {
> /** @ggtt_region: GGTT region assigned to the VF. */
> - struct xe_ggtt_node ggtt_region;
> + struct xe_ggtt_node *ggtt_region;
> /** @lmem_obj: LMEM allocation for use by the VF. */
> struct xe_bo *lmem_obj;
> /** @num_ctxs: number of GuC contexts IDs. */
> diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> index a478e6e1b20e..5c540e20c785 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> @@ -495,6 +495,22 @@ u64 xe_gt_sriov_vf_lmem(struct xe_gt *gt)
> return gt->sriov.vf.self_config.lmem_size;
> }
>
> +static int vf_balloon_ggtt_node(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> + u64 start, u64 end)
> +{
> + int err;
> +
> + node = xe_ggtt_node_init(ggtt);
> + if (IS_ERR(node))
> + return PTR_ERR(node);
> +
> + err = xe_ggtt_node_balloon(ggtt, start, end, node);
> + if (err)
> + xe_ggtt_node_force_fini(node);
> +
> + return err;
> +}
> +
> static int vf_balloon_ggtt(struct xe_gt *gt)
> {
> struct xe_gt_sriov_vf_selfconfig *config = >->sriov.vf.self_config;
> @@ -528,7 +544,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
> start = xe_wopcm_size(xe);
> end = config->ggtt_base;
> if (end != start) {
> - err = xe_ggtt_node_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[0]);
> + err = vf_balloon_ggtt_node(ggtt, tile->sriov.vf.ggtt_balloon[0], start, end);
> if (err)
> goto failed;
> }
> @@ -536,7 +552,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
> start = config->ggtt_base + config->ggtt_size;
> end = GUC_GGTT_TOP;
> if (end != start) {
> - err = xe_ggtt_node_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[1]);
> + err = vf_balloon_ggtt_node(ggtt, tile->sriov.vf.ggtt_balloon[1], start, end);
> if (err)
> goto deballoon;
> }
> @@ -544,7 +560,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
> return 0;
>
> deballoon:
> - xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
> + xe_ggtt_node_deballoon(ggtt, tile->sriov.vf.ggtt_balloon[0]);
> failed:
> return err;
> }
> @@ -555,8 +571,8 @@ static void deballoon_ggtt(struct drm_device *drm, void *arg)
> struct xe_ggtt *ggtt = tile->mem.ggtt;
>
> xe_tile_assert(tile, IS_SRIOV_VF(tile_to_xe(tile)));
> - xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[1]);
> - xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
> + xe_ggtt_node_deballoon(ggtt, tile->sriov.vf.ggtt_balloon[1]);
> + xe_ggtt_node_deballoon(ggtt, tile->sriov.vf.ggtt_balloon[0]);
> }
>
> /**
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole
2024-07-11 20:00 ` Michal Wajdeczko
@ 2024-08-09 21:33 ` Rodrigo Vivi
0 siblings, 0 replies; 38+ messages in thread
From: Rodrigo Vivi @ 2024-08-09 21:33 UTC (permalink / raw)
To: Michal Wajdeczko; +Cc: intel-xe
On Thu, Jul 11, 2024 at 10:00:51PM +0200, Michal Wajdeczko wrote:
>
>
> On 11.07.2024 19:11, Rodrigo Vivi wrote:
> > Introduce a new xe_ggtt_largest_hole helper that attends the SRIOV
> > demand and continue with the goal of limiting drm_mm access to xe_ggtt.
> >
> > Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_ggtt.c | 35 ++++++++++++++++++++++
> > drivers/gpu/drm/xe/xe_ggtt.h | 1 +
> > drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 23 ++------------
> > 3 files changed, 38 insertions(+), 21 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> > index 67337bfeb81e..dbaf1ce87fb4 100644
> > --- a/drivers/gpu/drm/xe/xe_ggtt.c
> > +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> > @@ -584,6 +584,41 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> > bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
> > }
> >
> > +/**
> > + * xe_ggtt_largest_hole - Largest GGTT hole
> > + * @ggtt: the &xe_ggtt that will be inspected
> > + * @alignment: mininum alignment
>
> typo: minimum
thanks, addressed this...
>
> > + * @spare: If not NULL: in: desired memory size to be spared / out: Adjusted possible spare
> > + *
> > + * Return: size of the largest continuous GGTT region
> > + */
> > +u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare)
> > +{
> > + const struct drm_mm *mm = &ggtt->mm;
> > + const struct drm_mm_node *entry;
> > + u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
>
> this is likely not needed any more as xe_ggtt is always above WOPCM
> (unlikely to previous driver ;)
hmmm... probably... but can we leave this to a follow up after we
get this series merged?
I'm trying to not modify the current behavior more then it is already
doing...
>
> > + u64 hole_start, hole_end, hole_size;
> > + u64 max_hole = 0;
> > +
> > + mutex_lock(&ggtt->lock);
> > +
> > + drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> > + hole_start = max(hole_start, hole_min_start);
> > + hole_start = ALIGN(hole_start, alignment);
> > + hole_end = ALIGN_DOWN(hole_end, alignment);
> > + if (hole_start >= hole_end)
> > + continue;
> > + hole_size = hole_end - hole_start;
> > + if (spare)
> > + *spare -= min3(*spare, hole_size, max_hole);
> > + max_hole = max(max_hole, hole_size);
> > + }
> > +
> > + mutex_unlock(&ggtt->lock);
> > +
> > + return max_hole;
> > +}
> > +
> > #ifdef CONFIG_PCI_IOV
> > static u64 xe_encode_vfid_pte(u16 vfid)
> > {
> > diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> > index f816b3c0732b..31060fe7644b 100644
> > --- a/drivers/gpu/drm/xe/xe_ggtt.h
> > +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> > @@ -29,6 +29,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> > int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> > u64 start, u64 end);
> > void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> > +u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
> >
> > int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
> >
> > diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > index efaf188290ea..1d17c34fe5a4 100644
> > --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > @@ -590,30 +590,11 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
> > static u64 pf_get_max_ggtt(struct xe_gt *gt)
> > {
> > struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
> > - const struct drm_mm *mm = &ggtt->mm;
> > - const struct drm_mm_node *entry;
> > u64 alignment = pf_get_ggtt_alignment(gt);
> > u64 spare = pf_get_spare_ggtt(gt);
> > - u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
> > - u64 hole_start, hole_end, hole_size;
> > - u64 max_hole = 0;
> > -
> > - mutex_lock(&ggtt->lock);
> > -
> > - drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> > - hole_start = max(hole_start, hole_min_start);
> > - hole_start = ALIGN(hole_start, alignment);
> > - hole_end = ALIGN_DOWN(hole_end, alignment);
> > - if (hole_start >= hole_end)
> > - continue;
> > - hole_size = hole_end - hole_start;
> > - xe_gt_sriov_dbg_verbose(gt, "HOLE start %llx size %lluK\n",
> > - hole_start, hole_size / SZ_1K);
> > - spare -= min3(spare, hole_size, max_hole);
> > - max_hole = max(max_hole, hole_size);
> > - }
> > + u64 max_hole;
> >
> > - mutex_unlock(&ggtt->lock);
> > + max_hole = xe_ggtt_largest_hole(ggtt, alignment, &spare);
> >
> > xe_gt_sriov_dbg_verbose(gt, "HOLE max %lluK reserved %lluK\n",
> > max_hole / SZ_1K, spare / SZ_1K);
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes
2024-07-11 20:09 ` Michal Wajdeczko
@ 2024-08-09 21:38 ` Rodrigo Vivi
0 siblings, 0 replies; 38+ messages in thread
From: Rodrigo Vivi @ 2024-08-09 21:38 UTC (permalink / raw)
To: Michal Wajdeczko; +Cc: intel-xe
On Thu, Jul 11, 2024 at 10:09:01PM +0200, Michal Wajdeczko wrote:
>
>
> On 11.07.2024 19:11, Rodrigo Vivi wrote:
> > Introduce a new xe_ggtt_print_holes helper that attends the SRIOV
> > demand and finishes the goal of limiting drm_mm access to xe_ggtt.
> >
> > Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_ggtt.c | 40 ++++++++++++++++++++++
> > drivers/gpu/drm/xe/xe_ggtt.h | 1 +
> > drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 25 +-------------
> > 3 files changed, 42 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> > index dbaf1ce87fb4..5b51753fe1ba 100644
> > --- a/drivers/gpu/drm/xe/xe_ggtt.c
> > +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> > @@ -682,3 +682,43 @@ int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p)
> > mutex_unlock(&ggtt->lock);
> > return err;
> > }
> > +
> > +/**
> > + * xe_ggtt_print_holes - Print holes
> > + * @ggtt: the &xe_ggtt to be inspected
> > + * @alignment: min alignment
> > + * @p: the &drm_printer
> > + *
> > + * Print GGTT ranges that are available and return total size available.
> > + *
> > + * Return: Total available size.
>
> I would rather prefer to lost that info than make the 'print' function
> return some real value (which may be immediately stale as it will be out
> of mutex)
>
> > + */
> > +u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer *p)
> > +{
> > + const struct drm_mm *mm = &ggtt->mm;
> > + const struct drm_mm_node *entry;
> > + u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
> > + u64 hole_start, hole_end, hole_size;
> > + u64 total;
> > + char buf[10];
> > +
> > + mutex_lock(&ggtt->lock);
> > +
> > + drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> > + hole_start = max(hole_start, hole_min_start);
> > + hole_start = ALIGN(hole_start, alignment);
> > + hole_end = ALIGN_DOWN(hole_end, alignment);
> > + if (hole_start >= hole_end)
> > + continue;
> > + hole_size = hole_end - hole_start;
> > + total += hole_size;
> > +
> > + string_get_size(hole_size, 1, STRING_UNITS_2, buf, sizeof(buf));
> > + drm_printf(p, "range:\t%#llx-%#llx\t(%s)\n",
> > + hole_start, hole_end - 1, buf);
> > + }
>
> or we can print that 'total' here, as it is still kind of related since
> it is "sum of all holes" ;)
it is actually used in one of the cases after this print...
string_get_size(total, 1, STRING_UNITS_2, buf, sizeof(buf));
perhaps print is a bad name then... but I'm out of ideas...
>
> > +
> > + mutex_unlock(&ggtt->lock);
> > +
> > + return total;
> > +}
> > diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> > index 31060fe7644b..67ae5f1602a3 100644
> > --- a/drivers/gpu/drm/xe/xe_ggtt.h
> > +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> > @@ -32,6 +32,7 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> > u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
> >
> > int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
>
> hmm, maybe xe_ggtt_dump() from prev patch should be xe_ggtt_print() ?
hmm... likely, but this needs to calculate the whole...
but we could perhaps
s/xe_ggtt_print/xe_ggtt_get_holes_total
s/xe_ggtt_dump/xe_ggtt_print
?
>
> > +u64 xe_ggtt_print_holes(struct xe_ggtt *ggtt, u64 alignment, struct drm_printer *p);
> >
> > #ifdef CONFIG_PCI_IOV
> > void xe_ggtt_assign(struct xe_ggtt *ggtt, const struct xe_ggtt_node *node, u16 vfid);
> > diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > index 1d17c34fe5a4..d0995680f53f 100644
> > --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> > @@ -6,9 +6,6 @@
> > #include <linux/string_choices.h>
> > #include <linux/wordpart.h>
> >
> > -/* FIXME: remove this after encapsulating all drm_mm_node access into xe_ggtt */
> > -#include <drm/drm_mm.h>
> > -
> > #include "abi/guc_actions_sriov_abi.h"
> > #include "abi/guc_klvs_abi.h"
> >
> > @@ -2096,11 +2093,7 @@ int xe_gt_sriov_pf_config_print_dbs(struct xe_gt *gt, struct drm_printer *p)
> > int xe_gt_sriov_pf_config_print_available_ggtt(struct xe_gt *gt, struct drm_printer *p)
> > {
> > struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
> > - const struct drm_mm *mm = &ggtt->mm;
> > - const struct drm_mm_node *entry;
> > u64 alignment = pf_get_ggtt_alignment(gt);
> > - u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
> > - u64 hole_start, hole_end, hole_size;
> > u64 spare, avail, total = 0;
> > char buf[10];
> >
> > @@ -2109,24 +2102,8 @@ int xe_gt_sriov_pf_config_print_available_ggtt(struct xe_gt *gt, struct drm_prin
> > mutex_lock(xe_gt_sriov_pf_master_mutex(gt));
> >
> > spare = pf_get_spare_ggtt(gt);
> > + total = xe_ggtt_print_holes(ggtt, alignment, p);
> >
> > - mutex_lock(&ggtt->lock);
> > -
> > - drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
> > - hole_start = max(hole_start, hole_min_start);
> > - hole_start = ALIGN(hole_start, alignment);
> > - hole_end = ALIGN_DOWN(hole_end, alignment);
> > - if (hole_start >= hole_end)
> > - continue;
> > - hole_size = hole_end - hole_start;
> > - total += hole_size;
> > -
> > - string_get_size(hole_size, 1, STRING_UNITS_2, buf, sizeof(buf));
> > - drm_printf(p, "range:\t%#llx-%#llx\t(%s)\n",
> > - hole_start, hole_end - 1, buf);
> > - }
> > -
> > - mutex_unlock(&ggtt->lock);
> > mutex_unlock(xe_gt_sriov_pf_master_mutex(gt));
> >
> > string_get_size(total, 1, STRING_UNITS_2, buf, sizeof(buf));
^ permalink raw reply [flat|nested] 38+ messages in thread
* Re: [PATCH 10/12] drm/xe: Rename xe_ggtt balloon functions to make the node clear
2024-07-11 20:17 ` Michal Wajdeczko
@ 2024-08-09 21:42 ` Rodrigo Vivi
0 siblings, 0 replies; 38+ messages in thread
From: Rodrigo Vivi @ 2024-08-09 21:42 UTC (permalink / raw)
To: Michal Wajdeczko; +Cc: intel-xe
On Thu, Jul 11, 2024 at 10:17:24PM +0200, Michal Wajdeczko wrote:
>
>
> On 11.07.2024 19:11, Rodrigo Vivi wrote:
> > These operations are related to node. Convert them to the
> > new appropriate name space xe_ggtt_node.
>
> hmm, actually these operations were meant to be GGTT related [1], but it
> was suggested that it would be better to keep required nodes on the
> client side
>
> [1] https://patchwork.freedesktop.org/patch/341977/?series=69844&rev=1
>
> but maybe we can return to this idea and on the Xe driver lets hide
> balloon nodes inside the xe_ggtt ?
>
> and later on we may want to add xe_ggtt_reballoon() to shift the range
either way works for me... could we leave this to a follow-up rework
and for now just fix the name space?
>
> >
> > Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
> > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_ggtt.c | 12 ++++++------
> > drivers/gpu/drm/xe/xe_ggtt.h | 4 ++--
> > drivers/gpu/drm/xe/xe_gt_sriov_vf.c | 10 +++++-----
> > 3 files changed, 13 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
> > index 5b51753fe1ba..928c01f9e212 100644
> > --- a/drivers/gpu/drm/xe/xe_ggtt.c
> > +++ b/drivers/gpu/drm/xe/xe_ggtt.c
> > @@ -347,17 +347,17 @@ static void xe_ggtt_dump_node(struct xe_ggtt *ggtt,
> > }
> >
> > /**
> > - * xe_ggtt_balloon - prevent allocation of specified GGTT addresses
> > + * xe_ggtt_node_balloon - prevent allocation of specified GGTT addresses
> > * @ggtt: the &xe_ggtt where we want to make reservation
> > * @start: the starting GGTT address of the reserved region
> > * @end: then end GGTT address of the reserved region
> > * @node: the &xe_ggtt_node to hold reserved GGTT node
> > *
> > - * Use xe_ggtt_deballoon() to release a reserved GGTT node.
> > + * Use xe_ggtt_node_deballoon() to release a reserved GGTT node.
> > *
> > * Return: 0 on success or a negative error code on failure.
> > */
> > -int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_node *node)
> > +int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_node *node)
> > {
> > int err;
> >
> > @@ -384,13 +384,13 @@ int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 end, struct xe_ggtt_nod
> > }
> >
> > /**
> > - * xe_ggtt_deballoon - release a reserved GGTT region
> > + * xe_ggtt_node_deballoon - release a reserved GGTT region
> > * @ggtt: the &xe_ggtt where reserved node belongs
> > * @node: the &xe_ggtt_node with reserved GGTT region
> > *
> > - * See xe_ggtt_balloon() for details.
> > + * See xe_ggtt_node_balloon() for details.
> > */
> > -void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> > +void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node)
> > {
> > if (!drm_mm_node_allocated(&node->base))
> > return;
> > diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
> > index 67ae5f1602a3..e68cede2e6b5 100644
> > --- a/drivers/gpu/drm/xe/xe_ggtt.h
> > +++ b/drivers/gpu/drm/xe/xe_ggtt.h
> > @@ -13,8 +13,8 @@ struct drm_printer;
> > int xe_ggtt_init_early(struct xe_ggtt *ggtt);
> > int xe_ggtt_init(struct xe_ggtt *ggtt);
> >
> > -int xe_ggtt_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
> > -void xe_ggtt_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
> > +int xe_ggtt_node_balloon(struct xe_ggtt *ggtt, u64 start, u64 size, struct xe_ggtt_node *node);
> > +void xe_ggtt_node_deballoon(struct xe_ggtt *ggtt, struct xe_ggtt_node *node);
> >
> > int xe_ggtt_node_insert(struct xe_ggtt *ggtt, struct xe_ggtt_node *node,
> > u32 size, u32 align);
> > diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> > index 41e46a00c01e..a478e6e1b20e 100644
> > --- a/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> > +++ b/drivers/gpu/drm/xe/xe_gt_sriov_vf.c
> > @@ -528,7 +528,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
> > start = xe_wopcm_size(xe);
> > end = config->ggtt_base;
> > if (end != start) {
> > - err = xe_ggtt_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[0]);
> > + err = xe_ggtt_node_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[0]);
> > if (err)
> > goto failed;
> > }
> > @@ -536,7 +536,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
> > start = config->ggtt_base + config->ggtt_size;
> > end = GUC_GGTT_TOP;
> > if (end != start) {
> > - err = xe_ggtt_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[1]);
> > + err = xe_ggtt_node_balloon(ggtt, start, end, &tile->sriov.vf.ggtt_balloon[1]);
> > if (err)
> > goto deballoon;
> > }
> > @@ -544,7 +544,7 @@ static int vf_balloon_ggtt(struct xe_gt *gt)
> > return 0;
> >
> > deballoon:
> > - xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
> > + xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
> > failed:
> > return err;
> > }
> > @@ -555,8 +555,8 @@ static void deballoon_ggtt(struct drm_device *drm, void *arg)
> > struct xe_ggtt *ggtt = tile->mem.ggtt;
> >
> > xe_tile_assert(tile, IS_SRIOV_VF(tile_to_xe(tile)));
> > - xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[1]);
> > - xe_ggtt_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
> > + xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[1]);
> > + xe_ggtt_node_deballoon(ggtt, &tile->sriov.vf.ggtt_balloon[0]);
> > }
> >
> > /**
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole
2024-08-15 22:07 [PATCH 01/12] " Rodrigo Vivi
@ 2024-08-15 22:07 ` Rodrigo Vivi
0 siblings, 0 replies; 38+ messages in thread
From: Rodrigo Vivi @ 2024-08-15 22:07 UTC (permalink / raw)
To: intel-xe; +Cc: lucas.demarchi, jose.souza, Rodrigo Vivi, Michal Wajdeczko
Introduce a new xe_ggtt_largest_hole helper that attends the SRIOV
demand and continue with the goal of limiting drm_mm access to xe_ggtt.
v2: Fix a typo (Michal)
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 35 ++++++++++++++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 1 +
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 23 ++------------
3 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 7c8bbaa30fca..2d055f489879 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -584,6 +584,41 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
}
+/**
+ * xe_ggtt_largest_hole - Largest GGTT hole
+ * @ggtt: the &xe_ggtt that will be inspected
+ * @alignment: minimum alignment
+ * @spare: If not NULL: in: desired memory size to be spared / out: Adjusted possible spare
+ *
+ * Return: size of the largest continuous GGTT region
+ */
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare)
+{
+ const struct drm_mm *mm = &ggtt->mm;
+ const struct drm_mm_node *entry;
+ u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
+ u64 hole_start, hole_end, hole_size;
+ u64 max_hole = 0;
+
+ mutex_lock(&ggtt->lock);
+
+ drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
+ hole_start = max(hole_start, hole_min_start);
+ hole_start = ALIGN(hole_start, alignment);
+ hole_end = ALIGN_DOWN(hole_end, alignment);
+ if (hole_start >= hole_end)
+ continue;
+ hole_size = hole_end - hole_start;
+ if (spare)
+ *spare -= min3(*spare, hole_size, max_hole);
+ max_hole = max(max_hole, hole_size);
+ }
+
+ mutex_unlock(&ggtt->lock);
+
+ return max_hole;
+}
+
#ifdef CONFIG_PCI_IOV
static u64 xe_encode_vfid_pte(u16 vfid)
{
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index f816b3c0732b..31060fe7644b 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -29,6 +29,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u64 start, u64 end);
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index 947750d97d7d..1852ff45bea4 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -590,30 +590,11 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
static u64 pf_get_max_ggtt(struct xe_gt *gt)
{
struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
- const struct drm_mm *mm = &ggtt->mm;
- const struct drm_mm_node *entry;
u64 alignment = pf_get_ggtt_alignment(gt);
u64 spare = pf_get_spare_ggtt(gt);
- u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
- u64 hole_start, hole_end, hole_size;
- u64 max_hole = 0;
-
- mutex_lock(&ggtt->lock);
-
- drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
- hole_start = max(hole_start, hole_min_start);
- hole_start = ALIGN(hole_start, alignment);
- hole_end = ALIGN_DOWN(hole_end, alignment);
- if (hole_start >= hole_end)
- continue;
- hole_size = hole_end - hole_start;
- xe_gt_sriov_dbg_verbose(gt, "HOLE start %llx size %lluK\n",
- hole_start, hole_size / SZ_1K);
- spare -= min3(spare, hole_size, max_hole);
- max_hole = max(max_hole, hole_size);
- }
+ u64 max_hole;
- mutex_unlock(&ggtt->lock);
+ max_hole = xe_ggtt_largest_hole(ggtt, alignment, &spare);
xe_gt_sriov_dbg_verbose(gt, "HOLE max %lluK reserved %lluK\n",
max_hole / SZ_1K, spare / SZ_1K);
--
2.46.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole
2024-08-16 15:02 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
@ 2024-08-16 15:02 ` Rodrigo Vivi
2024-08-16 15:35 ` Lucas De Marchi
0 siblings, 1 reply; 38+ messages in thread
From: Rodrigo Vivi @ 2024-08-16 15:02 UTC (permalink / raw)
To: intel-xe; +Cc: lucas.demarchi, jose.souza, Rodrigo Vivi, Michal Wajdeczko
Introduce a new xe_ggtt_largest_hole helper that attends the SRIOV
demand and continue with the goal of limiting drm_mm access to xe_ggtt.
v2: Fix a typo (Michal)
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 35 ++++++++++++++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 1 +
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 23 ++------------
3 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 7c8bbaa30fca..2d055f489879 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -584,6 +584,41 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
}
+/**
+ * xe_ggtt_largest_hole - Largest GGTT hole
+ * @ggtt: the &xe_ggtt that will be inspected
+ * @alignment: minimum alignment
+ * @spare: If not NULL: in: desired memory size to be spared / out: Adjusted possible spare
+ *
+ * Return: size of the largest continuous GGTT region
+ */
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare)
+{
+ const struct drm_mm *mm = &ggtt->mm;
+ const struct drm_mm_node *entry;
+ u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
+ u64 hole_start, hole_end, hole_size;
+ u64 max_hole = 0;
+
+ mutex_lock(&ggtt->lock);
+
+ drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
+ hole_start = max(hole_start, hole_min_start);
+ hole_start = ALIGN(hole_start, alignment);
+ hole_end = ALIGN_DOWN(hole_end, alignment);
+ if (hole_start >= hole_end)
+ continue;
+ hole_size = hole_end - hole_start;
+ if (spare)
+ *spare -= min3(*spare, hole_size, max_hole);
+ max_hole = max(max_hole, hole_size);
+ }
+
+ mutex_unlock(&ggtt->lock);
+
+ return max_hole;
+}
+
#ifdef CONFIG_PCI_IOV
static u64 xe_encode_vfid_pte(u16 vfid)
{
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index f816b3c0732b..31060fe7644b 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -29,6 +29,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u64 start, u64 end);
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index 947750d97d7d..1852ff45bea4 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -590,30 +590,11 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
static u64 pf_get_max_ggtt(struct xe_gt *gt)
{
struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
- const struct drm_mm *mm = &ggtt->mm;
- const struct drm_mm_node *entry;
u64 alignment = pf_get_ggtt_alignment(gt);
u64 spare = pf_get_spare_ggtt(gt);
- u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
- u64 hole_start, hole_end, hole_size;
- u64 max_hole = 0;
-
- mutex_lock(&ggtt->lock);
-
- drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
- hole_start = max(hole_start, hole_min_start);
- hole_start = ALIGN(hole_start, alignment);
- hole_end = ALIGN_DOWN(hole_end, alignment);
- if (hole_start >= hole_end)
- continue;
- hole_size = hole_end - hole_start;
- xe_gt_sriov_dbg_verbose(gt, "HOLE start %llx size %lluK\n",
- hole_start, hole_size / SZ_1K);
- spare -= min3(spare, hole_size, max_hole);
- max_hole = max(max_hole, hole_size);
- }
+ u64 max_hole;
- mutex_unlock(&ggtt->lock);
+ max_hole = xe_ggtt_largest_hole(ggtt, alignment, &spare);
xe_gt_sriov_dbg_verbose(gt, "HOLE max %lluK reserved %lluK\n",
max_hole / SZ_1K, spare / SZ_1K);
--
2.46.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* Re: [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole
2024-08-16 15:02 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
@ 2024-08-16 15:35 ` Lucas De Marchi
0 siblings, 0 replies; 38+ messages in thread
From: Lucas De Marchi @ 2024-08-16 15:35 UTC (permalink / raw)
To: Rodrigo Vivi; +Cc: intel-xe, jose.souza, Michal Wajdeczko
On Fri, Aug 16, 2024 at 11:02:39AM GMT, Rodrigo Vivi wrote:
>Introduce a new xe_ggtt_largest_hole helper that attends the SRIOV
>demand and continue with the goal of limiting drm_mm access to xe_ggtt.
>
>v2: Fix a typo (Michal)
>
>Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
>Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
>---
> drivers/gpu/drm/xe/xe_ggtt.c | 35 ++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_ggtt.h | 1 +
> drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 23 ++------------
> 3 files changed, 38 insertions(+), 21 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
>index 7c8bbaa30fca..2d055f489879 100644
>--- a/drivers/gpu/drm/xe/xe_ggtt.c
>+++ b/drivers/gpu/drm/xe/xe_ggtt.c
>@@ -584,6 +584,41 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
> bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
> }
>
>+/**
>+ * xe_ggtt_largest_hole - Largest GGTT hole
>+ * @ggtt: the &xe_ggtt that will be inspected
>+ * @alignment: minimum alignment
>+ * @spare: If not NULL: in: desired memory size to be spared / out: Adjusted possible spare
>+ *
>+ * Return: size of the largest continuous GGTT region
>+ */
>+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare)
>+{
>+ const struct drm_mm *mm = &ggtt->mm;
>+ const struct drm_mm_node *entry;
>+ u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
>+ u64 hole_start, hole_end, hole_size;
>+ u64 max_hole = 0;
>+
>+ mutex_lock(&ggtt->lock);
>+
>+ drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
>+ hole_start = max(hole_start, hole_min_start);
>+ hole_start = ALIGN(hole_start, alignment);
>+ hole_end = ALIGN_DOWN(hole_end, alignment);
>+ if (hole_start >= hole_end)
>+ continue;
>+ hole_size = hole_end - hole_start;
>+ if (spare)
>+ *spare -= min3(*spare, hole_size, max_hole);
>+ max_hole = max(max_hole, hole_size);
>+ }
>+
>+ mutex_unlock(&ggtt->lock);
>+
>+ return max_hole;
>+}
>+
> #ifdef CONFIG_PCI_IOV
> static u64 xe_encode_vfid_pte(u16 vfid)
> {
>diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
>index f816b3c0732b..31060fe7644b 100644
>--- a/drivers/gpu/drm/xe/xe_ggtt.h
>+++ b/drivers/gpu/drm/xe/xe_ggtt.h
>@@ -29,6 +29,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
> int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
> u64 start, u64 end);
> void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
>+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
>
> int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
>
>diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
>index 947750d97d7d..1852ff45bea4 100644
>--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
>+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
>@@ -590,30 +590,11 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
> static u64 pf_get_max_ggtt(struct xe_gt *gt)
> {
> struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
>- const struct drm_mm *mm = &ggtt->mm;
>- const struct drm_mm_node *entry;
> u64 alignment = pf_get_ggtt_alignment(gt);
> u64 spare = pf_get_spare_ggtt(gt);
>- u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
>- u64 hole_start, hole_end, hole_size;
>- u64 max_hole = 0;
>-
>- mutex_lock(&ggtt->lock);
>-
>- drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
>- hole_start = max(hole_start, hole_min_start);
>- hole_start = ALIGN(hole_start, alignment);
>- hole_end = ALIGN_DOWN(hole_end, alignment);
>- if (hole_start >= hole_end)
>- continue;
>- hole_size = hole_end - hole_start;
>- xe_gt_sriov_dbg_verbose(gt, "HOLE start %llx size %lluK\n",
>- hole_start, hole_size / SZ_1K);
>- spare -= min3(spare, hole_size, max_hole);
>- max_hole = max(max_hole, hole_size);
>- }
>+ u64 max_hole;
>
>- mutex_unlock(&ggtt->lock);
>+ max_hole = xe_ggtt_largest_hole(ggtt, alignment, &spare);
optional: I think this would read better with a single name for the same
thing:
max_hole = xe_ggtt_max_hole(ggtt, alignment, &spare);
Anyway, checked with git show --color-moved to make sure it retains the
current behavior.
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Lucas De Marchi
>
> xe_gt_sriov_dbg_verbose(gt, "HOLE max %lluK reserved %lluK\n",
> max_hole / SZ_1K, spare / SZ_1K);
>--
>2.46.0
>
^ permalink raw reply [flat|nested] 38+ messages in thread
* [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole
2024-08-17 10:35 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
@ 2024-08-17 10:35 ` Rodrigo Vivi
0 siblings, 0 replies; 38+ messages in thread
From: Rodrigo Vivi @ 2024-08-17 10:35 UTC (permalink / raw)
To: intel-xe; +Cc: lucas.demarchi, jose.souza, Rodrigo Vivi, Michal Wajdeczko
Introduce a new xe_ggtt_largest_hole helper that attends the SRIOV
demand and continue with the goal of limiting drm_mm access to xe_ggtt.
v2: Fix a typo (Michal)
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 35 ++++++++++++++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 1 +
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 23 ++------------
3 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 7c8bbaa30fca..2d055f489879 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -584,6 +584,41 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
}
+/**
+ * xe_ggtt_largest_hole - Largest GGTT hole
+ * @ggtt: the &xe_ggtt that will be inspected
+ * @alignment: minimum alignment
+ * @spare: If not NULL: in: desired memory size to be spared / out: Adjusted possible spare
+ *
+ * Return: size of the largest continuous GGTT region
+ */
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare)
+{
+ const struct drm_mm *mm = &ggtt->mm;
+ const struct drm_mm_node *entry;
+ u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
+ u64 hole_start, hole_end, hole_size;
+ u64 max_hole = 0;
+
+ mutex_lock(&ggtt->lock);
+
+ drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
+ hole_start = max(hole_start, hole_min_start);
+ hole_start = ALIGN(hole_start, alignment);
+ hole_end = ALIGN_DOWN(hole_end, alignment);
+ if (hole_start >= hole_end)
+ continue;
+ hole_size = hole_end - hole_start;
+ if (spare)
+ *spare -= min3(*spare, hole_size, max_hole);
+ max_hole = max(max_hole, hole_size);
+ }
+
+ mutex_unlock(&ggtt->lock);
+
+ return max_hole;
+}
+
#ifdef CONFIG_PCI_IOV
static u64 xe_encode_vfid_pte(u16 vfid)
{
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index f816b3c0732b..31060fe7644b 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -29,6 +29,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u64 start, u64 end);
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index 947750d97d7d..1852ff45bea4 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -590,30 +590,11 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
static u64 pf_get_max_ggtt(struct xe_gt *gt)
{
struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
- const struct drm_mm *mm = &ggtt->mm;
- const struct drm_mm_node *entry;
u64 alignment = pf_get_ggtt_alignment(gt);
u64 spare = pf_get_spare_ggtt(gt);
- u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
- u64 hole_start, hole_end, hole_size;
- u64 max_hole = 0;
-
- mutex_lock(&ggtt->lock);
-
- drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
- hole_start = max(hole_start, hole_min_start);
- hole_start = ALIGN(hole_start, alignment);
- hole_end = ALIGN_DOWN(hole_end, alignment);
- if (hole_start >= hole_end)
- continue;
- hole_size = hole_end - hole_start;
- xe_gt_sriov_dbg_verbose(gt, "HOLE start %llx size %lluK\n",
- hole_start, hole_size / SZ_1K);
- spare -= min3(spare, hole_size, max_hole);
- max_hole = max(max_hole, hole_size);
- }
+ u64 max_hole;
- mutex_unlock(&ggtt->lock);
+ max_hole = xe_ggtt_largest_hole(ggtt, alignment, &spare);
xe_gt_sriov_dbg_verbose(gt, "HOLE max %lluK reserved %lluK\n",
max_hole / SZ_1K, spare / SZ_1K);
--
2.46.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole
2024-08-20 20:25 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
@ 2024-08-20 20:25 ` Rodrigo Vivi
0 siblings, 0 replies; 38+ messages in thread
From: Rodrigo Vivi @ 2024-08-20 20:25 UTC (permalink / raw)
To: intel-xe; +Cc: lucas.demarchi, Rodrigo Vivi, Michal Wajdeczko
Introduce a new xe_ggtt_largest_hole helper that attends the SRIOV
demand and continue with the goal of limiting drm_mm access to xe_ggtt.
v2: Fix a typo (Michal)
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 35 ++++++++++++++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 1 +
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 23 ++------------
3 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 7c8bbaa30fca..2d055f489879 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -584,6 +584,41 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
}
+/**
+ * xe_ggtt_largest_hole - Largest GGTT hole
+ * @ggtt: the &xe_ggtt that will be inspected
+ * @alignment: minimum alignment
+ * @spare: If not NULL: in: desired memory size to be spared / out: Adjusted possible spare
+ *
+ * Return: size of the largest continuous GGTT region
+ */
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare)
+{
+ const struct drm_mm *mm = &ggtt->mm;
+ const struct drm_mm_node *entry;
+ u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
+ u64 hole_start, hole_end, hole_size;
+ u64 max_hole = 0;
+
+ mutex_lock(&ggtt->lock);
+
+ drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
+ hole_start = max(hole_start, hole_min_start);
+ hole_start = ALIGN(hole_start, alignment);
+ hole_end = ALIGN_DOWN(hole_end, alignment);
+ if (hole_start >= hole_end)
+ continue;
+ hole_size = hole_end - hole_start;
+ if (spare)
+ *spare -= min3(*spare, hole_size, max_hole);
+ max_hole = max(max_hole, hole_size);
+ }
+
+ mutex_unlock(&ggtt->lock);
+
+ return max_hole;
+}
+
#ifdef CONFIG_PCI_IOV
static u64 xe_encode_vfid_pte(u16 vfid)
{
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index f816b3c0732b..31060fe7644b 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -29,6 +29,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u64 start, u64 end);
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index 947750d97d7d..1852ff45bea4 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -590,30 +590,11 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
static u64 pf_get_max_ggtt(struct xe_gt *gt)
{
struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
- const struct drm_mm *mm = &ggtt->mm;
- const struct drm_mm_node *entry;
u64 alignment = pf_get_ggtt_alignment(gt);
u64 spare = pf_get_spare_ggtt(gt);
- u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
- u64 hole_start, hole_end, hole_size;
- u64 max_hole = 0;
-
- mutex_lock(&ggtt->lock);
-
- drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
- hole_start = max(hole_start, hole_min_start);
- hole_start = ALIGN(hole_start, alignment);
- hole_end = ALIGN_DOWN(hole_end, alignment);
- if (hole_start >= hole_end)
- continue;
- hole_size = hole_end - hole_start;
- xe_gt_sriov_dbg_verbose(gt, "HOLE start %llx size %lluK\n",
- hole_start, hole_size / SZ_1K);
- spare -= min3(spare, hole_size, max_hole);
- max_hole = max(max_hole, hole_size);
- }
+ u64 max_hole;
- mutex_unlock(&ggtt->lock);
+ max_hole = xe_ggtt_largest_hole(ggtt, alignment, &spare);
xe_gt_sriov_dbg_verbose(gt, "HOLE max %lluK reserved %lluK\n",
max_hole / SZ_1K, spare / SZ_1K);
--
2.46.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
* [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole
2024-08-21 19:38 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
@ 2024-08-21 19:38 ` Rodrigo Vivi
0 siblings, 0 replies; 38+ messages in thread
From: Rodrigo Vivi @ 2024-08-21 19:38 UTC (permalink / raw)
To: intel-xe; +Cc: lucas.demarchi, Rodrigo Vivi, Michal Wajdeczko
Introduce a new xe_ggtt_largest_hole helper that attends the SRIOV
demand and continue with the goal of limiting drm_mm access to xe_ggtt.
v2: Fix a typo (Michal)
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
---
drivers/gpu/drm/xe/xe_ggtt.c | 35 ++++++++++++++++++++++
drivers/gpu/drm/xe/xe_ggtt.h | 1 +
drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c | 23 ++------------
3 files changed, 38 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_ggtt.c b/drivers/gpu/drm/xe/xe_ggtt.c
index 7c8bbaa30fca..2d055f489879 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.c
+++ b/drivers/gpu/drm/xe/xe_ggtt.c
@@ -584,6 +584,41 @@ void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo)
bo->flags & XE_BO_FLAG_GGTT_INVALIDATE);
}
+/**
+ * xe_ggtt_largest_hole - Largest GGTT hole
+ * @ggtt: the &xe_ggtt that will be inspected
+ * @alignment: minimum alignment
+ * @spare: If not NULL: in: desired memory size to be spared / out: Adjusted possible spare
+ *
+ * Return: size of the largest continuous GGTT region
+ */
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare)
+{
+ const struct drm_mm *mm = &ggtt->mm;
+ const struct drm_mm_node *entry;
+ u64 hole_min_start = xe_wopcm_size(tile_to_xe(ggtt->tile));
+ u64 hole_start, hole_end, hole_size;
+ u64 max_hole = 0;
+
+ mutex_lock(&ggtt->lock);
+
+ drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
+ hole_start = max(hole_start, hole_min_start);
+ hole_start = ALIGN(hole_start, alignment);
+ hole_end = ALIGN_DOWN(hole_end, alignment);
+ if (hole_start >= hole_end)
+ continue;
+ hole_size = hole_end - hole_start;
+ if (spare)
+ *spare -= min3(*spare, hole_size, max_hole);
+ max_hole = max(max_hole, hole_size);
+ }
+
+ mutex_unlock(&ggtt->lock);
+
+ return max_hole;
+}
+
#ifdef CONFIG_PCI_IOV
static u64 xe_encode_vfid_pte(u16 vfid)
{
diff --git a/drivers/gpu/drm/xe/xe_ggtt.h b/drivers/gpu/drm/xe/xe_ggtt.h
index f816b3c0732b..31060fe7644b 100644
--- a/drivers/gpu/drm/xe/xe_ggtt.h
+++ b/drivers/gpu/drm/xe/xe_ggtt.h
@@ -29,6 +29,7 @@ int xe_ggtt_insert_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
int xe_ggtt_insert_bo_at(struct xe_ggtt *ggtt, struct xe_bo *bo,
u64 start, u64 end);
void xe_ggtt_remove_bo(struct xe_ggtt *ggtt, struct xe_bo *bo);
+u64 xe_ggtt_largest_hole(struct xe_ggtt *ggtt, u64 alignment, u64 *spare);
int xe_ggtt_dump(struct xe_ggtt *ggtt, struct drm_printer *p);
diff --git a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
index 947750d97d7d..1852ff45bea4 100644
--- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
+++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
@@ -590,30 +590,11 @@ int xe_gt_sriov_pf_config_bulk_set_ggtt(struct xe_gt *gt, unsigned int vfid,
static u64 pf_get_max_ggtt(struct xe_gt *gt)
{
struct xe_ggtt *ggtt = gt_to_tile(gt)->mem.ggtt;
- const struct drm_mm *mm = &ggtt->mm;
- const struct drm_mm_node *entry;
u64 alignment = pf_get_ggtt_alignment(gt);
u64 spare = pf_get_spare_ggtt(gt);
- u64 hole_min_start = xe_wopcm_size(gt_to_xe(gt));
- u64 hole_start, hole_end, hole_size;
- u64 max_hole = 0;
-
- mutex_lock(&ggtt->lock);
-
- drm_mm_for_each_hole(entry, mm, hole_start, hole_end) {
- hole_start = max(hole_start, hole_min_start);
- hole_start = ALIGN(hole_start, alignment);
- hole_end = ALIGN_DOWN(hole_end, alignment);
- if (hole_start >= hole_end)
- continue;
- hole_size = hole_end - hole_start;
- xe_gt_sriov_dbg_verbose(gt, "HOLE start %llx size %lluK\n",
- hole_start, hole_size / SZ_1K);
- spare -= min3(spare, hole_size, max_hole);
- max_hole = max(max_hole, hole_size);
- }
+ u64 max_hole;
- mutex_unlock(&ggtt->lock);
+ max_hole = xe_ggtt_largest_hole(ggtt, alignment, &spare);
xe_gt_sriov_dbg_verbose(gt, "HOLE max %lluK reserved %lluK\n",
max_hole / SZ_1K, spare / SZ_1K);
--
2.46.0
^ permalink raw reply related [flat|nested] 38+ messages in thread
end of thread, other threads:[~2024-08-21 19:39 UTC | newest]
Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-11 17:11 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 02/12] drm/xe: Introduce GGTT documentation Rodrigo Vivi
2024-07-11 19:41 ` Michal Wajdeczko
2024-07-11 17:11 ` [PATCH 03/12] drm/xe: Remove unnecessary drm_mm.h includes Rodrigo Vivi
2024-07-11 18:35 ` Cavitt, Jonathan
2024-07-11 17:11 ` [PATCH 04/12] drm/{i915, xe}: Avoid direct inspection of dpt_vma from outside dpt Rodrigo Vivi
2024-07-11 18:38 ` Cavitt, Jonathan
2024-07-11 17:11 ` [PATCH 05/12] drm/xe: Encapsulate drm_mm_node inside xe_ggtt_node Rodrigo Vivi
2024-07-11 19:51 ` Michal Wajdeczko
2024-07-16 17:16 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 06/12] drm/xe: Rename xe_ggtt_node related functions Rodrigo Vivi
2024-07-16 17:24 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 07/12] drm/xe: Limit drm_mm_node_allocated access to xe_ggtt_node Rodrigo Vivi
2024-07-17 23:27 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
2024-07-11 20:00 ` Michal Wajdeczko
2024-08-09 21:33 ` Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 09/12] drm/xe: Introduce xe_ggtt_print_holes Rodrigo Vivi
2024-07-11 18:43 ` Cavitt, Jonathan
2024-07-11 20:09 ` Michal Wajdeczko
2024-08-09 21:38 ` Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 10/12] drm/xe: Rename xe_ggtt balloon functions to make the node clear Rodrigo Vivi
2024-07-11 20:17 ` Michal Wajdeczko
2024-08-09 21:42 ` Rodrigo Vivi
2024-07-11 17:11 ` [PATCH 11/12] drm/xe: Make xe_ggtt_node struct independent Rodrigo Vivi
2024-07-17 23:50 ` Matthew Brost
2024-07-11 17:11 ` [PATCH 12/12] drm/xe: Fix missing runtime outer protection for ggtt_remove_node Rodrigo Vivi
2024-07-16 17:32 ` Matthew Brost
2024-07-11 17:25 ` ✓ CI.Patch_applied: success for series starting with [01/12] drm/xe: Removed unused xe_ggtt_printk Patchwork
2024-07-11 17:26 ` ✓ CI.checkpatch: " Patchwork
2024-07-11 17:28 ` ✓ CI.KUnit: " Patchwork
2024-07-11 17:34 ` ✗ CI.Build: failure " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2024-08-15 22:07 [PATCH 01/12] " Rodrigo Vivi
2024-08-15 22:07 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
2024-08-16 15:02 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-08-16 15:02 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
2024-08-16 15:35 ` Lucas De Marchi
2024-08-17 10:35 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-08-17 10:35 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
2024-08-20 20:25 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-08-20 20:25 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
2024-08-21 19:38 [PATCH 01/12] drm/xe: Removed unused xe_ggtt_printk Rodrigo Vivi
2024-08-21 19:38 ` [PATCH 08/12] drm/xe: Introduce xe_ggtt_largest_hole Rodrigo Vivi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox