[PATCH 00/12][SRU][B][C][D][OEM-B] To reduce the Realtek USB cardreader power consumption

classic Classic list List threaded Threaded
17 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 00/12][SRU][B][C][D][OEM-B] To reduce the Realtek USB cardreader power consumption

AceLan Kao
BugLink: https://bugs.launchpad.net/bugs/1811337

[Impact]
Realtek USB cardreader consumes more than 1 Watt during long idle if
it's not suspended. And it's runtime PM functions are available after
v4.20.

[Fix]
To avoid conflicts, have to backport some patches for mmc core.

[Test]
Note: Inside () are the previous value (non-patch)
Sort idle: 7.76W (7.88)
Long idle: 4.658W (5.79)
S3: 0.5W (0.5)
S5: 0.20W (0.208)

[Regression Potential]
Low, most commits are for rtsx_usb_{sdmmc,ms} and are all small changes.

Kai-Heng Feng (5):
  memstick: rtsx_usb_ms: Add missing pm_runtime_disable() in probe
    function
  misc: rtsx_usb: Use USB remote wakeup signaling for card insertion
    detection
  memstick: Prevent memstick host from getting runtime suspended during
    card detection
  memstick: rtsx_usb_ms: Use ms_dev() helper
  memstick: rtsx_usb_ms: Support runtime power management

Kishon Vijay Abraham I (1):
  mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't
    support 1.8v

Ulf Hansson (6):
  mmc: core: Introduce MMC_CAP_SYNC_RUNTIME_PM
  mmc: rtsx_usb_sdmmc: Don't runtime resume the device while changing
    led
  mmc: rtsx_usb: Use MMC_CAP2_NO_SDIO
  mmc: rtsx_usb: Enable MMC_CAP_ERASE to allow erase/discard/trim
    requests
  mmc: rtsx_usb_sdmmc: Re-work runtime PM support
  mmc: rtsx_usb_sdmmc: Re-work card detection/removal support

 drivers/memstick/core/memstick.c    |   3 +
 drivers/memstick/host/rtsx_usb_ms.c | 170 +++++++++++++++++-----------
 drivers/misc/cardreader/rtsx_usb.c  |   8 ++
 drivers/mmc/core/core.c             |   5 +-
 drivers/mmc/host/rtsx_usb_sdmmc.c   |  59 ++++++----
 drivers/mmc/host/sdhci.c            |  10 ++
 include/linux/mmc/host.h            |   6 +-
 7 files changed, 172 insertions(+), 89 deletions(-)

--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 01/12][SRU][B][C][D][OEM-B] mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't support 1.8v

AceLan Kao
From: Kishon Vijay Abraham I <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

The SDHCI controller in a SoC might support HS200/HS400 (indicated
using mmc-hs200-1_8v/mmc-hs400-1_8v dt property), but if the board is
modeled such that the IO lines are not connected to 1.8v then
HS200/HS400 cannot be supported. Disable HS200/HS400 if the board
does not have 1.8v connected to the IO lines. Also Disable DDR/UHS in 1.8v
if the IO lines are not connected to 1.8v.

Signed-off-by: Kishon Vijay Abraham I <[hidden email]>
Acked-by: Tony Lindgren <[hidden email]>
Signed-off-by: Ulf Hansson <[hidden email]>
(cherry picked from commit c16bc9a7678a27ece028dcbfea8df2049a65dbec)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/mmc/host/sdhci.c | 10 ++++++++++
 include/linux/mmc/host.h |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
index 3a5f305fd442..3f2fd9f466bf 100644
--- a/drivers/mmc/host/sdhci.c
+++ b/drivers/mmc/host/sdhci.c
@@ -3649,6 +3649,16 @@ int sdhci_setup_host(struct sdhci_host *host)
  if (host->quirks2 & SDHCI_QUIRK2_NO_1_8_V) {
  host->caps1 &= ~(SDHCI_SUPPORT_SDR104 | SDHCI_SUPPORT_SDR50 |
  SDHCI_SUPPORT_DDR50);
+ /*
+ * The SDHCI controller in a SoC might support HS200/HS400
+ * (indicated using mmc-hs200-1_8v/mmc-hs400-1_8v dt property),
+ * but if the board is modeled such that the IO lines are not
+ * connected to 1.8v then HS200/HS400 cannot be supported.
+ * Disable HS200/HS400 if the board does not have 1.8v connected
+ * to the IO lines. (Applicable for other modes in 1.8v)
+ */
+ mmc->caps2 &= ~(MMC_CAP2_HSX00_1_8V | MMC_CAP2_HS400_ES);
+ mmc->caps &= ~(MMC_CAP_1_8V_DDR | MMC_CAP_UHS);
  }
 
  /* Any UHS-I mode in caps implies SDR12 and SDR25 support. */
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index e7743eca1021..b36723e8e99b 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -320,6 +320,9 @@ struct mmc_host {
 #define MMC_CAP_UHS_SDR50 (1 << 18) /* Host supports UHS SDR50 mode */
 #define MMC_CAP_UHS_SDR104 (1 << 19) /* Host supports UHS SDR104 mode */
 #define MMC_CAP_UHS_DDR50 (1 << 20) /* Host supports UHS DDR50 mode */
+#define MMC_CAP_UHS (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | \
+ MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | \
+ MMC_CAP_UHS_DDR50)
 /* (1 << 21) is free for reuse */
 #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */
 #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */
@@ -344,6 +347,7 @@ struct mmc_host {
 #define MMC_CAP2_HS400_1_2V (1 << 16) /* Can support HS400 1.2V */
 #define MMC_CAP2_HS400 (MMC_CAP2_HS400_1_8V | \
  MMC_CAP2_HS400_1_2V)
+#define MMC_CAP2_HSX00_1_8V (MMC_CAP2_HS200_1_8V_SDR | MMC_CAP2_HS400_1_8V)
 #define MMC_CAP2_HSX00_1_2V (MMC_CAP2_HS200_1_2V_SDR | MMC_CAP2_HS400_1_2V)
 #define MMC_CAP2_SDIO_IRQ_NOTHREAD (1 << 17)
 #define MMC_CAP2_NO_WRITE_PROTECT (1 << 18) /* No physical write protect pin, assume that card is always read-write */
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 02/12][SRU][B][C][D][OEM-B] mmc: core: Introduce MMC_CAP_SYNC_RUNTIME_PM

