Received: by 10.223.185.111 with SMTP id b44csp818311wrg; Fri, 9 Mar 2018 14:27:22 -0800 (PST) X-Google-Smtp-Source: AG47ELt53uN1udSDB7mq+MiykJRZ+gxFWLe0EApmY+Kn/+liVu0GFVoAf5/4xEuS+y5Ed4sJl48W X-Received: by 10.99.189.82 with SMTP id d18mr58134pgp.172.1520634442068; Fri, 09 Mar 2018 14:27:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520634442; cv=none; d=google.com; s=arc-20160816; b=nU0JrE4GFAJA3ZOloj84g+Uc61pY46WrocBYS6Jc0NFepCh6e7ra4pHYmG9mPFtvYd ERz8EpmqLvOajllzxixaRhq84GOXhW7Ybm0MxijN4VE+ORsf3TYpJhp+z6Z+flQT7oc/ CcPzWd26u1lGswJkPp0M9oDurG92z5X4BGM+OAyhZ+K2fLVZaTm1vgzluUvH7T/957c4 kayZt6ZX9uMy1ItkCgPPqwTj9nkeHi4QMgKXH2bWv3fUjwQR5+OtpHsmDJFAJWIt1Llm OivkNZAMQhTh/BfNPl9GE7SJXk5l0K0etWWWl/GRCywj8VoAD/iJAkuUErvSOH/gJfo7 Mq5Q== 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=ANYnbyKsVVDZduOq38yiA2OUj9S4TpDzlSiQh5RdSFs=; b=lJh+JMR3joCA2oPyo9J1/mtSlwqZ/ZXy8TU/7OzjpVNtuNLykCZrX6DpWRgRlRJDFY Gg4Aglv8Svj2LSmv7ChE8BiehsVPRxyEJ+Sk+xqo+yOq25H5O6sUNwRr3Z3rra+LKR1R VkAbLFdFux6X1oj9TO6LDDLiFY6S3hnwoaYWxhZKIkM3z+2Ag10H6Lo3FCcmt+B1JR/x nB9f/bPILkyWI7kgphUXHtkk7TtDIE8OFRdQ7eo1WwhG46gNVYGZIRw9U9DXlPbX5RtJ c4j/F+SgXF8/dGJav0AKP8kXnhtOSwC36qfRmvnw8CDz4kTgWujTV+SsbOucvmgtAFgO rMYA== 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 c193si1575096pfc.356.2018.03.09.14.27.07; Fri, 09 Mar 2018 14:27:22 -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 S933231AbeCIWZw (ORCPT + 99 others); Fri, 9 Mar 2018 17:25:52 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:43148 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932657AbeCIWZG (ORCPT ); Fri, 9 Mar 2018 17:25:06 -0500 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 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 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> 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.1