Skip to content

Commit 1b24b3c

Browse files
committed
Merge tag 'drm-misc-fixes-2024-04-11' of https://gitlab.freedesktop.org/drm/misc/kernel into drm-fixes
Short summary of fixes pull: ast: - Fix soft lockup client: - Protect connector modes with mode_config mutex host1x: - Do not setup DMA for virtual addresses ivpu: - Fix deadlock in context_xa - PCI fixes - Fixes to error handling nouveau: - gsp: Fix OOB access - Fix casting panfrost: - Fix error path in MMU code qxl: - Revert "drm/qxl: simplify qxl_fence_wait" vmwgfx: - Enable DMA for SEV mappings Signed-off-by: Dave Airlie <[email protected]> From: Thomas Zimmermann <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents b4589db + 4c08f01 commit 1b24b3c

File tree

17 files changed

+125
-75
lines changed

17 files changed

+125
-75
lines changed

drivers/accel/ivpu/ivpu_drv.c

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (C) 2020-2023 Intel Corporation
3+
* Copyright (C) 2020-2024 Intel Corporation
44
*/
55

66
#include <linux/firmware.h>
@@ -131,22 +131,6 @@ static int ivpu_get_capabilities(struct ivpu_device *vdev, struct drm_ivpu_param
131131
return 0;
132132
}
133133

