Skip to content

Commit bcd8430

Browse files
committed
Merge tag 'drm-misc-fixes-2023-06-08' of git://anongit.freedesktop.org/drm/drm-misc into drm-fixes
drm-misc-fixes for v6.4-rc6: - resume and modeset fixes for ast. - Fill in fb-helper vars more correctly. - Assorted ivpu fixes. - lima context destroy fix. Signed-off-by: Dave Airlie <[email protected]> From: Maarten Lankhorst <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 02b8f0b + a3efabe commit bcd8430

File tree

13 files changed

+90
-84
lines changed

13 files changed

+90
-84
lines changed

drivers/accel/ivpu/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ config DRM_ACCEL_IVPU
77
depends on PCI && PCI_MSI
88
select FW_LOADER
99
select SHMEM
10+
select GENERIC_ALLOCATOR
1011
help
1112
Choose this option if you have a system that has an 14th generation Intel CPU
1213
or newer. VPU stands for Versatile Processing Unit and it's a CPU-integrated

drivers/accel/ivpu/ivpu_hw_mtl.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ static void ivpu_pll_init_frequency_ratios(struct ivpu_device *vdev)
197197
hw->pll.pn_ratio = clamp_t(u8, fuse_pn_ratio, hw->pll.min_ratio, hw->pll.max_ratio);
198198
}
199199

200+
static int ivpu_hw_mtl_wait_for_vpuip_bar(struct ivpu_device *vdev)
201+
{
202+
return REGV_POLL_FLD(MTL_VPU_HOST_SS_CPR_RST_CLR, AON, 0, 100);
203+
}
204+
200205
static int ivpu_pll_drive(struct ivpu_device *vdev, bool enable)
201206
{
202207
struct ivpu_hw_info *hw = vdev->hw;
@@ -239,6 +244,12 @@ static int ivpu_pll_drive(struct ivpu_device *vdev, bool enable)
239244
ivpu_err(vdev, "Timed out waiting for PLL ready status\n");
240245
return ret;
241246
}
247+
248+
ret = ivpu_hw_mtl_wait_for_vpuip_bar(vdev);
249+
if (ret) {
250+
ivpu_err(vdev, "Timed out waiting for VPUIP bar\n");
251+
return ret;
252+
}
242253
}
243254

244255
return 0;
@@ -256,7 +267,7 @@ static int ivpu_pll_disable(struct ivpu_device *vdev)
256267

