Skip to content

Commit 93413c8

Browse files
committed
Merge tag 'drm-fixes-2022-05-21' of git://anongit.freedesktop.org/drm/drm
Pull drm fixes from Dave Airlie: "Few final fixes for 5.18, one amdgpu, core dp mst leak fix, dma-buf two fixes, and i915 has a few fixes, one for a regression on older GM45 chipsets, dma-buf: - ioctl userspace use fix - fix dma-buf sysfs name generation core: - dp/mst leak fix amdgpu: - suspend/resume regression fix i915: - fix for #5806: GPU hangs and display artifacts on Intel GM45 - reject DMC with out-of-spec MMIO - correctly mark guilty contexts on GuC reset" * tag 'drm-fixes-2022-05-21' of git://anongit.freedesktop.org/drm/drm: drm/i915: Use i915_gem_object_ggtt_pin_ww for reloc_iomap drm/amd: Don't reset dGPUs if the system is going to s2idle drm/dp/mst: fix a possible memory leak in fetch_monitor_name() dma-buf: fix use of DMA_BUF_SET_NAME_{A,B} in userspace i915/guc/reset: Make __guc_reset_context aware of guilty engines drm/i915/dmc: Add MMIO range restrictions dma-buf: ensure unique directory name for dmabuf stats
2 parents 3ac6487 + 64eea68 commit 93413c8

File tree

14 files changed

+102
-19
lines changed

14 files changed

+102
-19
lines changed

drivers/dma-buf/dma-buf.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ static inline int is_dma_buf_file(struct file *file)
407407

408408
static struct file *dma_buf_getfile(struct dma_buf *dmabuf, int flags)
409409
{
410+
static atomic64_t dmabuf_inode = ATOMIC64_INIT(0);
410411
struct file *file;
411412
struct inode *inode = alloc_anon_inode(dma_buf_mnt->mnt_sb);
412413

@@ -416,6 +417,13 @@ static struct file *dma_buf_getfile(struct dma_buf *dmabuf, int flags)
416417
inode->i_size = dmabuf->size;
417418
inode_set_bytes(inode, dmabuf->size);
418419

420+
/*
421+
* The ->i_ino acquired from get_next_ino() is not unique thus
422+
* not suitable for using it as dentry name by dmabuf stats.
423+
* Override ->i_ino with the unique and dmabuffs specific
424+
* value.
425+
*/
426+
inode->i_ino = atomic64_add_return(1, &dmabuf_inode);
419427
file = alloc_file_pseudo(inode, dma_buf_mnt, "dmabuf",
420428
flags, &dma_buf_fops);
421429
if (IS_ERR(file))

drivers/gpu/drm/amd/amdgpu/amdgpu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,9 +1342,11 @@ static inline int amdgpu_acpi_smart_shift_update(struct drm_device *dev,
13421342

13431343
#if defined(CONFIG_ACPI) && defined(CONFIG_SUSPEND)
13441344
bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev);
1345+
bool amdgpu_acpi_should_gpu_reset(struct amdgpu_device *adev);
13451346
bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev);
13461347
#else
13471348
static inline bool amdgpu_acpi_is_s0ix_active(struct amdgpu_device *adev) { return false; }
1349+
static inline bool amdgpu_acpi_should_gpu_reset(struct amdgpu_device *adev) { return false; }
13481350
static inline bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev) { return false; }
13491351
#endif
13501352

drivers/gpu/drm/amd/amdgpu/amdgpu_acpi.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,20 @@ bool amdgpu_acpi_is_s3_active(struct amdgpu_device *adev)
10451045
(pm_suspend_target_state == PM_SUSPEND_MEM);
10461046
}
10471047

