Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'exynos-drm-next-for-v5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/daeinki/drm-exynos into drm-next

Two cleanups
- These patches make Exynos DRM driver to use pm_runtime_resume_and_get()
function instead of m_runtime_get_sync() to deal with usage counter.
pm_runtime_get_sync() increases the usage counter even when it failed,
which could make callers to forget to decrease the usage counter.
pm_runtime_resume_and_get() decreases the usage counter regardless of
whether it failed or not.

Signed-off-by: Dave Airlie <airlied@redhat.com>

From: Inki Dae <inki.dae@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210611025939.393282-1-inki.dae@samsung.com

+86 -22
+6 -1
drivers/gpu/drm/exynos/exynos5433_drm_decon.c
··· 513 513 static void decon_atomic_enable(struct exynos_drm_crtc *crtc) 514 514 { 515 515 struct decon_context *ctx = crtc->ctx; 516 + int ret; 516 517 517 - pm_runtime_get_sync(ctx->dev); 518 + ret = pm_runtime_resume_and_get(ctx->dev); 519 + if (ret < 0) { 520 + DRM_DEV_ERROR(ctx->dev, "failed to enable DECON device.\n"); 521 + return; 522 + } 518 523 519 524 exynos_drm_pipe_clk_enable(crtc, true); 520 525
+6 -1
drivers/gpu/drm/exynos/exynos7_drm_decon.c
··· 531 531 static void decon_atomic_enable(struct exynos_drm_crtc *crtc) 532 532 { 533 533 struct decon_context *ctx = crtc->ctx; 534 + int ret; 534 535 535 536 if (!ctx->suspended) 536 537 return; 537 538 538 - pm_runtime_get_sync(ctx->dev); 539 + ret = pm_runtime_resume_and_get(ctx->dev); 540 + if (ret < 0) { 541 + DRM_DEV_ERROR(ctx->dev, "failed to enable DECON device.\n"); 542 + return; 543 + } 539 544 540 545 decon_init(ctx); 541 546
+6 -1
drivers/gpu/drm/exynos/exynos_drm_dsi.c
··· 1383 1383 if (dsi->state & DSIM_STATE_ENABLED) 1384 1384 return; 1385 1385 1386 - pm_runtime_get_sync(dsi->dev); 1386 + ret = pm_runtime_resume_and_get(dsi->dev); 1387 + if (ret < 0) { 1388 + dev_err(dsi->dev, "failed to enable DSI device.\n"); 1389 + return; 1390 + } 1391 + 1387 1392 dsi->state |= DSIM_STATE_ENABLED; 1388 1393 1389 1394 if (dsi->panel) {
+7 -1
drivers/gpu/drm/exynos/exynos_drm_fimc.c
··· 1085 1085 { 1086 1086 struct fimc_context *ctx = 1087 1087 container_of(ipp, struct fimc_context, ipp); 1088 + int ret; 1088 1089 1089 - pm_runtime_get_sync(ctx->dev); 1090 + ret = pm_runtime_resume_and_get(ctx->dev); 1091 + if (ret < 0) { 1092 + dev_err(ctx->dev, "failed to enable FIMC device.\n"); 1093 + return ret; 1094 + } 1095 + 1090 1096 ctx->task = task; 1091 1097 1092 1098 fimc_src_set_fmt(ctx, task->src.buf.fourcc, task->src.buf.modifier);
+20 -5
drivers/gpu/drm/exynos/exynos_drm_fimd.c
··· 343 343 writel(val, ctx->regs + SHADOWCON); 344 344 } 345 345 346 - static void fimd_clear_channels(struct exynos_drm_crtc *crtc) 346 + static int fimd_clear_channels(struct exynos_drm_crtc *crtc) 347 347 { 348 348 struct fimd_context *ctx = crtc->ctx; 349 349 unsigned int win, ch_enabled = 0; 350 + int ret; 350 351 351 352 /* Hardware is in unknown state, so ensure it gets enabled properly */ 352 - pm_runtime_get_sync(ctx->dev); 353 + ret = pm_runtime_resume_and_get(ctx->dev); 354 + if (ret < 0) { 355 + dev_err(ctx->dev, "failed to enable FIMD device.\n"); 356 + return ret; 357 + } 353 358 354 359 clk_prepare_enable(ctx->bus_clk); 355 360 clk_prepare_enable(ctx->lcd_clk); ··· 389 384 clk_disable_unprepare(ctx->bus_clk); 390 385 391 386 pm_runtime_put(ctx->dev); 387 + 388 + return 0; 392 389 } 393 390 394 391 ··· 912 905 913 906 ctx->suspended = false; 914 907 915 - pm_runtime_get_sync(ctx->dev); 908 + if (pm_runtime_resume_and_get(ctx->dev) < 0) { 909 + dev_warn(ctx->dev, "failed to enable FIMD device.\n"); 910 + return; 911 + } 916 912 917 913 /* if vblank was enabled status, enable it again. */ 918 914 if (test_and_clear_bit(0, &ctx->irq_flags)) ··· 1099 1089 if (ctx->encoder) 1100 1090 exynos_dpi_bind(drm_dev, ctx->encoder); 1101 1091 1102 - if (is_drm_iommu_supported(drm_dev)) 1103 - fimd_clear_channels(ctx->crtc); 1092 + if (is_drm_iommu_supported(drm_dev)) { 1093 + int ret; 1094 + 1095 + ret = fimd_clear_channels(ctx->crtc); 1096 + if (ret < 0) 1097 + return ret; 1098 + } 1104 1099 1105 1100 return exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv); 1106 1101 }
+8 -1
drivers/gpu/drm/exynos/exynos_drm_g2d.c
··· 892 892 g2d->runqueue_node = g2d_get_runqueue_node(g2d); 893 893 894 894 if (g2d->runqueue_node) { 895 - pm_runtime_get_sync(g2d->dev); 895 + int ret; 896 + 897 + ret = pm_runtime_resume_and_get(g2d->dev); 898 + if (ret < 0) { 899 + dev_err(g2d->dev, "failed to enable G2D device.\n"); 900 + return; 901 + } 902 + 896 903 g2d_dma_start(g2d, g2d->runqueue_node); 897 904 } 898 905 }
+6 -1
drivers/gpu/drm/exynos/exynos_drm_gsc.c
··· 1118 1118 struct gsc_context *ctx = container_of(ipp, struct gsc_context, ipp); 1119 1119 int ret; 1120 1120 1121 - pm_runtime_get_sync(ctx->dev); 1121 + ret = pm_runtime_resume_and_get(ctx->dev); 1122 + if (ret < 0) { 1123 + dev_err(ctx->dev, "failed to enable GScaler device.\n"); 1124 + return ret; 1125 + } 1126 + 1122 1127 ctx->task = task; 1123 1128 1124 1129 ret = gsc_reset(ctx);
+2 -4
drivers/gpu/drm/exynos/exynos_drm_mic.c
··· 268 268 if (mic->enabled) 269 269 goto unlock; 270 270 271 - ret = pm_runtime_get_sync(mic->dev); 272 - if (ret < 0) { 273 - pm_runtime_put_noidle(mic->dev); 271 + ret = pm_runtime_resume_and_get(mic->dev); 272 + if (ret < 0) 274 273 goto unlock; 275 - } 276 274 277 275 mic_set_path(mic, 1); 278 276
+6 -1
drivers/gpu/drm/exynos/exynos_drm_rotator.c
··· 219 219 { 220 220 struct rot_context *rot = 221 221 container_of(ipp, struct rot_context, ipp); 222 + int ret; 222 223 223 - pm_runtime_get_sync(rot->dev); 224 + ret = pm_runtime_resume_and_get(rot->dev); 225 + if (ret < 0) { 226 + dev_err(rot->dev, "failed to enable ROTATOR device.\n"); 227 + return ret; 228 + } 224 229 rot->task = task; 225 230 226 231 rotator_src_set_fmt(rot, task->src.buf.fourcc);
+6 -4
drivers/gpu/drm/exynos/exynos_drm_scaler.c
··· 362 362 struct drm_exynos_ipp_task_rect *src_pos = &task->src.rect; 363 363 struct drm_exynos_ipp_task_rect *dst_pos = &task->dst.rect; 364 364 const struct scaler_format *src_fmt, *dst_fmt; 365 + int ret = 0; 365 366 366 367 src_fmt = scaler_get_format(task->src.buf.fourcc); 367 368 dst_fmt = scaler_get_format(task->dst.buf.fourcc); 368 369 369 - pm_runtime_get_sync(scaler->dev); 370 - if (scaler_reset(scaler)) { 371 - pm_runtime_put(scaler->dev); 370 + ret = pm_runtime_resume_and_get(scaler->dev); 371 + if (ret < 0) 372 + return ret; 373 + 374 + if (scaler_reset(scaler)) 372 375 return -EIO; 373 - } 374 376 375 377 scaler->task = task; 376 378
+7 -1
drivers/gpu/drm/exynos/exynos_hdmi.c
··· 1483 1483 /* Should be called with hdata->mutex mutex held. */ 1484 1484 static void hdmiphy_enable(struct hdmi_context *hdata) 1485 1485 { 1486 + int ret; 1487 + 1486 1488 if (hdata->powered) 1487 1489 return; 1488 1490 1489 - pm_runtime_get_sync(hdata->dev); 1491 + ret = pm_runtime_resume_and_get(hdata->dev); 1492 + if (ret < 0) { 1493 + dev_err(hdata->dev, "failed to enable HDMIPHY device.\n"); 1494 + return; 1495 + } 1490 1496 1491 1497 if (regulator_bulk_enable(ARRAY_SIZE(supply), hdata->regul_bulk)) 1492 1498 DRM_DEV_DEBUG_KMS(hdata->dev,
+6 -1
drivers/gpu/drm/exynos/exynos_mixer.c
··· 992 992 static void mixer_atomic_enable(struct exynos_drm_crtc *crtc) 993 993 { 994 994 struct mixer_context *ctx = crtc->ctx; 995 + int ret; 995 996 996 997 if (test_bit(MXR_BIT_POWERED, &ctx->flags)) 997 998 return; 998 999 999 - pm_runtime_get_sync(ctx->dev); 1000 + ret = pm_runtime_resume_and_get(ctx->dev); 1001 + if (ret < 0) { 1002 + dev_err(ctx->dev, "failed to enable MIXER device.\n"); 1003 + return; 1004 + } 1000 1005 1001 1006 exynos_drm_pipe_clk_enable(crtc, true); 1002 1007