Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1747787pxv; Fri, 2 Jul 2021 11:09:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxX2pVr4TsgbtZR8wkKDQ5ni3ZnWtsYvIsoYYLtnSeX3nfLC+hID5LKxwS7nTUkBnZC+Vuk X-Received: by 2002:aa7:cf91:: with SMTP id z17mr1016660edx.112.1625249363975; Fri, 02 Jul 2021 11:09:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625249363; cv=none; d=google.com; s=arc-20160816; b=Xyi0DknAKGRZnx8MdDLSPq/4X47MdxB+fjUh8VlzJYWNzIA119otvvw0BUpAyKJRQH k/cZ6A7xkKhWiR+FNW+ezCadGzVCEuu/GlD0rXZexvQQ+MAXuGjM30OfhatzzRWXCcwN qB1fuRfYvOo3+et2f/v752beMD3Tzuxx80avcPJ3sU8KkiUSaRnV3wz/MWASAeYSmqXg op3JosDjIDoZKaFUlFv+hfrBti6ymV4oiZ+qcshk9it8duiKib5kHvWvXWDMcT+aEb0R a170Q2W4YJVxqL9mnDgGtVmxWWL3D3zJh+Hdvm7cQqKgd9ZxQDOzIuwfiJnMURPT2ojy gV7Q== 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=DVXT6/CYOSAyDwpNFBEXfSTGeNkDxbgh/EoHZVqJm+A=; b=CRNw4gnwG0/q9004dU00LoAd7NTzlbF12V9ug0u33cQWUR9+dMUFMjQkChfbaBC65Y gTOGhlBtprCRs2qAFJlAIjgGtjaWBsSxcchvlm6OCwA6b352HISi3ZQxaVjxq5cvH89f GZfpgS09ujsE4q/kcj4Gm1sSiXP2qoqwN0O3peCbE1+N5XC3nWZVKRPfA5KGHeC2s50V 7BuFUW7Pk3+wAW/+de2TdYNV5O+wy/1+yiShAGO7NVFLfNK4GTzqYGaJR1U2hIXHEtvU ttILQj0ToHRzY5lBpSCT7G7PbNbeGKPKIzkENboHbSLBwdAweayOjWcw/zCeruwbtBf0 RXaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b="Z/ej3xyy"; 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 ig2si3779947ejc.57.2021.07.02.11.08.55; Fri, 02 Jul 2021 11:09:23 -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="Z/ej3xyy"; 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 S230001AbhGBSKK (ORCPT + 99 others); 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 ?