Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1412546pxv; Fri, 2 Jul 2021 03:14:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzojShTAgWZVwRFRi3HLvHC5B9+gSHAEOEeb/Vm+5ezOKi/xquHqqR+/9IiCjiS8qh8ek+V X-Received: by 2002:a02:ce88:: with SMTP id y8mr3613362jaq.34.1625220867079; Fri, 02 Jul 2021 03:14:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625220867; cv=none; d=google.com; s=arc-20160816; b=ZfMB97lqs3NJy+oIMJTw/ZP+WkGMaZK0Zjv3maX7x+yR+eWLqZPjXWtPei8VztjQ50 zTWHPKVYqOqv00ol05ZS5ZvfNjd7TJDa1ruZ6xK4JjXvTH7HPLRfEDoqRbB1U1LAS+Ji 2WwD9PvInPFmSV2ffrQk9siUEHsS4/+buNDlAeqZ/e8VbkoUDTW6yGWzlEIBKVjv4BzG yBiC9NOCH8X5kDeYemjsWDn55q78mu080FM5X1Cwv4vMi9TnFPpjP1f8MeUt8Ct31Mma 1Xnxu3PHsfT68t4OaymwNH1QIDh1kSp2IC77orXgDJWlpuuicU+CYI7MyCUCVCG9DLGD jXkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=5ywvL4VVQ+2r/jhdIM14ypRiW/ywajQXfPzZ2maovTA=; b=KKWrjRGv9Fw2pIh6mv/0DFtwwbK8UDImBBc5E9CHivAMDh3s1lD7lCGrioKRGqq5vb pBdO5l/yr5R8DUEpRWbuXUW9FqeQ9rVcPXmOj6sDcuMZHyrtxZyK26T3FPNzLaDwIBjh 9HEOeOLqQr7U+pKHz8SLHNa0Zxsq4smFrlmElzVxQMB9dcfWGEP/eyV39ouf3J0SfCxu VfUhqax3wqEYLWyuIozFTdmcBX+1k5pKMWUHA/MLM7selunorCOcN1o0ASomMe8i/8/y chM1OUkWm9y4SOT4A2toJg3n5DL3ucdeFqQJaF7sRnYwP5ikr+W8eqiurNAo0Do94PQW hwew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b="LCFPp+Y/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m22si3336128jat.35.2021.07.02.03.14.14; Fri, 02 Jul 2021 03:14:27 -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=@foss.st.com header.s=selector1 header.b="LCFPp+Y/"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230424AbhGBJ0P (ORCPT + 99 others); Fri, 2 Jul 2021 05:26:15 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:37072 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230078AbhGBJ0O (ORCPT ); Fri, 2 Jul 2021 05:26:14 -0400 Received: from pps.filterd (m0241204.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1629AxOI019441; Fri, 2 Jul 2021 11:23:25 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=selector1; bh=5ywvL4VVQ+2r/jhdIM14ypRiW/ywajQXfPzZ2maovTA=; b=LCFPp+Y/RgFx7ixHPOVRqbIYocI4RlvALr9i9XihsloC62P6IqcJYwyoVmO8ylFHUZ20 L8og9QpEFFl1aiSqTNk9cS9Z7SrCTiYbrmqAsWAxFMurq+NRNG26/Sl2q2j4+Kmtysz5 k0vqFhDN2uHI6j8gFBRBfBWOgFNkLlXVQGdpeN5Sxsf19WOtmvPibI9VciZUFYW9yYdL gc/Mewf4JRC9Ocf81Ywq18JbF7ik0ZCTLv5Bb7qoXfgJQ0Zjm56yfEe6pdpc4QASptl3 H9b5gRz0WrsJfQE7zpIvK19h/jh6l6GLIR4EuT5PLLUFMAC9x0eLi+cos7DiI+ViAvAo lg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 39hw3cscpu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 02 Jul 2021 11:23:25 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 317E610002A; Fri, 2 Jul 2021 11:23:23 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 8E2F8217B92; Fri, 2 Jul 2021 11:23:23 +0200 (CEST) Received: from lmecxl0557.lme.st.com (10.75.127.47) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 2 Jul 2021 11:23:22 +0200 Subject: Re: [PATCH] drm/stm: ltdc: improve pm_runtime to stop clocks To: Marek Vasut 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> From: Raphael Gallais-Pou Message-ID: <3bb823e4-4724-7072-fe9f-7b8a355c8e50@foss.st.com> Date: Fri, 2 Jul 2021 11:23:21 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <420e243d-7541-a07e-177b-d2db11c26aef@denx.de> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.790 definitions=2021-07-02_01:2021-07-02,2021-07-02 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Marek, Sorry for the late answer. 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. Regards, Raphaël G-P