Skip to content

Commit 6734cd0

Browse files
committed
Merge tag 'drm-intel-gt-next-2023-12-08' of git://anongit.freedesktop.org/drm/drm-intel into drm-next
UAPI Changes: - drm/i915: Implement fdinfo memory stats printing Use the newly added drm_print_memory_stats helper to show memory utilisation of our objects in drm/driver specific fdinfo output. To collect the stats we walk the per memory regions object lists and accumulate object size into the respective drm_memory_stats categories. Cross-subsystem Changes: - Backmerge of drm-next (to bring drm-intel-next for PXP changes) Driver Changes: - Wa_18028616096 now applies to all DG2 (Matt R) - Drop Wa_22014600077 on all DG2 (Matt R) - Add new ATS-M device ID (Haridhar) - More Meteorlake (MTL) workarounds (Matt R, Dnyaneshwar, Jonathan, Gustavo, Radhakrishna) - PMU WARN_ON cleanup on driver unbind (Umesh) - Limit GGTT WC flushing workaround to pre BXT/ICL platforms - Complement implementation for Wa_16018031267 / Wa_16018063123 (Andrzej, Jonathan, Nirmoy, Chris) - Properly print internal GSC engine in trace logs (Tvrtko) - Track gt pm wakerefs (Andrzej) - Fix null deref bugs on perf code when perf is disabled (Harshit, Tvrtko) - Fix __i915_request_create memory leak on driver unbind (Andrzej) - Remove spurious unsupported HuC message on MTL (Daniele) - Read a shadowed mmio register for ggtt flush (Vinay) - Add missing new-line to GT_TRACE (Andrzej) - Add drm_dbgs for critical PXP events (Alan) - Skip pxp init if gt is wedged (Zhanjun) - Replace custom intel runtime_pm tracker with ref_tracker library (Andrzej) - Compiler warning/static checker/coding style cleanups (Arnd, Nirmoy, Soumya, Gilbert, Dorcas, Kunwu, Sam, Tvrtko) - Code structure and helper cleanups (Jani, Tvrtko, Andi) - Selftest improvements (John, Tvrtko, Andrzej) Signed-off-by: Dave Airlie <[email protected]> # Conflicts: # drivers/gpu/drm/i915/gt/intel_gt_mcr.c From: Joonas Lahtinen <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 3c2eb78 + be5bcc4 commit 6734cd0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+1232
-635
lines changed

drivers/gpu/drm/i915/Kconfig.debug

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ config DRM_I915_DEBUG
2424
select DEBUG_FS
2525
select PREEMPT_COUNT
2626
select I2C_CHARDEV
27+
select REF_TRACKER
2728
select STACKDEPOT
29+
select STACKTRACE
2830
select DRM_DP_AUX_CHARDEV
2931
select X86_MSR # used by igt/pm_rpm
3032
select DRM_VGEM # used by igt/prime_vgem (dmabuf interop checks)
@@ -38,6 +40,7 @@ config DRM_I915_DEBUG
3840
select DRM_I915_DEBUG_GEM_ONCE
3941
select DRM_I915_DEBUG_MMIO
4042
select DRM_I915_DEBUG_RUNTIME_PM
43+
select DRM_I915_DEBUG_WAKEREF
4144
select DRM_I915_SW_FENCE_DEBUG_OBJECTS
4245
select DRM_I915_SELFTEST
4346
default n
@@ -231,7 +234,9 @@ config DRM_I915_DEBUG_RUNTIME_PM
231234
bool "Enable extra state checking for runtime PM"
232235
depends on DRM_I915
233236
default n
237+
select REF_TRACKER
234238
select STACKDEPOT
239+
select STACKTRACE
235240
help
236241
Choose this option to turn on extra state checking for the
237242
runtime PM functionality. This may introduce overhead during
@@ -240,3 +245,16 @@ config DRM_I915_DEBUG_RUNTIME_PM
240245
Recommended for driver developers only.
241246

