Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp39803pxb; Mon, 11 Apr 2022 18:11:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzq4pNLOER4OonCrNY/Xi89nqJfEjN/VeXocloCuvrLgy78bbR6d3CCctID1/1RjvZERcg8 X-Received: by 2002:a63:2c4c:0:b0:398:997d:b5b8 with SMTP id s73-20020a632c4c000000b00398997db5b8mr29000536pgs.86.1649725900974; Mon, 11 Apr 2022 18:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649725900; cv=none; d=google.com; s=arc-20160816; b=yiY0bB2Hky6geLGMffuU7G2w9JNEodX/fVhcQjuT870Sy6VcChLdylSduP2o5HvXoI 3ch6aOYUtKincRCwuVvs00sLnMMpXPmv7p9Y+6Xs2euXjv7oQXwzbgT639O6Nj/dSb8s UVpcgdtAHXynOgc/gMpma1hcpiOEBF0tGHqXu7XgZ+5tECuSWFjZ+l7UZvUptLZILd3l i085STdDihNx1Uk3QkzVUEsdv0WRLhIsZMdWmMUwMsIsMV33bB5NPHFTissnqtfi4KwQ ogBaS1t9/sN7DTs61pIwI777tr4X25HNjnCJNeSlK9KEcL0pT+8Grx+f6qqut6rGWQHL P5xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xIyVq4yGO1cuz+wgqr4zvd6o8IjqdDVp2SdhzgQ7d3s=; b=DINKYPNy9cpDB3VS2GjSGf51UMHW19m4XCdmCB8Bm1HZYq5xThGxsP4UFsZF++nRE3 QQY1hFTMHTxJwRLHtBdJLxSghVd99wZM+KDbtOMsp+140TR9UkNn5fdyxpFz+u+y4K3D H9wT520aEmR9S9OgSCjz5VUwCd4s7e6XPbXP9Py6GI251PfNFwrLnkFbHG12DfVkUmVI sGQWUexuC+CtyWrHujOORq6pe0NHI1iOaPFuRw+7Ch5KglGIsJU2bqR7pek/eGDvHTR9 OHqNB5VSVtM+TWjQrtQDmEIOx578bc39NyK/pBTLQ5LMMW7GDjkURVdhLKdy6C3wD4Ha ZLsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="c7NRIa6/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y1-20020a1709027c8100b00153b2d165c6si9681798pll.462.2022.04.11.18.11.25; Mon, 11 Apr 2022 18:11:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="c7NRIa6/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346709AbiDKNvW (ORCPT + 99 others); Mon, 11 Apr 2022 09:51:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346708AbiDKNvV (ORCPT ); Mon, 11 Apr 2022 09:51:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFD9AD56; Mon, 11 Apr 2022 06:49:04 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 49A2F6110F; Mon, 11 Apr 2022 13:49:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 368C3C385A4; Mon, 11 Apr 2022 13:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1649684943; bh=/0A9RpEJ7REnvajp9XnL1qbAsYgD6WdtYUuCp70lPuE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=c7NRIa6/3QJzic6TUhKuERXEHkt6FvlYPg0Eca4L2iuKcH4/frGG7D0H6qDJiqNcd rr0t2u9lFXWOhUvsbq0Tidp9cSSJpaKCq9wdjsB+AyA8q/uXrMAiY1uKAilE1wK3d9 rLEiJ5v/v/ImJkdzukYCsvkq5nfhDERdGj0TbcK+1AkuhsxooD+zCyV3N5nga1rapp fVYRp6q4VzVlYFnpcdUiP2psCz5bAVDNoqdqIlOshGIVe/bo7Fleiy50visJ53pEyK AqQzt1TlflPVkQGfOZAHcV+tql4k97H+vXyTIFaNR8dfCcNUYsQQqBhGgj9KQbPO+x wD9WbRlJ03b9Q== Date: Mon, 11 Apr 2022 19:18:59 +0530 From: Vinod Koul To: Sugar Zhang Cc: Huibin Hong , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] dmaengine: pl330: Fix unbalanced runtime PM Message-ID: References: <1648296988-45745-1-git-send-email-sugar.zhang@rock-chips.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1648296988-45745-1-git-send-email-sugar.zhang@rock-chips.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 26-03-22, 20:16, Sugar Zhang wrote: > This driver use runtime PM autosuspend mechanism to manager clk. > > pm_runtime_use_autosuspend(&adev->dev); > pm_runtime_set_autosuspend_delay(&adev->dev, PL330_AUTOSUSPEND_DELAY); > > So, after ref count reached to zero, it will enter suspend > after the delay time elapsed. > > The unbalanced PM: > > * May cause dmac the next start failed. > * May cause dmac read unexpected state. > * May cause dmac stall if power down happen at the middle of the transfer. > e.g. may lose ack from AXI bus and stall. > > Considering the following situation: > > DMA TERMINATE TASKLET ROUTINE > | | > | issue_pending > | | > | pch->active = true > | pm_runtime_get > pm_runtime_put(if active) | > pch->active = false | > | work_list empty > | | > | pm_runtime_put(force) maybe unconditional is a better word than force here? > | | > > At this point, it's unbalanced(1 get / 2 put). > > After this patch: > > DMA TERMINATE TASKLET ROUTINE > | | > | issue_pending > | | > | pch->active = true > | pm_runtime_get > pm_runtime_put(if active) | > pch->active = false | > | work_list empty > | | > | pm_runtime_put(if active) > | | > > Now, it's balanced(1 get / 1 put). > > Fixes: > commit 5c9e6c2b2ba3 ("dmaengine: pl330: Fix runtime PM support for terminated transfers") > commit ae43b3289186 ("ARM: 8202/1: dmaengine: pl330: Add runtime Power Management support v12") That is not the right way for Fixes tag > > Signed-off-by: Huibin Hong > Signed-off-by: Sugar Zhang > --- > > drivers/dma/pl330.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c > index 858400e..ccd430e 100644 > --- a/drivers/dma/pl330.c > +++ b/drivers/dma/pl330.c > @@ -2084,7 +2084,7 @@ static void pl330_tasklet(struct tasklet_struct *t) > spin_lock(&pch->thread->dmac->lock); > _stop(pch->thread); > spin_unlock(&pch->thread->dmac->lock); > - power_down = true; > + power_down = pch->active; > pch->active = false; > } else { > /* Make sure the PL330 Channel thread is active */ > -- > 2.7.4 -- ~Vinod