Received: by 10.223.176.46 with SMTP id f43csp684487wra; Fri, 26 Jan 2018 05:21:31 -0800 (PST) X-Google-Smtp-Source: AH8x2265cUFXJzeYfIIeEsjn54mMdiLR1uuOdKGenT9Ei8OWCc/gdxVIdBm6oMF10LpDSC6StoTa X-Received: by 10.98.73.157 with SMTP id r29mr19352845pfi.41.1516972891095; Fri, 26 Jan 2018 05:21:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516972891; cv=none; d=google.com; s=arc-20160816; b=q2b4xWWs51Va566ogVDmkKdlpNFTxtGwT3UXbFOoVwurKgA+5JCG07OQL2eywqkbYK obDu8C+CSwyxVeMx9vzgPuOlSH6K6dcIwNef5GnqV+uEF3CU8rqGeo0S1Qbnw3eYtm4D 1E35C4+G20uNvt6T8ss9sBVGd3ANgxKxSHHXCxr2q8lneKim5Jl1tRSr/VHRZ0LIXMCF ml0lYJrmCBPouAY+gYYj1Zx0dYMl7HF91gfn9Iq7z9xq/4Y+IObh8M8QB4kYezxGu32j VAp4ZSTJ/aGZFpm2zYnZx7sSZ9y41Wso6xqhXzO6S7mWitp5/YCXnqj1kB3CtEzRXGQE Iv4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfert-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=dWZtGwTVCkNQ6hPsh8nretCp3/eUAbDwXO58bXG8Zqg=; b=qfMQmdjbmML9YpQHTHdClP0qH5GWHdfef7vqhsibA4284zqYBlBAiyrTHaA33AL0lh rfTKK2yY+BBwGVWkdbwEyvuF5r9WYlHOrsXNnve94PVbHl7/VBx9+PrV1ajfwMIKwWjH 0zzrFcu2ClpAXbil0zjvk6BeBGR2tVYLw2oOeWvVNpufTt8n/GzwkRaFMfMPCazK3sK2 6PDrgKXSnVTdLP1oKRdZkJ0yaXo70wAhHW+OhEabMQw3VLN+hV+j5LEjUqaD83fw4L1d ty9VKt1zxIkuuStQv0scHylr0jiJX1CibUMHczdMZzuX6VQ8+T/RS5qATeLGF3LHWN/y FMXQ== 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 e190si6347188pfe.96.2018.01.26.05.21.16; Fri, 26 Jan 2018 05:21:31 -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 S1752502AbeAZNSH (ORCPT + 99 others); Fri, 26 Jan 2018 08:18:07 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:34516 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752408AbeAZNSF (ORCPT ); Fri, 26 Jan 2018 08:18:05 -0500 Received: from localhost.localdomain (unknown [IPv6:2a01:e35:8a7e:4790:a8d7:ca4:7b4f:7f87]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: tescande) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 27C54274ED7; Fri, 26 Jan 2018 13:18:04 +0000 (GMT) From: Thierry Escande To: Archit Taneja , Inki Dae , Thierry Reding , Sandy Huang , Sean Paul , David Airlie , Tomasz Figa Cc: Haixia Shi , =?UTF-8?q?=C3=98rjan=20Eide?= , Zain Wang , Yakir Yang , Lin Huang , Douglas Anderson , Mark Yao , linux-kernel@vger.kernel.org, linux-rockchip@lists.infradead.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 38/43] drm/rockchip: Cancel PSR enable work before changing the state Date: Fri, 26 Jan 2018 14:17:05 +0100 Message-Id: <20180126131710.7622-39-thierry.escande@collabora.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180126131710.7622-1-thierry.escande@collabora.com> References: <20180126131710.7622-1-thierry.escande@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset = "utf-8" Content-Transfert-Encoding: 8bit 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 --- 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.14.1