All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux PM <linux-pm@vger.kernel.org>,
	Al Cooper <alcooperx@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	BCM Kernel Feedback <bcm-kernel-feedback-list@broadcom.com>,
	DTML <devicetree@vger.kernel.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	linux-mmc <linux-mmc@vger.kernel.org>,
	Nicolas Saenz Julienne <nsaenz@kernel.org>,
	Ray Jui <rjui@broadcom.com>, Rob Herring <robh+dt@kernel.org>,
	Scott Branden <sbranden@broadcom.com>
Subject: Re: [PATCH 2/2] mmc: sdhci-iproc: Add support for the legacy sdhci controller on the BCM7211
Date: Fri, 11 Jun 2021 12:23:14 +0200	[thread overview]
Message-ID: <CAPDyKFq-rofbCyAhcQGt2xZykip6Le+CUDXgDwAisVOj=Tt-uA@mail.gmail.com> (raw)
In-Reply-To: <a1199e99-eb29-125b-2bac-f0abb4803c9b@gmail.com>

On Thu, 10 Jun 2021 at 17:59, Florian Fainelli <f.fainelli@gmail.com> wrote:
>
>
>
> On 6/10/2021 1:49 AM, Ulf Hansson wrote:
> > On Thu, 10 Jun 2021 at 01:59, Florian Fainelli <f.fainelli@gmail.com> wrote:
> >>
> >>
> >>
> >> On 6/9/2021 2:22 AM, Ulf Hansson wrote:
> >>> On Wed, 9 Jun 2021 at 05:07, Florian Fainelli <f.fainelli@gmail.com> wrote:
> >>>>
> >>>>
> >>>>
> >>>> On 6/8/2021 5:40 AM, Ulf Hansson wrote:
> >>>>> On Wed, 2 Jun 2021 at 21:28, Al Cooper <alcooperx@gmail.com> wrote:
> >>>>>>
> >>>>>> Add support for the legacy Arasan sdhci controller on the BCM7211 and
> >>>>>> related SoC's. This includes adding a .shutdown callback to increase
> >>>>>> the power savings during S5.
> >>>>>
> >>>>> Please split this into two separate changes.
> >>>>>
> >>>>> May I also ask about the ->shutdown() callback and in relation to S5.
> >>>>> What makes the ->shutdown callback only being invoked for S5?
> >>>>
> >>>> It is not only called for S5 (entered via poweroff on a prompt) but also
> >>>> during kexec or reboot. The poweroff path is via:
> >>>>
> >>>> kernel_power_off() -> kernel_shutdown_prepare() -> device_shutdown() ->
> >>>> .shutdown()
> >>>>
> >>>> For kexec or reboot we do not really care about power savings since we
> >>>> are about to load a new image anyway, however for S5/poweroff we do care
> >>>> about quiescing the eMMC controller in a way that its clocks and the
> >>>> eMMC device can be put into low power mode since we will stay in that
> >>>> mode for seconds/hours/days until someone presses a button on their
> >>>> remote (or other wake-up sources).
> >>>
> >>> Hmm, I am not sure I understand correctly. At shutdown we don't care
> >>> about wake-up sources from the kernel point of view, instead we treat
> >>> everything as if it will be powered off.
> >>
> >> The same .shutdown() path is used whether you kexec, reboot or poweroff,
> >> but for poweroff we do care about allowing specific wake-up sources
> >> configured as such to wake-up the system at a later time, like GPIOs,
> >> RTC, etc.
> >
> > That's true, but using the ->shutdown() callbacks in this way would
> > certainly be a new use case.
> >
> > Most subsystems/drivers don't care about power management in those
> > callbacks, but rather just about managing a graceful shutdown.
> >
> > It sounds to me like you should have a look at the hibernation
> > path/callbacks instead - or perhaps even the system suspend
> > path/callback. Normally, that's where we care about power management.
>
> The platforms we use do not support hibernation, keep in mind that these
> are embedded SoCs that support the S2 (standby), S3 (mem) and poweroff
> suspend states, hibernation is not something that we can support.
>
> >
> > I have looped in Rafael, to allow him to share his opinion on this.
> >
> >>
> >>>
> >>> We put devices into low power state at system suspend and potentially
> >>> also during some of the hibernation phases.
> >>>
> >>> Graceful shutdown of the eMMC is also managed by the mmc core.
> >>
> >> AFAICT that calls mmc_blk_shutdown() but that is pretty much it, the
> >> SDHCI platform_driver still needs to do something in order to conserve
> >> power including disabling host->clk, otherwise we would not have done
> >> that for sdhci-brcmstb.c.
> >
> > That's not entirely correct. When mmc_bus_shutdown() is called for the
> > struct device* that belongs to an eMMC card, two actions are taken.
> >
> > *) We call mmc_blk_shutdown(), to suspend the block device queue from
> > receiving new I/O requests.
> > **) We call host->bus_ops->shutdown(), which is an eMMC specific
> > callback set to mmc_shutdown(). In this step, we do a graceful
> > shutdown/power-off of the eMMC card.
> >
> > When it comes to controller specific resources, like clocks and PM
> > domains, for example, those may very well stay turned on. Do deal with
> > these, then yes, you would need to implement the ->shutdown()
> > callback. But as I said above, I am not sure it's the right thing to
> > do.
>
> As explained before, we can enter S5 for an indefinite amount of time
> until a wake-up source wakes us up so we must conserve power, even if we
> happen to wake up the next second, we don't know that ahead of time. The
> point of calling sdhci_pltfm_suspend() here is to ensure that host->clk
> is turned off which cuts the eMMC controller digital clock, I forgot how
> much power we save by doing so, but every 10s of mW counts for us.

