Skip to content

Commit 168174d

Browse files
committed
Merge tag 'drm-fixes-2024-01-27' of git://anongit.freedesktop.org/drm/drm
Pull drm fixes from Dave Airlie: "Lots going on for rc2, ivpu has a bunch of stabilisation and debugging work, then amdgpu and xe are the main fixes. i915, exynos have a few, then some misc panel and bridge fixes. Worth mentioning are three regressions. One of the nouveau fixes in 6.7 for a serious deadlock had side effects, so I guess we will bring back the deadlock until I can figure out what should be done properly. There was a scheduler regression vs amdgpu which was reported in a few places and is now fixed. There was an i915 vs simpledrm problem resulting in black screens, that is reverted also. I'll be working on a proper nouveau fix, it kinda looks like one of those cases where someone tried to use an atomic where they should have probably used a lock, but I'll see. fb: - fix simpledrm/i915 regression by reverting change scheduler: - fix regression affecting amdgpu users due to sched draining nouveau: - revert 6.7 deadlock fix as it has side effects dp: - fix documentation warning ttm: - fix dummy page read on some platforms bridge: - anx7625 suspend fix - sii902x: fix probing and audio registration - parade-ps8640: fix suspend of bridge, aux fixes - samsung-dsim: avoid using FORCE_STOP_STATE panel: - simple add missing bus flags - fix samsung-s6d7aa0 flags amdgpu: - AC/DC power supply tracking fix - Don't show invalid vram vendor data - SMU 13.0.x fixes - GART fix for umr on systems without VRAM - GFX 10/11 UNORD_DISPATCH fixes - IPS display fixes (required for S0ix on some platforms) - Misc fixes i915: - DSI sequence revert to fix GitLab #10071 and DP test-pattern fix - Drop -Wstringop-overflow (broken on GCC11) ivpu: - fix recovery/reset support - improve submit ioctl stability - fix dev open/close races on unbind - PLL disable reset fix - deprecate context priority param - improve debug buffer logging - disable buffer sharing across VPU contexts - free buffer sgt on unbind - fix missing lock around shmem vmap - add better boot diagnostics - add more debug prints around mapping - dump MMU events in case of timeout v3d: - NULL ptr dereference fix exynos: - fix stack usage - fix incorrect type - fix dt typo - fix gsc runtime resume xe: - Make an ops struct static - Fix an implicit 0 to NULL conversion - A couple of 32-bit fixes - A migration coherency fix for Lunar Lake. - An error path vm id leak fix - Remove PVC references in kunit tests" * tag 'drm-fixes-2024-01-27' of git://anongit.freedesktop.org/drm/drm: (66 commits) Revert "nouveau: push event block/allowing out of the fence context" drm: bridge: samsung-dsim: Don't use FORCE_STOP_STATE drm/sched: Drain all entities in DRM sched run job worker drm/amd/display: "Enable IPS by default" drm/amd: Add a DC debug mask for IPS drm/amd/display: Disable ips before dc interrupt setting drm/amd/display: Replay + IPS + ABM in Full Screen VPB drm/amd/display: Add IPS checks before dcn register access drm/amd/display: Add Replay IPS register for DMUB command table drm/amd/display: Allow IPS2 during Replay drm/amdgpu/gfx11: set UNORD_DISPATCH in compute MQDs drm/amdgpu/gfx10: set UNORD_DISPATCH in compute MQDs drm/amd/amdgpu: Assign GART pages to AMD device mapping drm/amd/pm: Fetch current power limit from FW drm/amdgpu: Fix null pointer dereference drm/amdgpu: Show vram vendor only if available drm/amd/pm: update the power cap setting drm/amdgpu: Avoid fetching vram vendor information drm/amdgpu/pm: Fix the power source flag error drm/amd/display: Fix uninitialized variable usage in core_link_ 'read_dpcd() & write_dpcd()' functions ...
2 parents 2047b0b + 987940f commit 168174d

Some content is hidden

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

71 files changed

+736
-465
lines changed

