Skip to content

Commit ac6c043

Browse files
committed
Merge tag 'drm-fixes-2023-04-06' of git://anongit.freedesktop.org/drm/drm
Pull drm fixes from Daniel Vetter: "Mostly i915 fixes: dp mst for compression/dsc, perf ioctl uaf, ctx rpm accounting, gt reset vs huc loading. And a few individual driver fixes: ivpu dma fence&suspend, panfrost mmap, nouveau color depth" * tag 'drm-fixes-2023-04-06' of git://anongit.freedesktop.org/drm/drm: accel/ivpu: Fix S3 system suspend when not idle accel/ivpu: Add dma fence to command buffers only drm/i915: Fix context runtime accounting drm/i915: fix race condition UAF in i915_perf_add_config_ioctl drm/i915: Use compressed bpp when calculating m/n value for DP MST DSC drm/i915/huc: Cancel HuC delayed load timer on reset. drm/i915/ttm: fix sparse warning drm/panfrost: Fix the panfrost_mmu_map_fault_addr() error path drm/nouveau/disp: Support more modes by checking with lower bpc
2 parents 2a28a8b + 3dfa892 commit ac6c043

File tree

11 files changed

+81
-43
lines changed

11 files changed

+81
-43
lines changed

drivers/accel/ivpu/ivpu_job.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -461,26 +461,22 @@ ivpu_job_prepare_bos_for_submit(struct drm_file *file, struct ivpu_job *job, u32
461461

462462
job->cmd_buf_vpu_addr = bo->vpu_addr + commands_offset;
463463

464-
ret = drm_gem_lock_reservations((struct drm_gem_object **)job->bos, buf_count,
465-
&acquire_ctx);
464+
ret = drm_gem_lock_reservations((struct drm_gem_object **)job->bos, 1, &acquire_ctx);
466465
if (ret) {
467466
ivpu_warn(vdev, "Failed to lock reservations: %d\n", ret);
468467
return ret;
469468
}
470469

471-
for (i = 0; i < buf_count; i++) {
472-
ret = dma_resv_reserve_fences(job->bos[i]->base.resv, 1);
473-
if (ret) {
474-
ivpu_warn(vdev, "Failed to reserve fences: %d\n", ret);
475-
goto unlock_reservations;
476-
}
470+
ret = dma_resv_reserve_fences(bo->base.resv, 1);
471+
if (ret) {
472+
ivpu_warn(vdev, "Failed to reserve fences: %d\n", ret);
473+
goto unlock_reservations;
477474
}
478475

479-
for (i = 0; i < buf_count; i++)
480-
dma_resv_add_fence(job->bos[i]->base.resv, job->done_fence, DMA_RESV_USAGE_WRITE);
476+
dma_resv_add_fence(bo->base.resv, job->done_fence, DMA_RESV_USAGE_WRITE);
481477

482478
unlock_reservations:
483-
drm_gem_unlock_reservations((struct drm_gem_object **)job->bos, buf_count, &acquire_ctx);
479+
drm_gem_unlock_reservations((struct drm_gem_object **)job->bos, 1, &acquire_ctx);
484480

485481
wmb(); /* Flush write combining buffers */
486482

drivers/accel/ivpu/ivpu_pm.c

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -140,32 +140,28 @@ int ivpu_pm_suspend_cb(struct device *dev)
140140
{
141141
struct drm_device *drm = dev_get_drvdata(dev);
142142
struct ivpu_device *vdev = to_ivpu_device(drm);
143-
int ret;
143+
unsigned long timeout;
144144

145145
ivpu_dbg(vdev, PM, "Suspend..\n");
146146

147-
ret = ivpu_suspend(vdev);
148-
if (ret && vdev->pm->suspend_reschedule_counter) {
149-
ivpu_dbg(vdev, PM, "Failed to enter idle, rescheduling suspend, retries left %d\n",
150-
vdev->pm->suspend_reschedule_counter);
151-
pm_schedule_suspend(dev, vdev->timeout.reschedule_suspend);
152-
vdev->pm->suspend_reschedule_counter--;
153-
return -EBUSY;
154-
} else if (!vdev->pm->suspend_reschedule_counter) {
155-
ivpu_warn(vdev, "Failed to enter idle, force suspend\n");
156-
ivpu_pm_prepare_cold_boot(vdev);
157-
} else {
158-
ivpu_pm_prepare_warm_boot(vdev);
147+
timeout = jiffies + msecs_to_jiffies(vdev->timeout.tdr);
148+
while (!ivpu_hw_is_idle(vdev)) {
149+
cond_resched();
150+
if (time_after_eq(jiffies, timeout)) {
151+
ivpu_err(vdev, "Failed to enter idle on system suspend\n");
152+
return -EBUSY;
153+
}
159154
}
160155

161-
vdev->pm->suspend_reschedule_counter = PM_RESCHEDULE_LIMIT;
156+
ivpu_suspend(vdev);
157+
ivpu_pm_prepare_warm_boot(vdev);
162158

163159
pci_save_state(to_pci_dev(dev));
164160
pci_set_power_state(to_pci_dev(dev), PCI_D3hot);
165161

166162
ivpu_dbg(vdev, PM, "Suspend done.\n");
167163

168-
return ret;
164+
return 0;
169165
}
170166

171167
int ivpu_pm_resume_cb(struct device *dev)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static int intel_dp_dsc_mst_compute_link_config(struct intel_encoder *encoder,
232232
return slots;
233233
}
234234

235-
intel_link_compute_m_n(crtc_state->pipe_bpp,
235+
intel_link_compute_m_n(crtc_state->dsc.compressed_bpp,
236236
crtc_state->lane_count,
237237
adjusted_mode->crtc_clock,
238238
crtc_state->port_clock,

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,11 +1067,12 @@ static vm_fault_t vm_fault_ttm(struct vm_fault *vmf)
10671067
.interruptible = true,
10681068
.no_wait_gpu = true, /* should be idle already */
10691069
};
1070+
int err;
10701071

10711072
GEM_BUG_ON(!bo->ttm || !(bo->ttm->page_flags & TTM_TT_FLAG_SWAPPED));
10721073

1073-
ret = ttm_bo_validate(bo, i915_ttm_sys_placement(), &ctx);
1074-
if (ret) {
1074+
err = ttm_bo_validate(bo, i915_ttm_sys_placement(), &ctx);
1075+
if (err) {
10751076
dma_resv_unlock(bo->base.resv);
10761077
return VM_FAULT_SIGBUS;
10771078
}

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,6 +2018,8 @@ process_csb(struct intel_engine_cs *engine, struct i915_request **inactive)
20182018
* inspecting the queue to see if we need to resumbit.
20192019
*/
20202020
if (*prev != *execlists->active) { /* elide lite-restores */
2021+
struct intel_context *prev_ce = NULL, *active_ce = NULL;
2022+
20212023
/*
20222024
* Note the inherent discrepancy between the HW runtime,
20232025
* recorded as part of the context switch, and the CPU
@@ -2029,9 +2031,15 @@ process_csb(struct intel_engine_cs *engine, struct i915_request **inactive)
20292031
* and correct overselves later when updating from HW.
20302032
*/
20312033
if (*prev)
2032-
lrc_runtime_stop((*prev)->context);
2034+
prev_ce = (*prev)->context;
20332035
if (*execlists->active)
2034-
lrc_runtime_start((*execlists->active)->context);
2036+
active_ce = (*execlists->active)->context;
2037+
if (prev_ce != active_ce) {
2038+
if (prev_ce)
2039+
lrc_runtime_stop(prev_ce);
2040+
if (active_ce)
2041+
lrc_runtime_start(active_ce);
2042+
}
20352043
new_timeslice(execlists);
20362044
}
20372045

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ static void delayed_huc_load_fini(struct intel_huc *huc)
235235
i915_sw_fence_fini(&huc->delayed_load.fence);
236236
}
237237

238+
int intel_huc_sanitize(struct intel_huc *huc)
239+
{
240+
delayed_huc_load_complete(huc);
241+
intel_uc_fw_sanitize(&huc->fw);
242+
return 0;
243+
}
244+
238245
static bool vcs_supported(struct intel_gt *gt)
239246
{
240247
intel_engine_mask_t mask = gt->info.engine_mask;

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct intel_huc {
4141
} delayed_load;
4242
};
4343

44+
int intel_huc_sanitize(struct intel_huc *huc);
4445
void intel_huc_init_early(struct intel_huc *huc);
4546
int intel_huc_init(struct intel_huc *huc);
4647
void intel_huc_fini(struct intel_huc *huc);
@@ -54,12 +55,6 @@ bool intel_huc_is_authenticated(struct intel_huc *huc);
5455
void intel_huc_register_gsc_notifier(struct intel_huc *huc, struct bus_type *bus);
5556
void intel_huc_unregister_gsc_notifier(struct intel_huc *huc, struct bus_type *bus);
5657

57-
static inline int intel_huc_sanitize(struct intel_huc *huc)
58-
{
59-
intel_uc_fw_sanitize(&huc->fw);
60-
return 0;
61-
}
62-
6358
static inline bool intel_huc_is_supported(struct intel_huc *huc)
6459
{
6560
return intel_uc_fw_is_supported(&huc->fw);

drivers/gpu/drm/i915/i915_perf.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4638,13 +4638,13 @@ int i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
46384638
err = oa_config->id;
46394639
goto sysfs_err;
46404640
}
4641-
4642-
mutex_unlock(&perf->metrics_lock);
4641+
id = oa_config->id;
46434642

46444643
drm_dbg(&perf->i915->drm,
46454644
"Added config %s id=%i\n", oa_config->uuid, oa_config->id);
4645+
mutex_unlock(&perf->metrics_lock);
46464646

4647-
return oa_config->id;
4647+
return id;
46484648

46494649
sysfs_err:
46504650
mutex_unlock(&perf->metrics_lock);

drivers/gpu/drm/nouveau/dispnv50/disp.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,35 @@ nv50_outp_atomic_check_view(struct drm_encoder *encoder,
363363
return 0;
364364
}
365365

366+
static void
367+
nv50_outp_atomic_fix_depth(struct drm_encoder *encoder, struct drm_crtc_state *crtc_state)
368+
{
369+
struct nv50_head_atom *asyh = nv50_head_atom(crtc_state);
370+
struct nouveau_encoder *nv_encoder = nouveau_encoder(encoder);
371+
struct drm_display_mode *mode = &asyh->state.adjusted_mode;
372+
unsigned int max_rate, mode_rate;
373+
374+
switch (nv_encoder->dcb->type) {
375+
case DCB_OUTPUT_DP:
376+
max_rate = nv_encoder->dp.link_nr * nv_encoder->dp.link_bw;
377+
378+
/* we don't support more than 10 anyway */
379+
asyh->or.bpc = min_t(u8, asyh->or.bpc, 10);
380+
381+
/* reduce the bpc until it works out */
382+
while (asyh->or.bpc > 6) {
383+
mode_rate = DIV_ROUND_UP(mode->clock * asyh->or.bpc * 3, 8);
384+
if (mode_rate <= max_rate)
385+
break;
386+
387+
asyh->or.bpc -= 2;
388+
}
389+
break;
390+
default:
391+
break;
392+
}
393+
}
394+
366395
static int
367396
nv50_outp_atomic_check(struct drm_encoder *encoder,
368397
struct drm_crtc_state *crtc_state,
@@ -381,6 +410,9 @@ nv50_outp_atomic_check(struct drm_encoder *encoder,
381410
if (crtc_state->mode_changed || crtc_state->connectors_changed)
382411
asyh->or.bpc = connector->display_info.bpc;
383412

413+
/* We might have to reduce the bpc */
414+
nv50_outp_atomic_fix_depth(encoder, crtc_state);
415+
384416
return 0;
385417
}
386418

drivers/gpu/drm/nouveau/nouveau_dp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,6 @@ nouveau_dp_irq(struct work_struct *work)
263263
}
264264

265265
/* TODO:
266-
* - Use the minimum possible BPC here, once we add support for the max bpc
267-
* property.
268266
* - Validate against the DP caps advertised by the GPU (we don't check these
269267
* yet)
270268
*/
@@ -276,7 +274,11 @@ nv50_dp_mode_valid(struct drm_connector *connector,
276274
{
277275
const unsigned int min_clock = 25000;
278276
unsigned int max_rate, mode_rate, ds_max_dotclock, clock = mode->clock;
279-
const u8 bpp = connector->display_info.bpc * 3;
277+
/* Check with the minmum bpc always, so we can advertise better modes.
278+
* In particlar not doing this causes modes to be dropped on HDR
279+
* displays as we might check with a bpc of 16 even.
280+
*/
281+
const u8 bpp = 6 * 3;
280282

281283
if (mode->flags & DRM_MODE_FLAG_INTERLACE && !outp->caps.dp_interlace)
282284
return MODE_NO_INTERLACE;

0 commit comments

Comments
 (0)