AceLan Kao
In reply to this post by AceLan Kao
From: Ulf Hansson <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

To allow mmc host drivers to inform the mmc core about rather using
pm_runtime_put_sync_suspend() instead of pm_runtime_put_autosuspend(),
let's introduce MMC_CAP_SYNC_RUNTIME_PM.

This is especially useful for those mmc host drivers that don't benefit
from using the runtime PM autosuspend feature. Typically this is those that
relies on parent devices to power the card via runtime PM, like some USB
host drivers for example.

Signed-off-by: Ulf Hansson <[hidden email]>
Tested-by: Kai-Heng Feng <[hidden email]>
Tested-by: Oleksandr Natalenko <[hidden email]>
(cherry picked from commit 7d5ef512575663695cf85f3aeb985a0aeb03e364)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/mmc/core/core.c  | 5 ++++-
 include/linux/mmc/host.h | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index af194640dbc6..c36299d71e79 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -1088,7 +1088,10 @@ void mmc_release_host(struct mmc_host *host)
  spin_unlock_irqrestore(&host->lock, flags);
  wake_up(&host->wq);
  pm_runtime_mark_last_busy(mmc_dev(host));
- pm_runtime_put_autosuspend(mmc_dev(host));
+ if (host->caps & MMC_CAP_SYNC_RUNTIME_PM)
+ pm_runtime_put_sync_suspend(mmc_dev(host));
+ else
+ pm_runtime_put_autosuspend(mmc_dev(host));
  }
 }
 EXPORT_SYMBOL(mmc_release_host);
diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index b36723e8e99b..07aa01f5d8bd 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -323,7 +323,7 @@ struct mmc_host {
 #define MMC_CAP_UHS (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | \
  MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | \
  MMC_CAP_UHS_DDR50)
-/* (1 << 21) is free for reuse */
+#define MMC_CAP_SYNC_RUNTIME_PM (1 << 21) /* Synced runtime PM suspends. */
 #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */
 #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */
 #define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 03/12][SRU][B][C][D][OEM-B] mmc: rtsx_usb_sdmmc: Don't runtime resume the device while changing led

AceLan Kao
In reply to this post by AceLan Kao
From: Ulf Hansson <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

In case the card has been powered off, it seems silly to continue to allow
the led to be updated. Instead let's forbid that, as it enables us to
prevent runtime resuming the device and thus avoids wasting energy.

Signed-off-by: Ulf Hansson <[hidden email]>
Tested-by: Kai-Heng Feng <[hidden email]>
Tested-by: Oleksandr Natalenko <[hidden email]>
(cherry picked from commit 4bfdd76dcb672dd55121b04ed7f1c1ff4343f1ef)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
index 78422079ecfa..bb0ec00ef357 100644
--- a/drivers/mmc/host/rtsx_usb_sdmmc.c
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -1309,14 +1309,18 @@ static void rtsx_usb_update_led(struct work_struct *work)
  container_of(work, struct rtsx_usb_sdmmc, led_work);
  struct rtsx_ucr *ucr = host->ucr;
 
- pm_runtime_get_sync(sdmmc_dev(host));
+ pm_runtime_get_noresume(sdmmc_dev(host));
  mutex_lock(&ucr->dev_mutex);
 
+ if (host->power_mode == MMC_POWER_OFF)
+ goto out;
+
  if (host->led.brightness == LED_OFF)
  rtsx_usb_turn_off_led(ucr);
  else
  rtsx_usb_turn_on_led(ucr);
 
+out:
  mutex_unlock(&ucr->dev_mutex);
  pm_runtime_put(sdmmc_dev(host));
 }
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 04/12][SRU][B][C][D][OEM-B] mmc: rtsx_usb: Use MMC_CAP2_NO_SDIO

AceLan Kao
In reply to this post by AceLan Kao
From: Ulf Hansson <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

Instead of having to return -EINVAL when requested to send SDIO specific
commands, let's set MMC_CAP2_NO_SDIO as it completely prevents them.

Signed-off-by: Ulf Hansson <[hidden email]>
Tested-by: Michał Pecio <[hidden email]>
(cherry picked from commit 4b7d45451dff133b6453cb9571ea5349be1ce14f)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 15 ++-------------
 1 file changed, 2 insertions(+), 13 deletions(-)

diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
index bb0ec00ef357..96ddb3d3f80f 100644
--- a/drivers/mmc/host/rtsx_usb_sdmmc.c
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -26,7 +26,6 @@
 #include <linux/mmc/host.h>
 #include <linux/mmc/mmc.h>
 #include <linux/mmc/sd.h>
-#include <linux/mmc/sdio.h>
 #include <linux/mmc/card.h>
 #include <linux/scatterlist.h>
 #include <linux/pm_runtime.h>
@@ -839,17 +838,6 @@ static void sdmmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
  goto finish_detect_card;
  }
 
- /*
- * Reject SDIO CMDs to speed up card identification
- * since unsupported
- */
- if (cmd->opcode == SD_IO_SEND_OP_COND ||
-    cmd->opcode == SD_IO_RW_DIRECT ||
-    cmd->opcode == SD_IO_RW_EXTENDED) {
- cmd->error = -EINVAL;
- goto finish;
- }
-
  mutex_lock(&ucr->dev_mutex);
 
  mutex_lock(&host->host_mutex);
@@ -1337,7 +1325,8 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host)
  MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST |
  MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 |
  MMC_CAP_NEEDS_POLL;
- mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE;
+ mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE |
+ MMC_CAP2_NO_SDIO;
 
  mmc->max_current_330 = 400;
  mmc->max_current_180 = 800;
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 05/12][SRU][B][C][D][OEM-B] mmc: rtsx_usb: Enable MMC_CAP_ERASE to allow erase/discard/trim requests

