Skip to content

Commit 3c5ab24

Browse files
committed
Merge tag 'drm-misc-next-fixes-2026-02-05' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-next
Several fixes for amdxdna around PM handling, error reporting and memory safety, a compilation fix for ilitek-ili9882t, a NULL pointer dereference fix for imx8qxp-pixel-combiner and several PTE fixes for nouveau Signed-off-by: Dave Airlie <[email protected]> From: Maxime Ripard <[email protected]> Link: https://patch.msgid.link/20260205-refreshing-natural-vole-4c73af@houat
2 parents 1099b65 + 69674c1 commit 3c5ab24

13 files changed

Lines changed: 103 additions & 80 deletions

File tree

drivers/accel/amdxdna/aie2_ctx.c

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,6 @@ static void aie2_job_put(struct amdxdna_sched_job *job)
4747
kref_put(&job->refcnt, aie2_job_release);
4848
}
4949

50-
static void aie2_hwctx_status_shift_stop(struct amdxdna_hwctx *hwctx)
51-
{
52-
hwctx->old_status = hwctx->status;
53-
hwctx->status = HWCTX_STAT_STOP;
54-
}
55-
56-
static void aie2_hwctx_status_restore(struct amdxdna_hwctx *hwctx)
57-
{
58-
hwctx->status = hwctx->old_status;
59-
}
60-
6150
/* The bad_job is used in aie2_sched_job_timedout, otherwise, set it to NULL */
6251
static void aie2_hwctx_stop(struct amdxdna_dev *xdna, struct amdxdna_hwctx *hwctx,
6352
struct drm_sched_job *bad_job)
@@ -84,11 +73,6 @@ static int aie2_hwctx_restart(struct amdxdna_dev *xdna, struct amdxdna_hwctx *hw
8473
goto out;
8574
}
8675

87-
if (hwctx->status != HWCTX_STAT_READY) {
88-
XDNA_DBG(xdna, "hwctx is not ready, status %d", hwctx->status);
89-
goto out;
90-
}
91-
9276
ret = aie2_config_cu(hwctx, NULL);
9377
if (ret) {
9478
XDNA_ERR(xdna, "Config cu failed, ret %d", ret);
@@ -140,7 +124,6 @@ static int aie2_hwctx_suspend_cb(struct amdxdna_hwctx *hwctx, void *arg)
140124

141125
aie2_hwctx_wait_for_idle(hwctx);
142126
aie2_hwctx_stop(xdna, hwctx, NULL);
143-
aie2_hwctx_status_shift_stop(hwctx);
144127

145128
return 0;
146129
}
@@ -162,7 +145,6 @@ static int aie2_hwctx_resume_cb(struct amdxdna_hwctx *hwctx, void *arg)
162145
{
163146
struct amdxdna_dev *xdna = hwctx->client->xdna;
164147

165-
aie2_hwctx_status_restore(hwctx);
166148
return aie2_hwctx_restart(xdna, hwctx);
167149
}
168150

@@ -292,7 +274,7 @@ aie2_sched_cmdlist_resp_handler(void *handle, void __iomem *data, size_t size)
292274
ret = -EINVAL;
293275
goto out;
294276
}
295-
amdxdna_cmd_set_state(cmd_abo, fail_cmd_status);
277+
amdxdna_cmd_set_state(cmd_abo, ERT_CMD_STATE_ERROR);
296278

