Received: by 10.213.65.68 with SMTP id h4csp1734537imn; Thu, 5 Apr 2018 02:54:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/7yuDMxxTKgXzkASTYJpRpH3T1jXjl+bqwCCAakBzH5HlMB586+xo33MYxubnp7l6Fwdy4 X-Received: by 10.99.53.130 with SMTP id c124mr14292697pga.233.1522922098461; Thu, 05 Apr 2018 02:54:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522922098; cv=none; d=google.com; s=arc-20160816; b=jdF5GGkkmUHzNd5Db9u2o96S+8EO5W/Kx+lkR646GXJtZ5LTGYjgtFuBThbp/a1lNU 1TN6vNvEUIw5VoMvHVRfmu+0l6s2p8XQFVPclcXS6gb0DW3xMl7G3u+IazCGCnt3kBK/ WOGY1BVc23TUqX/RxFV3ZNMpu25HbS/qHV6kZj6CG98RLTqgl50SIeLAs0bLUxBS6Ag/ RHOicctgHL2vzyG/Ky+eu84/TpM9Qg8YgIWUjRgUNLma3bmQ0cSZUmCFYUAdbbK7VUX0 4CxKalMz/UPQmGB+ti+6YquIr2bbeCp42FmP0A7De0PPAEVX3yV6O0lHJuH0fhj9TXAI 4YVw== 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=oBYZMDIYhNvZztEyXzhm1Lo+01PtpHobYaK8Nq2RzOY=; b=jHyC9KUcVXICSQSMTwGu531K0sJhT+Cp2WhWMCNINnFEpz2iSqxJGW/kH42k/oKl6M kpBpgKT/0w1dlEPv2ufveyIqv5RHBIDRxuFxN+6P7O41nVuVBIZ/E6XpOcrqMXcLy4a6 7H1o4GKQIAy0rUPifQKZsQosu9AcV7IXWJMAEt6HqSxm2VvshJAymEdt+TE2YQ07KBQo W0NiRtBtxZQk2TGDmo9ZTfGBYtQ0u9rmBgOw8tiB4aXYEFKuu8qMiXbHhkjmPRnwvPp+ Vzs4q7uh6/+elYNfblK5SIpxFal42REEmSB2wS6c7tgztCwt6xr7kFeMzy8yoFRxVDRR fGXg== 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 142si5182978pgg.29.2018.04.05.02.54.44; Thu, 05 Apr 2018 02:54:58 -0700 (PDT) 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 S1752255AbeDEJvL (ORCPT + 99 others); Thu, 5 Apr 2018 05:51:11 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:32908 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752220AbeDEJvI (ORCPT ); Thu, 5 Apr 2018 05:51:08 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 549E127A64E 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 v6 25/30] drm/rockchip: Cancel PSR enable work before changing the state Date: Thu, 5 Apr 2018 11:49:55 +0200 Message-Id: <20180405095000.9756-26-enric.balletbo@collabora.com> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180405095000.9756-1-enric.balletbo@collabora.com> References: <20180405095000.9756-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.3