Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3908736iog; Tue, 28 Jun 2022 05:24:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sf/a4EofOoa9iYy42W5MJLw2JIdpz1VS9aTuwP/6DpYNkWuSJKDxmDvN5/+Jvy/N8Vl/ER X-Received: by 2002:a17:906:a3ca:b0:726:2bd2:87bc with SMTP id ca10-20020a170906a3ca00b007262bd287bcmr17648097ejb.226.1656419058284; Tue, 28 Jun 2022 05:24:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656419058; cv=none; d=google.com; s=arc-20160816; b=b3OS7MDuBIgZ+ZJNxU+FeNv7fSQixjGQ+ZG9OwVGwZiH0hPVhID2GPHYRr+CJ6sXa+ icVaKJwVyTHdkm/riFxhvPcmeztqTsByvmCrqiq++GFVMSFtuc+T5FSzJDVwZ241CcXu PSSJk7ZALPm7eTGK7Cm/opv1Ooc0631vkj86Sxy/ZvZXCwBOnMYXM9Kq17ZLzztNEWCE nkFHbiCzrkgNg11j02Kja93Nu9FFrz7tRnLUsTH5k1Xuk13gAEZwV6Yb9wSwgwK6Mi2D ZI/yLbScn32OpY1ZSC1+6F+E6vFb6VpS8+6VAqjNeNbhcmE+Z3qx5C6LOlMnh3IAL4T7 LXng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=3XA6dQx2okYJlav+7EBcRXTzZuGUDtxOanRBdKGs0BY=; b=phtscCj6JnffHhlWO2l761+qobhWa9++AXk4vXi6pdZ1XAo2M5kRuoX2q2uehWE8+q bSO/0f52ZfUKVN+uYNHhvrQ1ItYO0JTvWPYaN8CBmPFHxf1ALfyg4pg0JKkQ9v1eX4Ea fHLHUfvjQrTaO+s7QSWEG/KAQpGRvuUlDYurk6dyQldK/BnWSuokCJZpQrKrvkWfT++o NfbQGvF6OUl1t+uODtH4vhUjgSiE45aCmSIY2uACJdgeY0pgxy8nmin1EeybSpJ59ooh UaHat2DDmFoGAzzESUtGfbYlW/RPsbrqFf89Q8lv3bv4aqhvglS9yW0cHr5ep4LtJ4JW NMig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SXKEXVwV; 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=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y9-20020a056402270900b0043763a95ce9si14416600edd.458.2022.06.28.05.23.53; Tue, 28 Jun 2022 05:24:18 -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=@linaro.org header.s=google header.b=SXKEXVwV; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239550AbiF1MIs (ORCPT + 99 others); Tue, 28 Jun 2022 08:08:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235331AbiF1MIr (ORCPT ); Tue, 28 Jun 2022 08:08:47 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8626133348 for ; Tue, 28 Jun 2022 05:08:45 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id z19so17208503edb.11 for ; Tue, 28 Jun 2022 05:08:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=3XA6dQx2okYJlav+7EBcRXTzZuGUDtxOanRBdKGs0BY=; b=SXKEXVwV1LXjuUVs4Grljr7qurz7/UMqbt1kPD6WOCog/OUfNetmO279XsQQ+MC4wA ywSLYTwl7UaleD8jnS80jxMkLOA8GGgr8inMKWBgf9Aytr6nx4pttcrB3vYcU4OeAvqM 8Q0FqOX0MaUxqwEDBxSxFlSU1M4ca3cjjeX4NAsVhUAbkhPFXgWVcWPbJGoh1D0EeoMh AZpzV/LkdRANyEnweW1WJMwM8NyhgXY/QKsBy4wDew068v6WGBPCTac9GRARakGHvg6z NR+jSjWAU3kaFLy3qMc0eR5tT01eJvBCELfK7d99IH4E1CdhH4sU2CBy9JM3puE4kxmR SpHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=3XA6dQx2okYJlav+7EBcRXTzZuGUDtxOanRBdKGs0BY=; b=Dotdba4rkXIkdmJualOWIKfnoPQmzgQNCpNnVOS+wlEBPWNcs1zeMmgCtyYq8YKb4b HfR8YyFusV7h+RZR7NMPr7Mz+EWukuH2r/2kXkcwRJ5zzx3JY07ya4YuzpuiKif8zWO6 mrzVDeBfRFdgrEPemyAWB8eXT9KOw9Q8vkCJ+f8lYPBxlrCdjEsUAKG+1PaLtLjSH9b+ o3Ex1KEQvxTUIwpZg1R3L1tohj3sUAWUo9U65CcaQMedw/SncaxLFtqf2gTaaiNAMT7e GV/uj4K/KWctCwropX7afRCEUcs8hULqw2QLJkeNd0HZqSZd5h8YXk3kFURGEMz8MUzQ +XMg== X-Gm-Message-State: AJIora+aXFuP8sA+hKLEJgeXD9AQFvC0Q43ZbGR5DxeOC5xYXbS1ct9y oRD7uXkQyVpNr0ZGNaNytHC7xw== X-Received: by 2002:a05:6402:1e93:b0:435:7f3f:407f with SMTP id f19-20020a0564021e9300b004357f3f407fmr23061634edf.173.1656418124118; Tue, 28 Jun 2022 05:08:44 -0700 (PDT) Received: from [192.168.1.12] (88-107-17-60.dynamic.dsl.as9105.com. [88.107.17.60]) by smtp.gmail.com with ESMTPSA id w20-20020aa7dcd4000000b0042dc882c823sm9322319edu.70.2022.06.28.05.08.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 28 Jun 2022 05:08:43 -0700 (PDT) Message-ID: <408cb630-9ded-0e47-5dcd-6fc8feec79e0@linaro.org> Date: Tue, 28 Jun 2022 13:08:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 Subject: Re: [PATCH] dmaengine: qcom: bam_dma: fix runtime PM underflow Content-Language: en-US To: Vinod Koul Cc: Andy Gross , Bjorn Andersson , Srinivas Kandagatla , linux-arm-msm@vger.kernel.org, dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220609195043.1544625-1-caleb.connolly@linaro.org> From: Caleb Connolly In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 16/06/2022 15:00, Vinod Koul wrote: > On 09-06-22, 20:50, Caleb Connolly wrote: >> When PM runtime is disabled, pm_runtime_get() isn't called, but >> pm_runtime_put() still is. Fix this by creating a matching wrapper >> on pm_runtime_put_autosuspend(). >> >> Fixes: dbad41e7bb5f ("dmaengine: qcom: bam_dma: check if the runtime pm enabled") >> Signed-off-by: Caleb Connolly >> --- >> drivers/dma/qcom/bam_dma.c | 18 +++++++++++++----- >> 1 file changed, 13 insertions(+), 5 deletions(-) >> >> diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c >> index 87f6ca1541cf..a36dedee262e 100644 >> --- a/drivers/dma/qcom/bam_dma.c >> +++ b/drivers/dma/qcom/bam_dma.c >> @@ -566,6 +566,14 @@ static int bam_pm_runtime_get_sync(struct device *dev) >> return 0; >> } >> >> +static int bam_pm_runtime_put_autosuspend(struct device *dev) >> +{ >> + if (pm_runtime_enabled(dev)) >> + return pm_runtime_put_autosuspend(dev); >> + >> + return 0; >> +} > > should we really do a wrapper to fix this ;-) I would think dropping the > get wrapper and calling pm_runtime_get() unconditionally would be > better..? The original pm_runtime_get() wrapper was added because _get() returns -EACCES if PM is disabled for the device, I've read through some of the pm_runtime docs and I don't see any way to handle this nicely in the framework. I think the real fix will have to be in pm_runtime. I can rework this to explicitly check for -EACCES on every _get() call, but we still need to check if pm_runtime is enabled before calling _put(). > >> + >> /** >> * bam_free_chan - Frees dma resources associated with specific channel >> * @chan: specified channel >> @@ -617,7 +625,7 @@ static void bam_free_chan(struct dma_chan *chan) >> >> err: >> pm_runtime_mark_last_busy(bdev->dev); >> - pm_runtime_put_autosuspend(bdev->dev); >> + bam_pm_runtime_put_autosuspend(bdev->dev); >> } >> >> /** >> @@ -793,7 +801,7 @@ static int bam_pause(struct dma_chan *chan) >> bchan->paused = 1; >> spin_unlock_irqrestore(&bchan->vc.lock, flag); >> pm_runtime_mark_last_busy(bdev->dev); >> - pm_runtime_put_autosuspend(bdev->dev); >> + bam_pm_runtime_put_autosuspend(bdev->dev); >> >> return 0; >> } >> @@ -819,7 +827,7 @@ static int bam_resume(struct dma_chan *chan) >> bchan->paused = 0; >> spin_unlock_irqrestore(&bchan->vc.lock, flag); >> pm_runtime_mark_last_busy(bdev->dev); >> - pm_runtime_put_autosuspend(bdev->dev); >> + bam_pm_runtime_put_autosuspend(bdev->dev); >> >> return 0; >> } >> @@ -936,7 +944,7 @@ static irqreturn_t bam_dma_irq(int irq, void *data) >> } >> >> pm_runtime_mark_last_busy(bdev->dev); >> - pm_runtime_put_autosuspend(bdev->dev); >> + bam_pm_runtime_put_autosuspend(bdev->dev); >> >> return IRQ_HANDLED; >> } >> @@ -1111,7 +1119,7 @@ static void bam_start_dma(struct bam_chan *bchan) >> bam_addr(bdev, bchan->id, BAM_P_EVNT_REG)); >> >> pm_runtime_mark_last_busy(bdev->dev); >> - pm_runtime_put_autosuspend(bdev->dev); >> + bam_pm_runtime_put_autosuspend(bdev->dev); >> } >> >> /** >> -- >> 2.36.1 > -- Kind Regards, Caleb (they/he)