Documentation/devicetree/bindings/display/samsung/samsung,exynos-mixer.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ allOf:
8585
clocks:
8686
minItems: 6
8787
maxItems: 6
88-
regs:
88+
reg:
8989
minItems: 2
9090
maxItems: 2
9191

@@ -99,7 +99,7 @@ allOf:
9999
clocks:
100100
minItems: 4
101101
maxItems: 4
102-
regs:
102+
reg:
103103
minItems: 2
104104
maxItems: 2
105105

@@ -116,7 +116,7 @@ allOf:
116116
clocks:
117117
minItems: 3
118118
maxItems: 3
119-
regs:
119+
reg:
120120
minItems: 1
121121
maxItems: 1
122122

drivers/accel/ivpu/ivpu_debugfs.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ static int reset_pending_show(struct seq_file *s, void *v)
102102
{
103103
struct ivpu_device *vdev = seq_to_ivpu(s);
104104

105-
seq_printf(s, "%d\n", atomic_read(&vdev->pm->in_reset));
105+
seq_printf(s, "%d\n", atomic_read(&vdev->pm->reset_pending));
106106
return 0;
107107
}
108108

@@ -130,7 +130,9 @@ dvfs_mode_fops_write(struct file *file, const char __user *user_buf, size_t size
130130

131131
fw->dvfs_mode = dvfs_mode;
132132

133-
ivpu_pm_schedule_recovery(vdev);
133+
ret = pci_try_reset_function(to_pci_dev(vdev->drm.dev));
134+
if (ret)
135+
return ret;
134136

135137
return size;
136138
}
@@ -190,7 +192,10 @@ fw_profiling_freq_fops_write(struct file *file, const char __user *user_buf,
190192
return ret;
191193

192194
ivpu_hw_profiling_freq_drive(vdev, enable);
193-
ivpu_pm_schedule_recovery(vdev);
195+
196+
ret = pci_try_reset_function(to_pci_dev(vdev->drm.dev));
197+
if (ret)
198+
return ret;
194199

195200
return size;
196201
}
@@ -301,11 +306,18 @@ static ssize_t
301306
ivpu_force_recovery_fn(struct file *file, const char __user *user_buf, size_t size, loff_t *pos)
302307
{
303308
struct ivpu_device *vdev = file->private_data;
309+
int ret;
304310

305311
if (!size)
306312
return -EINVAL;
307313

308-
ivpu_pm_schedule_recovery(vdev);
314+
ret = ivpu_rpm_get(vdev);
315+
if (ret)
316+
return ret;
317+
318+
ivpu_pm_trigger_recovery(vdev, "debugfs");
319+
flush_work(&vdev->pm->recovery_work);
320+
ivpu_rpm_put(vdev);
309321
return size;
310322
}
311323

drivers/accel/ivpu/ivpu_drv.c

Lines changed: 71 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <linux/firmware.h>
77
#include <linux/module.h>
88
#include <linux/pci.h>
9+
#include <linux/pm_runtime.h>
910

1011
#include <drm/drm_accel.h>
1112
#include <drm/drm_file.h>
@@ -17,6 +18,7 @@
1718
#include "ivpu_debugfs.h"
1819
#include "ivpu_drv.h"
1920
#include "ivpu_fw.h"
21+
#include "ivpu_fw_log.h"
2022
#include "ivpu_gem.h"
2123
#include "ivpu_hw.h"
2224
#include "ivpu_ipc.h"
@@ -65,36 +67,36 @@ struct ivpu_file_priv *ivpu_file_priv_get(struct ivpu_file_priv *file_priv)
6567
return file_priv;
6668
}
6769

