Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>,
	Matthew Brost <matthew.brost@intel.com>
Subject: [PATCH v2 06/11] drm/xe/sa: Allow creating suballocator with custom guard size
Date: Fri, 20 Dec 2024 20:41:59 +0100	[thread overview]
Message-ID: <20241220194205.995-7-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20241220194205.995-1-michal.wajdeczko@intel.com>

Actual xe_sa_manager implementation uses hardcoded 4K to exclude
it from making suballocations but in upcoming patch we want to
reuse the xe_sa_manager where such 4K guard is not needed. Add
another variant of the xe_sa_bo_manager_init() function that
accepts arbitrary guard size.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
---
 drivers/gpu/drm/xe/xe_sa.c | 18 ++++++++++++++++--
 drivers/gpu/drm/xe/xe_sa.h |  9 +++++++--
 2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_sa.c b/drivers/gpu/drm/xe/xe_sa.c
index 5f89e32b0640..f8fe61e25518 100644
--- a/drivers/gpu/drm/xe/xe_sa.c
+++ b/drivers/gpu/drm/xe/xe_sa.c
@@ -31,14 +31,28 @@ static void xe_sa_bo_manager_fini(struct drm_device *drm, void *arg)
 	sa_manager->bo = NULL;
 }
 
-struct xe_sa_manager *xe_sa_bo_manager_init(struct xe_tile *tile, u32 size, u32 align)
+/**
+ * __xe_sa_bo_manager_init() - Create and initialize the suballocator
+ * @tile: the &xe_tile where allocate
+ * @size: number of bytes to allocate
+ * @guard: number of bytes to exclude from suballocations
+ * @align: alignment for each suballocated chunk
+ *
+ * Prepares the suballocation manager for suballocations.
+ *
+ * Return: a pointer to the &xe_sa_manager or an ERR_PTR on failure.
+ */
+struct xe_sa_manager *__xe_sa_bo_manager_init(struct xe_tile *tile, u32 size, u32 guard, u32 align)
 {
 	struct xe_device *xe = tile_to_xe(tile);
 	struct xe_sa_manager *sa_manager;
-	u32 managed_size = size - SZ_4K;
+	u32 managed_size;
 	struct xe_bo *bo;
 	int ret;
 
+	xe_tile_assert(tile, size > guard);
+	managed_size = size - guard;
+
 	sa_manager = drmm_kzalloc(&xe->drm, sizeof(*sa_manager), GFP_KERNEL);
 	if (!sa_manager)
 		return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpu/drm/xe/xe_sa.h b/drivers/gpu/drm/xe/xe_sa.h
index a0341eafbe77..de0330eb36d4 100644
--- a/drivers/gpu/drm/xe/xe_sa.h
+++ b/drivers/gpu/drm/xe/xe_sa.h
@@ -5,6 +5,7 @@
 #ifndef _XE_SA_H_
 #define _XE_SA_H_
 
+#include <linux/sizes.h>
 #include <linux/types.h>
 #include "xe_sa_types.h"
 
@@ -12,10 +13,14 @@ struct dma_fence;
 struct xe_bo;
 struct xe_tile;
 
-struct xe_sa_manager *xe_sa_bo_manager_init(struct xe_tile *tile, u32 size, u32 align);
-
+struct xe_sa_manager *__xe_sa_bo_manager_init(struct xe_tile *tile, u32 size, u32 guard, u32 align);
 struct drm_suballoc *__xe_sa_bo_new(struct xe_sa_manager *sa_manager, u32 size, gfp_t gfp);
 
+static inline struct xe_sa_manager *xe_sa_bo_manager_init(struct xe_tile *tile, u32 size, u32 align)
+{
+	return __xe_sa_bo_manager_init(tile, size, SZ_4K, align);
+}
+
 /**
  * xe_sa_bo_new() - Make a suballocation.
  * @sa_manager: the &xe_sa_manager
-- 
2.47.1


  parent reply	other threads:[~2024-12-20 19:42 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-20 19:41 [PATCH v2 00/11] The xe_sa_manager based GuC Buffer Cache Michal Wajdeczko
2024-12-20 19:41 ` [PATCH v2 01/11] drm/xe/sa: Always call drm_suballoc_manager_fini() Michal Wajdeczko
2024-12-20 19:41 ` [PATCH v2 02/11] drm/xe/sa: Drop redundant NULL assignments Michal Wajdeczko
2024-12-20 19:41 ` [PATCH v2 03/11] drm/xe/sa: Improve error message on init failure Michal Wajdeczko
2024-12-20 19:41 ` [PATCH v2 04/11] drm/xe/sa: Tidy up coding style in init() Michal Wajdeczko
2024-12-20 19:41 ` [PATCH v2 05/11] drm/xe/sa: Allow making suballocations using custom gfp flags Michal Wajdeczko
2024-12-20 19:41 ` Michal Wajdeczko [this message]
2024-12-20 19:42 ` [PATCH v2 07/11] drm/xe/sa: Minor header cleanups Michal Wajdeczko
2024-12-20 19:42 ` [PATCH v2 08/11] drm/xe/guc: Introduce the GuC Buffer Cache Michal Wajdeczko
2024-12-20 21:15   ` Matthew Brost
2024-12-20 19:42 ` [PATCH v2 09/11] drm/xe/pf: Use GuC Buffer Cache during VFs provisioning Michal Wajdeczko
2024-12-20 21:23   ` Matthew Brost
2024-12-20 19:42 ` [PATCH v2 10/11] drm/xe/kunit: Allow to replace xe_managed_bo_create_pin_map() Michal Wajdeczko
2025-01-14 12:01   ` Michał Winiarski
2024-12-20 19:42 ` [PATCH v2 11/11] drm/xe/kunit: Add KUnit tests for GuC Buffer Cache Michal Wajdeczko
2025-01-14 12:04   ` Michał Winiarski
2025-01-14 19:21   ` [PATCH v3 " Michal Wajdeczko
2024-12-20 19:47 ` ✓ CI.Patch_applied: success for The xe_sa_manager based GuC Buffer Cache (rev2) Patchwork
2024-12-20 19:47 ` ✗ CI.checkpatch: warning " Patchwork
2024-12-20 19:49 ` ✓ CI.KUnit: success " Patchwork
2024-12-20 20:14 ` ✓ CI.Build: " Patchwork
2024-12-20 20:17 ` ✓ CI.Hooks: " Patchwork
2024-12-20 20:20 ` ✓ CI.checksparse: " Patchwork
2024-12-20 20:53 ` ✓ Xe.CI.BAT: " Patchwork
2024-12-22  0:59 ` ✗ Xe.CI.Full: failure " Patchwork
2025-01-14 21:53 ` ✓ CI.Patch_applied: success for The xe_sa_manager based GuC Buffer Cache (rev3) Patchwork
2025-01-14 21:54 ` ✗ CI.checkpatch: warning " Patchwork
2025-01-14 21:55 ` ✓ CI.KUnit: success " Patchwork
2025-01-14 22:13 ` ✓ CI.Build: " Patchwork
2025-01-14 22:15 ` ✓ CI.Hooks: " Patchwork
2025-01-14 22:17 ` ✓ CI.checksparse: " Patchwork
2025-01-14 22:42 ` ✓ Xe.CI.BAT: " Patchwork
2025-01-15  2:19 ` ✗ Xe.CI.Full: failure " Patchwork
2025-01-18 23:08   ` Michal Wajdeczko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241220194205.995-7-michal.wajdeczko@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox