Skip to content

Commit dca2701

Browse files
committed
drm/xe: Allow the caller to pass guc_buf_cache size
An upcoming change will use GuC buffer cache as a place where GuC migration data will be stored, and the memory requirement for that is larger than indirect data. Allow the caller to pass the size based on the intended usecase. Reviewed-by: Michal Wajdeczko <michal.wajdeczko@intel.com> Link: https://patch.msgid.link/20251112132220.516975-12-michal.winiarski@intel.com Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
1 parent 4f4bdbd commit dca2701

2 files changed

Lines changed: 34 additions & 11 deletions

File tree

drivers/gpu/drm/xe/xe_guc_buf.c

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#include "xe_guc_buf.h"
1414
#include "xe_sa.h"
1515

16+
#define XE_GUC_BUF_CACHE_DEFAULT_SIZE SZ_8K
17+
1618
static struct xe_guc *cache_to_guc(struct xe_guc_buf_cache *cache)
1719
{
1820
return container_of(cache, struct xe_guc, buf);
@@ -23,21 +25,12 @@ static struct xe_gt *cache_to_gt(struct xe_guc_buf_cache *cache)
2325
return guc_to_gt(cache_to_guc(cache));
2426
}
2527

26-
/**
27-
* xe_guc_buf_cache_init() - Initialize the GuC Buffer Cache.
28-
* @cache: the &xe_guc_buf_cache to initialize
29-
*
30-
* The Buffer Cache allows to obtain a reusable buffer that can be used to pass
31-
* indirect H2G data to GuC without a need to create a ad-hoc allocation.
32-
*
33-
* Return: 0 on success or a negative error code on failure.
34-
*/
35-
int xe_guc_buf_cache_init(struct xe_guc_buf_cache *cache)
28+
static int guc_buf_cache_init(struct xe_guc_buf_cache *cache, u32 size)
3629
{
3730
struct xe_gt *gt = cache_to_gt(cache);
3831
struct xe_sa_manager *sam;
3932

40-
sam = __xe_sa_bo_manager_init(gt_to_tile(gt), SZ_8K, 0, sizeof(u32));
33+
sam = __xe_sa_bo_manager_init(gt_to_tile(gt), size, 0, sizeof(u32));
4134
if (IS_ERR(sam))
4235
return PTR_ERR(sam);
4336
cache->sam = sam;
@@ -48,6 +41,35 @@ int xe_guc_buf_cache_init(struct xe_guc_buf_cache *cache)
4841
return 0;
4942
}
5043

44+
/**
45+
* xe_guc_buf_cache_init() - Initialize the GuC Buffer Cache.
46+
* @cache: the &xe_guc_buf_cache to initialize
47+
*
48+
* The Buffer Cache allows to obtain a reusable buffer that can be used to pass
49+
* data to GuC or read data from GuC without a need to create a ad-hoc allocation.
50+
*
51+
* Return: 0 on success or a negative error code on failure.
52+
*/
53+
int xe_guc_buf_cache_init(struct xe_guc_buf_cache *cache)
54+
{
55+
return guc_buf_cache_init(cache, XE_GUC_BUF_CACHE_DEFAULT_SIZE);
56+
}
57+
58+
/**
59+
* xe_guc_buf_cache_init_with_size() - Initialize the GuC Buffer Cache.
60+
* @cache: the &xe_guc_buf_cache to initialize
61+
* @size: size in bytes
62+
*
63+
* Like xe_guc_buf_cache_init(), except it allows the caller to make the cache
64+
* buffer larger, allowing to accommodate larger objects.
65+
*
66+
* Return: 0 on success or a negative error code on failure.
67+
*/
68+
int xe_guc_buf_cache_init_with_size(struct xe_guc_buf_cache *cache, u32 size)
69+
{
70+
return guc_buf_cache_init(cache, max(XE_GUC_BUF_CACHE_DEFAULT_SIZE, size));
71+
}
72+
5173
/**
5274
* xe_guc_buf_cache_dwords() - Number of dwords the GuC Buffer Cache supports.
5375
* @cache: the &xe_guc_buf_cache to query

drivers/gpu/drm/xe/xe_guc_buf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "xe_guc_buf_types.h"
1313

1414
int xe_guc_buf_cache_init(struct xe_guc_buf_cache *cache);
15+
int xe_guc_buf_cache_init_with_size(struct xe_guc_buf_cache *cache, u32 size);
1516
u32 xe_guc_buf_cache_dwords(struct xe_guc_buf_cache *cache);
1617
struct xe_guc_buf xe_guc_buf_reserve(struct xe_guc_buf_cache *cache, u32 dwords);
1718
struct xe_guc_buf xe_guc_buf_from_data(struct xe_guc_buf_cache *cache,

0 commit comments

Comments
 (0)