68-
struct ivpu_file_priv *ivpu_file_priv_get_by_ctx_id(struct ivpu_device *vdev, unsigned long id)
70+
static void file_priv_unbind(struct ivpu_device *vdev, struct ivpu_file_priv *file_priv)
6971
{
70-
struct ivpu_file_priv *file_priv;
71-
72-
xa_lock_irq(&vdev->context_xa);
73-
file_priv = xa_load(&vdev->context_xa, id);
74-
/* file_priv may still be in context_xa during file_priv_release() */
75-
if (file_priv && !kref_get_unless_zero(&file_priv->ref))
76-
file_priv = NULL;
77-
xa_unlock_irq(&vdev->context_xa);
78-
79-
if (file_priv)
80-
ivpu_dbg(vdev, KREF, "file_priv get by id: ctx %u refcount %u\n",
81-
file_priv->ctx.id, kref_read(&file_priv->ref));
82-
83-
return file_priv;
72+
mutex_lock(&file_priv->lock);
73+
if (file_priv->bound) {
74+
ivpu_dbg(vdev, FILE, "file_priv unbind: ctx %u\n", file_priv->ctx.id);
75+
76+
ivpu_cmdq_release_all_locked(file_priv);
77+
ivpu_jsm_context_release(vdev, file_priv->ctx.id);
78+
ivpu_bo_unbind_all_bos_from_context(vdev, &file_priv->ctx);
79+
ivpu_mmu_user_context_fini(vdev, &file_priv->ctx);
80+
file_priv->bound = false;
81+
drm_WARN_ON(&vdev->drm, !xa_erase_irq(&vdev->context_xa, file_priv->ctx.id));
82+
}
83+
mutex_unlock(&file_priv->lock);
8484
}
8585

