Received: by 10.213.65.68 with SMTP id h4csp1732881imn; Thu, 5 Apr 2018 02:52:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+pbStYqukNNvAQoOSWqMVFg/mLDRgPSPCWiRmhckZwkeu277nXoUXvu8WFqrMRgt5nIQDV X-Received: by 10.99.147.82 with SMTP id w18mr14151717pgm.181.1522921969151; Thu, 05 Apr 2018 02:52:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522921969; cv=none; d=google.com; s=arc-20160816; b=Dj9McQsOKFEptxttpJcU6dycRoonYr5baF12K5eKSQZfxoO5kMPd9w9p9jqMXweb1Y fLTBm8prpe9yQ9hv2ekH5rE5mbyJ2ECYzokRF7ASXb7pTriYNOKV79BAkDl5YDB+nhNu /fL/E7hSm84vhJAb2tfNQprdT0KKWSokDpWyLxDLfgu7014vEU9HiM7az4lCSi/yMK5Z K9U965z5tL2daI1lpH13yFtnqSks3vPwVs2Y7Q1UgMFYNA0ITWb0yifttS0sIEbcv7ei iDLjQSq3xft/SQeamwK+hvwiHxAgn91lZyp7+0I4DGO5uM9BH7QYNmJUcRtoCvg8TNp1 USyA== 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=yvo7Dnda3pfXXq/dh9xcS+QlDKAvAwN+cI6vEABfgNM=; b=TtJttGR6M+cIJySJl7BgnKVgFioOCghoRv1Ww6agn5uSMMOkynEm/QZYeWuRA7j6wC qT1Bpg7AmP1YW1oZIL+ujZoBuM8FuSTbMhlxhXlVHb6T/BFCezWl8Kyx7Pt2d+uViW4t DGWpQYklIYEDEyBAT1Srpwve717GPHi7oTF6MgkJbOaTmtF2vv9pIfPoJlV+Fcdp4kDu nPvTFIwkcJNdR3ybrOSnRes0d2mBE0pFpKGxHKTquRmy4hRjrsymOWZNr0WjDe0noLgQ I5fwBnJDNbQdieKHmreaFYExBOVVaMLn2haUh4+gwd1ovQbC2Xpnrb8huR/OYnk7yjtI EdGw== 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 y10-v6si5457359plt.533.2018.04.05.02.52.34; Thu, 05 Apr 2018 02:52:49 -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 S1752391AbeDEJvX (ORCPT + 99 others); Thu, 5 Apr 2018 05:51:23 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:32992 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752274AbeDEJvP (ORCPT ); Thu, 5 Apr 2018 05:51:15 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id E62CC27A64B 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 28/30] drm/rockchip: Disable PSR from reboot notifier Date: Thu, 5 Apr 2018 11:49:58 +0200 Message-Id: <20180405095000.9756-29-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 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 Signed-off-by: Enric Balletbo i Serra Tested-by: Marek Szyprowski --- 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.16.3