Skip to content

Commit 84bdf45

Browse files
dceraolodanvet
authored andcommitted
drm/i915/guc: Use guc_class instead of engine_class in fw interface
GuC has its own defines for the engine classes. They're currently mapping 1:1 to the defines used by the driver, but there is no guarantee this will continue in the future. Given that we've been caught off-guard in the past by similar divergences, we can prepare for the changes by introducing helper functions to convert from engine class to GuC class and back again. Signed-off-by: Daniele Ceraolo Spurio <[email protected]> Signed-off-by: Matthew Brost <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Cc: John Harrison <[email protected]> Cc: Michal Wajdeczko <[email protected]> Signed-off-by: Daniel Vetter <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent e09be87 commit 84bdf45

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

drivers/gpu/drm/i915/gt/intel_engine_cs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
265265
const struct engine_info *info = &intel_engines[id];
266266
struct drm_i915_private *i915 = gt->i915;
267267
struct intel_engine_cs *engine;
268+
u8 guc_class;
268269

269270
BUILD_BUG_ON(MAX_ENGINE_CLASS >= BIT(GEN11_ENGINE_CLASS_WIDTH));
270271
BUILD_BUG_ON(MAX_ENGINE_INSTANCE >= BIT(GEN11_ENGINE_INSTANCE_WIDTH));
@@ -293,9 +294,10 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
293294
engine->i915 = i915;
294295
engine->gt = gt;
295296
engine->uncore = gt->uncore;
296-
engine->mmio_base = __engine_mmio_base(i915, info->mmio_bases);
297297
engine->hw_id = info->hw_id;
298-
engine->guc_id = MAKE_GUC_ID(info->class, info->instance);
298+
guc_class = engine_class_to_guc_class(info->class);
299+
engine->guc_id = MAKE_GUC_ID(guc_class, info->instance);
300+
engine->mmio_base = __engine_mmio_base(i915, info->mmio_bases);
299301

300302
engine->irq_handler = nop_irq_handler;
301303

drivers/gpu/drm/i915/gt/uc/intel_guc_ads.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "gt/intel_gt.h"
77
#include "gt/intel_lrc.h"
88
#include "intel_guc_ads.h"
9+
#include "intel_guc_fwif.h"
910
#include "intel_uc.h"
1011
#include "i915_drv.h"
1112

