Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3179635imw; Mon, 11 Jul 2022 03:41:02 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tcZTsTzxGfvy0Keo3PFoentKSy65WWfHbSbi/i0hnr8Jb0dTufxVv0d7V7R5EznMKjewD6 X-Received: by 2002:a17:907:7f8e:b0:712:f503:1a56 with SMTP id qk14-20020a1709077f8e00b00712f5031a56mr17409352ejc.364.1657536062262; Mon, 11 Jul 2022 03:41:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657536062; cv=none; d=google.com; s=arc-20160816; b=Go1a1cXPiHA/GA2ldQg8vI5KvyaW65nO737Hkr8KdwGkhPgSi5OBJAzns73SWgruj1 uK9DLD+BGc1qeJMhhp5b+F12AgYLg3od81e1c3t5zReUOiG27Ox0mFnlp0wIsoA8wqb4 Q0QeWtg/nStr4xrDsIWEaKQsA4tw/PrB1LMn+RdevSS73WVbY+vzSK3wKI+ahCitt3t1 Jf+4/EAlrV2IuETAjoN6Ih5TjHRMdO14NGV9WlgElu/5pxuHMRrpFsUEk3UgGPaFth1i fCHTsWkuGCnmy8gES+q8ElurEXZkDud+XANKRKV7MfFJB05zx+IQgz7rd7qv7YdgUR/c Uz/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AOMw4VrIuh6RjZV/XZ8La6zTONM8dcJCFPsDXfjMffo=; b=eS8ASi9nZ6FWZxVBLG/1T/xoIUAar4+oVubj26qPsz4L6LK2dDGi04+RBf/63W/LAM KZGYa/GOtVESbSaaDZtigO+YFSHrydytFZLWKKxxBkjWY+YRpRzaHhn4Grx6LQbeQkeP 3JCewJ7HEuny8K2KVIDvOVs1NIyloh89uynDS2BD1YdUYN2P0ezBxQRiLE9jnRkww6KV geRG26KEodPUkNz3/959wDT4tJwkpUnhy5MhXphfJIIp6voE4JAvBbiB9oxaxFQGb3l7 UWoU5R6J6Y6DDPL08hpK+GAtTdMhuWAdEQ63F3v5X9WxNi1qZZqraW4goJTqvEBN6ING LJYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="nQNBR/Rw"; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u3-20020a17090657c300b007263a6115adsi8570913ejr.893.2022.07.11.03.40.37; Mon, 11 Jul 2022 03:41:02 -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=@linuxfoundation.org header.s=korg header.b="nQNBR/Rw"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233029AbiGKJhO (ORCPT + 99 others); Mon, 11 Jul 2022 05:37:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232879AbiGKJgi (ORCPT ); Mon, 11 Jul 2022 05:36:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E9B9823A0; Mon, 11 Jul 2022 02:19:03 -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 BAEF86111F; Mon, 11 Jul 2022 09:19:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4D83C34115; Mon, 11 Jul 2022 09:19:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1657531142; bh=gqWazm/mNwpkstb0KhVnW7UFdBsaUH4OBtp1yI4PIXk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nQNBR/Rwn3S/TOl5S0m3nWKHazzCN2hbiFq8ZNAaCQrevJ684hGA9D77YYI8BwzA4 tT0AcpSEafdB2E7Sx8NXom2G3ntoFuHX24HqJ+UB8wMRK7777DBXWDbkKXQLucfZ7M qVAXBtCy+ErOODTABACI18//JikqapyntHE65kbQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephan Gerhold , Caleb Connolly , Vinod Koul Subject: [PATCH 5.18 110/112] dmaengine: qcom: bam_dma: fix runtime PM underflow Date: Mon, 11 Jul 2022 11:07:50 +0200 Message-Id: <20220711090552.690669633@linuxfoundation.org> X-Mailer: git-send-email 2.37.0 In-Reply-To: <20220711090549.543317027@linuxfoundation.org> References: <20220711090549.543317027@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 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 From: Caleb Connolly commit 0ac9c3dd0d6fe293cd5044cfad10bec27d171e4e upstream. Commit dbad41e7bb5f ("dmaengine: qcom: bam_dma: check if the runtime pm enabled") caused unbalanced pm_runtime_get/put() calls when the bam is controlled remotely. This commit reverts it and just enables pm_runtime in all cases, the clk_* functions already just nop when the clock is NULL. Also clean up a bit by removing unnecessary bamclk null checks. Suggested-by: Stephan Gerhold Fixes: dbad41e7bb5f ("dmaengine: qcom: bam_dma: check if the runtime pm enabled") Signed-off-by: Caleb Connolly Link: https://lore.kernel.org/r/20220629140559.118537-1-caleb.connolly@linaro.org Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman --- drivers/dma/qcom/bam_dma.c | 39 +++++++++++---------------------------- 1 file changed, 11 insertions(+), 28 deletions(-) --- a/drivers/dma/qcom/bam_dma.c +++ b/drivers/dma/qcom/bam_dma.c @@ -558,14 +558,6 @@ static int bam_alloc_chan(struct dma_cha return 0; } -static int bam_pm_runtime_get_sync(struct device *dev) -{ - if (pm_runtime_enabled(dev)) - return pm_runtime_get_sync(dev); - - return 0; -} - /** * bam_free_chan - Frees dma resources associated with specific channel * @chan: specified channel @@ -581,7 +573,7 @@ static void bam_free_chan(struct dma_cha unsigned long flags; int ret; - ret = bam_pm_runtime_get_sync(bdev->dev); + ret = pm_runtime_get_sync(bdev->dev); if (ret < 0) return; @@ -784,7 +776,7 @@ static int bam_pause(struct dma_chan *ch unsigned long flag; int ret; - ret = bam_pm_runtime_get_sync(bdev->dev); + ret = pm_runtime_get_sync(bdev->dev); if (ret < 0) return ret; @@ -810,7 +802,7 @@ static int bam_resume(struct dma_chan *c unsigned long flag; int ret; - ret = bam_pm_runtime_get_sync(bdev->dev); + ret = pm_runtime_get_sync(bdev->dev); if (ret < 0) return ret; @@ -919,7 +911,7 @@ static irqreturn_t bam_dma_irq(int irq, if (srcs & P_IRQ) tasklet_schedule(&bdev->task); - ret = bam_pm_runtime_get_sync(bdev->dev); + ret = pm_runtime_get_sync(bdev->dev); if (ret < 0) return IRQ_NONE; @@ -1037,7 +1029,7 @@ static void bam_start_dma(struct bam_cha if (!vd) return; - ret = bam_pm_runtime_get_sync(bdev->dev); + ret = pm_runtime_get_sync(bdev->dev); if (ret < 0) return; @@ -1374,11 +1366,6 @@ static int bam_dma_probe(struct platform if (ret) goto err_unregister_dma; - if (!bdev->bamclk) { - pm_runtime_disable(&pdev->dev); - return 0; - } - pm_runtime_irq_safe(&pdev->dev); pm_runtime_set_autosuspend_delay(&pdev->dev, BAM_DMA_AUTOSUSPEND_DELAY); pm_runtime_use_autosuspend(&pdev->dev); @@ -1462,10 +1449,8 @@ static int __maybe_unused bam_dma_suspen { struct bam_device *bdev = dev_get_drvdata(dev); - if (bdev->bamclk) { - pm_runtime_force_suspend(dev); - clk_unprepare(bdev->bamclk); - } + pm_runtime_force_suspend(dev); + clk_unprepare(bdev->bamclk); return 0; } @@ -1475,13 +1460,11 @@ static int __maybe_unused bam_dma_resume struct bam_device *bdev = dev_get_drvdata(dev); int ret; - if (bdev->bamclk) { - ret = clk_prepare(bdev->bamclk); - if (ret) - return ret; + ret = clk_prepare(bdev->bamclk); + if (ret) + return ret; - pm_runtime_force_resume(dev); - } + pm_runtime_force_resume(dev); return 0; }