Skip to contentSkip to conversation

mmc: core: move suspend/resume to dev_pm_ops and add hibernation support

PATCH In review Barry Song 3 participants 4 messages Jan 9, 2012 – Jan 11, 2012 MMC, SD and SDIO

lore
Share & tools
lore

Barry Song

author
#0 lore raw

PATCH 1/1 mmc: core: move suspend/resume to dev_pm_ops and add hibernation support

From: Bin Shi <[email protected]>

This patch moves suspend/resume to dev_pm_ops and add hibernation support. It was tested on CSR SiRFprimaII cortex-a9 platform. A sd partition is used as swsusp partition.

---
 drivers/mmc/core/bus.c |   38 +++++++++++++++++++++++++-------------
 1 files changed, 25 insertions(+), 13 deletions(-)
drivers/mmc/core/bus.c +25 -13
index 6be4924..bab50f7 100644
@@ -122,14 +122,14 @@ static int mmc_bus_remove(struct device *dev)
 	return 0;
 }
 
-static int mmc_bus_suspend(struct device *dev, pm_message_t state)
+static int mmc_bus_suspend(struct device *dev)
 {
 	struct mmc_driver *drv = to_mmc_driver(dev->driver);
 	struct mmc_card *card = mmc_dev_to_card(dev);
 	int ret = 0;
 
 	if (dev->driver && drv->suspend)
-		ret = drv->suspend(card, state);
+		ret = drv->suspend(card, PMSG_SUSPEND);
 	return ret;
 }
 
@@ -144,6 +144,17 @@ static int mmc_bus_resume(struct device *dev)
 	return ret;
 }
 
+static int mmc_bus_freeze(struct device *dev)
+{
+	struct mmc_driver *drv = to_mmc_driver(dev->driver);
+	struct mmc_card *card = mmc_dev_to_card(dev);
+	int ret = 0;
+
+	if (dev->driver && drv->suspend)
+		ret = drv->suspend(card, PMSG_FREEZE);
+	return ret;
+}
+
 #ifdef CONFIG_PM_RUNTIME
 
 static int mmc_runtime_suspend(struct device *dev)
@@ -165,20 +176,23 @@ static int mmc_runtime_idle(struct device *dev)
 	return pm_runtime_suspend(dev);
 }
 
+#else /* !CONFIG_PM_RUNTIME */
+#define mmc_runtime_suspend	NULL
+#define mmc_runtime_resume	NULL
+#define mmc_runtime_idle	NULL
+#endif /* !CONFIG_PM_RUNTIME */
+
 static const struct dev_pm_ops mmc_bus_pm_ops = {
 	.runtime_suspend	= mmc_runtime_suspend,
 	.runtime_resume		= mmc_runtime_resume,
 	.runtime_idle		= mmc_runtime_idle,
+	.suspend		= mmc_bus_suspend,
+	.resume			= mmc_bus_resume,
+	.freeze			= mmc_bus_freeze,
+	.restore		= mmc_bus_resume,
+	.thaw			= mmc_bus_resume,
 };
 
-#define MMC_PM_OPS_PTR	(&mmc_bus_pm_ops)
-
-#else /* !CONFIG_PM_RUNTIME */
-
-#define MMC_PM_OPS_PTR	NULL
-
-#endif /* !CONFIG_PM_RUNTIME */
-
 static struct bus_type mmc_bus_type = {
 	.name		= "mmc",
 	.dev_attrs	= mmc_dev_attrs,
@@ -186,9 +200,7 @@ static struct bus_type mmc_bus_type = {
 	.uevent		= mmc_bus_uevent,
 	.probe		= mmc_bus_probe,
 	.remove		= mmc_bus_remove,
-	.suspend	= mmc_bus_suspend,
-	.resume		= mmc_bus_resume,
-	.pm		= MMC_PM_OPS_PTR,
+	.pm		= &mmc_bus_pm_ops,
 };
 
 int mmc_register_bus(void)
Signature · 6 lines
1.7.1



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
#1 lore raw

Hi Bin,

Quoted 35 lines · Barry Song

From: Bin Shi <[email protected]>

This patch moves suspend/resume to dev_pm_ops and add hibernation support. It was tested on CSR SiRFprimaII cortex-a9 platform. A sd partition is used as swsusp partition.

---
 drivers/mmc/core/bus.c |   38 +++++++++++++++++++++++++-------------

 1 files changed, 25 insertions(+), 13 deletions(-)
drivers/mmc/core/bus.c +2 -2
index 6be4924..bab50f7 100644
@@ -122,14 +122,14 @@ static int mmc_bus_remove(struct device *dev)
        return 0;
  }
 