@@ -104,7 +105,7 @@ static void guc_mapping_table_init(struct intel_gt *gt,
104105
GUC_MAX_INSTANCES_PER_CLASS;
105106

106107
for_each_engine(engine, gt, id) {
107-
u8 guc_class = engine->class;
108+
u8 guc_class = engine_class_to_guc_class(engine->class);
108109

109110
system_info->mapping_table[guc_class][engine->instance] =
110111
engine->instance;
@@ -124,7 +125,7 @@ static void __guc_ads_init(struct intel_guc *guc)
124125
struct __guc_ads_blob *blob = guc->ads_blob;
125126
const u32 skipped_size = LRC_PPHWSP_SZ * PAGE_SIZE + LR_HW_CONTEXT_SIZE;
126127
u32 base;
127-
u8 engine_class;
128+
u8 engine_class, guc_class;
128129

129130
/* GuC scheduling policies */
130131
guc_policies_init(&blob->policies);
@@ -140,22 +141,25 @@ static void __guc_ads_init(struct intel_guc *guc)
140141
for (engine_class = 0; engine_class <= MAX_ENGINE_CLASS; ++engine_class) {
141142
if (engine_class == OTHER_CLASS)
142143
continue;
144+
145+
guc_class = engine_class_to_guc_class(engine_class);
146+
143147
/*
144148
* TODO: Set context pointer to default state to allow
145149
* GuC to re-init guilty contexts after internal reset.
146150
*/
147-
blob->ads.golden_context_lrca[engine_class] = 0;
148-
blob->ads.eng_state_size[engine_class] =
151+
blob->ads.golden_context_lrca[guc_class] = 0;
152+
blob->ads.eng_state_size[guc_class] =
149153
intel_engine_context_size(guc_to_gt(guc),
150154
engine_class) -
151155
skipped_size;
152156
}
153157

154158
/* System info */
155-
blob->system_info.engine_enabled_masks[RENDER_CLASS] = 1;
156-
blob->system_info.engine_enabled_masks[COPY_ENGINE_CLASS] = 1;
157-
blob->system_info.engine_enabled_masks[VIDEO_DECODE_CLASS] = VDBOX_MASK(gt);
158-
blob->system_info.engine_enabled_masks[VIDEO_ENHANCEMENT_CLASS] = VEBOX_MASK(gt);
159+
blob->system_info.engine_enabled_masks[GUC_RENDER_CLASS] = 1;
160+
blob->system_info.engine_enabled_masks[GUC_BLITTER_CLASS] = 1;
161+
blob->system_info.engine_enabled_masks[GUC_VIDEO_CLASS] = VDBOX_MASK(gt);
162+
blob->system_info.engine_enabled_masks[GUC_VIDEOENHANCE_CLASS] = VEBOX_MASK(gt);
159163

160164
blob->system_info.generic_gt_sysinfo[GUC_GENERIC_GT_SYSINFO_SLICE_ENABLED] =
161165
hweight8(gt->info.sseu.slice_mask);

drivers/gpu/drm/i915/gt/uc/intel_guc_fwif.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/bits.h>
1010
#include <linux/compiler.h>
1111
#include <linux/types.h>
12+
#include "gt/intel_engine_types.h"
1213

1314
#include "abi/guc_actions_abi.h"
1415
#include "abi/guc_errors_abi.h"
@@ -32,6 +33,12 @@
3233
#define GUC_VIDEO_ENGINE2 4
3334
#define GUC_MAX_ENGINES_NUM (GUC_VIDEO_ENGINE2 + 1)
3435

36+
#define GUC_RENDER_CLASS 0
37+
#define GUC_VIDEO_CLASS 1
38+
#define GUC_VIDEOENHANCE_CLASS 2
39+
#define GUC_BLITTER_CLASS 3
40+
#define GUC_RESERVED_CLASS 4
41+
#define GUC_LAST_ENGINE_CLASS GUC_RESERVED_CLASS
3542
#define GUC_MAX_ENGINE_CLASSES 16
3643
#define GUC_MAX_INSTANCES_PER_CLASS 32
3744

@@ -129,6 +136,25 @@
129136
#define GUC_ID_TO_ENGINE_INSTANCE(guc_id) \
130137
(((guc_id) & GUC_ENGINE_INSTANCE_MASK) >> GUC_ENGINE_INSTANCE_SHIFT)
131138

139+
static inline u8 engine_class_to_guc_class(u8 class)
140+
{
141+
BUILD_BUG_ON(GUC_RENDER_CLASS != RENDER_CLASS);
142+
BUILD_BUG_ON(GUC_BLITTER_CLASS != COPY_ENGINE_CLASS);
143+
BUILD_BUG_ON(GUC_VIDEO_CLASS != VIDEO_DECODE_CLASS);
144+
BUILD_BUG_ON(GUC_VIDEOENHANCE_CLASS != VIDEO_ENHANCEMENT_CLASS);
145+
GEM_BUG_ON(class > MAX_ENGINE_CLASS || class == OTHER_CLASS);
146+
147+
return class;
148+
}
149+
150+
static inline u8 guc_class_to_engine_class(u8 guc_class)
151+
{
152+
GEM_BUG_ON(guc_class > GUC_LAST_ENGINE_CLASS);
153+
GEM_BUG_ON(guc_class == GUC_RESERVED_CLASS);
154+
155+
return guc_class;
156+
}
157+
132158
/* Work item for submitting workloads into work queue of GuC. */
133159
struct guc_wq_item {
134160
u32 header;

0 commit comments

Comments
 (0)