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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 61495C48BC4 for ; Fri, 23 Feb 2024 09:47:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 91F6410E0BB; Fri, 23 Feb 2024 09:47:42 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.b="Q84ZGIoY"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 19A3910E0BB for ; Fri, 23 Feb 2024 09:47:40 +0000 (UTC) Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 46D65865F5; Fri, 23 Feb 2024 10:47:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1708681659; bh=IZHVudK+hRMDUNPMuE2ak5MJNoyz9q6t1GotRHn/DV0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Q84ZGIoYjVpWmhoPCKqWHlBt3ulGpumIYfrUOTuTjUy782TN3WF2LBZ6yp3UXshcu OMoAq6z+EUlwbZMXr1HvsULftZoZQyzSHVjYBq1ayCHUGSUYsQj+UJnWgzB/pqP7Kp S0sd+rYsINr4VyAxkpMyiGT25Y/0AHQYF/j6a6T5XOyFjkclmap7G3fu4UobyWz/9J HthPUYrW3t5gyHlE/PVdtoiii7JyUs/sYSSURFXZuKvLeMDb4/SK1+2Cj2Xowh1EEL 3hpry5b4UPu/yVER6+BYCCsPK++1z9ZkklCcA24p/hc6zdSZhpUIAIl5zZkyN38RNY OGA4lUAcwYkaA== Message-ID: <1898e9b8-9b88-4458-86bb-cd013cb95875@denx.de> Date: Fri, 23 Feb 2024 10:47:37 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] drm/lcdif: Do not disable clock on already suspended hardware Content-Language: en-US To: dri-devel@lists.freedesktop.org, Liu Ying Cc: 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 References: <20240118183924.144221-1-marex@denx.de> From: Marek Vasut In-Reply-To: <20240118183924.144221-1-marex@denx.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On 1/18/24 19:39, Marek Vasut wrote: > In case the LCDIF is enabled in DT but unused, the clock used by the > LCDIF are not enabled. Those clock may even have a use count of 0 in > case there are no other users of those clock. 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 clock in the suspend callback and re-enable > clock 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 clock 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 clock disable and enable operations and act > as runtime PM hooks too. > > 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 > --- > 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 ea10bf81582e9..0f895b8a99d62 100644 > --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c > +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c > @@ -343,6 +343,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); > } > > @@ -350,7 +353,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); > } Moving Victor to To: , it would be good to get some input on this as it fixes suspend/resume on MX8MP with HDMI .