Skip to content

Commit d6da81a

Browse files
bnilawarmwajdecz
authored andcommitted
drm/xe/guc: Add support for workaround KLVs
To prevent running out of bits, new workaround (w/a) enable flags are being added via a KLV system instead of a 32 bit flags word. v2: GuC version check > 70.10 is not needed as base line xe doesnot support anything below < 70.19 v3: Use 64 bit ggtt address for future compatibility (John Harrison/Daniele) v4: %s/PAGE_SIZE/SZ_4K/ (Michal) Cc: John Harrison <[email protected]> Signed-off-by: Badal Nilawar <[email protected]> Reviewed-by: John Harrison <[email protected]> Signed-off-by: Michal Wajdeczko <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 1db3594 commit d6da81a

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed

drivers/gpu/drm/xe/xe_guc_ads.c

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ ads_to_map(struct xe_guc_ads *ads)
8080
* +---------------------------------------+
8181
* | padding |
8282
* +---------------------------------------+ <== 4K aligned
83+
* | w/a KLVs |
84+
* +---------------------------------------+
85+
* | padding |
86+
* +---------------------------------------+ <== 4K aligned
8387
* | capture lists |
8488
* +---------------------------------------+
8589
* | padding |
@@ -131,6 +135,11 @@ static size_t guc_ads_golden_lrc_size(struct xe_guc_ads *ads)
131135
return PAGE_ALIGN(ads->golden_lrc_size);
132136
}
133137

138+
static u32 guc_ads_waklv_size(struct xe_guc_ads *ads)
139+
{
140+
return PAGE_ALIGN(ads->ads_waklv_size);
141+
}
142+
134143
static size_t guc_ads_capture_size(struct xe_guc_ads *ads)
135144
{
136145
/* FIXME: Allocate a proper capture list */
@@ -167,12 +176,22 @@ static size_t guc_ads_golden_lrc_offset(struct xe_guc_ads *ads)
167176
return PAGE_ALIGN(offset);
168177
}
169178

179+
static size_t guc_ads_waklv_offset(struct xe_guc_ads *ads)
180+
{
181+
u32 offset;
182+
183+
offset = guc_ads_golden_lrc_offset(ads) +
184+
guc_ads_golden_lrc_size(ads);
185+
186+
return PAGE_ALIGN(offset);
187+
}
188+
170189
static size_t guc_ads_capture_offset(struct xe_guc_ads *ads)
171190
{
172191
size_t offset;
173192

174-
offset = guc_ads_golden_lrc_offset(ads) +
175-
guc_ads_golden_lrc_size(ads);
193+
offset = guc_ads_waklv_offset(ads) +
194+
guc_ads_waklv_size(ads);
176195

177196
return PAGE_ALIGN(offset);
178197
}
@@ -260,6 +279,43 @@ static size_t calculate_golden_lrc_size(struct xe_guc_ads *ads)
260279
return total_size;
261280
}
262281

282+
static void guc_waklv_init(struct xe_guc_ads *ads)
283+
{
284+
u64 addr_ggtt;
285+
u32 offset, remain, size;
286+
287+
offset = guc_ads_waklv_offset(ads);
288+
remain = guc_ads_waklv_size(ads);
289+
290+
/* Add workarounds here
291+
*
292+
* if (XE_WA(gt, wa_id))
293+
* guc_waklv_enable_simple(ads,
294+
* wa_klv_id,
295+
* &offset, &remain);
296+
*/
297+
298+
size = guc_ads_waklv_size(ads) - remain;
299+
if (!size)
300+
return;
301+
302+
offset = guc_ads_waklv_offset(ads);
303+
addr_ggtt = xe_bo_ggtt_addr(ads->bo) + offset;
304+
305+
ads_blob_write(ads, ads.wa_klv_addr_lo, lower_32_bits(addr_ggtt));
306+
ads_blob_write(ads, ads.wa_klv_addr_hi, upper_32_bits(addr_ggtt));
307+
ads_blob_write(ads, ads.wa_klv_size, size);
308+
}
309+
310+
static int calculate_waklv_size(struct xe_guc_ads *ads)
311+
{
312+
/*
313+
* A single page is both the minimum size possible and
314+
* is sufficiently large enough for all current platforms.
315+
*/
316+
return SZ_4K;
317+
}
318+
263319
#define MAX_GOLDEN_LRC_SIZE (SZ_4K * 64)
264320

265321
int xe_guc_ads_init(struct xe_guc_ads *ads)
@@ -271,6 +327,7 @@ int xe_guc_ads_init(struct xe_guc_ads *ads)
271327

272328
ads->golden_lrc_size = calculate_golden_lrc_size(ads);
273329
ads->regset_size = calculate_regset_size(gt);
330+
ads->ads_waklv_size = calculate_waklv_size(ads);
274331

275332
bo = xe_managed_bo_create_pin_map(xe, tile, guc_ads_size(ads) + MAX_GOLDEN_LRC_SIZE,
276333
XE_BO_FLAG_SYSTEM |
@@ -598,6 +655,7 @@ void xe_guc_ads_populate(struct xe_guc_ads *ads)
598655
guc_mapping_table_init(gt, &info_map);
599656
guc_capture_list_init(ads);
600657
guc_doorbell_init(ads);
658+
guc_waklv_init(ads);
601659

602660
if (xe->info.has_usm) {
603661
guc_um_init_params(ads);

drivers/gpu/drm/xe/xe_guc_ads_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ struct xe_guc_ads {
2020
size_t golden_lrc_size;
2121
/** @regset_size: size of register set passed to GuC for save/restore */
2222
u32 regset_size;
23+
/** @ads_waklv_size: total waklv size supported by platform */
24+
u32 ads_waklv_size;
2325
};
2426

2527
#endif

drivers/gpu/drm/xe/xe_guc_fwif.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ struct guc_ads {
209209
u32 capture_instance[GUC_CAPTURE_LIST_INDEX_MAX][GUC_MAX_ENGINE_CLASSES];
210210
u32 capture_class[GUC_CAPTURE_LIST_INDEX_MAX][GUC_MAX_ENGINE_CLASSES];
211211
u32 capture_global[GUC_CAPTURE_LIST_INDEX_MAX];
212-
u32 reserved[14];
212+
u32 wa_klv_addr_lo;
213+
u32 wa_klv_addr_hi;
214+
u32 wa_klv_size;
215+
u32 reserved[11];
213216
} __packed;
214217

215218
/* Engine usage stats */

0 commit comments

Comments
 (0)