From patchwork Fri Mar 9 22:23:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enric Balletbo i Serra X-Patchwork-Id: 10272473 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6635B605CE for ; Fri, 9 Mar 2018 22:58:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58FD82A034 for ; Fri, 9 Mar 2018 22:58:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D7B42A036; Fri, 9 Mar 2018 22:58:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D32542A034 for ; Fri, 9 Mar 2018 22:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=yHoTr8F6kGa74JNe5YkDcjnU80gUDmCxQTsBpy5Oflk=; b=dxCh63pGRAwV9lx6ppuX9wDfWo 9ruhYC92fJFpC11z9Qt9i2Mi17lbiqtYoB9wPsMQY0QGbMjd6zjIVsJ2rZms8mMuwl47xjzfqCXL3 e9tmHEc1pirI16pbP9CS0ZB6TNqggxtPTLxCSof9q6ol+FsQGMKAYEV5iQWzEMwiezmiCIuc6HBkq IzIPg3cc/8ftTKLJd918GMU/LxvrearFLrqDX1VRwbgTORnySo+rkClJmiC0f1gN9NMEiWg0dNbwx 0ZJik96cyvgNoD6nvXgC2YJfUq0wQAK9+JKgFv91TRL6oeINNMctwxsOYw+Hje4kNzFNUehTycMa9 YWdcZ+JQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1euQy8-0002cI-VU; Fri, 09 Mar 2018 22:58:32 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euQwd-0001Id-D4; Fri, 09 Mar 2018 22:56:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ANYnbyKsVVDZduOq38yiA2OUj9S4TpDzlSiQh5RdSFs=; b=toOiLX75ZmSCISAs2Q/X5fUgi TmWCAVU02yxxS9Gop6wM1024ZQ07FHzMv6ZggVzt+2hWTonURcpEKWtvjZsCk/WbSk3WVITPtJXQQ 9OhtjqnGP9X2loORYzxILisjDh98foJaw+dpNXm07onntAI4dIDssA+Hqdpm24oiuR6Wi8CA2pOqR tjXRaVv779HkdC1vEtkmJgT8n3rnOPwVmBCJ3cIi9J7k6xvGHwXLcghaK+C69SpApouPaqzQIN1jK 1jLqI8YWrCHoEg27O9uTPCMGhRsLl0C7d0DycIEENDYReGSf3WeJ39LAix+pQrtHEmaX2B3YWL9v6 1NB7V7BrQ==; Received: from bhuna.collabora.co.uk ([2a00:1098:0:82:1000:25:2eeb:e3e3]) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1euQRr-0006uw-Mr; Fri, 09 Mar 2018 22:25:13 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 3051D2792E3 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 Subject: [PATCH v5 34/36] drm/rockchip: Disable PSR from reboot notifier Date: Fri, 9 Mar 2018 23:23:25 +0100 Message-Id: <20180309222327.18689-35-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180309_222511_747918_21D3DE48 X-CRM114-Status: GOOD ( 13.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.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, dianders@chromium.org, kyungmin.park@samsung.com, Enric Balletbo i Serra , kuankuan.y@gmail.com, hshi@chromium.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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);