AceLan Kao
In reply to this post by AceLan Kao
From: Ulf Hansson <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

Signed-off-by: Ulf Hansson <[hidden email]>
Tested-by: Michał Pecio <[hidden email]>
(cherry picked from commit 400fdb25c87431dd23194b5f6ec62ffae1b224ce)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
index 96ddb3d3f80f..86ac77bd3e9e 100644
--- a/drivers/mmc/host/rtsx_usb_sdmmc.c
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -1324,7 +1324,7 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host)
  mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED |
  MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST |
  MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 |
- MMC_CAP_NEEDS_POLL;
+ MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE;
  mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE |
  MMC_CAP2_NO_SDIO;
 
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 06/12][SRU][B][C][D][OEM-B] mmc: rtsx_usb_sdmmc: Re-work runtime PM support

AceLan Kao
In reply to this post by AceLan Kao
From: Ulf Hansson <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

The current implementation uses the runtime PM autosuspend feature with a
default timeout set to 50ms. This really doesn't makes sense, as it's a USB
driven host device, which needs it rtsx USB device (parent device) to be
runtime resumed to provide power to the card.

In practise, using the autosuspend or any async runtime PM suspend method,
means unnecessary delaying the host device and thus the parent, to be
runtime suspended when a card is removed/powered off. For this reasons,
let's simply drop the support for runtime PM autosuspend and tell the mmc
core to use synced runtime PM suspend methods, via setting
MMC_CAP_SYNC_RUNTIME_PM during probe.

Moreover, as the mmc core nowadays deploys runtime PM reference counting of
the mmc host device, convert ->set_ios() to use the more lightweight
pm_runtime_get_noresume() and pm_runtime_put_noidle() APIs.

Signed-off-by: Ulf Hansson <[hidden email]>
Tested-by: Kai-Heng Feng <[hidden email]>
Tested-by: Oleksandr Natalenko <[hidden email]>
(cherry picked from commit f275179f7bdcf08f4c74c2d1d19c4e8269be3454)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
index 86ac77bd3e9e..5ba66396a8ae 100644
--- a/drivers/mmc/host/rtsx_usb_sdmmc.c
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -1042,9 +1042,9 @@ static int sd_set_power_mode(struct rtsx_usb_sdmmc *host,
 
  if (power_mode == MMC_POWER_OFF) {
  err = sd_power_off(host);
- pm_runtime_put(sdmmc_dev(host));
+ pm_runtime_put_noidle(sdmmc_dev(host));
  } else {
- pm_runtime_get_sync(sdmmc_dev(host));
+ pm_runtime_get_noresume(sdmmc_dev(host));
  err = sd_power_on(host);
  }
 
@@ -1310,7 +1310,7 @@ static void rtsx_usb_update_led(struct work_struct *work)
 
 out:
  mutex_unlock(&ucr->dev_mutex);
- pm_runtime_put(sdmmc_dev(host));
+ pm_runtime_put_sync_suspend(sdmmc_dev(host));
 }
 #endif
 
@@ -1324,7 +1324,7 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host)
  mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED |
  MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST |
  MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 |
- MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE;
+ MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE | MMC_CAP_SYNC_RUNTIME_PM;
  mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE |
  MMC_CAP2_NO_SDIO;
 
@@ -1367,8 +1367,6 @@ static int rtsx_usb_sdmmc_drv_probe(struct platform_device *pdev)
 
  mutex_init(&host->host_mutex);
  rtsx_usb_init_host(host);
- pm_runtime_use_autosuspend(&pdev->dev);
- pm_runtime_set_autosuspend_delay(&pdev->dev, 50);
  pm_runtime_enable(&pdev->dev);
 
 #ifdef RTSX_USB_USE_LEDS_CLASS
@@ -1423,7 +1421,6 @@ static int rtsx_usb_sdmmc_drv_remove(struct platform_device *pdev)
 
  mmc_free_host(mmc);
  pm_runtime_disable(&pdev->dev);
- pm_runtime_dont_use_autosuspend(&pdev->dev);
  platform_set_drvdata(pdev, NULL);
 
  dev_dbg(&(pdev->dev),
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 07/12][SRU][B][C][D][OEM-B] mmc: rtsx_usb_sdmmc: Re-work card detection/removal support

AceLan Kao
In reply to this post by AceLan Kao
From: Ulf Hansson <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

The rtsx USB parent device, has logic to detect when a card is inserted
into the card slot. Although, the logic can't detect when a card is
removed. This makes things a bit tricky, which is why the current method is
simply to turn on MMC_CAP_NEEDS_POLL during probe.

Using MMC_CAP_NEEDS_POLL means lots of energy being wasted, as the mmc host
becomes runtime resumed frequently by the mmc core, while it polls for new
cards being inserted.

To address this problem, let's start relying on that the rtsx USB driver
runtime resumes its child device, which is the rtsx_usb_sdmmc device, when
it detects that a new card being inserted.

This means dropping MMC_CAP_NEEDS_POLL from being set during probe. Instead
let's implement a ->runtime_resume() callback to schedule a detect work and
to set MMC_CAP_NEEDS_POLL. In this way, polling is enabled as long as there
is card inserted, thus we can rely on the mmc core to detect also when the
card becomes removed.

Furthermore, to avoid polling forever after a card has been removed, let's
implement a ->runtime_suspend() callback and make it clear
MMC_CAP_NEEDS_POLL.

Signed-off-by: Ulf Hansson <[hidden email]>
Tested-by: Kai-Heng Feng <[hidden email]>
Tested-by: Oleksandr Natalenko <[hidden email]>
(cherry picked from commit 4dad599b8b5d1ffc5ef12a2edb13d15d537202ba)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/mmc/host/rtsx_usb_sdmmc.c | 29 ++++++++++++++++++++++++++++-
 1 file changed, 28 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/rtsx_usb_sdmmc.c b/drivers/mmc/host/rtsx_usb_sdmmc.c
