Received: by 10.223.185.111 with SMTP id b44csp819377wrg; Fri, 9 Mar 2018 14:28:58 -0800 (PST) X-Google-Smtp-Source: AG47ELvG1uvC/FL3ilqqQE2yEd/IovRxkS0xelDkw+f9eAsTOKsRxmU2cuZETSClNzLJlCFJrimZ X-Received: by 10.98.149.90 with SMTP id p87mr83294pfd.28.1520634538016; Fri, 09 Mar 2018 14:28:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520634537; cv=none; d=google.com; s=arc-20160816; b=OT2zQxBJoA2fAw7Nur3QTdpddJb5nQuVT2gY2mw6tuZ48rHc0KIp7oXSl4xfyZg+d/ Ol8mexaKgRdN/bXZOT2SPn4REFybkve//uUNVxhz5zs0L81u2M+0H+he7zm4lcBYGk+9 yRS6ekEuLMRwABUpO3hhYuV+3SKAh/gulmwDXEER87kJuYJVF6tg5tgGdvgspwJqpAcD D/kie5zo4zO94K4Wnqd9QBz9O1EaGmY25wwz3yJgrH7UhRID8WCxV0L5Edufwtn9KIlm DgLpnl3ldNc62GLLDxhKD8Ud3ZK18GZQWvak2BmA22oHikWSUUZErJdvHsU+DpJRuIPY tSmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=DDFjAM99d/Vt7rUJVmLp/UDP/klDGon/dQtWLB6LfGI=; b=f9HikmHS/EUNcI/yUWzIu2/mubQK3qXI6nudslmUwKs++/T0G/cq32cvM/RCTtZOF7 IK8t9Uv3RsGiY0O1R4OgsBvGrbzWj6f7Sym3Hq5l9+5etT4epAs5ffHh8cfXsjKn8kZu NQ0NBt9EOyl0JucakpFb4HtRP/04uxJ+nQxUzK5Es+XhR+jp4KqgLb5wIGjgnLI6hNBK Fum2gs1Lts6T3yKLWDbi8ynyJfmJgbyjE6oxjZ+u0wiEhCVKNXX4hRcT/lHU4L2ldcPa NqWV4O8VrvrRM9ewtJoG5vT7teoiiA7gaqOp4N0p8eJHrnhzZI5iiGQgln/1METvhtjZ zT3Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k12si1367292pgn.502.2018.03.09.14.28.43; Fri, 09 Mar 2018 14:28:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933313AbeCIW0V (ORCPT + 99 others); Fri, 9 Mar 2018 17:26:21 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43052 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933205AbeCIWZA (ORCPT ); Fri, 9 Mar 2018 17:25:00 -0500 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 68EA02792CF From: Enric Balletbo i Serra To: architt@codeaurora.org, inki.dae@samsung.com, thierry.reding@gmail.com, hjc@rock-chips.com, seanpaul@chromium.org, airlied@linux.ie, tfiga@chromium.org, heiko@sntech.de Cc: dri-devel@lists.freedesktop.org, dianders@chromium.org, a.hajda@samsung.com, ykk@rock-chips.com, kernel@collabora.com, m.szyprowski@samsung.com, linux-samsung-soc@vger.kernel.org, jy0922.shim@samsung.com, rydberg@bitmath.org, krzk@kernel.org, linux-rockchip@lists.infradead.org, kgene@kernel.org, linux-input@vger.kernel.org, orjan.eide@arm.com, wxt@rock-chips.com, jeffy.chen@rock-chips.com, linux-arm-kernel@lists.infradead.org, mark.yao@rock-chips.com, wzz@rock-chips.com, hl@rock-chips.com, jingoohan1@gmail.com, sw0312.kim@samsung.com, linux-kernel@vger.kernel.org, kyungmin.park@samsung.com, Laurent.pinchart@ideasonboard.com, kuankuan.y@gmail.com, hshi@chromium.org, Enric Balletbo i Serra Subject: [PATCH v5 31/36] drm/rockchip: Cancel PSR enable work before changing the state Date: Fri, 9 Mar 2018 23:23:22 +0100 Message-Id: <20180309222327.18689-32-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180309222327.18689-1-enric.balletbo@collabora.com> References: <20180309222327.18689-1-enric.balletbo@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tomasz Figa If we change the state first and reschedule later, we might have the work executed according to previous scheduled time and end up with PSR re-enabled instantly. Let's cancel the work before changing the state. While at it, consolidate psr_disable_handler() to just call rockchip_drm_do_flush(), as they are both supposed to do the same. Signed-off-by: Tomasz Figa Signed-off-by: Thierry Escande Signed-off-by: Enric Balletbo i Serra Tested-by: Marek Szyprowski --- drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c index a107845ba97c..c8655e625ba2 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c @@ -138,18 +138,6 @@ static void psr_flush_handler(struct work_struct *work) mutex_unlock(&psr->lock); } -static void psr_disable_handler(struct work_struct *work) -{ - struct psr_drv *psr = container_of(work, struct psr_drv, disable_work); - - /* If the state has changed since we initiated the flush, do nothing */ - mutex_lock(&psr->lock); - if (psr->state == PSR_ENABLE) - psr_set_state_locked(psr, PSR_FLUSH); - mutex_unlock(&psr->lock); - mod_delayed_work(system_wq, &psr->flush_work, PSR_FLUSH_TIMEOUT_MS); -} - /** * rockchip_drm_psr_activate - activate PSR on the given pipe * @encoder: encoder to obtain the PSR encoder @@ -198,6 +186,7 @@ EXPORT_SYMBOL(rockchip_drm_psr_deactivate); static void rockchip_drm_do_flush(struct psr_drv *psr) { + cancel_delayed_work_sync(&psr->flush_work); psr_set_state(psr, PSR_FLUSH); mod_delayed_work(system_wq, &psr->flush_work, PSR_FLUSH_TIMEOUT_MS); } @@ -244,6 +233,13 @@ void rockchip_drm_psr_flush_all(struct drm_device *dev) } EXPORT_SYMBOL(rockchip_drm_psr_flush_all); +static void psr_disable_handler(struct work_struct *work) +{ + struct psr_drv *psr = container_of(work, struct psr_drv, disable_work); + + rockchip_drm_do_flush(psr); +} + static void psr_input_event(struct input_handle *handle, unsigned int type, unsigned int code, int value) -- 2.16.1