Skip to content

Commit ee71434

Browse files
aravind-iddceraolo
authored andcommitted
drm/i915/mtl: Handle wopcm per-GT and limit calculations.
With MTL standalone media architecture the wopcm layout has changed, with separate partitioning in WOPCM for the root GT GuC and the media GT GuC. The size of WOPCM is 4MB with the lower 2MB reserved for the media GT and the upper 2MB for the root GT. Given that MTL has GuC deprivilege, the WOPCM registers are pre-locked by the bios. Therefore, we can skip all the math for the partitioning and just limit ourselves to sanity-checking the values. v2: fix makefile file ordering (Jani) v3: drop XELPM_SAMEDIA_WOPCM_SIZE, check huc instead of VDBOX (John) v4: further clarify commit message, remove blank line (John) Signed-off-by: Aravind Iddamsetty <[email protected]> Signed-off-by: Daniele Ceraolo Spurio <[email protected]> Cc: Matt Roper <[email protected]> Cc: John Harrison <[email protected]> Cc: Alan Previn <[email protected]> Cc: Jani Nikula <[email protected]> Reviewed-by: John Harrison <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 00b4c0e commit ee71434

File tree

12 files changed

+51
-32
lines changed

12 files changed

+51
-32
lines changed

Documentation/gpu/i915.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ WOPCM
494494
WOPCM Layout
495495
~~~~~~~~~~~~
496496

497-
.. kernel-doc:: drivers/gpu/drm/i915/intel_wopcm.c
497+
.. kernel-doc:: drivers/gpu/drm/i915/gt/intel_wopcm.c
498498
:doc: WOPCM Layout
499499

500500
GuC

drivers/gpu/drm/i915/Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,11 @@ gt-y += \
127127
gt/intel_sseu.o \
128128
gt/intel_sseu_debugfs.o \
129129
gt/intel_timeline.o \
130+
gt/intel_wopcm.o \
130131
gt/intel_workarounds.o \
131132
gt/shmem_utils.o \
132133
gt/sysfs_engines.o
134+
133135
# x86 intel-gtt module support
134136
gt-$(CONFIG_X86) += gt/intel_ggtt_gmch.o
135137
# autogenerated null render state
@@ -183,8 +185,7 @@ i915-y += \
183185
i915_trace_points.o \
184186
i915_ttm_buddy_manager.o \
185187
i915_vma.o \
186-
i915_vma_resource.o \
187-
intel_wopcm.o
188+
i915_vma_resource.o
188189

189190
# general-purpose microcontroller (GuC) support
190191
i915-y += gt/uc/intel_uc.o \

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ static int init_ggtt(struct i915_ggtt *ggtt)
560560
* why.
561561
*/
562562
ggtt->pin_bias = max_t(u32, I915_GTT_PAGE_SIZE,
563-
intel_wopcm_guc_size(&ggtt->vm.i915->wopcm));
563+
intel_wopcm_guc_size(&ggtt->vm.gt->wopcm));
564564

565565
ret = intel_vgt_balloon(ggtt);
566566
if (ret)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ void intel_gt_common_init_early(struct intel_gt *gt)
5454
seqcount_mutex_init(&gt->tlb.seqno, &gt->tlb.invalidate_lock);
5555
intel_gt_pm_init_early(gt);
5656

57+
intel_wopcm_init_early(&gt->wopcm);
5758
intel_uc_init_early(&gt->uc);
5859
intel_rps_init_early(&gt->rps);
5960
}

drivers/gpu/drm/i915/gt/intel_gt_types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "intel_migrate_types.h"
3232
#include "intel_wakeref.h"
3333
#include "pxp/intel_pxp_types.h"
34+
#include "intel_wopcm.h"
3435