I fully understand that you want to avoid draining energy, every
single uA certainly counts in cases like these.

What puzzles me, is that your platform seems to keep some resources
powered on (like device clocks) when entering the system wide low
power state, S5.

In principle, I am wondering if it would be possible to use S5 as the
system-wide low power state for the system suspend path, rather than
S3, for example? In this way, we would be able to re-use already
implemented ->suspend|resume callbacks from most subsystems/drivers, I
believe. Or is there a problem with that?

I think we need an opinion from Rafel to move forward.

Kind regards
Uffe

WARNING: multiple messages have this Message-ID (diff)
From: Ulf Hansson <ulf.hansson@linaro.org>
To: Florian Fainelli <f.fainelli@gmail.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Linux PM <linux-pm@vger.kernel.org>,
	Al Cooper <alcooperx@gmail.com>,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	 BCM Kernel Feedback <bcm-kernel-feedback-list@broadcom.com>,
	DTML <devicetree@vger.kernel.org>,
	 Linux ARM <linux-arm-kernel@lists.infradead.org>,
	 linux-mmc <linux-mmc@vger.kernel.org>,
	Nicolas Saenz Julienne <nsaenz@kernel.org>,
	 Ray Jui <rjui@broadcom.com>, Rob Herring <robh+dt@kernel.org>,
	 Scott Branden <sbranden@broadcom.com>
Subject: Re: [PATCH 2/2] mmc: sdhci-iproc: Add support for the legacy sdhci controller on the BCM7211
Date: Fri, 11 Jun 2021 12:23:14 +0200	[thread overview]
Message-ID: <CAPDyKFq-rofbCyAhcQGt2xZykip6Le+CUDXgDwAisVOj=Tt-uA@mail.gmail.com> (raw)
In-Reply-To: <a1199e99-eb29-125b-2bac-f0abb4803c9b@gmail.com>

On Thu, 10 Jun 2021 at 17:59, Florian Fainelli <f.fainelli@gmail.com> wrote:
>
>
>
> On 6/10/2021 1:49 AM, Ulf Hansson wrote:
> > On Thu, 10 Jun 2021 at 01:59, Florian Fainelli <f.fainelli@gmail.com> wrote:
> >>
> >>
> >>
> >> On 6/9/2021 2:22 AM, Ulf Hansson wrote:
> >>> On Wed, 9 Jun 2021 at 05:07, Florian Fainelli <f.fainelli@gmail.com> wrote:
> >>>>
> >>>>
> >>>>
> >>>> On 6/8/2021 5:40 AM, Ulf Hansson wrote:
> >>>>> On Wed, 2 Jun 2021 at 21:28, Al Cooper <alcooperx@gmail.com> wrote:
> >>>>>>
> >>>>>> Add support for the legacy Arasan sdhci controller on the BCM7211 and
> >>>>>> related SoC's. This includes adding a .shutdown callback to increase
> >>>>>> the power savings during S5.
> >>>>>
> >>>>> Please split this into two separate changes.
> >>>>>
> >>>>> May I also ask about the ->shutdown() callback and in relation to S5.
> >>>>> What makes the ->shutdown callback only being invoked for S5?
> >>>>
> >>>> It is not only called for S5 (entered via poweroff on a prompt) but also
> >>>> during kexec or reboot. The poweroff path is via:
> >>>>
> >>>> kernel_power_off() -> kernel_shutdown_prepare() -> device_shutdown() ->
> >>>> .shutdown()
> >>>>
> >>>> For kexec or reboot we do not really care about power savings since we
> >>>> are about to load a new image anyway, however for S5/poweroff we do care
> >>>> about quiescing the eMMC controller in a way that its clocks and the
> >>>> eMMC device can be put into low power mode since we will stay in that
> >>>> mode for seconds/hours/days until someone presses a button on their
> >>>> remote (or other wake-up sources).
> >>>
> >>> Hmm, I am not sure I understand correctly. At shutdown we don't care
> >>> about wake-up sources from the kernel point of view, instead we treat
> >>> everything as if it will be powered off.
> >>
> >> The same .shutdown() path is used whether you kexec, reboot or poweroff,
> >> but for poweroff we do care about allowing specific wake-up sources
> >> configured as such to wake-up the system at a later time, like GPIOs,
> >> RTC, etc.
> >
> > That's true, but using the ->shutdown() callbacks in this way would
> > certainly be a new use case.
> >
> > Most subsystems/drivers don't care about power management in those
> > callbacks, but rather just about managing a graceful shutdown.
> >
> > It sounds to me like you should have a look at the hibernation
> > path/callbacks instead - or perhaps even the system suspend
> > path/callback. Normally, that's where we care about power management.
>
> The platforms we use do not support hibernation, keep in mind that these
> are embedded SoCs that support the S2 (standby), S3 (mem) and poweroff
> suspend states, hibernation is not something that we can support.
>
> >
> > I have looped in Rafael, to allow him to share his opinion on this.
> >
> >>
> >>>
> >>> We put devices into low power state at system suspend and potentially
> >>> also during some of the hibernation phases.
> >>>
> >>> Graceful shutdown of the eMMC is also managed by the mmc core.
> >>
> >> AFAICT that calls mmc_blk_shutdown() but that is pretty much it, the
> >> SDHCI platform_driver still needs to do something in order to conserve
> >> power including disabling host->clk, otherwise we would not have done
> >> that for sdhci-brcmstb.c.
> >
> > That's not entirely correct. When mmc_bus_shutdown() is called for the
> > struct device* that belongs to an eMMC card, two actions are taken.
> >
> > *) We call mmc_blk_shutdown(), to suspend the block device queue from
> > receiving new I/O requests.
> > **) We call host->bus_ops->shutdown(), which is an eMMC specific
> > callback set to mmc_shutdown(). In this step, we do a graceful
> > shutdown/power-off of the eMMC card.
> >
> > When it comes to controller specific resources, like clocks and PM
> > domains, for example, those may very well stay turned on. Do deal with
> > these, then yes, you would need to implement the ->shutdown()
> > callback. But as I said above, I am not sure it's the right thing to
> > do.
>
> As explained before, we can enter S5 for an indefinite amount of time
> until a wake-up source wakes us up so we must conserve power, even if we
> happen to wake up the next second, we don't know that ahead of time. The
> point of calling sdhci_pltfm_suspend() here is to ensure that host->clk
> is turned off which cuts the eMMC controller digital clock, I forgot how
> much power we save by doing so, but every 10s of mW counts for us.

