Skip to content

Commit

Permalink
Merge tag 'exynos-drm-next-for-v5.14' of git://git.kernel.org/pub/scm…
Browse files Browse the repository at this point in the history
…/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
  • Loading branch information
airlied committed Jun 11, 2021
2 parents 2a7005c + 445d3be commit 1bd8a7d
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 22 deletions.
7 changes: 6 additions & 1 deletion drivers/gpu/drm/exynos/exynos5433_drm_decon.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,13 @@ static void decon_swreset(struct decon_context *ctx)
static void decon_atomic_enable(struct exynos_drm_crtc *crtc)
{
struct decon_context *ctx = crtc->ctx;
int ret;

pm_runtime_get_sync(ctx->dev);
ret = pm_runtime_resume_and_get(ctx->dev);
if (ret < 0) {
DRM_DEV_ERROR(ctx->dev, "failed to enable DECON device.\n");
return;
}

exynos_drm_pipe_clk_enable(crtc, true);

Expand Down
7 changes: 6 additions & 1 deletion drivers/gpu/drm/exynos/exynos7_drm_decon.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,11 +531,16 @@ static void decon_init(struct decon_context *ctx)
static void decon_atomic_enable(struct exynos_drm_crtc *crtc)
{
struct decon_context *ctx = crtc->ctx;
int ret;

if (!ctx->suspended)
return;

pm_runtime_get_sync(ctx->dev);
ret = pm_runtime_resume_and_get(ctx->dev);
if (ret < 0) {
DRM_DEV_ERROR(ctx->dev, "failed to enable DECON device.\n");
return;
}

decon_init(ctx);

Expand Down
7 changes: 6 additions & 1 deletion drivers/gpu/drm/exynos/exynos_drm_dsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1383,7 +1383,12 @@ static void exynos_dsi_enable(struct drm_encoder *encoder)
if (dsi->state & DSIM_STATE_ENABLED)
return;

pm_runtime_get_sync(dsi->dev);
ret = pm_runtime_resume_and_get(dsi->dev);
if (ret < 0) {
dev_err(dsi->dev, "failed to enable DSI device.\n");
return;
}

dsi->state |= DSIM_STATE_ENABLED;

if (dsi->panel) {
Expand Down
8 changes: 7 additions & 1 deletion drivers/gpu/drm/exynos/exynos_drm_fimc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,8 +1085,14 @@ static int fimc_commit(struct exynos_drm_ipp *ipp,
{
struct fimc_context *ctx =
container_of(ipp, struct fimc_context, ipp);
int ret;

ret = pm_runtime_resume_and_get(ctx->dev);
if (ret < 0) {
dev_err(ctx->dev, "failed to enable FIMC device.\n");
return ret;
}

pm_runtime_get_sync(ctx->dev);
ctx->task = task;

fimc_src_set_fmt(ctx, task->src.buf.fourcc, task->src.buf.modifier);
Expand Down
25 changes: 20 additions & 5 deletions drivers/gpu/drm/exynos/exynos_drm_fimd.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,18 @@ static void fimd_enable_shadow_channel_path(struct fimd_context *ctx,
writel(val, ctx->regs + SHADOWCON);
}

static void fimd_clear_channels(struct exynos_drm_crtc *crtc)
static int fimd_clear_channels(struct exynos_drm_crtc *crtc)
{
struct fimd_context *ctx = crtc->ctx;
unsigned int win, ch_enabled = 0;
int ret;

/* Hardware is in unknown state, so ensure it gets enabled properly */
pm_runtime_get_sync(ctx->dev);
ret = pm_runtime_resume_and_get(ctx->dev);
if (ret < 0) {
dev_err(ctx->dev, "failed to enable FIMD device.\n");
return ret;
}

clk_prepare_enable(ctx->bus_clk);
clk_prepare_enable(ctx->lcd_clk);
Expand Down Expand Up @@ -384,6 +389,8 @@ static void fimd_clear_channels(struct exynos_drm_crtc *crtc)
clk_disable_unprepare(ctx->bus_clk);

pm_runtime_put(ctx->dev);

return 0;
}


Expand Down Expand Up @@ -905,7 +912,10 @@ static void fimd_atomic_enable(struct exynos_drm_crtc *crtc)

ctx->suspended = false;

pm_runtime_get_sync(ctx->dev);
if (pm_runtime_resume_and_get(ctx->dev) < 0) {
dev_warn(ctx->dev, "failed to enable FIMD device.\n");
return;
}

/* if vblank was enabled status, enable it again. */
if (test_and_clear_bit(0, &ctx->irq_flags))
Expand Down Expand Up @@ -1089,8 +1099,13 @@ static int fimd_bind(struct device *dev, struct device *master, void *data)
if (ctx->encoder)
exynos_dpi_bind(drm_dev, ctx->encoder);

if (is_drm_iommu_supported(drm_dev))
fimd_clear_channels(ctx->crtc);
if (is_drm_iommu_supported(drm_dev)) {
int ret;

ret = fimd_clear_channels(ctx->crtc);
if (ret < 0)
return ret;
}

return exynos_drm_register_dma(drm_dev, dev, &ctx->dma_priv);
}
Expand Down
9 changes: 8 additions & 1 deletion drivers/gpu/drm/exynos/exynos_drm_g2d.c
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,14 @@ static void g2d_runqueue_worker(struct work_struct *work)
g2d->runqueue_node = g2d_get_runqueue_node(g2d);

if (g2d->runqueue_node) {
pm_runtime_get_sync(g2d->dev);
int ret;

ret = pm_runtime_resume_and_get(g2d->dev);
if (ret < 0) {
dev_err(g2d->dev, "failed to enable G2D device.\n");
return;
}

g2d_dma_start(g2d, g2d->runqueue_node);
}
}
Expand Down
7 changes: 6 additions & 1 deletion drivers/gpu/drm/exynos/exynos_drm_gsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,12 @@ static int gsc_commit(struct exynos_drm_ipp *ipp,
struct gsc_context *ctx = container_of(ipp, struct gsc_context, ipp);
int ret;

pm_runtime_get_sync(ctx->dev);
ret = pm_runtime_resume_and_get(ctx->dev);
if (ret < 0) {
dev_err(ctx->dev, "failed to enable GScaler device.\n");
return ret;
}

ctx->task = task;

ret = gsc_reset(ctx);
Expand Down
6 changes: 2 additions & 4 deletions drivers/gpu/drm/exynos/exynos_drm_mic.c
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,9 @@ static void mic_pre_enable(struct drm_bridge *bridge)
if (mic->enabled)
goto unlock;

ret = pm_runtime_get_sync(mic->dev);
if (ret < 0) {
pm_runtime_put_noidle(mic->dev);
ret = pm_runtime_resume_and_get(mic->dev);
if (ret < 0)
goto unlock;
}

mic_set_path(mic, 1);

Expand Down
7 changes: 6 additions & 1 deletion drivers/gpu/drm/exynos/exynos_drm_rotator.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,13 @@ static int rotator_commit(struct exynos_drm_ipp *ipp,
{
struct rot_context *rot =
container_of(ipp, struct rot_context, ipp);
int ret;

pm_runtime_get_sync(rot->dev);
ret = pm_runtime_resume_and_get(rot->dev);
if (ret < 0) {
dev_err(rot->dev, "failed to enable ROTATOR device.\n");
return ret;
}
rot->task = task;

rotator_src_set_fmt(rot, task->src.buf.fourcc);
Expand Down
10 changes: 6 additions & 4 deletions drivers/gpu/drm/exynos/exynos_drm_scaler.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,15 +362,17 @@ static int scaler_commit(struct exynos_drm_ipp *ipp,
struct drm_exynos_ipp_task_rect *src_pos = &task->src.rect;
struct drm_exynos_ipp_task_rect *dst_pos = &task->dst.rect;
const struct scaler_format *src_fmt, *dst_fmt;
int ret = 0;

src_fmt = scaler_get_format(task->src.buf.fourcc);
dst_fmt = scaler_get_format(task->dst.buf.fourcc);

pm_runtime_get_sync(scaler->dev);
if (scaler_reset(scaler)) {
pm_runtime_put(scaler->dev);
ret = pm_runtime_resume_and_get(scaler->dev);
if (ret < 0)
return ret;

if (scaler_reset(scaler))
return -EIO;
}

scaler->task = task;

Expand Down
8 changes: 7 additions & 1 deletion drivers/gpu/drm/exynos/exynos_hdmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1483,10 +1483,16 @@ static void hdmi_set_refclk(struct hdmi_context *hdata, bool on)
/* Should be called with hdata->mutex mutex held. */
static void hdmiphy_enable(struct hdmi_context *hdata)
{
int ret;

if (hdata->powered)
return;

pm_runtime_get_sync(hdata->dev);
ret = pm_runtime_resume_and_get(hdata->dev);
if (ret < 0) {
dev_err(hdata->dev, "failed to enable HDMIPHY device.\n");
return;
}

if (regulator_bulk_enable(ARRAY_SIZE(supply), hdata->regul_bulk))
DRM_DEV_DEBUG_KMS(hdata->dev,
Expand Down
7 changes: 6 additions & 1 deletion drivers/gpu/drm/exynos/exynos_mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -992,11 +992,16 @@ static void mixer_atomic_flush(struct exynos_drm_crtc *crtc)
static void mixer_atomic_enable(struct exynos_drm_crtc *crtc)
{
struct mixer_context *ctx = crtc->ctx;
int ret;

if (test_bit(MXR_BIT_POWERED, &ctx->flags))
return;

pm_runtime_get_sync(ctx->dev);
ret = pm_runtime_resume_and_get(ctx->dev);
if (ret < 0) {
dev_err(ctx->dev, "failed to enable MIXER device.\n");
return;
}

exynos_drm_pipe_clk_enable(crtc, true);

Expand Down

0 comments on commit 1bd8a7d

Please sign in to comment.