242247
If in doubt, say "N"
248+
249+
config DRM_I915_DEBUG_WAKEREF
250+
bool "Enable extra tracking for wakerefs"
251+
depends on DRM_I915
252+
select REF_TRACKER
253+
select STACKDEPOT
254+
select STACKTRACE
255+
help
256+
Choose this option to turn on extra state checking and usage
257+
tracking for the wakerefPM functionality. This may introduce
258+
overhead during driver runtime.
259+
260+
If in doubt, say "N"

drivers/gpu/drm/i915/display/intel_display_power.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ print_async_put_domains_state(struct i915_power_domains *power_domains)
405405
struct drm_i915_private,
406406
display.power.domains);
407407

408-
drm_dbg(&i915->drm, "async_put_wakeref %u\n",
408+
drm_dbg(&i915->drm, "async_put_wakeref %lu\n",
409409
power_domains->async_put_wakeref);
410410

411411
print_power_domains(power_domains, "async_put_domains[0]",

drivers/gpu/drm/i915/gem/i915_gem_context.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,14 +279,16 @@ static int proto_context_set_protected(struct drm_i915_private *i915,
279279
}
280280

281281
static struct i915_gem_proto_context *
282-
proto_context_create(struct drm_i915_private *i915, unsigned int flags)
282+
proto_context_create(struct drm_i915_file_private *fpriv,
283+
struct drm_i915_private *i915, unsigned int flags)
283284
{
284285
struct i915_gem_proto_context *pc, *err;
285286

286287
pc = kzalloc(sizeof(*pc), GFP_KERNEL);
287288
if (!pc)
288289
return ERR_PTR(-ENOMEM);
289290

291+
pc->fpriv = fpriv;
290292
pc->num_user_engines = -1;
291293
pc->user_engines = NULL;
292294
pc->user_flags = BIT(UCONTEXT_BANNABLE) |
@@ -1622,6 +1624,7 @@ i915_gem_create_context(struct drm_i915_private *i915,
16221624
err = PTR_ERR(ppgtt);
16231625
goto err_ctx;
16241626
}
1627+
ppgtt->vm.fpriv = pc->fpriv;
16251628
vm = &ppgtt->vm;
16261629
}
16271630
if (vm)
@@ -1741,7 +1744,7 @@ int i915_gem_context_open(struct drm_i915_private *i915,
17411744
/* 0 reserved for invalid/unassigned ppgtt */
17421745
xa_init_flags(&file_priv->vm_xa, XA_FLAGS_ALLOC1);
17431746

1744-
pc = proto_context_create(i915, 0);
1747+
pc = proto_context_create(file_priv, i915, 0);
17451748
if (IS_ERR(pc)) {
17461749
err = PTR_ERR(pc);
17471750
goto err;
@@ -1823,6 +1826,7 @@ int i915_gem_vm_create_ioctl(struct drm_device *dev, void *data,
18231826

18241827
GEM_BUG_ON(id == 0); /* reserved for invalid/unassigned ppgtt */
18251828
args->vm_id = id;
1829+
ppgtt->vm.fpriv = file_priv;
18261830
return 0;
18271831

18281832
err_put:
@@ -2285,7 +2289,8 @@ int i915_gem_context_create_ioctl(struct drm_device *dev, void *data,
22852289
return -EIO;
22862290
}
22872291

2288-
ext_data.pc = proto_context_create(i915, args->flags);
2292+
ext_data.pc = proto_context_create(file->driver_priv, i915,
2293+
args->flags);
22892294
if (IS_ERR(ext_data.pc))
22902295
return PTR_ERR(ext_data.pc);
22912296

drivers/gpu/drm/i915/gem/i915_gem_context_types.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,9 @@ struct i915_gem_proto_engine {
188188
* CONTEXT_CREATE_SET_PARAM during GEM_CONTEXT_CREATE.
189189
*/
190190
struct i915_gem_proto_context {
191+
/** @fpriv: Client which creates the context */
192+
struct drm_i915_file_private *fpriv;
193+
191194
/** @vm: See &i915_gem_context.vm */
192195
struct i915_address_space *vm;
193196

drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ struct i915_execbuffer {
254254
struct intel_gt *gt; /* gt for the execbuf */
255255
struct intel_context *context; /* logical state for the request */
256256
struct i915_gem_context *gem_context; /** caller's context */
257+
intel_wakeref_t wakeref;
258+
intel_wakeref_t wakeref_gt0;
257259

258260
/** our requests to build */
259261
struct i915_request *requests[MAX_ENGINE_INSTANCE + 1];
@@ -1679,7 +1681,7 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb)
16791681
urelocs = u64_to_user_ptr(eb->exec[i].relocs_ptr);
16801682
size = nreloc * sizeof(*relocs);
16811683

1682-
relocs = kvmalloc_array(size, 1, GFP_KERNEL);
1684+
relocs = kvmalloc_array(1, size, GFP_KERNEL);
16831685
if (!relocs) {
16841686
err = -ENOMEM;
16851687
goto err;
@@ -2720,13 +2722,13 @@ eb_select_engine(struct i915_execbuffer *eb)
27202722

27212723
for_each_child(ce, child)
27222724
intel_context_get(child);
2723-
intel_gt_pm_get(gt);
2725+
eb->wakeref = intel_gt_pm_get(ce->engine->gt);
27242726
/*
27252727
* Keep GT0 active on MTL so that i915_vma_parked() doesn't
27262728
* free VMAs while execbuf ioctl is validating VMAs.
27272729
*/
27282730
if (gt->info.id)
2729-
intel_gt_pm_get(to_gt(gt->i915));
2731+
eb->wakeref_gt0 = intel_gt_pm_get(to_gt(gt->i915));
27302732

27312733
if (!test_bit(CONTEXT_ALLOC_BIT, &ce->flags)) {
27322734
err = intel_context_alloc_state(ce);
@@ -2766,9 +2768,9 @@ eb_select_engine(struct i915_execbuffer *eb)
27662768

27672769
err:
27682770
if (gt->info.id)
2769-
intel_gt_pm_put(to_gt(gt->i915));
2771+
intel_gt_pm_put(to_gt(gt->i915), eb->wakeref_gt0);
27702772

2771-
intel_gt_pm_put(gt);
2773+
intel_gt_pm_put(ce->engine->gt, eb->wakeref);
27722774
for_each_child(ce, child)
27732775
intel_context_put(child);
27742776
intel_context_put(ce);
@@ -2786,8 +2788,8 @@ eb_put_engine(struct i915_execbuffer *eb)
27862788
* i915_vma_parked() from interfering while execbuf validates vmas.
27872789
*/
27882790
if (eb->gt->info.id)
2789-
intel_gt_pm_put(to_gt(eb->gt->i915));
2790-
intel_gt_pm_put(eb->gt);
2791+
intel_gt_pm_put(to_gt(eb->gt->i915), eb->wakeref_gt0);
2792+
intel_gt_pm_put(eb->context->engine->gt, eb->wakeref);
27912793
for_each_child(eb->context, child)
27922794
intel_context_put(child);
27932795
intel_context_put(eb->context);

drivers/gpu/drm/i915/gem/i915_gem_object.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,
106106

107107
INIT_LIST_HEAD(&obj->mm.link);
108108

109+
#ifdef CONFIG_PROC_FS
110+
INIT_LIST_HEAD(&obj->client_link);
111+
#endif
112+
109113
INIT_LIST_HEAD(&obj->lut_list);
110114
spin_lock_init(&obj->lut_lock);
111115

@@ -293,6 +297,10 @@ void __i915_gem_free_object_rcu(struct rcu_head *head)
293297
container_of(head, typeof(*obj), rcu);
294298
struct drm_i915_private *i915 = to_i915(obj->base.dev);
295299

300+
/* We need to keep this alive for RCU read access from fdinfo. */
301+
if (obj->mm.n_placements > 1)
302+
kfree(obj->mm.placements);
303+
296304
i915_gem_object_free(obj);
297305

298306
GEM_BUG_ON(!atomic_read(&i915->mm.free_count));
@@ -389,9 +397,6 @@ void __i915_gem_free_object(struct drm_i915_gem_object *obj)
389397
if (obj->ops->release)
390398
obj->ops->release(obj);
391399

392-
if (obj->mm.n_placements > 1)
393-
kfree(obj->mm.placements);
394-
395400
if (obj->shares_resv_from)
396401
i915_vm_resv_put(obj->shares_resv_from);
397402

@@ -442,6 +447,8 @@ static void i915_gem_free_object(struct drm_gem_object *gem_obj)
442447

443448
GEM_BUG_ON(i915_gem_object_is_framebuffer(obj));
444449

450+
i915_drm_client_remove_object(obj);
451+
445452
/*
446453
* Before we free the object, make sure any pure RCU-only
447454
* read-side critical sections are complete, e.g.

drivers/gpu/drm/i915/gem/i915_gem_object_types.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,18 @@ struct drm_i915_gem_object {
302302
*/
303303
struct i915_address_space *shares_resv_from;
304304

305+
#ifdef CONFIG_PROC_FS
306+
/**
307+
* @client: @i915_drm_client which created the object
308+
*/
309+
struct i915_drm_client *client;
310+
311+
/**
312+
* @client_link: Link into @i915_drm_client.objects_list
313+
*/
314+
struct list_head client_link;
315+
#endif
316+
305317
union {
306318
struct rcu_head rcu;
307319
struct llist_node freed;

drivers/gpu/drm/i915/gem/i915_gem_stolen.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,27 @@ static void icl_get_stolen_reserved(struct drm_i915_private *i915,
386386

387387
drm_dbg(&i915->drm, "GEN6_STOLEN_RESERVED = 0x%016llx\n", reg_val);
388388

389+
/* Wa_14019821291 */
390+
if (MEDIA_VER_FULL(i915) == IP_VER(13, 0)) {
391+
/*
392+
* This workaround is primarily implemented by the BIOS. We
393+
* just need to figure out whether the BIOS has applied the
394+
* workaround (meaning the programmed address falls within
395+
* the DSM) and, if so, reserve that part of the DSM to
396+
* prevent accidental reuse. The DSM location should be just
397+
* below the WOPCM.
398+
*/
399+
u64 gscpsmi_base = intel_uncore_read64_2x32(uncore,
400+
MTL_GSCPSMI_BASEADDR_LSB,
401+
MTL_GSCPSMI_BASEADDR_MSB);
402+
if (gscpsmi_base >= i915->dsm.stolen.start &&
403+
gscpsmi_base < i915->dsm.stolen.end) {
404+
*base = gscpsmi_base;
405+
*size = i915->dsm.stolen.end - gscpsmi_base;
406+
return;
407+
}
408+
}
409+
389410
switch (reg_val & GEN8_STOLEN_RESERVED_SIZE_MASK) {
390411
case GEN8_STOLEN_RESERVED_1M:
391412
*size = 1024 * 1024;

drivers/gpu/drm/i915/gem/selftests/i915_gem_coherency.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ static int cpu_get(struct context *ctx, unsigned long offset, u32 *v)
8585

8686
static int gtt_set(struct context *ctx, unsigned long offset, u32 v)
8787
{
88+
intel_wakeref_t wakeref;
8889
struct i915_vma *vma;
8990
u32 __iomem *map;
9091
int err = 0;
@@ -99,7 +100,7 @@ static int gtt_set(struct context *ctx, unsigned long offset, u32 v)
99100
if (IS_ERR(vma))
100101
return PTR_ERR(vma);
101102

102-
intel_gt_pm_get(vma->vm->gt);
103+
wakeref = intel_gt_pm_get(vma->vm->gt);
103104

104105
map = i915_vma_pin_iomap(vma);
105106
i915_vma_unpin(vma);
@@ -112,12 +113,13 @@ static int gtt_set(struct context *ctx, unsigned long offset, u32 v)
112113
i915_vma_unpin_iomap(vma);
113114

114115
out_rpm:
115-
intel_gt_pm_put(vma->vm->gt);
116+
intel_gt_pm_put(vma->vm->gt, wakeref);
116117
return err;
117118
}
118119

119120
static int gtt_get(struct context *ctx, unsigned long offset, u32 *v)
120121
{
122+
intel_wakeref_t wakeref;
121123
struct i915_vma *vma;
122124
u32 __iomem *map;
123125
int err = 0;
@@ -132,7 +134,7 @@ static int gtt_get(struct context *ctx, unsigned long offset, u32 *v)
132134
if (IS_ERR(vma))
133135
return PTR_ERR(vma);
134136

135-
intel_gt_pm_get(vma->vm->gt);
137+
wakeref = intel_gt_pm_get(vma->vm->gt);
136138

137139
map = i915_vma_pin_iomap(vma);
138140
i915_vma_unpin(vma);
@@ -145,7 +147,7 @@ static int gtt_get(struct context *ctx, unsigned long offset, u32 *v)
145147
i915_vma_unpin_iomap(vma);
146148

147149
out_rpm:
148-
intel_gt_pm_put(vma->vm->gt);
150+
intel_gt_pm_put(vma->vm->gt, wakeref);
149151
return err;
150152
}
151153

drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -630,14 +630,14 @@ static bool assert_mmap_offset(struct drm_i915_private *i915,
630630
static void disable_retire_worker(struct drm_i915_private *i915)
631631
{
632632
i915_gem_driver_unregister__shrinker(i915);
633-
intel_gt_pm_get(to_gt(i915));
633+
intel_gt_pm_get_untracked(to_gt(i915));
634634
cancel_delayed_work_sync(&to_gt(i915)->requests.retire_work);
635635
}
636636

637637
static void restore_retire_worker(struct drm_i915_private *i915)
638638
{
639639
igt_flush_test(i915);
640-
intel_gt_pm_put(to_gt(i915));
640+
intel_gt_pm_put_untracked(to_gt(i915));
641641
i915_gem_driver_register__shrinker(i915);
642642
}
643643

@@ -778,6 +778,7 @@ static int igt_mmap_offset_exhaustion(void *arg)
778778

779779
static int gtt_set(struct drm_i915_gem_object *obj)
780780
{
781+
intel_wakeref_t wakeref;
781782
struct i915_vma *vma;
782783
void __iomem *map;
783784
int err = 0;
@@ -786,7 +787,7 @@ static int gtt_set(struct drm_i915_gem_object *obj)
786787
if (IS_ERR(vma))
787788
return PTR_ERR(vma);
788789

789-
intel_gt_pm_get(vma->vm->gt);
790+
wakeref = intel_gt_pm_get(vma->vm->gt);
790791
map = i915_vma_pin_iomap(vma);
791792
i915_vma_unpin(vma);
792793
if (IS_ERR(map)) {
@@ -798,12 +799,13 @@ static int gtt_set(struct drm_i915_gem_object *obj)
798799
i915_vma_unpin_iomap(vma);
799800

800801
out:
801-
intel_gt_pm_put(vma->vm->gt);
802+
intel_gt_pm_put(vma->vm->gt, wakeref);
802803
return err;
803804
}
804805

805806
static int gtt_check(struct drm_i915_gem_object *obj)
806807
{
808+
intel_wakeref_t wakeref;
807809
struct i915_vma *vma;
808810
void __iomem *map;
809811
int err = 0;
@@ -812,7 +814,7 @@ static int gtt_check(struct drm_i915_gem_object *obj)
812814
if (IS_ERR(vma))
813815
return PTR_ERR(vma);
814816

815-
intel_gt_pm_get(vma->vm->gt);
817+
wakeref = intel_gt_pm_get(vma->vm->gt);
816818
map = i915_vma_pin_iomap(vma);
817819
i915_vma_unpin(vma);
818820
if (IS_ERR(map)) {
@@ -828,7 +830,7 @@ static int gtt_check(struct drm_i915_gem_object *obj)
828830
i915_vma_unpin_iomap(vma);
829831

830832
out:
831-
intel_gt_pm_put(vma->vm->gt);
833+
intel_gt_pm_put(vma->vm->gt, wakeref);
832834
return err;
833835
}
834836

0 commit comments

Comments
 (0)