134-
static int ivpu_get_core_clock_rate(struct ivpu_device *vdev, u64 *clk_rate)
135-
{
136-
int ret;
137-
138-
ret = ivpu_rpm_get_if_active(vdev);
139-
if (ret < 0)
140-
return ret;
141-
142-
*clk_rate = ret ? ivpu_hw_reg_pll_freq_get(vdev) : 0;
143-
144-
if (ret)
145-
ivpu_rpm_put(vdev);
146-
147-
return 0;
148-
}
149-
150134
static int ivpu_get_param_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
151135
{
152136
struct ivpu_file_priv *file_priv = file->driver_priv;
@@ -170,7 +154,7 @@ static int ivpu_get_param_ioctl(struct drm_device *dev, void *data, struct drm_f
170154
args->value = vdev->platform;
171155
break;
172156
case DRM_IVPU_PARAM_CORE_CLOCK_RATE:
173-
ret = ivpu_get_core_clock_rate(vdev, &args->value);
157+
args->value = ivpu_hw_ratio_to_freq(vdev, vdev->hw->pll.max_ratio);
174158
break;
175159
case DRM_IVPU_PARAM_NUM_CONTEXTS:
176160
args->value = ivpu_get_context_count(vdev);
@@ -387,12 +371,15 @@ int ivpu_shutdown(struct ivpu_device *vdev)
387371
{
388372
int ret;
389373

390-
ivpu_prepare_for_reset(vdev);
374+
/* Save PCI state before powering down as it sometimes gets corrupted if NPU hangs */
375+
pci_save_state(to_pci_dev(vdev->drm.dev));
391376

392377
ret = ivpu_hw_power_down(vdev);
393378
if (ret)
394379
ivpu_warn(vdev, "Failed to power down HW: %d\n", ret);
395380

381+
pci_set_power_state(to_pci_dev(vdev->drm.dev), PCI_D3hot);
382+
396383
return ret;
397384
}
398385

@@ -530,7 +517,7 @@ static int ivpu_dev_init(struct ivpu_device *vdev)
530517
vdev->context_xa_limit.min = IVPU_USER_CONTEXT_MIN_SSID;
531518
vdev->context_xa_limit.max = IVPU_USER_CONTEXT_MAX_SSID;
532519
atomic64_set(&vdev->unique_id_counter, 0);
533-
xa_init_flags(&vdev->context_xa, XA_FLAGS_ALLOC);
520+
xa_init_flags(&vdev->context_xa, XA_FLAGS_ALLOC | XA_FLAGS_LOCK_IRQ);
534521
xa_init_flags(&vdev->submitted_jobs_xa, XA_FLAGS_ALLOC1);
535522
xa_init_flags(&vdev->db_xa, XA_FLAGS_ALLOC1);
536523
lockdep_set_class(&vdev->submitted_jobs_xa.xa_lock, &submitted_jobs_xa_lock_class_key);
@@ -560,11 +547,11 @@ static int ivpu_dev_init(struct ivpu_device *vdev)
560547
/* Power up early so the rest of init code can access VPU registers */
561548
ret = ivpu_hw_power_up(vdev);
562549
if (ret)
563-
goto err_power_down;
550+
goto err_shutdown;
564551

565552
ret = ivpu_mmu_global_context_init(vdev);
566553
if (ret)
567-
goto err_power_down;
554+
goto err_shutdown;
568555

569556
ret = ivpu_mmu_init(vdev);
570557
if (ret)
@@ -601,10 +588,8 @@ static int ivpu_dev_init(struct ivpu_device *vdev)
601588
ivpu_mmu_reserved_context_fini(vdev);
602589
err_mmu_gctx_fini:
603590
ivpu_mmu_global_context_fini(vdev);
604-
err_power_down:
605-
ivpu_hw_power_down(vdev);
606-
if (IVPU_WA(d3hot_after_power_off))
607-
pci_set_power_state(to_pci_dev(vdev->drm.dev), PCI_D3hot);
591+
err_shutdown:
592+
ivpu_shutdown(vdev);
608593
err_xa_destroy:
609594
xa_destroy(&vdev->db_xa);
610595
xa_destroy(&vdev->submitted_jobs_xa);
@@ -628,9 +613,8 @@ static void ivpu_bo_unbind_all_user_contexts(struct ivpu_device *vdev)
628613
static void ivpu_dev_fini(struct ivpu_device *vdev)
629614
{
630615
ivpu_pm_disable(vdev);
616+
ivpu_prepare_for_reset(vdev);
631617
ivpu_shutdown(vdev);
632-
if (IVPU_WA(d3hot_after_power_off))
633-
pci_set_power_state(to_pci_dev(vdev->drm.dev), PCI_D3hot);
634618

635619
ivpu_jobs_abort_all(vdev);
636620
ivpu_job_done_consumer_fini(vdev);

drivers/accel/ivpu/ivpu_drv.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
/*
3-
* Copyright (C) 2020-2023 Intel Corporation
3+
* Copyright (C) 2020-2024 Intel Corporation
44
*/
55

66
#ifndef __IVPU_DRV_H__
@@ -90,7 +90,6 @@
9090
struct ivpu_wa_table {
9191
bool punit_disabled;
9292
bool clear_runtime_mem;
93-
bool d3hot_after_power_off;
9493
bool interrupt_clear_with_0;
9594
bool disable_clock_relinquish;
9695
bool disable_d0i3_msg;

drivers/accel/ivpu/ivpu_hw.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct ivpu_hw_ops {
2121
u32 (*profiling_freq_get)(struct ivpu_device *vdev);
2222
void (*profiling_freq_drive)(struct ivpu_device *vdev, bool enable);
2323
u32 (*reg_pll_freq_get)(struct ivpu_device *vdev);
24+
u32 (*ratio_to_freq)(struct ivpu_device *vdev, u32 ratio);
2425
u32 (*reg_telemetry_offset_get)(struct ivpu_device *vdev);
2526
u32 (*reg_telemetry_size_get)(struct ivpu_device *vdev);
2627
u32 (*reg_telemetry_enable_get)(struct ivpu_device *vdev);
@@ -130,6 +131,11 @@ static inline u32 ivpu_hw_reg_pll_freq_get(struct ivpu_device *vdev)
130131
return vdev->hw->ops->reg_pll_freq_get(vdev);
131132
};
132133

134+
static inline u32 ivpu_hw_ratio_to_freq(struct ivpu_device *vdev, u32 ratio)
135+
{
136+
return vdev->hw->ops->ratio_to_freq(vdev, ratio);
137+
}
138+
133139
static inline u32 ivpu_hw_reg_telemetry_offset_get(struct ivpu_device *vdev)
134140
{
135141
return vdev->hw->ops->reg_telemetry_offset_get(vdev);

drivers/accel/ivpu/ivpu_hw_37xx.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (C) 2020-2023 Intel Corporation
3+
* Copyright (C) 2020-2024 Intel Corporation
44
*/
55

66
#include "ivpu_drv.h"
@@ -75,7 +75,6 @@ static void ivpu_hw_wa_init(struct ivpu_device *vdev)
7575
{
7676
vdev->wa.punit_disabled = false;
7777
vdev->wa.clear_runtime_mem = false;
78-
vdev->wa.d3hot_after_power_off = true;
7978

8079
REGB_WR32(VPU_37XX_BUTTRESS_INTERRUPT_STAT, BUTTRESS_ALL_IRQ_MASK);
8180
if (REGB_RD32(VPU_37XX_BUTTRESS_INTERRUPT_STAT) == BUTTRESS_ALL_IRQ_MASK) {
@@ -86,7 +85,6 @@ static void ivpu_hw_wa_init(struct ivpu_device *vdev)
8685

8786
IVPU_PRINT_WA(punit_disabled);
8887
IVPU_PRINT_WA(clear_runtime_mem);
89-
IVPU_PRINT_WA(d3hot_after_power_off);
9088
IVPU_PRINT_WA(interrupt_clear_with_0);
9189
}
9290

@@ -805,12 +803,12 @@ static void ivpu_hw_37xx_profiling_freq_drive(struct ivpu_device *vdev, bool ena
805803
/* Profiling freq - is a debug feature. Unavailable on VPU 37XX. */
806804
}
807805

808-
static u32 ivpu_hw_37xx_pll_to_freq(u32 ratio, u32 config)
806+
static u32 ivpu_hw_37xx_ratio_to_freq(struct ivpu_device *vdev, u32 ratio)
809807
{
810808
u32 pll_clock = PLL_REF_CLK_FREQ * ratio;
811809
u32 cpu_clock;
812810

813-
if ((config & 0xff) == PLL_RATIO_4_3)
811+
if ((vdev->hw->config & 0xff) == PLL_RATIO_4_3)
814812
cpu_clock = pll_clock * 2 / 4;
815813
else
816814
cpu_clock = pll_clock * 2 / 5;
@@ -829,7 +827,7 @@ static u32 ivpu_hw_37xx_reg_pll_freq_get(struct ivpu_device *vdev)
829827
if (!ivpu_is_silicon(vdev))
830828
return PLL_SIMULATION_FREQ;
831829

832-
return ivpu_hw_37xx_pll_to_freq(pll_curr_ratio, vdev->hw->config);
830+
return ivpu_hw_37xx_ratio_to_freq(vdev, pll_curr_ratio);
833831
}
834832

835833
static u32 ivpu_hw_37xx_reg_telemetry_offset_get(struct ivpu_device *vdev)
@@ -1052,6 +1050,7 @@ const struct ivpu_hw_ops ivpu_hw_37xx_ops = {
10521050
.profiling_freq_get = ivpu_hw_37xx_profiling_freq_get,
10531051
.profiling_freq_drive = ivpu_hw_37xx_profiling_freq_drive,
10541052
.reg_pll_freq_get = ivpu_hw_37xx_reg_pll_freq_get,
1053+
.ratio_to_freq = ivpu_hw_37xx_ratio_to_freq,
10551054
.reg_telemetry_offset_get = ivpu_hw_37xx_reg_telemetry_offset_get,
10561055
.reg_telemetry_size_get = ivpu_hw_37xx_reg_telemetry_size_get,
10571056
.reg_telemetry_enable_get = ivpu_hw_37xx_reg_telemetry_enable_get,

drivers/accel/ivpu/ivpu_hw_40xx.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,11 @@ static u32 ivpu_hw_40xx_reg_pll_freq_get(struct ivpu_device *vdev)
980980
return PLL_RATIO_TO_FREQ(pll_curr_ratio);
981981
}
982982

983+
static u32 ivpu_hw_40xx_ratio_to_freq(struct ivpu_device *vdev, u32 ratio)
984+
{
985+
return PLL_RATIO_TO_FREQ(ratio);
986+
}
987+
983988
static u32 ivpu_hw_40xx_reg_telemetry_offset_get(struct ivpu_device *vdev)
984989
{
985990
return REGB_RD32(VPU_40XX_BUTTRESS_VPU_TELEMETRY_OFFSET);
@@ -1230,6 +1235,7 @@ const struct ivpu_hw_ops ivpu_hw_40xx_ops = {
12301235
.profiling_freq_get = ivpu_hw_40xx_profiling_freq_get,
12311236
.profiling_freq_drive = ivpu_hw_40xx_profiling_freq_drive,
12321237
.reg_pll_freq_get = ivpu_hw_40xx_reg_pll_freq_get,
1238+
.ratio_to_freq = ivpu_hw_40xx_ratio_to_freq,
12331239
.reg_telemetry_offset_get = ivpu_hw_40xx_reg_telemetry_offset_get,
12341240
.reg_telemetry_size_get = ivpu_hw_40xx_reg_telemetry_size_get,
12351241
.reg_telemetry_enable_get = ivpu_hw_40xx_reg_telemetry_enable_get,

drivers/accel/ivpu/ivpu_ipc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (C) 2020-2023 Intel Corporation
3+
* Copyright (C) 2020-2024 Intel Corporation
44
*/
55

66
#include <linux/genalloc.h>
@@ -501,7 +501,11 @@ int ivpu_ipc_init(struct ivpu_device *vdev)
501501
spin_lock_init(&ipc->cons_lock);
502502
INIT_LIST_HEAD(&ipc->cons_list);
503503
INIT_LIST_HEAD(&ipc->cb_msg_list);
504-
drmm_mutex_init(&vdev->drm, &ipc->lock);
504+
ret = drmm_mutex_init(&vdev->drm, &ipc->lock);
505+
if (ret) {
506+
ivpu_err(vdev, "Failed to initialize ipc->lock, ret %d\n", ret);
507+
goto err_free_rx;
508+
}
505509
ivpu_ipc_reset(vdev);
506510
return 0;
507511

drivers/accel/ivpu/ivpu_mmu.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,23 +278,23 @@ static const char *ivpu_mmu_event_to_str(u32 cmd)
278278
case IVPU_MMU_EVT_F_VMS_FETCH:
279279
return "Fetch of VMS caused external abort";
280280
default:
281-
return "Unknown CMDQ command";
281+
return "Unknown event";
282282
}
283283
}
284284

285285
static const char *ivpu_mmu_cmdq_err_to_str(u32 err)
286286
{
287287
switch (err) {
288288
case IVPU_MMU_CERROR_NONE:
289-
return "No CMDQ Error";
289+
return "No error";
290290
case IVPU_MMU_CERROR_ILL:
291291
return "Illegal command";
292292
case IVPU_MMU_CERROR_ABT:
293-
return "External abort on CMDQ read";
293+
return "External abort on command queue read";
294294
case IVPU_MMU_CERROR_ATC_INV_SYNC:
295295
return "Sync failed to complete ATS invalidation";
296296
default:
297-
return "Unknown CMDQ Error";
297+
return "Unknown error";
298298
}
299299
}
300300

drivers/accel/ivpu/ivpu_pm.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
3-
* Copyright (C) 2020-2023 Intel Corporation
3+
* Copyright (C) 2020-2024 Intel Corporation
44
*/
55

66
#include <linux/highmem.h>
@@ -58,14 +58,11 @@ static int ivpu_suspend(struct ivpu_device *vdev)
5858
{
5959
int ret;
6060

61-
/* Save PCI state before powering down as it sometimes gets corrupted if NPU hangs */
62-
pci_save_state(to_pci_dev(vdev->drm.dev));
61+
ivpu_prepare_for_reset(vdev);
6362

6463
ret = ivpu_shutdown(vdev);
6564
if (ret)
66-
ivpu_err(vdev, "Failed to shutdown VPU: %d\n", ret);
67-
68-
pci_set_power_state(to_pci_dev(vdev->drm.dev), PCI_D3hot);
65+
ivpu_err(vdev, "Failed to shutdown NPU: %d\n", ret);
6966

7067
return ret;
7168
}
@@ -74,10 +71,10 @@ static int ivpu_resume(struct ivpu_device *vdev)
7471
{
7572
int ret;
7673

77-
pci_set_power_state(to_pci_dev(vdev->drm.dev), PCI_D0);
74+
retry:
7875
pci_restore_state(to_pci_dev(vdev->drm.dev));
76+
pci_set_power_state(to_pci_dev(vdev->drm.dev), PCI_D0);
7977

80-
retry:
8178
ret = ivpu_hw_power_up(vdev);
8279
if (ret) {
8380
ivpu_err(vdev, "Failed to power up HW: %d\n", ret);
@@ -100,6 +97,7 @@ static int ivpu_resume(struct ivpu_device *vdev)
10097
ivpu_mmu_disable(vdev);
10198
err_power_down:
10299
ivpu_hw_power_down(vdev);
100+
pci_set_power_state(to_pci_dev(vdev->drm.dev), PCI_D3hot);
103101

104102
if (!ivpu_fw_is_cold_boot(vdev)) {
105103
ivpu_pm_prepare_cold_boot(vdev);

drivers/gpu/drm/ast/ast_dp.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
180180
{
181181
struct ast_device *ast = to_ast_device(dev);
182182
u8 video_on_off = on;
183+
u32 i = 0;
183184

184185
// Video On/Off
185186
ast_set_index_reg_mask(ast, AST_IO_VGACRI, 0xE3, (u8) ~AST_DP_VIDEO_ENABLE, on);
@@ -192,6 +193,8 @@ void ast_dp_set_on_off(struct drm_device *dev, bool on)
192193
ASTDP_MIRROR_VIDEO_ENABLE) != video_on_off) {
193194
// wait 1 ms
194195
mdelay(1);
196+
if (++i > 200)
197+
break;
195198
}
196199
}
197200
}

drivers/gpu/drm/drm_client_modeset.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
777777
unsigned int total_modes_count = 0;
778778
struct drm_client_offset *offsets;
779779
unsigned int connector_count = 0;
780+
/* points to modes protected by mode_config.mutex */
780781
struct drm_display_mode **modes;
781782
struct drm_crtc **crtcs;
782783
int i, ret = 0;
@@ -845,7 +846,6 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
845846
drm_client_pick_crtcs(client, connectors, connector_count,
846847
crtcs, modes, 0, width, height);
847848
}
848-
mutex_unlock(&dev->mode_config.mutex);
849849

850850
drm_client_modeset_release(client);
851851

@@ -875,6 +875,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
875875
modeset->y = offset->y;
876876
}
877877
}
878+
mutex_unlock(&dev->mode_config.mutex);
878879

879880
mutex_unlock(&client->modeset_mutex);
880881
out:

0 commit comments

Comments
 (0)