index 5ba66396a8ae..7e7831c66e7c 100644
--- a/drivers/mmc/host/rtsx_usb_sdmmc.c
+++ b/drivers/mmc/host/rtsx_usb_sdmmc.c
@@ -28,6 +28,7 @@
 #include <linux/mmc/sd.h>
 #include <linux/mmc/card.h>
 #include <linux/scatterlist.h>
+#include <linux/pm.h>
 #include <linux/pm_runtime.h>
 
 #include <linux/rtsx_usb.h>
@@ -1324,7 +1325,7 @@ static void rtsx_usb_init_host(struct rtsx_usb_sdmmc *host)
  mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED |
  MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST |
  MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 |
- MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE | MMC_CAP_SYNC_RUNTIME_PM;
+ MMC_CAP_ERASE | MMC_CAP_SYNC_RUNTIME_PM;
  mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE |
  MMC_CAP2_NO_SDIO;
 
@@ -1429,6 +1430,31 @@ static int rtsx_usb_sdmmc_drv_remove(struct platform_device *pdev)
  return 0;
 }
 
+#ifdef CONFIG_PM
+static int rtsx_usb_sdmmc_runtime_suspend(struct device *dev)
+{
+ struct rtsx_usb_sdmmc *host = dev_get_drvdata(dev);
+
+ host->mmc->caps &= ~MMC_CAP_NEEDS_POLL;
+ return 0;
+}
+
+static int rtsx_usb_sdmmc_runtime_resume(struct device *dev)
+{
+ struct rtsx_usb_sdmmc *host = dev_get_drvdata(dev);
+
+ host->mmc->caps |= MMC_CAP_NEEDS_POLL;
+ if (sdmmc_get_cd(host->mmc) == 1)
+ mmc_detect_change(host->mmc, 0);
+ return 0;
+}
+#endif
+
+static const struct dev_pm_ops rtsx_usb_sdmmc_dev_pm_ops = {
+ SET_RUNTIME_PM_OPS(rtsx_usb_sdmmc_runtime_suspend,
+   rtsx_usb_sdmmc_runtime_resume, NULL)
+};
+
 static const struct platform_device_id rtsx_usb_sdmmc_ids[] = {
  {
  .name = "rtsx_usb_sdmmc",
@@ -1444,6 +1470,7 @@ static struct platform_driver rtsx_usb_sdmmc_driver = {
  .id_table       = rtsx_usb_sdmmc_ids,
  .driver = {
  .name = "rtsx_usb_sdmmc",
+ .pm = &rtsx_usb_sdmmc_dev_pm_ops,
  },
 };
 module_platform_driver(rtsx_usb_sdmmc_driver);
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 08/12][SRU][B][C][D][OEM-B] memstick: rtsx_usb_ms: Add missing pm_runtime_disable() in probe function

AceLan Kao
In reply to this post by AceLan Kao
From: Kai-Heng Feng <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

If the probe fails, we should use pm_runtime_disable() to balance
pm_runtime_enable().

Add missing pm_runtime_disable() for rtsx_usb_ms.

Signed-off-by: Kai-Heng Feng <[hidden email]>
Tested-by: Oleksandr Natalenko <[hidden email]>
Signed-off-by: Ulf Hansson <[hidden email]>
(cherry picked from commit 01a7e8e066a505933b43a8df6da1ae1a1e7bddf2)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/memstick/host/rtsx_usb_ms.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c
index 4f64563df7de..e95e64974a91 100644
--- a/drivers/memstick/host/rtsx_usb_ms.c
+++ b/drivers/memstick/host/rtsx_usb_ms.c
@@ -770,6 +770,7 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)
  return 0;
 err_out:
  memstick_free_host(msh);
+ pm_runtime_disable(ms_dev(host));
  return err;
 }
 
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 09/12][SRU][B][C][D][OEM-B] misc: rtsx_usb: Use USB remote wakeup signaling for card insertion detection

AceLan Kao
In reply to this post by AceLan Kao
From: Kai-Heng Feng <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

Although rtsx_usb doesn't support card removal detection, card insertion
will resume rtsx_usb by USB remote wakeup signaling.

When rtsx_usb gets resumed, also resumes its child devices,
rtsx_usb_sdmmc and rtsx_usb_ms, to notify them there's a card in its
slot.

Signed-off-by: Kai-Heng Feng <[hidden email]>
Tested-by: Oleksandr Natalenko <[hidden email]>
Signed-off-by: Ulf Hansson <[hidden email]>
(cherry picked from commit 883a87ddf2f118fbce617b1b3472b8224803eb14)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/misc/cardreader/rtsx_usb.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/misc/cardreader/rtsx_usb.c b/drivers/misc/cardreader/rtsx_usb.c
index b97903ff1a72..f7a66f614085 100644
--- a/drivers/misc/cardreader/rtsx_usb.c
+++ b/drivers/misc/cardreader/rtsx_usb.c
@@ -723,8 +723,15 @@ static int rtsx_usb_suspend(struct usb_interface *intf, pm_message_t message)
  return 0;
 }
 
+static int rtsx_usb_resume_child(struct device *dev, void *data)
+{
+ pm_request_resume(dev);
+ return 0;
+}
+
 static int rtsx_usb_resume(struct usb_interface *intf)
 {
+ device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child);
  return 0;
 }
 
@@ -734,6 +741,7 @@ static int rtsx_usb_reset_resume(struct usb_interface *intf)
  (struct rtsx_ucr *)usb_get_intfdata(intf);
 
  rtsx_usb_reset_chip(ucr);
+ device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child);
  return 0;
 }
 
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 10/12][SRU][B][C][D][OEM-B] memstick: Prevent memstick host from getting runtime suspended during card detection

AceLan Kao
In reply to this post by AceLan Kao
From: Kai-Heng Feng <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

We can use MEMSTICK_POWER_{ON,OFF} along with pm_runtime_{get,put}
helpers to let memstick host support runtime pm.

The rpm count may go down to zero before the memstick host powers on, so
the host can be runtime suspended.

So before doing card detection, increment the rpm count to avoid the
host gets runtime suspended. Balance the rpm count after card detection
is done.