257268
static void ivpu_boot_host_ss_rst_clr_assert(struct ivpu_device *vdev)
258269
{
259-
u32 val = REGV_RD32(MTL_VPU_HOST_SS_CPR_RST_CLR);
270+
u32 val = 0;
260271

261272
val = REG_SET_FLD(MTL_VPU_HOST_SS_CPR_RST_CLR, TOP_NOC, val);
262273
val = REG_SET_FLD(MTL_VPU_HOST_SS_CPR_RST_CLR, DSS_MAS, val);
@@ -754,18 +765,19 @@ static int ivpu_hw_mtl_power_down(struct ivpu_device *vdev)
754765
{
755766
int ret = 0;
756767

757-
if (ivpu_hw_mtl_reset(vdev)) {
768+
if (!ivpu_hw_mtl_is_idle(vdev) && ivpu_hw_mtl_reset(vdev)) {
758769
ivpu_err(vdev, "Failed to reset the VPU\n");
759-
ret = -EIO;
760770
}
761771

762772
if (ivpu_pll_disable(vdev)) {
763773
ivpu_err(vdev, "Failed to disable PLL\n");
764774
ret = -EIO;
765775
}
766776

767-
if (ivpu_hw_mtl_d0i3_enable(vdev))
768-
ivpu_warn(vdev, "Failed to enable D0I3\n");
777+
if (ivpu_hw_mtl_d0i3_enable(vdev)) {
778+
ivpu_err(vdev, "Failed to enter D0I3\n");
779+
ret = -EIO;
780+
}
769781

770782
return ret;
771783
}

drivers/accel/ivpu/ivpu_hw_mtl_reg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#define MTL_VPU_HOST_SS_CPR_RST_SET_MSS_MAS_MASK BIT_MASK(11)
9292

9393
#define MTL_VPU_HOST_SS_CPR_RST_CLR 0x00000098u
94+
#define MTL_VPU_HOST_SS_CPR_RST_CLR_AON_MASK BIT_MASK(0)
9495
#define MTL_VPU_HOST_SS_CPR_RST_CLR_TOP_NOC_MASK BIT_MASK(1)
9596
#define MTL_VPU_HOST_SS_CPR_RST_CLR_DSS_MAS_MASK BIT_MASK(10)
9697
#define MTL_VPU_HOST_SS_CPR_RST_CLR_MSS_MAS_MASK BIT_MASK(11)

drivers/accel/ivpu/ivpu_ipc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,7 @@ ivpu_ipc_send(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons, struct v
183183
struct ivpu_ipc_info *ipc = vdev->ipc;
184184
int ret;
185185

186-
ret = mutex_lock_interruptible(&ipc->lock);
187-
if (ret)
188-
return ret;
186+
mutex_lock(&ipc->lock);
189187

190188
if (!ipc->on) {
191189
ret = -EAGAIN;

drivers/accel/ivpu/ivpu_job.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -431,6 +431,7 @@ ivpu_job_prepare_bos_for_submit(struct drm_file *file, struct ivpu_job *job, u32
431431
struct ivpu_file_priv *file_priv = file->driver_priv;
432432
struct ivpu_device *vdev = file_priv->vdev;
433433
struct ww_acquire_ctx acquire_ctx;
434+
enum dma_resv_usage usage;
434435
struct ivpu_bo *bo;
435436
int ret;
436437
u32 i;
@@ -461,22 +462,28 @@ ivpu_job_prepare_bos_for_submit(struct drm_file *file, struct ivpu_job *job, u32
461462

462463
job->cmd_buf_vpu_addr = bo->vpu_addr + commands_offset;
463464

464-
ret = drm_gem_lock_reservations((struct drm_gem_object **)job->bos, 1, &acquire_ctx);
465+
ret = drm_gem_lock_reservations((struct drm_gem_object **)job->bos, buf_count,
466+
&acquire_ctx);
465467
if (ret) {
466468
ivpu_warn(vdev, "Failed to lock reservations: %d\n", ret);
467469
return ret;
468470
}
469471

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;
472+
for (i = 0; i < buf_count; i++) {
473+
ret = dma_resv_reserve_fences(job->bos[i]->base.resv, 1);
474+
if (ret) {
475+
ivpu_warn(vdev, "Failed to reserve fences: %d\n", ret);
476+
goto unlock_reservations;
477+
}
474478
}
475479

476-
dma_resv_add_fence(bo->base.resv, job->done_fence, DMA_RESV_USAGE_WRITE);
480+
for (i = 0; i < buf_count; i++) {
481+
usage = (i == CMD_BUF_IDX) ? DMA_RESV_USAGE_WRITE : DMA_RESV_USAGE_BOOKKEEP;
482+
dma_resv_add_fence(job->bos[i]->base.resv, job->done_fence, usage);
483+
}
477484

478485
unlock_reservations:
479-
drm_gem_unlock_reservations((struct drm_gem_object **)job->bos, 1, &acquire_ctx);
486+
drm_gem_unlock_reservations((struct drm_gem_object **)job->bos, buf_count, &acquire_ctx);
480487

481488
wmb(); /* Flush write combining buffers */
482489

drivers/accel/ivpu/ivpu_mmu.c

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -587,16 +587,11 @@ static int ivpu_mmu_strtab_init(struct ivpu_device *vdev)
587587
int ivpu_mmu_invalidate_tlb(struct ivpu_device *vdev, u16 ssid)
588588
{
589589
struct ivpu_mmu_info *mmu = vdev->mmu;
590-
int ret;
591-
592-
ret = mutex_lock_interruptible(&mmu->lock);
593-
if (ret)
594-
return ret;
590+
int ret = 0;
595591

596-
if (!mmu->on) {
597-
ret = 0;
592+
mutex_lock(&mmu->lock);
593+
if (!mmu->on)
598594
goto unlock;
599-
}
600595

601596
ret = ivpu_mmu_cmdq_write_tlbi_nh_asid(vdev, ssid);
602597
if (ret)
@@ -614,7 +609,7 @@ static int ivpu_mmu_cd_add(struct ivpu_device *vdev, u32 ssid, u64 cd_dma)
614609
struct ivpu_mmu_cdtab *cdtab = &mmu->cdtab;
615610
u64 *entry;
616611
u64 cd[4];
617-
int ret;
612+
int ret = 0;
618613

619614
if (ssid > IVPU_MMU_CDTAB_ENT_COUNT)
620615
return -EINVAL;
@@ -655,14 +650,9 @@ static int ivpu_mmu_cd_add(struct ivpu_device *vdev, u32 ssid, u64 cd_dma)
655650
ivpu_dbg(vdev, MMU, "CDTAB %s entry (SSID=%u, dma=%pad): 0x%llx, 0x%llx, 0x%llx, 0x%llx\n",
656651
cd_dma ? "write" : "clear", ssid, &cd_dma, cd[0], cd[1], cd[2], cd[3]);
657652

658-
ret = mutex_lock_interruptible(&mmu->lock);
659-
if (ret)
660-
return ret;
661-
662-
if (!mmu->on) {
663-
ret = 0;
653+
mutex_lock(&mmu->lock);
654+
if (!mmu->on)
664655
goto unlock;
665-
}
666656

667657
ret = ivpu_mmu_cmdq_write_cfgi_all(vdev);
668658
if (ret)

drivers/gpu/drm/ast/ast_dp.c

Lines changed: 17 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -119,53 +119,32 @@ int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata)
119119
/*
120120
* Launch Aspeed DP
121121
*/
122-
void ast_dp_launch(struct drm_device *dev, u8 bPower)
122+
void ast_dp_launch(struct drm_device *dev)
123123
{
124-
u32 i = 0, j = 0, WaitCount = 1;
125-
u8 bDPTX = 0;
124+
u32 i = 0;
126125
u8 bDPExecute = 1;
127-
128126
struct ast_device *ast = to_ast_device(dev);
129-
// S3 come back, need more time to wait BMC ready.
130-
if (bPower)
131-
WaitCount = 300;
132-
133-
134-
// Wait total count by different condition.
135-
for (j = 0; j < WaitCount; j++) {
136-
bDPTX = ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, TX_TYPE_MASK);
137-
138-
if (bDPTX)
139-
break;
140127

128+
// Wait one second then timeout.
129+
while (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, ASTDP_MCU_FW_EXECUTING) !=
130+
ASTDP_MCU_FW_EXECUTING) {
131+
i++;
132+
// wait 100 ms
141133
msleep(100);
142-
}
143134

144-
// 0xE : ASTDP with DPMCU FW handling
145-
if (bDPTX == ASTDP_DPMCU_TX) {
146-
// Wait one second then timeout.
147-
i = 0;
148-
149-
while (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, COPROCESSOR_LAUNCH) !=
150-
COPROCESSOR_LAUNCH) {
151-
i++;
152-
// wait 100 ms
153-
msleep(100);
154-
155-
if (i >= 10) {
156-
// DP would not be ready.
157-
bDPExecute = 0;
158-
break;
159-
}
135+
if (i >= 10) {
136+
// DP would not be ready.
137+
bDPExecute = 0;
138+
break;
160139
}
140+
}
161141

162-
if (bDPExecute)
163-
ast->tx_chip_types |= BIT(AST_TX_ASTDP);
142+
if (!bDPExecute)
143+
drm_err(dev, "Wait DPMCU executing timeout\n");
164144

165-
ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xE5,
166-
(u8) ~ASTDP_HOST_EDID_READ_DONE_MASK,
167-
ASTDP_HOST_EDID_READ_DONE);
168-
}
145+
ast_set_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xE5,
146+
(u8) ~ASTDP_HOST_EDID_READ_DONE_MASK,
147+
ASTDP_HOST_EDID_READ_DONE);
169148
}
170149

171150

drivers/gpu/drm/ast/ast_drv.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,6 @@ int ast_mode_config_init(struct ast_device *ast);
350350
#define AST_DP501_LINKRATE 0xf014
351351
#define AST_DP501_EDID_DATA 0xf020
352352

353-
/* Define for Soc scratched reg */
354-
#define COPROCESSOR_LAUNCH BIT(5)
355-
356353
/*
357354
* Display Transmitter Type:
358355
*/
@@ -480,7 +477,7 @@ struct ast_i2c_chan *ast_i2c_create(struct drm_device *dev);
480477

481478
/* aspeed DP */
482479
int ast_astdp_read_edid(struct drm_device *dev, u8 *ediddata);
483-
void ast_dp_launch(struct drm_device *dev, u8 bPower);
480+
void ast_dp_launch(struct drm_device *dev);
484481
void ast_dp_power_on_off(struct drm_device *dev, bool no);
485482
void ast_dp_set_on_off(struct drm_device *dev, bool no);
486483
void ast_dp_set_mode(struct drm_crtc *crtc, struct ast_vbios_mode_info *vbios_mode);

drivers/gpu/drm/ast/ast_main.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,13 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
254254
case 0x0c:
255255
ast->tx_chip_types = AST_TX_DP501_BIT;
256256
}
257-
} else if (ast->chip == AST2600)
258-
ast_dp_launch(&ast->base, 0);
257+
} else if (ast->chip == AST2600) {
258+
if (ast_get_index_reg_mask(ast, AST_IO_CRTC_PORT, 0xD1, TX_TYPE_MASK) ==
259+
ASTDP_DPMCU_TX) {
260+
ast->tx_chip_types = AST_TX_ASTDP_BIT;
261+
ast_dp_launch(&ast->base);
262+
}
263+
}
259264

