Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp943102pxb; Thu, 19 Aug 2021 15:27:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKyC1fcHa6EyR47swkNBIVk9L6Rugio+0BkpTlycWYGmT6AMDPM0MtOfPMUpBJc9ZwEBqo X-Received: by 2002:a17:906:a24c:: with SMTP id bi12mr18208440ejb.530.1629412025683; Thu, 19 Aug 2021 15:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629412025; cv=none; d=google.com; s=arc-20160816; b=gMAUELxzIyTWK2+xiyyy7sJo1KEsIB+zmXJzWo8cJVXSeWjkpVhfK3O7xN4FxRSHFN BOXjEBIFSkaS4+IKFpLITqpLJJFAD9MtWMQH5JJES3tkC+t43UMRYIr1ewC+4JN30LEq hJZxXij7haIzbwYa+3QqSSI4Srs+foyPmoqz7LIp+2rZ+fipaJ9438KzlaGQ3z1Y++cB /mDIY3fZJMu1dpHhnbhDYMQR7uH84UeyKIXMtfHx+yfHWxEKT13nzMk4w3RPYikncLz2 HHsZEYJG1ys9RiNnErH2ptejKHWox/ofWYxxtn2NwkTjCqFJAKSzplg6U3ud2at6NreV sdtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=33UHPL0RZcL6+9jW56lcEU9a2CDzC1s+ybQGXQwzmfQ=; b=zBo6RWHqk9MnXmEcOfoII2OcPv5YHmjPIuIQQbFANbEXHhuZ09mg7T+lv41nY946KK 5N3B0ofDm94XOjSf4o0QE2h920FpKW14sv6yFlm+jmvjz5OCog3JA5wmN9tX8noOwd+S +Z0zegScowDs0p6lj6OIH07OpzXdS02tqqPcTJ+WPOh1UFaKB1FgtzSTJNb2sO1tRJ3F 3EObetI18gnR2panc4EKDnKyUIYWF3HpLR8jCXiTKB7Yv8Gvjadgbl0UDbVM5D7Hj/pO 23V/mfu+KZ9bGFKP0l5ufudFYRAl8OdOFF7TkpeCCi6irbntnUZsKUudJ8aPFRd/jASr i+jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=Dt65FNaC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g4si4888572ejh.515.2021.08.19.15.26.42; Thu, 19 Aug 2021 15:27:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=Dt65FNaC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236175AbhHSWXK (ORCPT + 99 others); Thu, 19 Aug 2021 18:23:10 -0400 Received: from phobos.denx.de ([85.214.62.61]:47116 "EHLO phobos.denx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235854AbhHSWXJ (ORCPT ); Thu, 19 Aug 2021 18:23:09 -0400 Received: from [IPv6:::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 3D71D82999; Fri, 20 Aug 2021 00:22:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1629411750; bh=33UHPL0RZcL6+9jW56lcEU9a2CDzC1s+ybQGXQwzmfQ=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Dt65FNaCxgBS+xEd01WWk4ajHnXrhGr0PbF+ALRxohsJqNUqyhXhbH0z/WMP51PzV J5K2nkxWLrY7YmMdxUOwaY9TfEq235oiKG3okvKE9/JbggRICauVU6ff35IRYP4Tap 4q316SIay5cHI4HYKr9md1UqKwsBRywA7AoRfZLtu2u9qyN/K6z76GdPBVZh61lfEk XuQLKJPm0Sj1N5cxXOtlPYdi7ZpxYWtk/C6umu29mZd2Q6uXWqgnjdMuX9dNtl6MVy J6UcVAoKrAA6sb/oZL9Qu0skmGXaO+cKXK+gkgW2/ZrjoCPOG+0FsRzkOSN0ZUtX62 r11+g2AKsPs/A== Subject: Re: [PATCH] drm/stm: ltdc: improve pm_runtime to stop clocks To: Raphael Gallais-Pou Cc: Yannick FERTRE , Philippe CORNU , Raphael GALLAIS-POU , Yannick FERTRE - foss , Philippe CORNU - foss , Benjamin Gaignard , David Airlie , Daniel Vetter , Maxime Coquelin , Alexandre TORGUE - foss , "dri-devel@lists.freedesktop.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" , Stephen Boyd References: <20210629115709.16145-1-raphael.gallais-pou@foss.st.com> <420e243d-7541-a07e-177b-d2db11c26aef@denx.de> <3bb823e4-4724-7072-fe9f-7b8a355c8e50@foss.st.com> <5d65ca80-4f94-49e1-5de1-cf29e8231a6a@denx.de> <629b6666-74b3-91f0-5c6c-e26d55ea62d8@foss.st.com> From: Marek Vasut Message-ID: Date: Fri, 20 Aug 2021 00:22:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <629b6666-74b3-91f0-5c6c-e26d55ea62d8@foss.st.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/17/21 11:43 AM, Raphael Gallais-Pou wrote: > > On 7/2/21 8:07 PM, Marek Vasut wrote: >> On 7/2/21 11:23 AM, Raphael Gallais-Pou wrote: >>> Hello Marek, >> >> Hi, >> >>> Sorry for the late answer. >> >> No worries, take your time >> >>> On 6/30/21 2:35 AM, Marek Vasut wrote: >>>> On 6/29/21 1:58 PM, Raphael GALLAIS-POU - foss wrote: >>>> >>>> [...] >>>> >>>>> +++ b/drivers/gpu/drm/stm/ltdc.c >>>>> @@ -425,10 +425,17 @@ static void ltdc_crtc_atomic_enable(struct drm_crtc *crtc, >>>>>   { >>>>>       struct ltdc_device *ldev = crtc_to_ltdc(crtc); >>>>>       struct drm_device *ddev = crtc->dev; >>>>> +    int ret; >>>>>         DRM_DEBUG_DRIVER("\n"); >>>>>   -    pm_runtime_get_sync(ddev->dev); >>>>> +    if (!pm_runtime_active(ddev->dev)) { >>>>> +        ret = pm_runtime_get_sync(ddev->dev); >>>> >>>> All these if (!pm_runtime_active()) then pm_runtime_get_sync() calls look like workaround for some larger issue. Shouldn't the pm_runtime do some refcounting on its own , so this shouldn't be needed ? >>> >>> >>> This problem purely comes from the driver internals, so I don't think it is a workaround. >>> >>> Because of the "ltdc_crtc_mode_set_nofb" function which does not have any "symmetrical" call, such as enable/disable functions, there was two calls to pm_runtime_get_sync against one call to pm_runtime_put_sync. >>> >>> This instability resulted in the LTDC clocks being always enabled, even when the peripheral was disabled. This could be seen in the clk_summary as explained in the patch summary among other things. >>> >>> By doing so, we first check if the clocks are not already activated, and in that case we call pm_runtime_get_sync. >> >> I just have to wonder, how come other drivers don't need these if (!pm_runtime_active()) pm_runtime_get_sync() conditions. I think they just get/put the runtime PM within a call itself, not across function calls. Maybe that could be the right fix here too ? > > > Hello Marek, Hi, > I've run a deeper analysis over this implementation. Thank you > If I may take rockchip's "rockchip_drm_vop.c" driver, there is an boolean "is_enabled" set to true when crtc_atomic_enable is called. > > The above implementation could save us from adding such field in the ltdc_dev structure. > > Another solution could be in order to simply call pm_runtime_get_sync() in ltdc_crtc_mode_set_nofb() and by removing this condition in ltdc_atomic_crtc_disable() the driver behaves just like the first version of this patch. > > In this way, it avoids such conditions and seems more to get along with the current implementation. Let me maybe ask a different question -- can ltdc_crtc_mode_set_nofb() ever be called with the LTDC suspended (so you would have to call pm_runtime_get_sync() in that function to power the block up and to get access to its registers) ? [...]