From patchwork Mon Feb 26 08:26:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13571536 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8E163C48BF6 for ; Mon, 26 Feb 2024 08:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=FcdNguY0PTPImIxQfEa0r8r/Lisl6xmxb40GIR/D1ss=; b=uIpWQ+MPGl8d0/ S0VfNgDVl5lDbbsRNn9ZWzuq1mWZ4/E5Hk7+tWLiyxIcVdyWH1bEbVfW37aZoQrBWO2tEvMAPWzdJ vhF0jhhoeP+GSfNKIyk+07mxoBYLe9hbN+w9ZRaS2RYwYhfd2HaFo1PGdeUlYuhxgIB4YrU2AFQfO uUXUklsQ/PDPLAh4gJpH3oCeNfq1TgdYgD7HF9JzhTLZ8lDCAn1fb/Kpczk34VgDAXCbCKpm3ftp7 IImGfmq9rggm5rXHRjJ55qffgk4GkMqe1tftTNvK5HGAS/FzkHwQ6AbF8996Nm3jcWpJ8QvTAm+GD NZoT95gWPxn/J2RLFLKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1reWKH-0000000Gyzp-1Y3a; Mon, 26 Feb 2024 08:27:05 +0000 Received: from phobos.denx.de ([85.214.62.61]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1reWKD-0000000GyyC-2aay for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2024 08:27:03 +0000 Received: from tr.lan (ip-86-49-120-218.bb.vodafone.cz [86.49.120.218]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 852558701B; Mon, 26 Feb 2024 09:26:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1708936020; bh=Iy1CBWeVFFcq60DRMeB/QGBeOlwgaptl4awgP96oLmM=; h=From:To:Cc:Subject:Date:From; b=OHqSA3aIyPaVUdnzRB9NbboRonQ/VTpJCNP0NSxktW/KCT+xWWfwZfDuLtFVxATEo 1V3mynJlUNhd8ni/wJV2ohW+q80n3MZqF0JZC7FW4cW6LCLfOHVPPpucFGnh+Ef8H9 yNhxbxyWp98gS1H+mxC3Wv4rS6thZiroSqxiWR/siXBkx/51Be3TaGcA3aZLwGJyQ3 3KNDHlALlLWfGd8lYhaO7dt+a59HHrxgJSpiv+MyeQbPRlTnCDQqDQMkgOOnhYl3ln mmmH2GqrA32YmJ2hIEAqu4BtePJ1OK3GkWbAeTj0CX/9s4++XmH8wqoS0qpJ77Y2Q4 SAlqDX2VEEJnA== From: Marek Vasut To: dri-devel@lists.freedesktop.org Cc: Marek Vasut , Liu Ying , Daniel Vetter , David Airlie , Fabio Estevam , Maarten Lankhorst , Maxime Ripard , NXP Linux Team , Pengutronix Kernel Team , Sascha Hauer , Shawn Guo , Stefan Agner , Thomas Zimmermann , linux-arm-kernel@lists.infradead.org Subject: [PATCH v3] drm/lcdif: Do not disable clocks on already suspended hardware Date: Mon, 26 Feb 2024 09:26:27 +0100 Message-ID: <20240226082644.32603-1-marex@denx.de> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240226_002702_002318_5D27EAC3 X-CRM114-Status: GOOD ( 17.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In case the LCDIF is enabled in DT but unused, the clocks used by the LCDIF are not enabled. Those clocks may even have a use count of 0 in case there are no other users of those clocks. This can happen e.g. in case the LCDIF drives HDMI bridge which has no panel plugged into the HDMI connector. Do not attempt to disable clocks in the suspend callback and re-enable clocks in the resume callback unless the LCDIF is enabled and was in use before the system entered suspend, otherwise the driver might end up trying to disable clocks which are already disabled with use count 0, and would trigger a warning from clock core about this condition. Note that the lcdif_rpm_suspend() and lcdif_rpm_resume() functions internally perform the clocks disable and enable operations and act as runtime PM hooks too. Reviewed-by: Liu Ying Fixes: 9db35bb349a0 ("drm: lcdif: Add support for i.MX8MP LCDIF variant") Signed-off-by: Marek Vasut --- Cc: Daniel Vetter Cc: David Airlie Cc: Fabio Estevam Cc: Liu Ying Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: NXP Linux Team Cc: Pengutronix Kernel Team Cc: Sascha Hauer Cc: Shawn Guo Cc: Stefan Agner Cc: Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org Cc: linux-arm-kernel@lists.infradead.org --- V2: - s@clock@clocks@g in commit message - Add RB from Liu V3: - Replace clocks core with clock core --- drivers/gpu/drm/mxsfb/lcdif_drv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c index 18de2f17e2491..6494e82707569 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c @@ -340,6 +340,9 @@ static int __maybe_unused lcdif_suspend(struct device *dev) if (ret) return ret; + if (pm_runtime_suspended(dev)) + return 0; + return lcdif_rpm_suspend(dev); } @@ -347,7 +350,8 @@ static int __maybe_unused lcdif_resume(struct device *dev) { struct drm_device *drm = dev_get_drvdata(dev); - lcdif_rpm_resume(dev); + if (!pm_runtime_suspended(dev)) + lcdif_rpm_resume(dev); return drm_mode_config_helper_resume(drm); }