Received: by 10.223.176.46 with SMTP id f43csp683134wra; Fri, 26 Jan 2018 05:20:11 -0800 (PST) X-Google-Smtp-Source: AH8x22683QFZCIdggOLttUuTdlA6o6AA1itkptCF4IM4MeQStKPoQ17i/PWLTrgffSIhbMpZgtCz X-Received: by 10.99.171.78 with SMTP id k14mr15602631pgp.287.1516972811487; Fri, 26 Jan 2018 05:20:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516972811; cv=none; d=google.com; s=arc-20160816; b=N6nZ6u1cVlK7Wq76gnNpORDCWMTCKbL3v5KbBBQDZtUTqFYomOVBHE5lZgdH5PSXZ4 8tICDX8IJ7e76A9T1UggQU1yBWt9by03et91GoQU1sdWf3G0kFYXHcRJUjra+ApA6fgh hSo8kFix96/4Aa9L02xKeEZf0IIeCyyBX1puXcm3h/NPHwANmDtKE5be97vqu+ROSeqH noxn5zPX4EtShqcxfEZVYtQiTyKYm8Am/zyTxBByAT2ecreED3erzXRIa9fDBhwx/CnR 2aPcUrykVBCqg6KjNI5etPMNM9RcXtQg3dsOJPxKzpaFbZptIYb3pLuPCtz4YK7LOEGQ BTYg== 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=8wXP/VtRSU2gNGlm/NJX8jHDzeWbHPaDIUvt0x6nY08=; b=zrGiSyG8lBdaQ8u7+UrQ4JffID/SxgYm7Ag0xEAmKVWn8wtMlzQVN4KOwtIBfgRBoC bHAssCMFMFjGjtyW6lGbon4oB95lDo8Vp8aPJxkmg68lV1VUT7ZQvky7ed4Rb66BN8/0 DQwMY52RIehC5eLgWVnPH2yTUdwBJJIO18GzQvz6gcmug5c1xc/VCCXDahQCfzfQb0gN MR2fpH4kDATkpVliJUin3Z+A+jiejkYbhBI1bUVgeWv6/ajbpR65eNVnJGhpBWxIxMu7 kjiDSPoc927TaA79wtjHFOnBxm5jnXmUQ6Ss5rJa0Fn0KsmzikCt+m10HpFP9soPFZyP 38mw== 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 u76si463693pfa.294.2018.01.26.05.19.57; Fri, 26 Jan 2018 05:20:11 -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 S1752597AbeAZNSu (ORCPT + 99 others); Fri, 26 Jan 2018 08:18:50 -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 S1752493AbeAZNSI (ORCPT ); Fri, 26 Jan 2018 08:18:08 -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 A8237274EDD; Fri, 26 Jan 2018 13:18:06 +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 41/43] drm/rockchip: Disable PSR from reboot notifier Date: Fri, 26 Jan 2018 14:17:08 +0100 Message-Id: <20180126131710.7622-42-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 It looks like the driver subsystem detaches devices from power domains at shutdown without consent of the drivers. This means that we might have our power domain turned off behind our back and the only way to avoid problems is to stop doing any hardware programming at some point before the power is cut. A reboot notifier, despite being a misnomer and handling shutdowns as well, is a good place to do it. Signed-off-by: Tomasz Figa Signed-off-by: Thierry Escande --- drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c index e7e16d92d5a1..1bf5cba9a64d 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c @@ -13,6 +13,7 @@ */ #include +#include #include #include @@ -33,6 +34,7 @@ struct psr_drv { struct delayed_work flush_work; struct work_struct disable_work; + struct notifier_block reboot_nb; struct input_handler input_handler; int (*set)(struct drm_encoder *encoder, bool enable); @@ -309,6 +311,24 @@ static const struct input_device_id psr_ids[] = { { }, }; +static int rockchip_drm_psr_reboot_notifier(struct notifier_block *nb, + unsigned long action, void *data) +{ + struct psr_drv *psr = container_of(nb, struct psr_drv, reboot_nb); + + /* + * It looks like the driver subsystem detaches devices from power + * domains at shutdown without consent of the drivers. This means + * that we might have our power domain turned off behind our back + * and the only way to avoid problems is to stop doing any hardware + * programming after this point, which is achieved by the unbalanced + * call below. + */ + rockchip_drm_psr_inhibit_get(psr->encoder); + + return 0; +} + /** * rockchip_drm_psr_register - register encoder to psr driver * @encoder: encoder that obtain the PSR function @@ -361,6 +381,9 @@ int rockchip_drm_psr_register(struct drm_encoder *encoder, if (error) goto err1; + psr->reboot_nb.notifier_call = rockchip_drm_psr_reboot_notifier; + register_reboot_notifier(&psr->reboot_nb); + mutex_lock(&drm_drv->psr_list_lock); list_add_tail(&psr->list, &drm_drv->psr_list); mutex_unlock(&drm_drv->psr_list_lock); @@ -403,6 +426,7 @@ void rockchip_drm_psr_unregister(struct drm_encoder *encoder) WARN_ON(psr->inhibit_count != 1); list_del(&psr->list); + unregister_reboot_notifier(&psr->reboot_nb); input_unregister_handler(&psr->input_handler); kfree(psr->input_handler.name); kfree(psr); -- 2.14.1