mbox series

[0/4] mmc: rtsx_usb_sdmmc: Don't waste energy polling for cards

Message ID 20180531094041.27902-1-ulf.hansson@linaro.org
Headers show
Series mmc: rtsx_usb_sdmmc: Don't waste energy polling for cards | expand

Message

Ulf Hansson May 31, 2018, 9:40 a.m. UTC
This series re-works the polling mechanism for the rtsx_usb_mmc driver, which
currently relies on pure polling via MMC_CAP_NEEDS_POLL. The problem is simply
that is wastes a lot of energy, while in fact the card detection logic don't
need to use polling.

Do note, this series doesn't work out of the box, as one addtional patch is
needed on the rtsx USB misc driver (runtime resuming the child at card detect).
I leave that for Kai Heng Feng to implement and moreover I rely on tests to be
done, as this series has only been compile tested.

Kind regards
Uffe

Ulf Hansson (4):
  mmc: core: Introduce MMC_CAP_SYNC_RUNTIME_PM
  mmc: rtsx_usb_sdmmc: Don't runtime resume the device while changing
    led
  mmc: rtsx_usb_sdmmc: Re-work runtime PM support
  mmc: rtsx_usb_sdmmc: Re-work card detection/removal support

 drivers/mmc/core/core.c           |  5 +++-
 drivers/mmc/host/rtsx_usb_sdmmc.c | 43 +++++++++++++++++++++++++------
 include/linux/mmc/host.h          |  2 +-
 3 files changed, 40 insertions(+), 10 deletions(-)

-- 
2.17.0

Comments

Kai-Heng Feng June 1, 2018, 11 a.m. UTC | #1
Hi Ulf,

> On May 31, 2018, at 5:40 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

>

> This series re-works the polling mechanism for the rtsx_usb_mmc driver,  

> which

> currently relies on pure polling via MMC_CAP_NEEDS_POLL. The problem is  

> simply

> that is wastes a lot of energy, while in fact the card detection logic  

> don't

> need to use polling.

>

> Do note, this series doesn't work out of the box, as one addtional patch is

> needed on the rtsx USB misc driver (runtime resuming the child at card  

> detect).

> I leave that for Kai Heng Feng to implement and moreover I rely on tests  

> to be

> done, as this series has only been compile tested.


After applying this patch series, the  
rtsx_usb_sdmmc_runtime_{suspend,resume} constantly get called, so the  
parent device can no longer suspend/resume. Not sure what went wrong here  
but I'll take a look.

Also, what do I need to do to use pm_runtime_idle()? I tried to add an idle  
function but it never gets called.

Kai-Heng

>

> Kind regards

> Uffe

>

> Ulf Hansson (4):

>   mmc: core: Introduce MMC_CAP_SYNC_RUNTIME_PM

>   mmc: rtsx_usb_sdmmc: Don't runtime resume the device while changing

>     led

>   mmc: rtsx_usb_sdmmc: Re-work runtime PM support

>   mmc: rtsx_usb_sdmmc: Re-work card detection/removal support

>

>  drivers/mmc/core/core.c           |  5 +++-

>  drivers/mmc/host/rtsx_usb_sdmmc.c | 43 +++++++++++++++++++++++++------

>  include/linux/mmc/host.h          |  2 +-

>  3 files changed, 40 insertions(+), 10 deletions(-)

>

> -- 

> 2.17.0

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Alan Stern June 1, 2018, 2:28 p.m. UTC | #2
On Fri, 1 Jun 2018, Kai Heng Feng wrote:

> Hi Ulf,

> 

> > On May 31, 2018, at 5:40 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

> >

> > This series re-works the polling mechanism for the rtsx_usb_mmc driver,  

> > which

> > currently relies on pure polling via MMC_CAP_NEEDS_POLL. The problem is  

> > simply

> > that is wastes a lot of energy, while in fact the card detection logic  

> > don't

> > need to use polling.

> >

> > Do note, this series doesn't work out of the box, as one addtional patch is

> > needed on the rtsx USB misc driver (runtime resuming the child at card  

> > detect).

> > I leave that for Kai Heng Feng to implement and moreover I rely on tests  

> > to be

> > done, as this series has only been compile tested.

> 

> After applying this patch series, the  

> rtsx_usb_sdmmc_runtime_{suspend,resume} constantly get called, so the  

> parent device can no longer suspend/resume. Not sure what went wrong here  

> but I'll take a look.

> 

> Also, what do I need to do to use pm_runtime_idle()? I tried to add an idle  

> function but it never gets called.


Basically, the PM core calls pm_runtime_idle() when it thinks the 
driver might want to suspend the device.  For example, after 
pm_runtime_put() runs, the core would call pm_runtime_idle() if the 
usage counter has dropped to 0.

pm_runtime_idle() is optional; if the callback doesn't exist then the 
PM core will call pm_runtime_suspend().

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ulf Hansson June 4, 2018, 6:33 a.m. UTC | #3
On 1 June 2018 at 13:00, Kai Heng Feng <kai.heng.feng@canonical.com> wrote:
> Hi Ulf,

>

>> On May 31, 2018, at 5:40 PM, Ulf Hansson <ulf.hansson@linaro.org> wrote:

>>

>> This series re-works the polling mechanism for the rtsx_usb_mmc driver,

>> which

>> currently relies on pure polling via MMC_CAP_NEEDS_POLL. The problem is

>> simply

>> that is wastes a lot of energy, while in fact the card detection logic

>> don't

>> need to use polling.

>>

>> Do note, this series doesn't work out of the box, as one addtional patch

>> is

>> needed on the rtsx USB misc driver (runtime resuming the child at card

>> detect).

>> I leave that for Kai Heng Feng to implement and moreover I rely on tests

>> to be

>> done, as this series has only been compile tested.

>

>

> After applying this patch series, the

> rtsx_usb_sdmmc_runtime_{suspend,resume} constantly get called, so the parent

> device can no longer suspend/resume. Not sure what went wrong here but I'll

> take a look.


Thanks for testing! I realize the problem. The detect work gets
scheduled over and over again, even if there is no card inserted.

I just posted a v2 of patch 4/4, please try it.

[...]

Kind regards
Uffe
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html