1048+
/**
1049+
* amdgpu_acpi_should_gpu_reset
1050+
*
1051+
* @adev: amdgpu_device_pointer
1052+
*
1053+
* returns true if should reset GPU, false if not
1054+
*/
1055+
bool amdgpu_acpi_should_gpu_reset(struct amdgpu_device *adev)
1056+
{
1057+
if (adev->flags & AMD_IS_APU)
1058+
return false;
1059+
return pm_suspend_target_state != PM_SUSPEND_TO_IDLE;
1060+
}
1061+
10481062
/**
10491063
* amdgpu_acpi_is_s0ix_active
10501064
*

drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2336,7 +2336,7 @@ static int amdgpu_pmops_suspend_noirq(struct device *dev)
23362336
struct drm_device *drm_dev = dev_get_drvdata(dev);
23372337
struct amdgpu_device *adev = drm_to_adev(drm_dev);
23382338

2339-
if (!adev->in_s0ix)
2339+
if (amdgpu_acpi_should_gpu_reset(adev))
23402340
return amdgpu_asic_reset(adev);
23412341

23422342
return 0;

drivers/gpu/drm/dp/drm_dp_mst_topology.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4852,6 +4852,7 @@ static void fetch_monitor_name(struct drm_dp_mst_topology_mgr *mgr,
48524852

48534853
mst_edid = drm_dp_mst_get_edid(port->connector, mgr, port);
48544854
drm_edid_get_monitor_name(mst_edid, name, namelen);
4855+
kfree(mst_edid);
48554856
}
48564857

48574858
/**

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,44 @@ static void dmc_set_fw_offset(struct intel_dmc *dmc,
367367
}
368368
}
369369

370+
static bool dmc_mmio_addr_sanity_check(struct intel_dmc *dmc,
371+
const u32 *mmioaddr, u32 mmio_count,
372+
int header_ver, u8 dmc_id)
373+
{
374+
struct drm_i915_private *i915 = container_of(dmc, typeof(*i915), dmc);
375+
u32 start_range, end_range;
376+
int i;
377+
378+
if (dmc_id >= DMC_FW_MAX) {
379+
drm_warn(&i915->drm, "Unsupported firmware id %u\n", dmc_id);
380+
return false;
381+
}
382+
383+
if (header_ver == 1) {
384+
start_range = DMC_MMIO_START_RANGE;
385+
end_range = DMC_MMIO_END_RANGE;
386+
} else if (dmc_id == DMC_FW_MAIN) {
387+
start_range = TGL_MAIN_MMIO_START;
388+
end_range = TGL_MAIN_MMIO_END;
389+
} else if (DISPLAY_VER(i915) >= 13) {
390+
start_range = ADLP_PIPE_MMIO_START;
391+
end_range = ADLP_PIPE_MMIO_END;
392+
} else if (DISPLAY_VER(i915) >= 12) {
393+
start_range = TGL_PIPE_MMIO_START(dmc_id);
394+
end_range = TGL_PIPE_MMIO_END(dmc_id);
395+
} else {
396+
drm_warn(&i915->drm, "Unknown mmio range for sanity check");
397+
return false;
398+
}
399+
400+
for (i = 0; i < mmio_count; i++) {
401+
if (mmioaddr[i] < start_range || mmioaddr[i] > end_range)
402+
return false;
403+
}
404+
405+
return true;
406+
}
407+
370408
static u32 parse_dmc_fw_header(struct intel_dmc *dmc,
371409
const struct intel_dmc_header_base *dmc_header,
372410
size_t rem_size, u8 dmc_id)
@@ -436,6 +474,12 @@ static u32 parse_dmc_fw_header(struct intel_dmc *dmc,
436474
return 0;
437475
}
438476

477+
if (!dmc_mmio_addr_sanity_check(dmc, mmioaddr, mmio_count,
478+
dmc_header->header_ver, dmc_id)) {
479+
drm_err(&i915->drm, "DMC firmware has Wrong MMIO Addresses\n");
480+
return 0;
481+
}
482+
439483
for (i = 0; i < mmio_count; i++) {
440484
dmc_info->mmioaddr[i] = _MMIO(mmioaddr[i]);
441485
dmc_info->mmiodata[i] = mmiodata[i];

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,14 +1252,12 @@ static void *reloc_iomap(struct i915_vma *batch,
12521252
* Only attempt to pin the batch buffer to ggtt if the current batch
12531253
* is not inside ggtt, or the batch buffer is not misplaced.
12541254
*/
1255-
if (!i915_is_ggtt(batch->vm)) {
1255+
if (!i915_is_ggtt(batch->vm) ||
1256+
!i915_vma_misplaced(batch, 0, 0, PIN_MAPPABLE)) {
12561257
vma = i915_gem_object_ggtt_pin_ww(obj, &eb->ww, NULL, 0, 0,
12571258
PIN_MAPPABLE |
12581259
PIN_NONBLOCK /* NOWARN */ |
12591260
PIN_NOEVICT);
1260-
} else if (i915_vma_is_map_and_fenceable(batch)) {
1261-
__i915_vma_pin(batch);
1262-
vma = batch;
12631261
}
12641262

12651263
if (vma == ERR_PTR(-EDEADLK))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ static int gt_reset(struct intel_gt *gt, intel_engine_mask_t stalled_mask)
806806
__intel_engine_reset(engine, stalled_mask & engine->mask);
807807
local_bh_enable();
808808

809-
intel_uc_reset(&gt->uc, true);
809+
intel_uc_reset(&gt->uc, ALL_ENGINES);
810810

811811
intel_ggtt_restore_fences(gt->ggtt);
812812

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ int intel_guc_global_policies_update(struct intel_guc *guc);
438438
void intel_guc_context_ban(struct intel_context *ce, struct i915_request *rq);
439439

440440
void intel_guc_submission_reset_prepare(struct intel_guc *guc);
441-
void intel_guc_submission_reset(struct intel_guc *guc, bool stalled);
441+
void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stalled);
442442
void intel_guc_submission_reset_finish(struct intel_guc *guc);
443443
void intel_guc_submission_cancel_requests(struct intel_guc *guc);
444444

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,9 +1590,9 @@ __unwind_incomplete_requests(struct intel_context *ce)
15901590
spin_unlock_irqrestore(&sched_engine->lock, flags);
15911591
}
15921592