-static int mmc_bus_suspend(struct device *dev, pm_message_t state)
+static int mmc_bus_suspend(struct device *dev)
  {
        struct mmc_driver *drv = to_mmc_driver(dev->driver);
        struct mmc_card *card = mmc_dev_to_card(dev);
        int ret = 0;
 
        if (dev->driver && drv->suspend)
-               ret = drv->suspend(card, state);
+               ret = drv->suspend(card, PMSG_SUSPEND);
        return ret;
  }
 
@@ -144,6 +144,17 @@ static int mmc_bus_resume(struct device *dev)
        return ret;

drivers/mmc/core/bus.c static int mmc_bus_resume(struct device *dev) · line 154

Quoted 10 lines
drivers/mmc/core/bus.c +8 -0
  }
 
+static int mmc_bus_freeze(struct device *dev)
+{
+       struct mmc_driver *drv = to_mmc_driver(dev->driver);
+       struct mmc_card *card = mmc_dev_to_card(dev);
+       int ret = 0;
+
+       if (dev->driver && drv->suspend)
+               ret = drv->suspend(card, PMSG_FREEZE);

Not a comment , rather a doubt

Any particular reason to differenciate freeze and suspend?

Quoted 60 lines
drivers/mmc/core/bus.c +15 -12
+       return ret;
+}
+
  #ifdef CONFIG_PM_RUNTIME
 
  static int mmc_runtime_suspend(struct device *dev)
@@ -165,20 +176,23 @@ static int mmc_runtime_idle(struct device *dev)
        return pm_runtime_suspend(dev);
  }
 
+#else /* !CONFIG_PM_RUNTIME */
+#define mmc_runtime_suspend    NULL
+#define mmc_runtime_resume     NULL
+#define mmc_runtime_idle       NULL
+#endif /* !CONFIG_PM_RUNTIME */
+
  static const struct dev_pm_ops mmc_bus_pm_ops = {
        .runtime_suspend        = mmc_runtime_suspend,
        .runtime_resume         = mmc_runtime_resume,
        .runtime_idle           = mmc_runtime_idle,
+       .suspend                = mmc_bus_suspend,
+       .resume                 = mmc_bus_resume,
+       .freeze                 = mmc_bus_freeze,
+       .restore                = mmc_bus_resume,
+       .thaw                   = mmc_bus_resume,
  };
 
-#define MMC_PM_OPS_PTR (&mmc_bus_pm_ops)
-
-#else /* !CONFIG_PM_RUNTIME */
-
-#define MMC_PM_OPS_PTR NULL
-
-#endif /* !CONFIG_PM_RUNTIME */
-
  static struct bus_type mmc_bus_type = {
        .name           = "mmc",
        .dev_attrs      = mmc_dev_attrs,
@@ -186,9 +200,7 @@ static struct bus_type mmc_bus_type = {
        .uevent         = mmc_bus_uevent,
        .probe          = mmc_bus_probe,
        .remove         = mmc_bus_remove,
-       .suspend        = mmc_bus_suspend,
-       .resume         = mmc_bus_resume,
-       .pm             = MMC_PM_OPS_PTR,
+       .pm             = &mmc_bus_pm_ops,
  };
 
  int mmc_register_bus(void)
--

1.7.1

Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

#2 lore raw

2012/1/9 Shubhrajyoti Datta <[email protected]>:

Quoted 51 lines

Hi Bin,

Quoted 35 lines · Barry Song

From: Bin Shi <[email protected]>

This patch moves suspend/resume to dev_pm_ops and add hibernation support. It was tested on CSR SiRFprimaII cortex-a9 platform. A sd partition is used as swsusp partition.

---
 drivers/mmc/core/bus.c |   38 +++++++++++++++++++++++++-------------

 1 files changed, 25 insertions(+), 13 deletions(-)
drivers/mmc/core/bus.c +2 -2
index 6be4924..bab50f7 100644
@@ -122,14 +122,14 @@ static int mmc_bus_remove(struct device *dev)
        return 0;
  }
 
