From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0340DC11F68 for ; Fri, 2 Jul 2021 18:07:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5EE761402 for ; Fri, 2 Jul 2021 18:07:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230104AbhGBSKK (ORCPT ); Fri, 2 Jul 2021 14:10:10 -0400 Received: from phobos.denx.de ([85.214.62.61]:55944 "EHLO phobos.denx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbhGBSKK (ORCPT ); Fri, 2 Jul 2021 14:10:10 -0400 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 337A680A22; Fri, 2 Jul 2021 20:07:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1625249256; bh=DVXT6/CYOSAyDwpNFBEXfSTGeNkDxbgh/EoHZVqJm+A=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Z/ej3xyycbNljAT+gmegjwcoP7YhWYaTK2I6wvT1bVp8h/7NUDq2uPR4QwZzKkWhe zHYhQtz/dPNMedT2FYFOJCV4Ey9Y/KE3UFXBRO60fPEzup5u3VaZziTz27Un4+UDpv Bw5EuevxgUCe7J5wRFX/OMDW6I7W3iJS6xJfJdr+3ZUKizs/ned4a184h8cHXtqGtO ZJSncVBluzXST22RIr9yvbvPUURj3NH3VCajJUEASJ6YDN5SGiG/vYcynv13+4ioaE 5Ill8a0Dm3B6111SPf/3AGXYgS11Fdv8qwxgtyZknIn+kW0D+XkkIAA1tKIp797nYx 8ACgqLHj3BQ4g== 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> From: Marek Vasut Message-ID: <5d65ca80-4f94-49e1-5de1-cf29e8231a6a@denx.de> Date: Fri, 2 Jul 2021 20:07:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <3bb823e4-4724-7072-fe9f-7b8a355c8e50@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 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 ? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF7D4C11F68 for ; Fri, 2 Jul 2021 18:09:23 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A65A960E0B for ; Fri, 2 Jul 2021 18:09:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A65A960E0B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:Cc:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=LbCaCo15u8fWM1e0VikRDJY1Ip4wA1dXwLa3BdWu3J4=; b=biNM9C/cTXaXE4DgtmBK0ZqWTy IHecMWd0ojdRu8iKjYj09fSaPv9dRLqiaIYIDKrHyTYTnNI3dbpIOJZ8fhx4rjdEJjBF6vi2XdMMr PEUWB2cxrmYsG8ycNOoAHbuWgDtNqZs40C4AyhvozItJ81XYWBzdrpiI/99BBaf+N5UXdy5+26bGM ZCzkqQqGhraNshWEXRlepONCc38+qdwKYnuR9uWKB0qDMUDPk+Ro7WNwIuXisIuYDF3LEfxZFA15a w4CeRVHiKyBhAogvSMpySr6q48sXoNukEYY9OfDe8BGNKCc8Wm3vDsZEGIgzoy3PWZiesSJ67ictJ GTPlXXzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzNZl-003jDv-0S; Fri, 02 Jul 2021 18:07:41 +0000 Received: from phobos.denx.de ([85.214.62.61]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lzNZi-003jDT-1e for linux-arm-kernel@lists.infradead.org; Fri, 02 Jul 2021 18:07:39 +0000 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 337A680A22; Fri, 2 Jul 2021 20:07:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1625249256; bh=DVXT6/CYOSAyDwpNFBEXfSTGeNkDxbgh/EoHZVqJm+A=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Z/ej3xyycbNljAT+gmegjwcoP7YhWYaTK2I6wvT1bVp8h/7NUDq2uPR4QwZzKkWhe zHYhQtz/dPNMedT2FYFOJCV4Ey9Y/KE3UFXBRO60fPEzup5u3VaZziTz27Un4+UDpv Bw5EuevxgUCe7J5wRFX/OMDW6I7W3iJS6xJfJdr+3ZUKizs/ned4a184h8cHXtqGtO ZJSncVBluzXST22RIr9yvbvPUURj3NH3VCajJUEASJ6YDN5SGiG/vYcynv13+4ioaE 5Ill8a0Dm3B6111SPf/3AGXYgS11Fdv8qwxgtyZknIn+kW0D+XkkIAA1tKIp797nYx 8ACgqLHj3BQ4g== 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> From: Marek Vasut Message-ID: <5d65ca80-4f94-49e1-5de1-cf29e8231a6a@denx.de> Date: Fri, 2 Jul 2021 20:07:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <3bb823e4-4724-7072-fe9f-7b8a355c8e50@foss.st.com> Content-Language: en-US X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210702_110738_436669_5A1D0C97 X-CRM114-Status: GOOD ( 22.83 ) 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: , Content-Transfer-Encoding: base64 Content-Type: text/plain; charset="utf-8"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org T24gNy8yLzIxIDExOjIzIEFNLCBSYXBoYWVsIEdhbGxhaXMtUG91IHdyb3RlOgo+IEhlbGxvIE1h cmVrLAoKSGksCgo+IFNvcnJ5IGZvciB0aGUgbGF0ZSBhbnN3ZXIuCgpObyB3b3JyaWVzLCB0YWtl IHlvdXIgdGltZQoKPiBPbiA2LzMwLzIxIDI6MzUgQU0sIE1hcmVrIFZhc3V0IHdyb3RlOgo+PiBP biA2LzI5LzIxIDE6NTggUE0sIFJhcGhhZWwgR0FMTEFJUy1QT1UgLSBmb3NzIHdyb3RlOgo+Pgo+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VsZCBiZSB0aGUgcmlnaHQg Zml4IGhlcmUgdG9vID8KCl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fCmxpbnV4LWFybS1rZXJuZWwgbWFpbGluZyBsaXN0CmxpbnV4LWFybS1rZXJuZWxAbGlz dHMuaW5mcmFkZWFkLm9yZwpodHRwOi8vbGlzdHMuaW5mcmFkZWFkLm9yZy9tYWlsbWFuL2xpc3Rp bmZvL2xpbnV4LWFybS1rZXJuZWwK From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13FA1C11F6A for ; Fri, 2 Jul 2021 18:07:41 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B2CFD61380 for ; Fri, 2 Jul 2021 18:07:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B2CFD61380 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1409F6E1B3; Fri, 2 Jul 2021 18:07:40 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) by gabe.freedesktop.org (Postfix) with ESMTPS id 338B16E1B3 for ; Fri, 2 Jul 2021 18:07:39 +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 337A680A22; Fri, 2 Jul 2021 20:07:35 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1625249256; bh=DVXT6/CYOSAyDwpNFBEXfSTGeNkDxbgh/EoHZVqJm+A=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Z/ej3xyycbNljAT+gmegjwcoP7YhWYaTK2I6wvT1bVp8h/7NUDq2uPR4QwZzKkWhe zHYhQtz/dPNMedT2FYFOJCV4Ey9Y/KE3UFXBRO60fPEzup5u3VaZziTz27Un4+UDpv Bw5EuevxgUCe7J5wRFX/OMDW6I7W3iJS6xJfJdr+3ZUKizs/ned4a184h8cHXtqGtO ZJSncVBluzXST22RIr9yvbvPUURj3NH3VCajJUEASJ6YDN5SGiG/vYcynv13+4ioaE 5Ill8a0Dm3B6111SPf/3AGXYgS11Fdv8qwxgtyZknIn+kW0D+XkkIAA1tKIp797nYx 8ACgqLHj3BQ4g== Subject: Re: [PATCH] drm/stm: ltdc: improve pm_runtime to stop clocks To: Raphael Gallais-Pou 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> From: Marek Vasut Message-ID: <5d65ca80-4f94-49e1-5de1-cf29e8231a6a@denx.de> Date: Fri, 2 Jul 2021 20:07:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <3bb823e4-4724-7072-fe9f-7b8a355c8e50@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 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: , Cc: Maxime Coquelin , Raphael GALLAIS-POU , David Airlie , "linux-kernel@vger.kernel.org" , Yannick FERTRE - foss , Philippe CORNU , "dri-devel@lists.freedesktop.org" , Alexandre TORGUE - foss , Yannick FERTRE , Philippe CORNU - foss , Benjamin Gaignard , Stephen Boyd , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 ?