297279
if (amdxdna_cmd_get_op(cmd_abo) == ERT_CMD_CHAIN) {
298280
struct amdxdna_cmd_chain *cc = amdxdna_cmd_get_payload(cmd_abo, NULL);
@@ -315,12 +297,19 @@ aie2_sched_job_run(struct drm_sched_job *sched_job)
315297
struct dma_fence *fence;
316298
int ret;
317299

300+
if (!hwctx->priv->mbox_chann)
301+
return NULL;
302+
318303
if (!mmget_not_zero(job->mm))
319304
return ERR_PTR(-ESRCH);
320305

321306
kref_get(&job->refcnt);
322307
fence = dma_fence_get(job->fence);
323308

309+
ret = amdxdna_pm_resume_get(hwctx->client->xdna);
310+
if (ret)
311+
goto out;
312+
324313
if (job->drv_cmd) {
325314
switch (job->drv_cmd->opcode) {
326315
case SYNC_DEBUG_BO:
@@ -347,6 +336,7 @@ aie2_sched_job_run(struct drm_sched_job *sched_job)
347336

348337
out:
349338
if (ret) {
339+
amdxdna_pm_suspend_put(hwctx->client->xdna);
350340
dma_fence_put(job->fence);
351341
aie2_job_put(job);
352342
mmput(job->mm);
@@ -663,7 +653,6 @@ int aie2_hwctx_init(struct amdxdna_hwctx *hwctx)
663653
}
664654
amdxdna_pm_suspend_put(xdna);
665655

666-
hwctx->status = HWCTX_STAT_INIT;
667656
init_waitqueue_head(&priv->job_free_wq);
668657

669658
XDNA_DBG(xdna, "hwctx %s init completed", hwctx->name);
@@ -705,7 +694,9 @@ void aie2_hwctx_fini(struct amdxdna_hwctx *hwctx)
705694
aie2_hwctx_wait_for_idle(hwctx);
706695

707696
/* Request fw to destroy hwctx and cancel the rest pending requests */
697+
drm_sched_stop(&hwctx->priv->sched, NULL);
708698
aie2_release_resource(hwctx);
699+
drm_sched_start(&hwctx->priv->sched, 0);
709700

710701
mutex_unlock(&xdna->dev_lock);
711702
drm_sched_entity_destroy(&hwctx->priv->entity);
@@ -749,7 +740,7 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 size
749740
if (XDNA_MBZ_DBG(xdna, config->pad, sizeof(config->pad)))
750741
return -EINVAL;
751742

752-
if (hwctx->status != HWCTX_STAT_INIT) {
743+
if (hwctx->cus) {
753744
XDNA_ERR(xdna, "Not support re-config CU");
754745
return -EINVAL;
755746
}
@@ -780,7 +771,6 @@ static int aie2_hwctx_cu_config(struct amdxdna_hwctx *hwctx, void *buf, u32 size
780771
}
781772

782773
wmb(); /* To avoid locking in command submit when check status */
783-
hwctx->status = HWCTX_STAT_READY;
784774

785775
return 0;
786776

@@ -1003,23 +993,19 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
1003993
goto free_chain;
1004994
}
1005995

1006-
ret = amdxdna_pm_resume_get(xdna);
1007-
if (ret)
1008-
goto cleanup_job;
1009-
1010996
retry:
1011997
ret = drm_gem_lock_reservations(job->bos, job->bo_cnt, &acquire_ctx);
1012998
if (ret) {
1013999
XDNA_WARN(xdna, "Failed to lock BOs, ret %d", ret);
1014-
goto suspend_put;
1000+
goto cleanup_job;
10151001
}
10161002

10171003
for (i = 0; i < job->bo_cnt; i++) {
10181004
ret = dma_resv_reserve_fences(job->bos[i]->resv, 1);
10191005
if (ret) {
10201006
XDNA_WARN(xdna, "Failed to reserve fences %d", ret);
10211007
drm_gem_unlock_reservations(job->bos, job->bo_cnt, &acquire_ctx);
1022-
goto suspend_put;
1008+
goto cleanup_job;
10231009
}
10241010
}
10251011

@@ -1034,12 +1020,12 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
10341020
msecs_to_jiffies(HMM_RANGE_DEFAULT_TIMEOUT);
10351021
} else if (time_after(jiffies, timeout)) {
10361022
ret = -ETIME;
1037-
goto suspend_put;
1023+
goto cleanup_job;
10381024
}
10391025

10401026
ret = aie2_populate_range(abo);
10411027
if (ret)
1042-
goto suspend_put;
1028+
goto cleanup_job;
10431029
goto retry;
10441030
}
10451031
}
@@ -1065,8 +1051,6 @@ int aie2_cmd_submit(struct amdxdna_hwctx *hwctx, struct amdxdna_sched_job *job,
10651051

10661052
return 0;
10671053

1068-
suspend_put:
1069-
amdxdna_pm_suspend_put(xdna);
10701054
cleanup_job:
10711055
drm_sched_job_cleanup(&job->base);
10721056
free_chain:

drivers/accel/amdxdna/aie2_message.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,9 @@ int aie2_config_cu(struct amdxdna_hwctx *hwctx,
493493
if (!chann)
494494
return -ENODEV;
495495

496+
if (!hwctx->cus)
497+
return 0;
498+
496499
if (hwctx->cus->num_cus > MAX_NUM_CUS) {
497500
XDNA_DBG(xdna, "Exceed maximum CU %d", MAX_NUM_CUS);
498501
return -EINVAL;

drivers/accel/amdxdna/aie2_pm.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ int aie2_pm_set_dpm(struct amdxdna_dev_hdl *ndev, u32 dpm_level)
3636
return ret;
3737

3838
ret = ndev->priv->hw_ops.set_dpm(ndev, dpm_level);
39+
if (!ret)
40+
ndev->dpm_level = dpm_level;
3941
amdxdna_pm_suspend_put(ndev->xdna);
4042

4143
return ret;
@@ -65,6 +67,7 @@ int aie2_pm_init(struct amdxdna_dev_hdl *ndev)
6567
ret = ndev->priv->hw_ops.set_dpm(ndev, ndev->max_dpm_level);
6668
if (ret)
6769
return ret;
70+
ndev->dpm_level = ndev->max_dpm_level;
6871

6972
ret = aie2_pm_set_clk_gating(ndev, AIE2_CLK_GATING_ENABLE);
7073
if (ret)

drivers/accel/amdxdna/aie2_smu.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ int npu1_set_dpm(struct amdxdna_dev_hdl *ndev, u32 dpm_level)
8484
}
8585

8686
ndev->hclk_freq = freq;
87-
ndev->dpm_level = dpm_level;
8887
ndev->max_tops = 2 * ndev->total_col;
8988
ndev->curr_tops = ndev->max_tops * freq / 1028;
9089

@@ -114,7 +113,6 @@ int npu4_set_dpm(struct amdxdna_dev_hdl *ndev, u32 dpm_level)
114113

115114
ndev->npuclk_freq = ndev->priv->dpm_clk_tbl[dpm_level].npuclk;
116115
ndev->hclk_freq = ndev->priv->dpm_clk_tbl[dpm_level].hclk;
117-
ndev->dpm_level = dpm_level;
118116
ndev->max_tops = NPU4_DPM_TOPS(ndev, ndev->max_dpm_level);
119117
ndev->curr_tops = NPU4_DPM_TOPS(ndev, dpm_level);
120118

drivers/accel/amdxdna/amdxdna_ctx.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,6 @@ struct amdxdna_hwctx {
9999
u32 start_col;
100100
u32 num_col;
101101
u32 num_unused_col;
102-
#define HWCTX_STAT_INIT 0
103-
#define HWCTX_STAT_READY 1
104-
#define HWCTX_STAT_STOP 2
105-
u32 status;
106-
u32 old_status;
107102

108103
struct amdxdna_qos_info qos;
109104
struct amdxdna_hwctx_param_config_cu *cus;

drivers/accel/amdxdna/amdxdna_pci_drv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ static int amdxdna_drm_open(struct drm_device *ddev, struct drm_file *filp)
8282
ret = -ENODEV;
8383
goto unbind_sva;
8484
}
85+
client->mm = current->mm;
86+
mmgrab(client->mm);
8587
init_srcu_struct(&client->hwctx_srcu);
8688
xa_init_flags(&client->hwctx_xa, XA_FLAGS_ALLOC);
8789
mutex_init(&client->mm_lock);
@@ -116,6 +118,7 @@ static void amdxdna_client_cleanup(struct amdxdna_client *client)
116118
drm_gem_object_put(to_gobj(client->dev_heap));
117119

118120
iommu_sva_unbind_device(client->sva);
121+
mmdrop(client->mm);
119122

120123
kfree(client);
121124
}

drivers/accel/amdxdna/amdxdna_pci_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ struct amdxdna_client {
130130

131131
struct iommu_sva *sva;
132132
int pasid;
133+
struct mm_struct *mm;
133134
};
134135

135136
#define amdxdna_for_each_hwctx(client, hwctx_id, entry) \

drivers/accel/amdxdna/amdxdna_ubuf.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,21 @@ static struct sg_table *amdxdna_ubuf_map(struct dma_buf_attachment *attach,
3434
ret = sg_alloc_table_from_pages(sg, ubuf->pages, ubuf->nr_pages, 0,
3535
ubuf->nr_pages << PAGE_SHIFT, GFP_KERNEL);
3636
if (ret)
37-
return ERR_PTR(ret);
37+
goto err_free_sg;
3838

3939
if (ubuf->flags & AMDXDNA_UBUF_FLAG_MAP_DMA) {
4040
ret = dma_map_sgtable(attach->dev, sg, direction, 0);
4141
if (ret)
42-
return ERR_PTR(ret);
42+
goto err_free_table;
4343
}
4444

4545
return sg;
46+
47+
err_free_table:
48+
sg_free_table(sg);
49+
err_free_sg:
50+
kfree(sg);
51+
return ERR_PTR(ret);
4652
}
4753

4854
static void amdxdna_ubuf_unmap(struct dma_buf_attachment *attach,

drivers/gpu/drm/bridge/imx/imx8qxp-pixel-combiner.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ static int imx8qxp_pc_bridge_probe(struct platform_device *pdev)
348348
free_child:
349349
of_node_put(child);
350350

351-
if (i == 1 && pc->ch[0]->bridge.next_bridge)
351+
if (i == 1 && pc->ch[0] && pc->ch[0]->bridge.next_bridge)
352352
drm_bridge_remove(&pc->ch[0]->bridge);
353353

354354
pm_runtime_disable(dev);

drivers/gpu/drm/nouveau/nouveau_drv.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
#define DRIVER_MAJOR 1
1212
#define DRIVER_MINOR 4
13-
#define DRIVER_PATCHLEVEL 1
13+
#define DRIVER_PATCHLEVEL 2
1414

1515
/*
1616
* 1.1.1:
@@ -37,6 +37,8 @@
3737
* - implemented limited ABI16/NVIF interop
3838
* 1.4.1:
3939
* - add variable page sizes and compression for Turing+
40+
* 1.4.2:
41+
* - tell userspace LPTE/SPTE races are fixed.
4042
*/
4143

4244
#include <linux/notifier.h>

0 commit comments

Comments
 (0)