LKML Archive on lore.kernel.org
 help / color / Atom feed
From: Dinghao Liu <dinghao.liu@zju.edu.cn>
To: dinghao.liu@zju.edu.cn, kjlu@umn.edu
Cc: Vinod Koul <vkoul@kernel.org>,
	Dan Williams <dan.j.williams@intel.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	dmaengine@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH] dmaengine: stm32-dmamux: Fix runtime PM imbalance on error
Date: Sun, 24 May 2020 14:02:23 +0800
Message-ID: <20200524060224.16189-1-dinghao.liu@zju.edu.cn> (raw)

In stm32_dmamux_route_allocate(),  pm_runtime_get_sync() increments
the runtime PM usage counter even when it returns an error code.
Thus a pairing decrement is needed on the error handling path to
keep the counter balanced.

In stm32_dmamux_probe(), when platform_get_resource() returns an
error code, a pairing runtime PM usage counter decrement is needed
to keep the counter balanced. For error paths after this call,
things are the same.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/dma/stm32-dmamux.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/stm32-dmamux.c b/drivers/dma/stm32-dmamux.c
index 12f7637e13a1..e68e7078ff94 100644
--- a/drivers/dma/stm32-dmamux.c
+++ b/drivers/dma/stm32-dmamux.c
@@ -139,6 +139,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
 	spin_lock_irqsave(&dmamux->lock, flags);
 	ret = pm_runtime_get_sync(&pdev->dev);
 	if (ret < 0) {
+		pm_runtime_put_noidle(&pdev->dev);
 		spin_unlock_irqrestore(&dmamux->lock, flags);
 		goto error;
 	}
@@ -246,8 +247,10 @@ static int stm32_dmamux_probe(struct platform_device *pdev)
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	iomem = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(iomem))
+	if (IS_ERR(iomem)) {
+		pm_runtime_put_noidle(&pdev->dev);
 		return PTR_ERR(iomem);
+	}
 
 	spin_lock_init(&stm32_dmamux->lock);
 
@@ -256,12 +259,14 @@ static int stm32_dmamux_probe(struct platform_device *pdev)
 		ret = PTR_ERR(stm32_dmamux->clk);
 		if (ret != -EPROBE_DEFER)
 			dev_err(&pdev->dev, "Missing clock controller\n");
+		pm_runtime_put_noidle(&pdev->dev);
 		return ret;
 	}
 
 	ret = clk_prepare_enable(stm32_dmamux->clk);
 	if (ret < 0) {
 		dev_err(&pdev->dev, "clk_prep_enable error: %d\n", ret);
+		pm_runtime_put_noidle(&pdev->dev);
 		return ret;
 	}
 
@@ -300,6 +305,7 @@ static int stm32_dmamux_probe(struct platform_device *pdev)
 	return 0;
 
 err_clk:
+	pm_runtime_put_noidle(&pdev->dev);
 	clk_disable_unprepare(stm32_dmamux->clk);
 
 	return ret;
-- 
2.17.1


                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200524060224.16189-1-dinghao.liu@zju.edu.cn \
    --to=dinghao.liu@zju.edu.cn \
    --cc=alexandre.torgue@st.com \
    --cc=dan.j.williams@intel.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=kjlu@umn.edu \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git