From: Lukas Wunner <lukas@wunner.de>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Marcel Holtmann <marcel@holtmann.org>,
Gustavo Padovan <gustavo@padovan.org>,
Johan Hedberg <johan.hedberg@gmail.com>,
linux-bluetooth@vger.kernel.org, linux-serial@vger.kernel.org,
linux-acpi@vger.kernel.org
Subject: Re: [PATCH 1/2] Bluetooth: hci_bcm: Don't change runtime-status when not using runtime-pm
Date: Sat, 24 Mar 2018 15:19:09 +0100 [thread overview]
Message-ID: <20180324141909.GA2013@wunner.de> (raw)
In-Reply-To: <8f97d9b8-ce7d-fa77-cf12-31c12025b0f1@redhat.com>
On Sat, Mar 24, 2018 at 12:07:10PM +0100, Hans de Goede wrote:
> On 24-03-18 09:02, Lukas Wunner wrote:
> >On Mon, Mar 19, 2018 at 10:02:36PM +0100, Hans de Goede wrote:
> >>The pm_runtime_set_suspended() call in bcm_close() is intended as a
> >>counterpart to the pm_runtime_set_active() call from bcm_request_irq()
> >>(which gets called from bcm_setup()).
> >>
> >>The pm_runtime_set_active() call only happens if our pre-requisites for
> >>doing runtime-pm are met. This commit adds the same check to the
> >>pm_runtime_set_suspended() call to avoid the runtime-pm state getting
> >>stuck in suspended after after a bcm_close().
> >
> >Have you actually observed the state getting stuck in suspended?
> >I'm asking because I don't quite see how this could happen:
> >pm_runtime_set_suspended() becomes a no-op unless runtime PM is disabled.
> >Now, a few lines further up in bcm_close(), pm_runtime_disable() is only
> >called under the conditions you're adding here. If it's not called,
> >pm_runtime_set_suspended() doesn't have any effect anyway so adding the
> >conditions is pointless. Am I missing something?
>
> All devices start with runtime-pm disabled and on devices without
> an IRQ we never enable it. So when the pm_runtime_set_suspended()
> gets called runtime-pm is still in its initial disabled state.
Okay but the device's initial state is set to RPM_SUSPENDED by
pm_runtime_init() and AFAICS neither the platform nor acpi buses
subsequently set it to RPM_ACTIVE, so the device is in suspended
state anyway, unless I've overlooked some detail.
Which raises another question, bcm_suspend() only calls
bcm_suspend_device() if it's runtime active. So devices
without IRQ, which are always in runtime suspended state,
are apparently never orderly put to sleep on ->suspend.
Also, if the device is always in suspended state, there's nothing
that keeps the UART in active state. Has anyone ever actually
tested if this driver works without IRQ?
> >Related: I notice that bcm_resume() calls pm_runtime_set_active().
> >Doesn't that have the effect that if the device is not opened and
> >the system goes to sleep, the device is kept in runtime active state
> >after resume and thus prevents the UART from runtime suspending until
> >the device is opened?
>
> AFAIK this just tells runtime pm that we've woken up the device
> (which we have), so that it does not call bcm_resume_device() *again*
> on the first runtime_pm_get().
That's odd, by default the PM core runtime resumes a device before
going to system sleep, the only exception is if the devices uses
the "direct_complete" procedure, which requires that ->prepare
returns a positive int. The platform bus doesn't even have a
->prepare hook, so never uses direct complete AFAICS, and the acpi
bus uses direct_complete only under certain conditions and even then
devices seem to be resumed to runtime active state when the system wakes,
according to the code comment in acpi_subsys_resume_noirq().
So the pm_runtime_set_active() in bcm_resume() looks odd to me.
> The pm_runtime_enable() will start the
> autosuspend timer I believe (I could be wrong I'm not an expert on this)
> and then we will autosuspend again after the timer expires.
No, pm_runtime_enable() doesn't do that, but device_complete calls
pm_runtime_put() as the last step when coming out of system sleep,
and that will start the autosuspend timer.
Thanks,
Lukas
next prev parent reply other threads:[~2018-03-24 14:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-19 21:02 [PATCH 1/2] Bluetooth: hci_bcm: Don't change runtime-status when not using runtime-pm Hans de Goede
2018-03-19 21:02 ` [PATCH 2/2] Bluetooth: hci_bcm: Add broken-irq dmi blacklist and add Meegopad T08 to it Hans de Goede
2018-03-24 8:02 ` [PATCH 1/2] Bluetooth: hci_bcm: Don't change runtime-status when not using runtime-pm Lukas Wunner
2018-03-24 11:07 ` Hans de Goede
2018-03-24 14:19 ` Lukas Wunner [this message]
2018-04-03 12:55 ` Hans de Goede
2018-04-03 14:16 ` Marcel Holtmann
2018-04-03 14:42 ` Hans de Goede
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=20180324141909.GA2013@wunner.de \
--to=lukas@wunner.de \
--cc=gustavo@padovan.org \
--cc=hdegoede@redhat.com \
--cc=johan.hedberg@gmail.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=marcel@holtmann.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.