260265
/* Print stuff for diagnostic purposes */
261266
if (ast->tx_chip_types & AST_TX_NONE_BIT)
@@ -264,6 +269,8 @@ static int ast_detect_chip(struct drm_device *dev, bool *need_post)
264269
drm_info(dev, "Using Sil164 TMDS transmitter\n");
265270
if (ast->tx_chip_types & AST_TX_DP501_BIT)
266271
drm_info(dev, "Using DP501 DisplayPort transmitter\n");
272+
if (ast->tx_chip_types & AST_TX_ASTDP_BIT)
273+
drm_info(dev, "Using ASPEED DisplayPort transmitter\n");
267274

268275
return 0;
269276
}

drivers/gpu/drm/ast/ast_mode.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,8 @@ static int ast_dp501_output_init(struct ast_device *ast)
16471647
static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
16481648
{
16491649
void *edid;
1650+
struct drm_device *dev = connector->dev;
1651+
struct ast_device *ast = to_ast_device(dev);
16501652

16511653
int succ;
16521654
int count;
@@ -1655,17 +1657,26 @@ static int ast_astdp_connector_helper_get_modes(struct drm_connector *connector)
16551657
if (!edid)
16561658
goto err_drm_connector_update_edid_property;
16571659

1660+
/*
1661+
* Protect access to I/O registers from concurrent modesetting
1662+
* by acquiring the I/O-register lock.
1663+
*/
1664+
mutex_lock(&ast->ioregs_lock);
1665+
16581666
succ = ast_astdp_read_edid(connector->dev, edid);
16591667
if (succ < 0)
1660-
goto err_kfree;
1668+
goto err_mutex_unlock;
1669+
1670+
mutex_unlock(&ast->ioregs_lock);
16611671

16621672
drm_connector_update_edid_property(connector, edid);
16631673
count = drm_add_edid_modes(connector, edid);
16641674
kfree(edid);
16651675

16661676
return count;
16671677

1668-
err_kfree:
1678+
err_mutex_unlock:
1679+
mutex_unlock(&ast->ioregs_lock);
16691680
kfree(edid);
16701681
err_drm_connector_update_edid_property:
16711682
drm_connector_update_edid_property(connector, NULL);

0 commit comments

Comments
 (0)