Signed-off-by: Kai-Heng Feng <[hidden email]>
Tested-by: Oleksandr Natalenko <[hidden email]>
Signed-off-by: Ulf Hansson <[hidden email]>
(cherry picked from commit e03e303edf1c63e6dd455ccd568c74e93ef3ba8c)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/memstick/core/memstick.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/memstick/core/memstick.c b/drivers/memstick/core/memstick.c
index 76382c858c35..1246d69ba187 100644
--- a/drivers/memstick/core/memstick.c
+++ b/drivers/memstick/core/memstick.c
@@ -18,6 +18,7 @@
 #include <linux/delay.h>
 #include <linux/slab.h>
 #include <linux/module.h>
+#include <linux/pm_runtime.h>
 
 #define DRIVER_NAME "memstick"
 
@@ -436,6 +437,7 @@ static void memstick_check(struct work_struct *work)
  struct memstick_dev *card;
 
  dev_dbg(&host->dev, "memstick_check started\n");
+ pm_runtime_get_noresume(host->dev.parent);
  mutex_lock(&host->lock);
  if (!host->card) {
  if (memstick_power_on(host))
@@ -479,6 +481,7 @@ static void memstick_check(struct work_struct *work)
  host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF);
 
  mutex_unlock(&host->lock);
+ pm_runtime_put(host->dev.parent);
  dev_dbg(&host->dev, "memstick_check finished\n");
 }
 
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 11/12][SRU][B][C][D][OEM-B] memstick: rtsx_usb_ms: Use ms_dev() helper

AceLan Kao
In reply to this post by AceLan Kao
From: Kai-Heng Feng <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

Use ms_dev() helper for consistency.

Signed-off-by: Kai-Heng Feng <[hidden email]>
Tested-by: Oleksandr Natalenko <[hidden email]>
Signed-off-by: Ulf Hansson <[hidden email]>
(cherry picked from commit ba9d5f83735fc00297e39ba5cd9ece1c61eb3995)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/memstick/host/rtsx_usb_ms.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c
index e95e64974a91..24e9e6acf01a 100644
--- a/drivers/memstick/host/rtsx_usb_ms.c
+++ b/drivers/memstick/host/rtsx_usb_ms.c
@@ -786,7 +786,7 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)
 
  mutex_lock(&host->host_mutex);
  if (host->req) {
- dev_dbg(&(pdev->dev),
+ dev_dbg(ms_dev(host),
  "%s: Controller removed during transfer\n",
  dev_name(&msh->dev));
  host->req->error = -ENOMEDIUM;
@@ -808,10 +808,10 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)
  if (pm_runtime_active(ms_dev(host)))
  pm_runtime_put(ms_dev(host));
 
- pm_runtime_disable(&pdev->dev);
+ pm_runtime_disable(ms_dev(host));
  platform_set_drvdata(pdev, NULL);
 
- dev_dbg(&(pdev->dev),
+ dev_dbg(ms_dev(host),
  ": Realtek USB Memstick controller has been removed\n");
 
  return 0;
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

[PATCH 12/12][SRU][B][C][D][OEM-B] memstick: rtsx_usb_ms: Support runtime power management

AceLan Kao
In reply to this post by AceLan Kao
From: Kai-Heng Feng <[hidden email]>

BugLink: https://bugs.launchpad.net/bugs/1811337

In order to let host's parent device, rtsx_usb, to use USB remote wake
up signaling to do card detection, it needs to be suspended. Hence it's
necessary to add runtime PM support for the memstick host.

To keep memstick host stays suspended when it's not in use, convert the
card detection function from kthread to delayed_work, which can be
scheduled when the host is resumed and can be canceled when the host is
suspended.

Put the device to suspend when there's no card and the power mode is
MEMSTICK_POWER_OFF.

Signed-off-by: Kai-Heng Feng <[hidden email]>
Tested-by: Oleksandr Natalenko <[hidden email]>
Signed-off-by: Ulf Hansson <[hidden email]>
(cherry picked from commit 6827ca573c03385439fdfc8b512d556dc7c54fc9)
Signed-off-by: AceLan Kao <[hidden email]>
---
 drivers/memstick/host/rtsx_usb_ms.c | 163 +++++++++++++++++-----------
 1 file changed, 100 insertions(+), 63 deletions(-)

diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c
index 24e9e6acf01a..97308dc28ccf 100644
--- a/drivers/memstick/host/rtsx_usb_ms.c
+++ b/drivers/memstick/host/rtsx_usb_ms.c
@@ -40,15 +40,14 @@ struct rtsx_usb_ms {
 
  struct mutex host_mutex;
  struct work_struct handle_req;
-
- struct task_struct *detect_ms;
- struct completion detect_ms_exit;
+ struct delayed_work poll_card;
 
  u8 ssc_depth;
  unsigned int clock;
  int power_mode;
  unsigned char           ifmode;
  bool eject;
+ bool system_suspending;
 };
 
 static inline struct device *ms_dev(struct rtsx_usb_ms *host)
@@ -545,7 +544,7 @@ static void rtsx_usb_ms_handle_req(struct work_struct *work)
  host->req->error);
  }
  } while (!rc);
- pm_runtime_put(ms_dev(host));
+ pm_runtime_put_sync(ms_dev(host));
  }
 
 }
@@ -585,14 +584,14 @@ static int rtsx_usb_ms_set_param(struct memstick_host *msh,
  break;
 
  if (value == MEMSTICK_POWER_ON) {
- pm_runtime_get_sync(ms_dev(host));
+ pm_runtime_get_noresume(ms_dev(host));
  err = ms_power_on(host);
+ if (err)
+ pm_runtime_put_noidle(ms_dev(host));
  } else if (value == MEMSTICK_POWER_OFF) {
  err = ms_power_off(host);
- if (host->msh->card)
+ if (!err)
  pm_runtime_put_noidle(ms_dev(host));
- else
- pm_runtime_put(ms_dev(host));
  } else
  err = -EINVAL;
  if (!err)
@@ -638,12 +637,16 @@ static int rtsx_usb_ms_set_param(struct memstick_host *msh,
  }
 out:
  mutex_unlock(&ucr->dev_mutex);
- pm_runtime_put(ms_dev(host));
+ pm_runtime_put_sync(ms_dev(host));
 
  /* power-on delay */
- if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON)
+ if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON) {
  usleep_range(10000, 12000);
 
+ if (!host->eject)
+ schedule_delayed_work(&host->poll_card, 100);
+ }
+
  dev_dbg(ms_dev(host), "%s: return = %d\n", __func__, err);
  return err;
 }