8686
static void file_priv_release(struct kref *ref)
8787
{
8888
struct ivpu_file_priv *file_priv = container_of(ref, struct ivpu_file_priv, ref);
8989
struct ivpu_device *vdev = file_priv->vdev;
9090

91-
ivpu_dbg(vdev, FILE, "file_priv release: ctx %u\n", file_priv->ctx.id);
91+
ivpu_dbg(vdev, FILE, "file_priv release: ctx %u bound %d\n",
92+
file_priv->ctx.id, (bool)file_priv->bound);
93+
94+
pm_runtime_get_sync(vdev->drm.dev);
95+
mutex_lock(&vdev->context_list_lock);
96+
file_priv_unbind(vdev, file_priv);
97+
mutex_unlock(&vdev->context_list_lock);
98+
pm_runtime_put_autosuspend(vdev->drm.dev);
9299

93-
ivpu_cmdq_release_all(file_priv);
94-
ivpu_jsm_context_release(vdev, file_priv->ctx.id);
95-
ivpu_bo_remove_all_bos_from_context(vdev, &file_priv->ctx);
96-
ivpu_mmu_user_context_fini(vdev, &file_priv->ctx);
97-
drm_WARN_ON(&vdev->drm, xa_erase_irq(&vdev->context_xa, file_priv->ctx.id) != file_priv);
98100
mutex_destroy(&file_priv->lock);
99101
kfree(file_priv);
100102
}
@@ -176,9 +178,6 @@ static int ivpu_get_param_ioctl(struct drm_device *dev, void *data, struct drm_f
176178
case DRM_IVPU_PARAM_CONTEXT_BASE_ADDRESS:
177179
args->value = vdev->hw->ranges.user.start;
178180
break;
179-
case DRM_IVPU_PARAM_CONTEXT_PRIORITY:
180-
args->value = file_priv->priority;
181-
break;
182181
case DRM_IVPU_PARAM_CONTEXT_ID:
183182
args->value = file_priv->ctx.id;
184183
break;
@@ -218,17 +217,10 @@ static int ivpu_get_param_ioctl(struct drm_device *dev, void *data, struct drm_f
218217

219218
static int ivpu_set_param_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
220219
{
221-
struct ivpu_file_priv *file_priv = file->driver_priv;
222220
struct drm_ivpu_param *args = data;
223221
int ret = 0;
224222

225223
switch (args->param) {
226-
case DRM_IVPU_PARAM_CONTEXT_PRIORITY:
227-
if (args->value <= DRM_IVPU_CONTEXT_PRIORITY_REALTIME)
228-
file_priv->priority = args->value;
229-
else
230-
ret = -EINVAL;
231-
break;
232224
default:
233225
ret = -EINVAL;
234226
}
@@ -241,50 +233,53 @@ static int ivpu_open(struct drm_device *dev, struct drm_file *file)
241233
struct ivpu_device *vdev = to_ivpu_device(dev);
242234
struct ivpu_file_priv *file_priv;
243235
u32 ctx_id;
244-
void *old;
245-
int ret;
236+
int idx, ret;
246237

247-
ret = xa_alloc_irq(&vdev->context_xa, &ctx_id, NULL, vdev->context_xa_limit, GFP_KERNEL);
248-
if (ret) {
249-
ivpu_err(vdev, "Failed to allocate context id: %d\n", ret);
250-
return ret;
251-
}
238+
if (!drm_dev_enter(dev, &idx))
239+
return -ENODEV;
252240

253241
file_priv = kzalloc(sizeof(*file_priv), GFP_KERNEL);
254242
if (!file_priv) {
255243
ret = -ENOMEM;
256-
goto err_xa_erase;
244+
goto err_dev_exit;
257245
}
258246

259247
file_priv->vdev = vdev;
260-
file_priv->priority = DRM_IVPU_CONTEXT_PRIORITY_NORMAL;
248+
file_priv->bound = true;
261249
kref_init(&file_priv->ref);
262250
mutex_init(&file_priv->lock);
263251

252+
mutex_lock(&vdev->context_list_lock);
253+
254+
ret = xa_alloc_irq(&vdev->context_xa, &ctx_id, file_priv,
255+
vdev->context_xa_limit, GFP_KERNEL);
256+
if (ret) {
257+
ivpu_err(vdev, "Failed to allocate context id: %d\n", ret);
258+
goto err_unlock;
259+
}
260+
264261
ret = ivpu_mmu_user_context_init(vdev, &file_priv->ctx, ctx_id);
265262
if (ret)
266-
goto err_mutex_destroy;
263+
goto err_xa_erase;
267264

268-
old = xa_store_irq(&vdev->context_xa, ctx_id, file_priv, GFP_KERNEL);
269-
if (xa_is_err(old)) {
270-
ret = xa_err(old);
271-
ivpu_err(vdev, "Failed to store context %u: %d\n", ctx_id, ret);
272-
goto err_ctx_fini;
273-
}
265+
mutex_unlock(&vdev->context_list_lock);
266+
drm_dev_exit(idx);
267+
268+
file->driver_priv = file_priv;
274269

275270
ivpu_dbg(vdev, FILE, "file_priv create: ctx %u process %s pid %d\n",
276271
ctx_id, current->comm, task_pid_nr(current));
277272

278-
file->driver_priv = file_priv;
279273
return 0;
280274

281-
err_ctx_fini:
282-
ivpu_mmu_user_context_fini(vdev, &file_priv->ctx);
283-
err_mutex_destroy:
284-
mutex_destroy(&file_priv->lock);
285-
kfree(file_priv);
286275
err_xa_erase:
287276
xa_erase_irq(&vdev->context_xa, ctx_id);
277+
err_unlock:
278+
mutex_unlock(&vdev->context_list_lock);
279+
mutex_destroy(&file_priv->lock);
280+
kfree(file_priv);
281+
err_dev_exit:
282+
drm_dev_exit(idx);
288283
return ret;
289284
}
290285

@@ -340,8 +335,6 @@ static int ivpu_wait_for_ready(struct ivpu_device *vdev)
340335

341336
if (!ret)
342337
ivpu_dbg(vdev, PM, "VPU ready message received successfully\n");
343-
else
344-
ivpu_hw_diagnose_failure(vdev);
345338

346339
return ret;
347340
}
@@ -369,6 +362,9 @@ int ivpu_boot(struct ivpu_device *vdev)
369362
ret = ivpu_wait_for_ready(vdev);
370363
if (ret) {
371364
ivpu_err(vdev, "Failed to boot the firmware: %d\n", ret);
365+
ivpu_hw_diagnose_failure(vdev);
366+
ivpu_mmu_evtq_dump(vdev);
367+
ivpu_fw_log_dump(vdev);
372368
return ret;
373369
}
374370

@@ -540,6 +536,10 @@ static int ivpu_dev_init(struct ivpu_device *vdev)
540536
lockdep_set_class(&vdev->submitted_jobs_xa.xa_lock, &submitted_jobs_xa_lock_class_key);
541537
INIT_LIST_HEAD(&vdev->bo_list);
542538

539+
ret = drmm_mutex_init(&vdev->drm, &vdev->context_list_lock);
540+
if (ret)
541+
goto err_xa_destroy;
542+
543543
ret = drmm_mutex_init(&vdev->drm, &vdev->bo_list_lock);
544544
if (ret)
545545
goto err_xa_destroy;
@@ -611,14 +611,30 @@ static int ivpu_dev_init(struct ivpu_device *vdev)
611611
return ret;
612612
}
613613

