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=-17.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 E5A27C433ED for ; Fri, 7 May 2021 13:23:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A69E861157 for ; Fri, 7 May 2021 13:23:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236752AbhEGNYx (ORCPT ); Fri, 7 May 2021 09:24:53 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:60262 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230499AbhEGNYv (ORCPT ); Fri, 7 May 2021 09:24:51 -0400 Received: from [192.168.1.111] (91-157-208-71.elisa-laajakaista.fi [91.157.208.71]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 4E444EF; Fri, 7 May 2021 15:23:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1620393830; bh=Z+/qATPuVcKfDSUD7dOeGR9wKJY7p3Dw+vktDAXvPbU=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=rA0/tLLo8qyaWE8DHa3y6WKj1IFO9evM61CpPBZDU3ELl6XSIhQ3SDXOLrR7Do6xl 7xQmU4C7zflQ1Ed6iiXTqQAjnMM2bedyeg4486cq5gjfOc7468nPDgWqneuMfuR4zd Fd6MyawtVrsv7elD0eX+l4WddBI4tjs639h7OkIQ= Subject: Re: [PATCH] PM: runtime: Fix unpaired parent child_count for force_resume To: Tony Lindgren , "Rafael J . Wysocki" Cc: Ulf Hansson , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Laurent Pinchart , Sebastian Reichel References: <20210505110915.6861-1-tony@atomide.com> From: Tomi Valkeinen Message-ID: <8ee97450-a568-765f-77b8-d48a494f1da1@ideasonboard.com> Date: Fri, 7 May 2021 16:23:49 +0300 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: <20210505110915.6861-1-tony@atomide.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/05/2021 14:09, Tony Lindgren wrote: > As pm_runtime_need_not_resume() relies also on usage_count, it can return > a different value in pm_runtime_force_suspend() compared to when called in > pm_runtime_force_resume(). Different return values can happen if anything > calls PM runtime functions in between, and causes the parent child_count > to increase on every resume. > > So far I've seen the issue only for omapdrm that does complicated things > with PM runtime calls during system suspend for legacy reasons: > > omap_atomic_commit_tail() for omapdrm.0 > dispc_runtime_get() > wakes up 58000000.dss as it's the dispc parent > dispc_runtime_resume() > rpm_resume() increases parent child_count > dispc_runtime_put() won't idle, PM runtime suspend blocked > pm_runtime_force_suspend() for 58000000.dss, !pm_runtime_need_not_resume() > __update_runtime_status() > system suspended > pm_runtime_force_resume() for 58000000.dss, pm_runtime_need_not_resume() > pm_runtime_enable() only called because of pm_runtime_need_not_resume() > omap_atomic_commit_tail() for omapdrm.0 > dispc_runtime_get() > wakes up 58000000.dss as it's the dispc parent > dispc_runtime_resume() > rpm_resume() increases parent child_count > dispc_runtime_put() won't idle, PM runtime suspend blocked > ... > rpm_suspend for 58000000.dss but parent child_count is now unbalanced > > Let's fix the issue by adding a flag for needs_force_resume and use it in > pm_runtime_force_resume() instead of pm_runtime_need_not_resume(). > > Additionally omapdrm system suspend could be simplified later on to avoid > lots of unnecessary PM runtime calls and the complexity it adds. The > driver can just use internal functions that are shared between the PM > runtime and system suspend related functions. > > Fixes: 4918e1f87c5f ("PM / runtime: Rework pm_runtime_force_suspend/resume()") > Cc: Laurent Pinchart > Cc: Sebastian Reichel > Cc: Tomi Valkeinen > Signed-off-by: Tony Lindgren > --- > drivers/base/power/runtime.c | 10 +++++++--- > include/linux/pm.h | 1 + > 2 files changed, 8 insertions(+), 3 deletions(-) Tested on DRA76 EVM, with and without HDMI plugged in. I can see DSS shutting down properly by looking at the CM_DSS_DSS_CLKCTRL register. Tested-by: Tomi Valkeinen Tomi