@@ -654,9 +657,24 @@ static int rtsx_usb_ms_suspend(struct device *dev)
  struct rtsx_usb_ms *host = dev_get_drvdata(dev);
  struct memstick_host *msh = host->msh;
 
- dev_dbg(ms_dev(host), "--> %s\n", __func__);
+ /* Since we use rtsx_usb's resume callback to runtime resume its
+ * children to implement remote wakeup signaling, this causes
+ * rtsx_usb_ms' runtime resume callback runs after its suspend
+ * callback:
+ * rtsx_usb_ms_suspend()
+ * rtsx_usb_resume()
+ *   -> rtsx_usb_ms_runtime_resume()
+ *     -> memstick_detect_change()
+ *
+ * rtsx_usb_suspend()
+ *
+ * To avoid this, skip runtime resume/suspend if system suspend is
+ * underway.
+ */
 
+ host->system_suspending = true;
  memstick_suspend_host(msh);
+
  return 0;
 }
 
@@ -665,58 +683,85 @@ static int rtsx_usb_ms_resume(struct device *dev)
  struct rtsx_usb_ms *host = dev_get_drvdata(dev);
  struct memstick_host *msh = host->msh;
 
- dev_dbg(ms_dev(host), "--> %s\n", __func__);
-
  memstick_resume_host(msh);
+ host->system_suspending = false;
+
  return 0;
 }
 #endif /* CONFIG_PM_SLEEP */
 
-/*
- * Thread function of ms card slot detection. The thread starts right after
- * successful host addition. It stops while the driver removal function sets
- * host->eject true.
- */
-static int rtsx_usb_detect_ms_card(void *__host)
+#ifdef CONFIG_PM
+static int rtsx_usb_ms_runtime_suspend(struct device *dev)
+{
+ struct rtsx_usb_ms *host = dev_get_drvdata(dev);
+
+ if (host->system_suspending)
+ return 0;
+
+ if (host->msh->card || host->power_mode != MEMSTICK_POWER_OFF)
+ return -EAGAIN;
+
+ return 0;
+}
+
+static int rtsx_usb_ms_runtime_resume(struct device *dev)
+{
+ struct rtsx_usb_ms *host = dev_get_drvdata(dev);
+
+
+ if (host->system_suspending)
+ return 0;
+
+ memstick_detect_change(host->msh);
+
+ return 0;
+}
+#endif /* CONFIG_PM */
+
+static const struct dev_pm_ops rtsx_usb_ms_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(rtsx_usb_ms_suspend, rtsx_usb_ms_resume)
+ SET_RUNTIME_PM_OPS(rtsx_usb_ms_runtime_suspend, rtsx_usb_ms_runtime_resume, NULL)
+};
+
+
+static void rtsx_usb_ms_poll_card(struct work_struct *work)
 {
- struct rtsx_usb_ms *host = (struct rtsx_usb_ms *)__host;
+ struct rtsx_usb_ms *host = container_of(work, struct rtsx_usb_ms,
+ poll_card.work);
  struct rtsx_ucr *ucr = host->ucr;
- u8 val = 0;
  int err;
+ u8 val;
 
- for (;;) {
- pm_runtime_get_sync(ms_dev(host));
- mutex_lock(&ucr->dev_mutex);
-
- /* Check pending MS card changes */
- err = rtsx_usb_read_register(ucr, CARD_INT_PEND, &val);
- if (err) {
- mutex_unlock(&ucr->dev_mutex);
- goto poll_again;
- }
+ if (host->eject || host->power_mode != MEMSTICK_POWER_ON)
+ return;
 
- /* Clear the pending */
- rtsx_usb_write_register(ucr, CARD_INT_PEND,
- XD_INT | MS_INT | SD_INT,
- XD_INT | MS_INT | SD_INT);
+ pm_runtime_get_sync(ms_dev(host));
+ mutex_lock(&ucr->dev_mutex);
 
+ /* Check pending MS card changes */
+ err = rtsx_usb_read_register(ucr, CARD_INT_PEND, &val);
+ if (err) {
  mutex_unlock(&ucr->dev_mutex);
+ goto poll_again;
+ }
 
- if (val & MS_INT) {
- dev_dbg(ms_dev(host), "MS slot change detected\n");
- memstick_detect_change(host->msh);
- }
+ /* Clear the pending */
+ rtsx_usb_write_register(ucr, CARD_INT_PEND,
+ XD_INT | MS_INT | SD_INT,
+ XD_INT | MS_INT | SD_INT);
 
-poll_again:
- pm_runtime_put(ms_dev(host));
- if (host->eject)
- break;
+ mutex_unlock(&ucr->dev_mutex);
 
- schedule_timeout_idle(HZ);
+ if (val & MS_INT) {
+ dev_dbg(ms_dev(host), "MS slot change detected\n");
+ memstick_detect_change(host->msh);
  }
 
- complete(&host->detect_ms_exit);
- return 0;
+poll_again:
+ pm_runtime_put_sync(ms_dev(host));
+
+ if (!host->eject && host->power_mode == MEMSTICK_POWER_ON)
+ schedule_delayed_work(&host->poll_card, 100);
 }
 
 static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)
@@ -747,40 +792,36 @@ static int rtsx_usb_ms_drv_probe(struct platform_device *pdev)
  mutex_init(&host->host_mutex);
  INIT_WORK(&host->handle_req, rtsx_usb_ms_handle_req);
 