-static int mmc_bus_suspend(struct device *dev, pm_message_t state)
+static int mmc_bus_suspend(struct device *dev)
  {
        struct mmc_driver *drv = to_mmc_driver(dev->driver);
        struct mmc_card *card = mmc_dev_to_card(dev);
        int ret = 0;
 
        if (dev->driver && drv->suspend)
-               ret = drv->suspend(card, state);
+               ret = drv->suspend(card, PMSG_SUSPEND);
        return ret;
  }
 
@@ -144,6 +144,17 @@ static int mmc_bus_resume(struct device *dev)
        return ret;

drivers/mmc/core/bus.c static int mmc_bus_resume(struct device *dev) · line 154

Quoted 10 lines
drivers/mmc/core/bus.c +8 -0
  }
 
+static int mmc_bus_freeze(struct device *dev)
+{
+       struct mmc_driver *drv = to_mmc_driver(dev->driver);
+       struct mmc_card *card = mmc_dev_to_card(dev);
+       int ret = 0;
+
+       if (dev->driver && drv->suspend)
+               ret = drv->suspend(card, PMSG_FREEZE);

Not a comment , rather a doubt

Quoted 1 line

Any particular reason to differenciate freeze and  suspend?

Shubhrajyoti,
there is no real difference for our system. this is just to keep back-compatible with old mmc_driver.suspend() since the function accepts a PMSG_xxx as param.
i think all things go well if we add freeze/thaw/restore in Dmitry Shmidt's "[PATCH V4] mmc: Set suspend/resume bus operations if CONFIG_PM_RUNTIME is used"

-barry

#3 lore raw

Hi Barry,

Quoted 55 lines · Barry Song

2012/1/9 Shubhrajyoti Datta <[email protected]>:

Quoted 51 lines

Hi Bin,

Quoted 35 lines · Barry Song

From: Bin Shi <[email protected]>

This patch moves suspend/resume to dev_pm_ops and add hibernation support. It was tested on CSR SiRFprimaII cortex-a9 platform. A sd partition is used as swsusp partition.

---
 drivers/mmc/core/bus.c |   38 +++++++++++++++++++++++++-------------

 1 files changed, 25 insertions(+), 13 deletions(-)
drivers/mmc/core/bus.c +2 -2
index 6be4924..bab50f7 100644
@@ -122,14 +122,14 @@ static int mmc_bus_remove(struct device *dev)
        return 0;
  }
 
-static int mmc_bus_suspend(struct device *dev, pm_message_t state)
+static int mmc_bus_suspend(struct device *dev)
  {
        struct mmc_driver *drv = to_mmc_driver(dev->driver);
        struct mmc_card *card = mmc_dev_to_card(dev);
        int ret = 0;
 
        if (dev->driver && drv->suspend)
-               ret = drv->suspend(card, state);
+               ret = drv->suspend(card, PMSG_SUSPEND);
        return ret;
  }
 
@@ -144,6 +144,17 @@ static int mmc_bus_resume(struct device *dev)
        return ret;

drivers/mmc/core/bus.c static int mmc_bus_resume(struct device *dev) · line 154

Quoted 10 lines
drivers/mmc/core/bus.c +8 -0
  }
 
+static int mmc_bus_freeze(struct device *dev)
+{
+       struct mmc_driver *drv = to_mmc_driver(dev->driver);
+       struct mmc_card *card = mmc_dev_to_card(dev);
+       int ret = 0;
+
+       if (dev->driver && drv->suspend)
+               ret = drv->suspend(card, PMSG_FREEZE);

Not a comment , rather a doubt

Quoted 1 line

Any particular reason to differenciate freeze and  suspend?

Quoted 8 lines

Shubhrajyoti,
there is no real difference for our system. this is just to keep back-compatible with old mmc_driver.suspend() since the function accepts a PMSG_xxx as param.
i think all things go well if we add freeze/thaw/restore in Dmitry Shmidt's "[PATCH V4] mmc: Set suspend/resume bus operations if CONFIG_PM_RUNTIME is used"

Thanks for the explanation.

Quoted 1 line

-barry