From: Frank Li <Frank.li@oss.nxp.com>
To: Mizuno Miotsuki <founder@crepuse.com>
Cc: "vkoul@kernel.org" <vkoul@kernel.org>,
"dmaengine@vger.kernel.org" <dmaengine@vger.kernel.org>,
"krzk@kernel.org" <krzk@kernel.org>,
"ulfh@kernel.org" <ulfh@kernel.org>,
"Frank.Li@kernel.org" <Frank.Li@kernel.org>,
"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
"huibin.hong@rock-chips.com" <huibin.hong@rock-chips.com>,
"rmk+kernel@arm.linux.org.uk" <rmk+kernel@arm.linux.org.uk>,
"sugar.zhang@rock-chips.com" <sugar.zhang@rock-chips.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] dmaengine: pl330: Fix unbalanced runtime PM
Date: Tue, 27 Oct 2026 11:34:08 -0400 [thread overview]
Message-ID: <auDEcFRBeICtT6LP@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <C35ADE64-5E80-454C-A66A-BA2B22EFF386@crepuse.com>
On Fri, Oct 16, 2026 at 10:49:31AM +0000, Mizuno Miotsuki wrote:
> Hi Frank,
>
> Thanks for the review.
>
> > Look like need lock between terminate and issue_pendings. There are should
> > other problems if interfere each others.
> >
> > terminate should wait issue_pending finish and block queue new request.
>
> Both pl330_issue_pending() and pl330_terminate_all() already use
> pch->lock to protect the channel state. However, issue_pending()
> also invokes pl330_tasklet() after releasing the lock, so this
> does not establish complete synchronization.
>
> I ran a source-based interleaving test. The original
> code reproduces the extra runtime PM put after termination, while
> the proposed one-line fix balances the references under the same
> interleaving.
>
> > This function can be called in an interrupt context
> >
> > call pm_runtime_get() is risk, which may sleep.
>
> pl330_probe() calls pm_runtime_irq_safe(&adev->dev), and the AMBA
> runtime PM callbacks use clk_enable()/clk_disable() for IRQ-safe
> devices. This allows pm_runtime_get_sync() to be called from
> atomic context, provided the relevant PM callbacks and dependencies
> satisfy the IRQ-safe requirements.
>
> I agree that the remaining synchronization and error-handling
> paths deserve further investigation.
>
> Would it be reasonable to keep this patch focused on the
> reproduced reference-count imbalance and address any confirmed
> synchronization issues separately?
This is quick fix after I read code again. but original mothed is not
good enough, which mix use check varible and runtime_pm reference-count.
If pair get() and put(), needn't pch->active.
if (list_empty(&pch->work_list)) {
/*
* Warn on nothing pending. Empty submitted_list may
* break our pm_runtime usage counter as it is
* updated on work_list emptiness status.
*/
WARN_ON(list_empty(&pch->submitted_list));
pch->active = true;
pm_runtime_get_sync(pch->dmac->ddma.dev);
}
simple call
for_each(work_list) {
pm_runtime_get_sync()
}
ideally, there are PM API (pm_runtime_get_sync(, count(work_list)) to bump
more than 1 ref count. But you can use above code to proof concept.
In pl330_tasklet()
while (!list_empty(&pch->completed_list)) {
...
pm_runtime_put_autosuspend()
}
Keep pm ref count is the same as count of work_list. So needn't pch->active
at all.
Frank
>
> Thanks,
> Mizuno
next prev parent reply other threads:[~2026-10-27 15:34 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-20 10:27 [PATCH v2] " Sugar Zhang
2026-10-14 23:58 ` [PATCH v3] " Mizuno Miotsuki via B4 Relay
2026-10-15 16:51 ` Frank Li
2026-10-16 10:49 ` Mizuno Miotsuki
2026-10-27 15:34 ` Frank Li [this message]
2026-10-16 14:25 ` Frank Li
2026-10-16 23:39 ` Mizuno Miotsuki
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=auDEcFRBeICtT6LP@lizhi-Precision-Tower-5810 \
--to=frank.li@oss.nxp.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=founder@crepuse.com \
--cc=huibin.hong@rock-chips.com \
--cc=krzk@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=rmk+kernel@arm.linux.org.uk \
--cc=sugar.zhang@rock-chips.com \
--cc=ulfh@kernel.org \
--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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®