I fully understand that you want to avoid draining energy, every
single uA certainly counts in cases like these.

What puzzles me, is that your platform seems to keep some resources
powered on (like device clocks) when entering the system wide low
power state, S5.

In principle, I am wondering if it would be possible to use S5 as the
system-wide low power state for the system suspend path, rather than
S3, for example? In this way, we would be able to re-use already
implemented ->suspend|resume callbacks from most subsystems/drivers, I
believe. Or is there a problem with that?

I think we need an opinion from Rafel to move forward.

Kind regards
Uffe

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2021-06-11 10:25 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-02 19:27 [PATCH 1/2] dt-bindings: mmc: sdhci-iproc: Add brcm,bcm7211a0-sdhci Al Cooper
2021-06-02 19:27 ` Al Cooper
2021-06-02 19:27 ` [PATCH 2/2] mmc: sdhci-iproc: Add support for the legacy sdhci controller on the BCM7211 Al Cooper
2021-06-02 19:27   ` Al Cooper
2021-06-08 12:40   ` Ulf Hansson
2021-06-08 12:40     ` Ulf Hansson
2021-06-09  3:07     ` Florian Fainelli
2021-06-09  3:07       ` Florian Fainelli
2021-06-09  9:22       ` Ulf Hansson
2021-06-09  9:22         ` Ulf Hansson
2021-06-09 23:59         ` Florian Fainelli
2021-06-09 23:59           ` Florian Fainelli
2021-06-10  8:49           ` Ulf Hansson
2021-06-10  8:49             ` Ulf Hansson
2021-06-10 15:59             ` Florian Fainelli
2021-06-10 15:59               ` Florian Fainelli
2021-06-11 10:23               ` Ulf Hansson [this message]
2021-06-11 10:23                 ` Ulf Hansson
2021-06-11 16:54                 ` Florian Fainelli
2021-06-11 16:54                   ` Florian Fainelli
2021-06-14 13:19                   ` Ulf Hansson
2021-06-14 13:19                     ` Ulf Hansson
2021-06-14 19:29                     ` Florian Fainelli
2021-06-14 19:29                       ` Florian Fainelli
2021-06-15 15:30                       ` Ulf Hansson
2021-06-15 15:30                         ` Ulf Hansson
2021-06-15 15:51                         ` Florian Fainelli
2021-06-15 15:51                           ` Florian Fainelli
2021-06-15 23:46 ` [PATCH 1/2] dt-bindings: mmc: sdhci-iproc: Add brcm,bcm7211a0-sdhci Rob Herring
2021-06-15 23:46   ` Rob Herring

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='CAPDyKFq-rofbCyAhcQGt2xZykip6Le+CUDXgDwAisVOj=Tt-uA@mail.gmail.com' \
    --to=ulf.hansson@linaro.org \
    --cc=adrian.hunter@intel.com \
    --cc=alcooperx@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nsaenz@kernel.org \
    --cc=rjui@broadcom.com \
    --cc=rjw@rjwysocki.net \
    --cc=robh+dt@kernel.org \
    --cc=sbranden@broadcom.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 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.