614+
static void ivpu_bo_unbind_all_user_contexts(struct ivpu_device *vdev)
615+
{
616+
struct ivpu_file_priv *file_priv;
617+
unsigned long ctx_id;
618+
619+
mutex_lock(&vdev->context_list_lock);
620+
621+
xa_for_each(&vdev->context_xa, ctx_id, file_priv)
622+
file_priv_unbind(vdev, file_priv);
623+
624+
mutex_unlock(&vdev->context_list_lock);
625+
}
626+
614627
static void ivpu_dev_fini(struct ivpu_device *vdev)
615628
{
616629
ivpu_pm_disable(vdev);
617630
ivpu_shutdown(vdev);
618631
if (IVPU_WA(d3hot_after_power_off))
619632
pci_set_power_state(to_pci_dev(vdev->drm.dev), PCI_D3hot);
633+
634+
ivpu_jobs_abort_all(vdev);
620635
ivpu_job_done_consumer_fini(vdev);
621636
ivpu_pm_cancel_recovery(vdev);
637+
ivpu_bo_unbind_all_user_contexts(vdev);
622638

623639
ivpu_ipc_fini(vdev);
624640
ivpu_fw_fini(vdev);

drivers/accel/ivpu/ivpu_drv.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#define IVPU_DBG_JSM BIT(10)
5757
#define IVPU_DBG_KREF BIT(11)
5858
#define IVPU_DBG_RPM BIT(12)
59+
#define IVPU_DBG_MMU_MAP BIT(13)
5960

6061
#define ivpu_err(vdev, fmt, ...) \
6162
drm_err(&(vdev)->drm, "%s(): " fmt, __func__, ##__VA_ARGS__)
@@ -114,6 +115,7 @@ struct ivpu_device {
114115

115116
struct ivpu_mmu_context gctx;
116117
struct ivpu_mmu_context rctx;
118+
struct mutex context_list_lock; /* Protects user context addition/removal */
117119
struct xarray context_xa;
118120
struct xa_limit context_xa_limit;
119121

@@ -145,8 +147,8 @@ struct ivpu_file_priv {
145147
struct mutex lock; /* Protects cmdq */
146148
struct ivpu_cmdq *cmdq[IVPU_NUM_ENGINES];
147149
struct ivpu_mmu_context ctx;
148-
u32 priority;
149150
bool has_mmu_faults;
151+
bool bound;
150152
};
151153

152154
extern int ivpu_dbg_mask;
@@ -162,7 +164,6 @@ extern bool ivpu_disable_mmu_cont_pages;
162164
extern int ivpu_test_mode;
163165

164166
struct ivpu_file_priv *ivpu_file_priv_get(struct ivpu_file_priv *file_priv);
165-
struct ivpu_file_priv *ivpu_file_priv_get_by_ctx_id(struct ivpu_device *vdev, unsigned long id);
166167
void ivpu_file_priv_put(struct ivpu_file_priv **link);
167168

168169
int ivpu_boot(struct ivpu_device *vdev);

0 commit comments

Comments
 (0)