mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>
To: "jassisinghbrar@gmail.com" <jassisinghbrar@gmail.com>,
	"angelogioacchino.delregno@collabora.com"
	<angelogioacchino.delregno@collabora.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Singo Chang (張興國)" <Singo.Chang@mediatek.com>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>
Subject: Re: [PATCH] mailbox: mtk-cmdq: Add unregister mailbox controller in cmdq_remove()
Date: Wed, 17 Jul 2024 03:44:15 +0000	[thread overview]
Message-ID: <470f96fc0dd48ad0ad6bedb235a2e510c808e3e7.camel@mediatek.com> (raw)
In-Reply-To: <a681e496-4979-4f4a-9f79-9636d9496fa3@collabora.com>

On Tue, 2024-06-18 at 13:47 +0200, AngeloGioacchino Del Regno wrote:
> Il 18/06/24 05:28, Jason-JH Lin (林睿祥) ha scritto:
> > Hi Angelo,
> > 
> > On Fri, 2024-06-14 at 00:52 +0800, Jason-JH.Lin wrote:
> > > Hi Angelo,
> > > 
> > > On Thu, 2024-06-13 at 17:10 +0200, AngeloGioacchino Del Regno
> > > wrote:
> > > > Il 13/06/24 17:06, Jason-JH.Lin ha scritto:
> > > > > Add unregister mailbox controller in cmdq_remove to fix cmdq
> > > > > unbind
> > > > > WARN_ON message from pm_runtime_get_sync() in
> > > > > cmdq_mbox_shutdown().
> > > > > 
> > > > > Fixes: 623a6143a845 ("mailbox: mediatek: Add Mediatek CMDQ
> > > > > driver")
> > > > > Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> > > > 
> > > > Hello,
> > > > 
> > > > I think you forgot about...
> > > > 
> > > > 
> > > 
> > > 
> > 
> > 
https://lore.kernel.org/all/6fcd48b14e865c25e6db7559fe6b946537bfa0ce.camel@mediatek.com/
> > > > 
> > > 
> > > I'll send this series next week after testing it.
> > > 
> > > 
> > > > ...as that would also resolve this one without any hacks.
> > > 
> > > I thought it was another problem, so I sent this patch.
> > > 
> > > After looking to the kerneldoc of
> > > devm_mbox_controller_unregister(),
> > > I
> > > found that it's not necessary to call this anywhere.
> > > 
> > > I'll drop this patch. Thanks for the review.
> > 
> > I found that the series of "Move pm_runimte_get and put to
> > mbox_chan_ops API" can not fix this unbind crash issue.
> > 
> > It seems they are 2 different issues.
> > 
> > So I think calling devm_mbox_controller_unregister() in
> > cmdq_remove()
> > can ensure the CMDQ device is not removed and be paired to
> > cmdq_probe().
> > 
> 
> Can you please paste the stack trace of that warning that you're
> seeing when
> calling cmdq_remove()?
> 
> I'm not convinced that this is the best solution - it might be, but I
> have
> a hunch that there might be a better way to address this issue.
> 

After tracing the stack trace again, I found this call trace warning is
caused in WARN_ON(pm_runtime_get_sync(cmdq->mbox.dev) < 0). The return
value of pm_runtime_get_sync() is -13(-EACCESS) that's caused by
calling pm_runtime_disable() before calling pm_runtime_get_sync().

CMDQ driver uses devm_mbox_controller_register() in cmdq_probe() to
bind the cmdq device to the mbox_controller, so
devm_mbox_controller_unregister() will automatically unregister the
device bound to the mailbox controller when the device-managed resource
is removed. That means devm_mbox_controller_unregister() and
cmdq_mbox_shoutdown() will be called after cmdq_remove().

CMDQ driver also uses devm_pm_runtime_enable() in cmdq_probe() after
devm_mbox_controller_register(), so that devm_pm_runtime_disable() will
be called after cmdq_remove(), but before
devm_mbox_controller_unregister().


To fix this problem, we need to make devm_pm_runtime_disable() be
called after devm_mbox_controller_unregister().

I've tried 2 ways can fix this problem:
- Swap the sequence of devm_mbox_controller_register() and
devm_pm_runtime_enable() in cmdq_probe()
- Change to use mbox_controller_register() in cmdq_probe() and use
mbox_controller_unregister() in cmdq_probe()

Which one do you think is better?

Regards,
Jason-JH.Lin

> Thanks!
> Angelo
> 
> > Regards,
> > Jason-JH.Lin
> > 
> > > 
> > > Regards,
> > > Jason-JH.Lin
> > > 
> > > > 
> > > > Cheers,
> > > > Angelo
> > > > 
> > > > > ---
> > > > >    drivers/mailbox/mtk-cmdq-mailbox.c | 2 ++
> > > > >    1 file changed, 2 insertions(+)
> > > > > 
> > > > > diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c
> > > > > b/drivers/mailbox/mtk-cmdq-mailbox.c
> > > > > index 4aa394e91109..1399e18a39a4 100644
> > > > > --- a/drivers/mailbox/mtk-cmdq-mailbox.c
> > > > > +++ b/drivers/mailbox/mtk-cmdq-mailbox.c
> > > > > @@ -371,6 +371,8 @@ static void cmdq_remove(struct
> > > > > platform_device
> > > > > *pdev)
> > > > >    {
> > > > >    	struct cmdq *cmdq = platform_get_drvdata(pdev);
> > > > >    
> > > > > +	devm_mbox_controller_unregister(&pdev->dev, &cmdq-
> > > > > >mbox);
> > > > > +
> > > > >    	if (cmdq->pdata->sw_ddr_en)
> > > > >    		cmdq_sw_ddr_enable(cmdq, false);
> > > > >    
> > > > 
> > > > 
> 
> 

  parent reply	other threads:[~2024-07-17  3:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-13 15:06 Jason-JH.Lin
2024-06-13 15:10 ` AngeloGioacchino Del Regno
2024-06-13 16:53   ` Jason-JH Lin (林睿祥)
2024-06-18  3:28     ` Jason-JH Lin (林睿祥)
2024-06-18 11:47       ` AngeloGioacchino Del Regno
2024-06-19 16:06         ` Jason-JH Lin (林睿祥)
2024-07-17  3:44         ` Jason-JH Lin (林睿祥) [this message]
2024-07-17 13:28           ` AngeloGioacchino Del Regno

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=470f96fc0dd48ad0ad6bedb235a2e510c808e3e7.camel@mediatek.com \
    --to=jason-jh.lin@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Singo.Chang@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    /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®