3536
struct drm_i915_private;
3637
struct i915_ggtt;
@@ -101,6 +102,7 @@ struct intel_gt {
101102

102103
struct intel_uc uc;
103104
struct intel_gsc gsc;
105+
struct intel_wopcm wopcm;
104106

105107
struct {
106108
/* Serialize global tlb invalidations */

drivers/gpu/drm/i915/intel_wopcm.c renamed to drivers/gpu/drm/i915/gt/intel_wopcm.c

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@
6464
#define GEN9_GUC_FW_RESERVED SZ_128K
6565
#define GEN9_GUC_WOPCM_OFFSET (GUC_WOPCM_RESERVED + GEN9_GUC_FW_RESERVED)
6666

67-
static inline struct drm_i915_private *wopcm_to_i915(struct intel_wopcm *wopcm)
67+
static inline struct intel_gt *wopcm_to_gt(struct intel_wopcm *wopcm)
6868
{
69-
return container_of(wopcm, struct drm_i915_private, wopcm);
69+
return container_of(wopcm, struct intel_gt, wopcm);
7070
}
7171

7272
/**
@@ -77,7 +77,8 @@ static inline struct drm_i915_private *wopcm_to_i915(struct intel_wopcm *wopcm)
7777
*/
7878
void intel_wopcm_init_early(struct intel_wopcm *wopcm)
7979
{
80-
struct drm_i915_private *i915 = wopcm_to_i915(wopcm);
80+
struct intel_gt *gt = wopcm_to_gt(wopcm);
81+
struct drm_i915_private *i915 = gt->i915;
8182

8283
if (!HAS_GT_UC(i915))
8384
return;
@@ -157,10 +158,11 @@ static bool check_hw_restrictions(struct drm_i915_private *i915,
157158
return true;
158159
}
159160

160-
static bool __check_layout(struct drm_i915_private *i915, u32 wopcm_size,
161+
static bool __check_layout(struct intel_gt *gt, u32 wopcm_size,
161162
u32 guc_wopcm_base, u32 guc_wopcm_size,
162163
u32 guc_fw_size, u32 huc_fw_size)
163164
{
165+
struct drm_i915_private *i915 = gt->i915;
164166
const u32 ctx_rsvd = context_reserved_size(i915);
165167
u32 size;
166168

@@ -181,12 +183,14 @@ static bool __check_layout(struct drm_i915_private *i915, u32 wopcm_size,
181183
return false;
182184
}
183185

184-
size = huc_fw_size + WOPCM_RESERVED_SIZE;
185-
if (unlikely(guc_wopcm_base < size)) {
186-
drm_err(&i915->drm, "WOPCM: no space for %s: %uK < %uK\n",
187-
intel_uc_fw_type_repr(INTEL_UC_FW_TYPE_HUC),
188-
guc_wopcm_base / SZ_1K, size / SZ_1K);
189-
return false;
186+
if (intel_uc_supports_huc(&gt->uc)) {
187+
size = huc_fw_size + WOPCM_RESERVED_SIZE;
188+
if (unlikely(guc_wopcm_base < size)) {
189+
drm_err(&i915->drm, "WOPCM: no space for %s: %uK < %uK\n",
190+
intel_uc_fw_type_repr(INTEL_UC_FW_TYPE_HUC),
191+
guc_wopcm_base / SZ_1K, size / SZ_1K);
192+
return false;
193+
}
190194
}
191195

192196
return check_hw_restrictions(i915, guc_wopcm_base, guc_wopcm_size,
@@ -228,8 +232,8 @@ static bool __wopcm_regs_writable(struct intel_uncore *uncore)
228232
*/
229233
void intel_wopcm_init(struct intel_wopcm *wopcm)
230234
{
231-
struct drm_i915_private *i915 = wopcm_to_i915(wopcm);
232-
struct intel_gt *gt = to_gt(i915);
235+
struct intel_gt *gt = wopcm_to_gt(wopcm);
236+
struct drm_i915_private *i915 = gt->i915;
233237
u32 guc_fw_size = intel_uc_fw_get_upload_size(&gt->uc.guc.fw);
234238
u32 huc_fw_size = intel_uc_fw_get_upload_size(&gt->uc.huc.fw);
235239
u32 ctx_rsvd = context_reserved_size(i915);
@@ -274,6 +278,19 @@ void intel_wopcm_init(struct intel_wopcm *wopcm)
274278
goto check;
275279
}
276280

281+
/*
282+
* On platforms with a media GT, the WOPCM is partitioned between the
283+
* two GTs, so we would have to take that into account when doing the
284+
* math below. There is also a new section reserved for the GSC context
285+
* that would have to be factored in. However, all platforms with a
286+
* media GT also have GuC depriv enabled, so the WOPCM regs are
287+
* pre-locked and therefore we don't have to do the math ourselves.
288+
*/
289+
if (unlikely(i915->media_gt)) {
290+
drm_err(&i915->drm, "Unlocked WOPCM regs with media GT\n");
291+
return;
292+
}
293+
277294
/*
278295
* Aligned value of guc_wopcm_base will determine available WOPCM space
279296
* for HuC firmware and mandatory reserved area.
@@ -295,7 +312,7 @@ void intel_wopcm_init(struct intel_wopcm *wopcm)
295312
guc_wopcm_base / SZ_1K, guc_wopcm_size / SZ_1K);
296313

297314
check:
298-
if (__check_layout(i915, wopcm_size, guc_wopcm_base, guc_wopcm_size,
315+
if (__check_layout(gt, wopcm_size, guc_wopcm_base, guc_wopcm_size,
299316
guc_fw_size, huc_fw_size)) {
300317
wopcm->guc.base = guc_wopcm_base;
301318
wopcm->guc.size = guc_wopcm_size;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ static int uc_init_wopcm(struct intel_uc *uc)
357357
{
358358
struct intel_gt *gt = uc_to_gt(uc);
359359
struct intel_uncore *uncore = gt->uncore;
360-
u32 base = intel_wopcm_guc_base(&gt->i915->wopcm);
361-
u32 size = intel_wopcm_guc_size(&gt->i915->wopcm);
360+
u32 base = intel_wopcm_guc_base(&gt->wopcm);
361+
u32 size = intel_wopcm_guc_size(&gt->wopcm);
362362
u32 huc_agent = intel_uc_uses_huc(uc) ? HUC_LOADING_AGENT_GUC : 0;
363363
u32 mask;
364364
int err;

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,10 +478,11 @@ static int check_gsc_manifest(const struct firmware *fw,
478478
return 0;
479479
}
480480

481-
static int check_ccs_header(struct drm_i915_private *i915,
481+
static int check_ccs_header(struct intel_gt *gt,
482482
const struct firmware *fw,
483483
struct intel_uc_fw *uc_fw)
484484
{
485+
struct drm_i915_private *i915 = gt->i915;
485486
struct uc_css_header *css;
486487
size_t size;
487488

@@ -523,10 +524,10 @@ static int check_ccs_header(struct drm_i915_private *i915,
523524

524525
/* Sanity check whether this fw is not larger than whole WOPCM memory */
525526
size = __intel_uc_fw_get_upload_size(uc_fw);
526-
if (unlikely(size >= i915->wopcm.size)) {
527+
if (unlikely(size >= gt->wopcm.size)) {
527528
drm_warn(&i915->drm, "%s firmware %s: invalid size: %zu > %zu\n",
528529
intel_uc_fw_type_repr(uc_fw->type), uc_fw->file_selected.path,
529-
size, (size_t)i915->wopcm.size);
530+
size, (size_t)gt->wopcm.size);
530531
return -E2BIG;
531532
}
532533

@@ -554,15 +555,16 @@ static int check_ccs_header(struct drm_i915_private *i915,
554555
*/
555556
int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw)
556557
{
557-
struct drm_i915_private *i915 = __uc_fw_to_gt(uc_fw)->i915;
558+
struct intel_gt *gt = __uc_fw_to_gt(uc_fw);
559+
struct drm_i915_private *i915 = gt->i915;
558560
struct intel_uc_fw_file file_ideal;
559561
struct device *dev = i915->drm.dev;
560562
struct drm_i915_gem_object *obj;
561563
const struct firmware *fw = NULL;
562564
bool old_ver = false;
563565
int err;
564566

565-
GEM_BUG_ON(!i915->wopcm.size);
567+
GEM_BUG_ON(!gt->wopcm.size);
566568
GEM_BUG_ON(!intel_uc_fw_is_enabled(uc_fw));
567569

568570
err = i915_inject_probe_error(i915, -ENXIO);
@@ -615,7 +617,7 @@ int intel_uc_fw_fetch(struct intel_uc_fw *uc_fw)
615617
if (uc_fw->loaded_via_gsc)
616618
err = check_gsc_manifest(fw, uc_fw);
617619
else
618-
err = check_ccs_header(i915, fw, uc_fw);
620+
err = check_ccs_header(gt, fw, uc_fw);
619621
if (err)
620622
goto fail;
621623

drivers/gpu/drm/i915/i915_driver.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,6 @@ static int i915_driver_early_probe(struct drm_i915_private *dev_priv)
372372
if (ret)
373373
goto err_ttm;
374374

375-
intel_wopcm_init_early(&dev_priv->wopcm);
376-
377375
ret = intel_root_gt_init_early(dev_priv);
378376
if (ret < 0)
379377
goto err_rootgt;

0 commit comments

Comments
 (0)