- init_completion(&host->detect_ms_exit);
- host->detect_ms = kthread_create(rtsx_usb_detect_ms_card, host,
- "rtsx_usb_ms_%d", pdev->id);
- if (IS_ERR(host->detect_ms)) {
- dev_dbg(&(pdev->dev),
- "Unable to create polling thread.\n");
- err = PTR_ERR(host->detect_ms);
- goto err_out;
- }
+ INIT_DELAYED_WORK(&host->poll_card, rtsx_usb_ms_poll_card);
 
  msh->request = rtsx_usb_ms_request;
  msh->set_param = rtsx_usb_ms_set_param;
  msh->caps = MEMSTICK_CAP_PAR4;
 
- pm_runtime_enable(&pdev->dev);
+ pm_runtime_get_noresume(ms_dev(host));
+ pm_runtime_set_active(ms_dev(host));
+ pm_runtime_enable(ms_dev(host));
+
  err = memstick_add_host(msh);
  if (err)
  goto err_out;
 
- wake_up_process(host->detect_ms);
+ pm_runtime_put(ms_dev(host));
+
  return 0;
 err_out:
  memstick_free_host(msh);
  pm_runtime_disable(ms_dev(host));
+ pm_runtime_put_noidle(ms_dev(host));
  return err;
 }
 
 static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)
 {
  struct rtsx_usb_ms *host = platform_get_drvdata(pdev);
- struct memstick_host *msh;
+ struct memstick_host *msh = host->msh;
  int err;
 
- msh = host->msh;
  host->eject = true;
  cancel_work_sync(&host->handle_req);
 
@@ -798,7 +839,6 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)
  }
  mutex_unlock(&host->host_mutex);
 
- wait_for_completion(&host->detect_ms_exit);
  memstick_remove_host(msh);
  memstick_free_host(msh);
 
