Commit 2fda6174 authored by Dave Airlie's avatar Dave Airlie

Merge tag 'mediatek-drm-fixes-20231211' of...

Merge tag 'mediatek-drm-fixes-20231211' of https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux into drm-fixes

Mediatek DRM Fixes - 20231211

1. mtk_disp_gamma: Fix breakage due to merge issue
2. fix kernel oops if no crtc is found
3. Add spinlock for setting vblank event in atomic_begin
4. Fix access violation in mtk_drm_crtc_dma_dev_get
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>

From: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20231211151510.6749-1-chunkuang.hu@kernel.org
parents a39b6ac3 b6961d18
...@@ -203,7 +203,7 @@ void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state) ...@@ -203,7 +203,7 @@ void mtk_gamma_set(struct device *dev, struct drm_crtc_state *state)
/* Disable RELAY mode to pass the processed image */ /* Disable RELAY mode to pass the processed image */
cfg_val &= ~GAMMA_RELAY_MODE; cfg_val &= ~GAMMA_RELAY_MODE;
cfg_val = readl(gamma->regs + DISP_GAMMA_CFG); writel(cfg_val, gamma->regs + DISP_GAMMA_CFG);
} }
void mtk_gamma_config(struct device *dev, unsigned int w, void mtk_gamma_config(struct device *dev, unsigned int w,
......
...@@ -788,6 +788,7 @@ static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc, ...@@ -788,6 +788,7 @@ static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc,
crtc); crtc);
struct mtk_crtc_state *mtk_crtc_state = to_mtk_crtc_state(crtc_state); struct mtk_crtc_state *mtk_crtc_state = to_mtk_crtc_state(crtc_state);
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc);
unsigned long flags;
if (mtk_crtc->event && mtk_crtc_state->base.event) if (mtk_crtc->event && mtk_crtc_state->base.event)
DRM_ERROR("new event while there is still a pending event\n"); DRM_ERROR("new event while there is still a pending event\n");
...@@ -795,7 +796,11 @@ static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc, ...@@ -795,7 +796,11 @@ static void mtk_drm_crtc_atomic_begin(struct drm_crtc *crtc,
if (mtk_crtc_state->base.event) { if (mtk_crtc_state->base.event) {
mtk_crtc_state->base.event->pipe = drm_crtc_index(crtc); mtk_crtc_state->base.event->pipe = drm_crtc_index(crtc);
WARN_ON(drm_crtc_vblank_get(crtc) != 0); WARN_ON(drm_crtc_vblank_get(crtc) != 0);
spin_lock_irqsave(&crtc->dev->event_lock, flags);
mtk_crtc->event = mtk_crtc_state->base.event; mtk_crtc->event = mtk_crtc_state->base.event;
spin_unlock_irqrestore(&crtc->dev->event_lock, flags);
mtk_crtc_state->base.event = NULL; mtk_crtc_state->base.event = NULL;
} }
} }
...@@ -921,7 +926,14 @@ static int mtk_drm_crtc_init_comp_planes(struct drm_device *drm_dev, ...@@ -921,7 +926,14 @@ static int mtk_drm_crtc_init_comp_planes(struct drm_device *drm_dev,
struct device *mtk_drm_crtc_dma_dev_get(struct drm_crtc *crtc) struct device *mtk_drm_crtc_dma_dev_get(struct drm_crtc *crtc)
{ {
struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); struct mtk_drm_crtc *mtk_crtc = NULL;
if (!crtc)
return NULL;
mtk_crtc = to_mtk_crtc(crtc);
if (!mtk_crtc)
return NULL;
return mtk_crtc->dma_dev; return mtk_crtc->dma_dev;
} }
......
...@@ -443,6 +443,7 @@ static int mtk_drm_kms_init(struct drm_device *drm) ...@@ -443,6 +443,7 @@ static int mtk_drm_kms_init(struct drm_device *drm)
struct mtk_drm_private *private = drm->dev_private; struct mtk_drm_private *private = drm->dev_private;
struct mtk_drm_private *priv_n; struct mtk_drm_private *priv_n;
struct device *dma_dev = NULL; struct device *dma_dev = NULL;
struct drm_crtc *crtc;
int ret, i, j; int ret, i, j;
if (drm_firmware_drivers_only()) if (drm_firmware_drivers_only())
...@@ -519,7 +520,9 @@ static int mtk_drm_kms_init(struct drm_device *drm) ...@@ -519,7 +520,9 @@ static int mtk_drm_kms_init(struct drm_device *drm)
} }
/* Use OVL device for all DMA memory allocations */ /* Use OVL device for all DMA memory allocations */
dma_dev = mtk_drm_crtc_dma_dev_get(drm_crtc_from_index(drm, 0)); crtc = drm_crtc_from_index(drm, 0);
if (crtc)
dma_dev = mtk_drm_crtc_dma_dev_get(crtc);
if (!dma_dev) { if (!dma_dev) {
ret = -ENODEV; ret = -ENODEV;
dev_err(drm->dev, "Need at least one OVL device\n"); dev_err(drm->dev, "Need at least one OVL device\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment