netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephan Gerhold <stephan.gerhold@linaro.org>
To: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>,
	stephan@gerhold.net, loic.poulain@linaro.org,
	ryazanov.s.a@gmail.com, johannes@sipsolutions.net,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com, netdev@vger.kernel.org,
	linux-arm-msm@vger.kernel.org
Subject: Re: [PATCH] net: wwan: qcom_bam_dmux: Fix missing pm_runtime_disable()
Date: Mon, 23 Sep 2024 11:05:00 +0200	[thread overview]
Message-ID: <ZvEvPIsraXpZFm4k@linaro.org> (raw)
In-Reply-To: <04cf9e68-ef69-dade-0b56-205a3aa4e653@huawei.com>

On Mon, Sep 23, 2024 at 10:25:28AM +0800, Jinjie Ruan wrote:
> 
> 
> On 2024/9/20 21:38, Stephan Gerhold wrote:
> > On Fri, Sep 20, 2024 at 03:05:13PM +0200, Dmitry Baryshkov wrote:
> >> On Fri, 20 Sept 2024 at 14:44, Stephan Gerhold
> >> <stephan.gerhold@linaro.org> wrote:
> >>>
> >>> On Fri, Sep 20, 2024 at 01:48:15PM +0300, Dmitry Baryshkov wrote:
> >>>> On Fri, Sep 20, 2024 at 06:07:11PM GMT, Jinjie Ruan wrote:
> >>>>> It's important to undo pm_runtime_use_autosuspend() with
> >>>>> pm_runtime_dont_use_autosuspend() at driver exit time.
> >>>>>
> >>>>> But the pm_runtime_disable() and pm_runtime_dont_use_autosuspend()
> >>>>> is missing in the error path for bam_dmux_probe(). So add it.
> >>>>
> >>>> Please use devm_pm_runtime_enable(), which handles autosuspend.
> >>>>
> >>>
> >>> This would conflict with the existing cleanup in bam_dmux_remove(),
> >>> which probably needs to stay manually managed since the tear down order
> >>> is quite important there.
> >>
> >> Hmm, the setup and teardown code makes me wonder now.
> > 
> > Yeah, you ask the right questions. :-) It's really tricky to get this
> > 100% right. I spent quite some time to get close, but there are likely
> > still some loopholes. I haven't heard of anyone running into trouble,
> > though. This driver has been rock solid for the past few years.
> > 
> >> Are we guaranteed that the IRQs can not be delivered after suspending
> >> the device?
> > 
> > I think bam_dmux_remove() should be safe. disable_irq(dmux->pc_irq)
> > prevents any further delivery of IRQs before doing the final power off.
> > 
> >> Also is there a race between IRQs being enabled, manual check of the
> >> IRQ state and the pc_ack / power_off calls?
> > 
> > Yes, I'm pretty sure this race exists in theory. I'm not sure how to
> > avoid it. We would need an atomic "return current state and enable IRQ"
> > operation, but I don't think this exists at the moment. Do you have any
> > suggestions?
> 
> Maybe use IRQF_NO_AUTOEN flag to reuqest irq and enable_irq() after that?
> 

I thought about that too, but I think that might introduce a small
window in between the two calls where we would miss the state change:

	irq_get_irqchip_state(..., IRQCHIP_STATE_LINE_LEVEL, ...);
	/* if an interrupt arrives here we will miss the state change */
	enable_irq();

Thanks,
Stephan

  reply	other threads:[~2024-09-23  9:05 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-20 10:07 [PATCH] net: wwan: qcom_bam_dmux: Fix missing pm_runtime_disable() Jinjie Ruan
2024-09-20 10:48 ` Dmitry Baryshkov
2024-09-20 12:44   ` Stephan Gerhold
2024-09-20 13:05     ` Dmitry Baryshkov
2024-09-20 13:38       ` Stephan Gerhold
2024-09-23  2:25         ` Jinjie Ruan
2024-09-23  9:05           ` Stephan Gerhold [this message]
2024-09-20 12:45 ` Stephan Gerhold
2024-09-23  9:16   ` Jinjie Ruan

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=ZvEvPIsraXpZFm4k@linaro.org \
    --to=stephan.gerhold@linaro.org \
    --cc=davem@davemloft.net \
    --cc=dmitry.baryshkov@linaro.org \
    --cc=edumazet@google.com \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=loic.poulain@linaro.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ruanjinjie@huawei.com \
    --cc=ryazanov.s.a@gmail.com \
    --cc=stephan@gerhold.net \
    /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;
as well as URLs for NNTP newsgroup(s).