@@ -817,9 +857,6 @@ static int rtsx_usb_ms_drv_remove(struct platform_device *pdev)
  return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(rtsx_usb_ms_pm_ops,
- rtsx_usb_ms_suspend, rtsx_usb_ms_resume);
-
 static struct platform_device_id rtsx_usb_ms_ids[] = {
  {
  .name = "rtsx_usb_ms",
--
2.17.1


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [PATCH 00/12][SRU][B][C][D][OEM-B] To reduce the Realtek USB cardreader power consumption

Colin King
In reply to this post by AceLan Kao
On 11/01/2019 08:30, AceLan Kao wrote:

> BugLink: https://bugs.launchpad.net/bugs/1811337
>
> [Impact]
> Realtek USB cardreader consumes more than 1 Watt during long idle if
> it's not suspended. And it's runtime PM functions are available after
> v4.20.
>
> [Fix]
> To avoid conflicts, have to backport some patches for mmc core.
>
> [Test]
> Note: Inside () are the previous value (non-patch)
> Sort idle: 7.76W (7.88)
> Long idle: 4.658W (5.79)
> S3: 0.5W (0.5)
> S5: 0.20W (0.208)
>
> [Regression Potential]
> Low, most commits are for rtsx_usb_{sdmmc,ms} and are all small changes.
>
> Kai-Heng Feng (5):
>   memstick: rtsx_usb_ms: Add missing pm_runtime_disable() in probe
>     function
>   misc: rtsx_usb: Use USB remote wakeup signaling for card insertion
>     detection
>   memstick: Prevent memstick host from getting runtime suspended during
>     card detection
>   memstick: rtsx_usb_ms: Use ms_dev() helper
>   memstick: rtsx_usb_ms: Support runtime power management
>
> Kishon Vijay Abraham I (1):
>   mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't
>     support 1.8v
>
> Ulf Hansson (6):
>   mmc: core: Introduce MMC_CAP_SYNC_RUNTIME_PM
>   mmc: rtsx_usb_sdmmc: Don't runtime resume the device while changing
>     led
>   mmc: rtsx_usb: Use MMC_CAP2_NO_SDIO
>   mmc: rtsx_usb: Enable MMC_CAP_ERASE to allow erase/discard/trim
>     requests
>   mmc: rtsx_usb_sdmmc: Re-work runtime PM support
>   mmc: rtsx_usb_sdmmc: Re-work card detection/removal support
>
>  drivers/memstick/core/memstick.c    |   3 +
>  drivers/memstick/host/rtsx_usb_ms.c | 170 +++++++++++++++++-----------
>  drivers/misc/cardreader/rtsx_usb.c  |   8 ++
>  drivers/mmc/core/core.c             |   5 +-
>  drivers/mmc/host/rtsx_usb_sdmmc.c   |  59 ++++++----
>  drivers/mmc/host/sdhci.c            |  10 ++
>  include/linux/mmc/host.h            |   6 +-
>  7 files changed, 172 insertions(+), 89 deletions(-)
>

The saving of power is SRU-worthy IMHO and can justify the potential SRU
risk with the benefit of power saving.  Changes look sane.

Acked-by: Colin Ian King <[hidden email]>

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

ACK: [PATCH 00/12][SRU][B][C][D][OEM-B] To reduce the Realtek USB cardreader power consumption

Kai-Heng Feng
In reply to this post by AceLan Kao


> On Jan 11, 2019, at 4:30 PM, AceLan Kao <[hidden email]> wrote:
>
> BugLink: https://bugs.launchpad.net/bugs/1811337
>
> [Impact]
> Realtek USB cardreader consumes more than 1 Watt during long idle if
> it's not suspended. And it's runtime PM functions are available after
> v4.20.
>
> [Fix]
> To avoid conflicts, have to backport some patches for mmc core.
>
> [Test]
> Note: Inside () are the previous value (non-patch)
> Sort idle: 7.76W (7.88)
> Long idle: 4.658W (5.79)
> S3: 0.5W (0.5)
> S5: 0.20W (0.208)
>
> [Regression Potential]
> Low, most commits are for rtsx_usb_{sdmmc,ms} and are all small changes.
>
> Kai-Heng Feng (5):
>  memstick: rtsx_usb_ms: Add missing pm_runtime_disable() in probe
>    function
>  misc: rtsx_usb: Use USB remote wakeup signaling for card insertion
>    detection
>  memstick: Prevent memstick host from getting runtime suspended during
>    card detection
>  memstick: rtsx_usb_ms: Use ms_dev() helper
>  memstick: rtsx_usb_ms: Support runtime power management
>
> Kishon Vijay Abraham I (1):
>  mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't
>    support 1.8v
>
> Ulf Hansson (6):
>  mmc: core: Introduce MMC_CAP_SYNC_RUNTIME_PM
>  mmc: rtsx_usb_sdmmc: Don't runtime resume the device while changing
>    led
>  mmc: rtsx_usb: Use MMC_CAP2_NO_SDIO
>  mmc: rtsx_usb: Enable MMC_CAP_ERASE to allow erase/discard/trim
>    requests
>  mmc: rtsx_usb_sdmmc: Re-work runtime PM support
>  mmc: rtsx_usb_sdmmc: Re-work card detection/removal support
>
> drivers/memstick/core/memstick.c    |   3 +
> drivers/memstick/host/rtsx_usb_ms.c | 170 +++++++++++++++++-----------
> drivers/misc/cardreader/rtsx_usb.c  |   8 ++
> drivers/mmc/core/core.c             |   5 +-
> drivers/mmc/host/rtsx_usb_sdmmc.c   |  59 ++++++----
> drivers/mmc/host/sdhci.c            |  10 ++
> include/linux/mmc/host.h            |   6 +-
> 7 files changed, 172 insertions(+), 89 deletions(-)
>

Acked-by: Kai-Heng Feng <[hidden email]>

> --
> 2.17.1
>
>
> --
> kernel-team mailing list
> [hidden email]
> https://lists.ubuntu.com/mailman/listinfo/kernel-team


--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED[B/C]/cmnt: [PATCH 00/12][SRU][B][C][D][OEM-B] To reduce the Realtek USB cardreader power consumption

Kleber Souza
In reply to this post by AceLan Kao
On 1/11/19 9:30 AM, AceLan Kao wrote:

> BugLink: https://bugs.launchpad.net/bugs/1811337
>
> [Impact]
> Realtek USB cardreader consumes more than 1 Watt during long idle if
> it's not suspended. And it's runtime PM functions are available after
> v4.20.
>
> [Fix]
> To avoid conflicts, have to backport some patches for mmc core.
>
> [Test]
> Note: Inside () are the previous value (non-patch)
> Sort idle: 7.76W (7.88)
> Long idle: 4.658W (5.79)
> S3: 0.5W (0.5)
> S5: 0.20W (0.208)
>
> [Regression Potential]
> Low, most commits are for rtsx_usb_{sdmmc,ms} and are all small changes.
>
> Kai-Heng Feng (5):
>   memstick: rtsx_usb_ms: Add missing pm_runtime_disable() in probe
>     function
>   misc: rtsx_usb: Use USB remote wakeup signaling for card insertion
>     detection
>   memstick: Prevent memstick host from getting runtime suspended during
>     card detection
>   memstick: rtsx_usb_ms: Use ms_dev() helper
>   memstick: rtsx_usb_ms: Support runtime power management
>
> Kishon Vijay Abraham I (1):
>   mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't
>     support 1.8v
>
> Ulf Hansson (6):
>   mmc: core: Introduce MMC_CAP_SYNC_RUNTIME_PM
>   mmc: rtsx_usb_sdmmc: Don't runtime resume the device while changing
>     led
>   mmc: rtsx_usb: Use MMC_CAP2_NO_SDIO
>   mmc: rtsx_usb: Enable MMC_CAP_ERASE to allow erase/discard/trim
>     requests
>   mmc: rtsx_usb_sdmmc: Re-work runtime PM support
>   mmc: rtsx_usb_sdmmc: Re-work card detection/removal support
>
>  drivers/memstick/core/memstick.c    |   3 +
>  drivers/memstick/host/rtsx_usb_ms.c | 170 +++++++++++++++++-----------
>  drivers/misc/cardreader/rtsx_usb.c  |   8 ++
>  drivers/mmc/core/core.c             |   5 +-
>  drivers/mmc/host/rtsx_usb_sdmmc.c   |  59 ++++++----
>  drivers/mmc/host/sdhci.c            |  10 ++
>  include/linux/mmc/host.h            |   6 +-
>  7 files changed, 172 insertions(+), 89 deletions(-)
>
Applied to bionic/master-next and cosmic/master-next branches.

The following commits were skipped on Cosmic because there were already
present on v4.18 (and will be skipped for D as well):

mmc: sdhci: Disable 1.8v modes (HS200/HS400/UHS) if controller can't
support 1.8v
mmc: rtsx_usb: Use MMC_CAP2_NO_SDIO
mmc: rtsx_usb: Enable MMC_CAP_ERASE to allow erase/discard/trim requests

Please tag a patch for multiple series *only* if it can be applied to
all of them without any intervention, it makes our job really easier if
they are tagged only for the relevant series.


Thanks,
Kleber



--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team
Reply | Threaded
Open this post in threaded view
|

APPLIED/cmt[D/Unstable]: [PATCH 00/12][SRU][B][C][D][OEM-B] To reduce the Realtek USB cardreader power consumption

Seth Forshee
In reply to this post by AceLan Kao
On Fri, Jan 11, 2019 at 04:30:07PM +0800, AceLan Kao wrote:

> BugLink: https://bugs.launchpad.net/bugs/1811337
>
> [Impact]
> Realtek USB cardreader consumes more than 1 Watt during long idle if
> it's not suspended. And it's runtime PM functions are available after
> v4.20.
>
> [Fix]
> To avoid conflicts, have to backport some patches for mmc core.
>
> [Test]
> Note: Inside () are the previous value (non-patch)
> Sort idle: 7.76W (7.88)
> Long idle: 4.658W (5.79)
> S3: 0.5W (0.5)
> S5: 0.20W (0.208)
>
> [Regression Potential]
> Low, most commits are for rtsx_usb_{sdmmc,ms} and are all small changes.

Applied patches 6-12 to disco/master-next and unstable/master. I ended
up cherry picking them myself however because the patches were not
applying cleanly, in the future please confirm which patches are needed
for each release and ensure they apply cleanly. Thanks!

--
kernel-team mailing list
[hidden email]
https://lists.ubuntu.com/mailman/listinfo/kernel-team