Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 483b88f8 authored by Inki Dae's avatar Inki Dae
Browse files

drm/exynos: fix vblank bug.



In case that vblank_disable_allowed is 1, the problem that manager->pipe
could be -1 at vsync interrupt handler could be induced so this patch fixes
that.

Signed-off-by: default avatarInki Dae <inki.dae@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
parent 2c871127
Loading
Loading
Loading
Loading
+36 −10
Original line number Diff line number Diff line
@@ -447,7 +447,9 @@ static void fimd_win_commit(struct device *dev)
static void fimd_win_disable(struct device *dev)
{
	struct fimd_context *ctx = get_fimd_context(dev);
	struct fimd_win_data *win_data;
	struct exynos_drm_subdrv *subdrv = &ctx->subdrv;
	struct drm_device *drm_dev = subdrv->drm_dev;
	struct exynos_drm_manager *manager = &subdrv->manager;
	int win = ctx->default_win;
	u32 val;

@@ -456,8 +458,6 @@ static void fimd_win_disable(struct device *dev)
	if (win < 0 || win > WINDOWS_NR)
		return;

	win_data = &ctx->win_data[win];

	/* protect windows */
	val = readl(ctx->regs + SHADOWCON);
	val |= SHADOWCON_WINx_PROTECT(win);
@@ -473,6 +473,29 @@ static void fimd_win_disable(struct device *dev)
	val &= ~SHADOWCON_CHx_ENABLE(win);
	val &= ~SHADOWCON_WINx_PROTECT(win);
	writel(val, ctx->regs + SHADOWCON);

	/* fimd dma off. */
	val = readl(ctx->regs + VIDCON0);
	val &= ~(VIDCON0_ENVID | VIDCON0_ENVID_F);
	writel(val, ctx->regs + VIDCON0);

	/*
	 * if vblank is enabled status with dma off then
	 * it disables vsync interrupt.
	 */
	if (drm_dev->vblank_enabled[manager->pipe] &&
			atomic_read(&drm_dev->vblank_refcount[manager->pipe])) {
		drm_vblank_put(drm_dev, manager->pipe);

		/*
		 * if vblank_disable_allowed is 0 then disable vsync interrupt
		 * right now else the vsync interrupt would be disabled by drm
		 * timer once a current process gives up ownershop of
		 * vblank event.
		 */
		if (!drm_dev->vblank_disable_allowed)
			drm_vblank_off(drm_dev, manager->pipe);
	}
}

static struct exynos_drm_overlay_ops fimd_overlay_ops = {
@@ -528,6 +551,16 @@ static irqreturn_t fimd_irq_handler(int irq, void *dev_id)
		/* VSYNC interrupt */
		writel(VIDINTCON1_INT_FRAME, ctx->regs + VIDINTCON1);

	/*
	 * in case that vblank_disable_allowed is 1, it could induce
	 * the problem that manager->pipe could be -1 because with
	 * disable callback, vsync interrupt isn't disabled and at this moment,
	 * vsync interrupt could occur. the vsync interrupt would be disabled
	 * by timer handler later.
	 */
	if (manager->pipe == -1)
		return IRQ_HANDLED;

	drm_handle_vblank(drm_dev, manager->pipe);
	fimd_finish_pageflip(drm_dev, manager->pipe);

@@ -548,13 +581,6 @@ static int fimd_subdrv_probe(struct drm_device *drm_dev, struct device *dev)
	 */
	drm_dev->irq_enabled = 1;

	/*
	 * with vblank_disable_allowed = 1, vblank interrupt will be disabled
	 * by drm timer once a current process gives up ownership of
	 * vblank event.(drm_vblank_put function was called)
	 */
	drm_dev->vblank_disable_allowed = 1;

	return 0;
}