1593-
static void __guc_reset_context(struct intel_context *ce, bool stalled)
1593+
static void __guc_reset_context(struct intel_context *ce, intel_engine_mask_t stalled)
15941594
{
1595-
bool local_stalled;
1595+
bool guilty;
15961596
struct i915_request *rq;
15971597
unsigned long flags;
15981598
u32 head;
@@ -1620,22 +1620,22 @@ static void __guc_reset_context(struct intel_context *ce, bool stalled)
16201620
if (!intel_context_is_pinned(ce))
16211621
goto next_context;
16221622

1623-
local_stalled = false;
1623+
guilty = false;
16241624
rq = intel_context_find_active_request(ce);
16251625
if (!rq) {
16261626
head = ce->ring->tail;
16271627
goto out_replay;
16281628
}
16291629

16301630
if (i915_request_started(rq))
1631-
local_stalled = true;
1631+
guilty = stalled & ce->engine->mask;
16321632

16331633
GEM_BUG_ON(i915_active_is_idle(&ce->active));
16341634
head = intel_ring_wrap(ce->ring, rq->head);
16351635

1636-
__i915_request_reset(rq, local_stalled && stalled);
1636+
__i915_request_reset(rq, guilty);
16371637
out_replay:
1638-
guc_reset_state(ce, head, local_stalled && stalled);
1638+
guc_reset_state(ce, head, guilty);
16391639
next_context:
16401640
if (i != number_children)
16411641
ce = list_next_entry(ce, parallel.child_link);
@@ -1645,7 +1645,7 @@ static void __guc_reset_context(struct intel_context *ce, bool stalled)
16451645
intel_context_put(parent);
16461646
}
16471647

1648-
void intel_guc_submission_reset(struct intel_guc *guc, bool stalled)
1648+
void intel_guc_submission_reset(struct intel_guc *guc, intel_engine_mask_t stalled)
16491649
{
16501650
struct intel_context *ce;
16511651
unsigned long index;
@@ -4013,7 +4013,7 @@ static void guc_context_replay(struct intel_context *ce)
40134013
{
40144014
struct i915_sched_engine *sched_engine = ce->engine->sched_engine;
40154015

4016-
__guc_reset_context(ce, true);
4016+
__guc_reset_context(ce, ce->engine->mask);
40174017
tasklet_hi_schedule(&sched_engine->tasklet);
40184018
}
40194019

0 commit comments

Comments
 (0)