mmc: block: use block layer pm helpers for pm of card device
Use of block layer runtime PM helpers, implementing the block layer's request-based mechanism, simplifies data path of mmc core layer. It enables to remove synchronous call pm_runtime_get_sync() from mmc core data path.
The idea and API is designed by Alan Stern and described here:
http://marc.info/?l=linux-scsi&m=133727953625963&w=2
Signed-off-by Konstantin Dorfman <[email protected]>
drivers/mmc/card/block.c +2 -2
@@ -2017,7 +2017,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)if (req && !mq->mqrq_prev->req)/* claim host only for the first request */ -mmc_get_card (card); +mmc_claim_host (card->host); ret =mmc_blk_part_switch (card, md);if (ret) {
@@ -2060,7 +2060,7 @@ out:* In case sepecial request, there is no reentry to * the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. */ -mmc_put_card (card); +mmc_release_host (card->host);return ret; }
drivers/mmc/card/queue.c +5 -0
@@ -213,6 +213,11 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,if (mmc_can_erase (card))mmc_queue_setup_discard (mq->queue, card); +if (!subname) { +blk_pm_runtime_init (mq->queue, &card->dev); + card->q = mq->queue; + } +#ifdef CONFIG_MMC_BLOCK_BOUNCE if (host->max_segs ==1 ) {unsigned int bouncesz;
drivers/mmc/core/mmc.c +12 -1
@@ -14,6 +14,7 @@#include <linux/slab.h> #include <linux/stat.h> #include <linux/pm_runtime.h> +#include <linux/blkdev.h> #include <linux/mmc/host.h> #include <linux/mmc/card.h>
@@ -1814,11 +1815,17 @@ static int mmc_runtime_suspend(struct mmc_host *host)if (!(host->caps &MMC_CAP_AGGRESSIVE_PM ))return 0 ; + err =blk_pre_runtime_suspend (host->card->q); +if (err) +return err; + err =_mmc_suspend (host, true);if (err)pr_err ("%s: error %d doing aggessive suspend\n" ,mmc_hostname (host), err); +blk_post_runtime_suspend (host->card->q, err); +return err; }
@@ -1832,12 +1839,16 @@ static int mmc_runtime_resume(struct mmc_host *host)if (!(host->caps & (MMC_CAP_AGGRESSIVE_PM |MMC_CAP_RUNTIME_RESUME )))return 0 ; +blk_pre_runtime_resume (host->card->q); + err =_mmc_resume (host);if (err)pr_err ("%s: error %d doing aggessive resume\n" ,mmc_hostname (host), err); -return 0 ; +blk_post_runtime_resume (host->card->q, err); + +return err; }static int mmc_power_restore (struct mmc_host *host)
include/linux/mmc/card.h +1 -0
@@ -244,6 +244,7 @@ struct mmc_part {struct mmc_card {struct mmc_host *host;/* the host this device belongs to */ struct device dev;/* the device */ +struct request_queue *q;u32 ocr;/* the current OCR setting */ unsigned int rca;/* relative card address of device */ unsigned int type;/* card type */
Signature · 3 lines
Qualcomm Israel, on behalf of Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Hello Ulf, Chris,
Now as rc1 is out and the patch format fixed, please look into it again.
Thanks,
Kostya
Quoted 109 lines · Konstantin Dorfman
Use of block layer runtime PM helpers, implementing the block layer's request-based mechanism, simplifies data path of mmc core layer. It enables to remove synchronous call
pm_runtime_get_sync()from mmc core data path.The idea and API is designed by Alan Stern and described here:
http://marc.info/?l=linux-scsi&m=133727953625963&w=2Signed-off-by Konstantin Dorfman <[email protected]>drivers/mmc/card/block.c +2
-2@@ -2017,7 +2017,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)if (req && !mq->mqrq_prev->req)/* claim host only for the first request */ -mmc_get_card (card); +mmc_claim_host (card->host); ret =mmc_blk_part_switch (card, md);if (ret) {@@ -2060,7 +2060,7 @@ out:* In case sepecial request, there is no reentry to * the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. */ -mmc_put_card (card); +mmc_release_host (card->host);return ret; }drivers/mmc/card/queue.c +5
-0@@ -213,6 +213,11 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card,if (mmc_can_erase (card))mmc_queue_setup_discard (mq->queue, card); +if (!subname) { +blk_pm_runtime_init (mq->queue, &card->dev); + card->q = mq->queue; + } +#ifdef CONFIG_MMC_BLOCK_BOUNCE if (host->max_segs ==1 ) {unsigned int bouncesz;drivers/mmc/core/mmc.c +12
-1@@ -14,6 +14,7 @@#include <linux/slab.h> #include <linux/stat.h> #include <linux/pm_runtime.h> +#include <linux/blkdev.h> #include <linux/mmc/host.h> #include <linux/mmc/card.h> @@ -1814,11 +1815,17 @@ static int mmc_runtime_suspend(struct mmc_host *host)if (!(host->caps &MMC_CAP_AGGRESSIVE_PM ))return 0 ; + err =blk_pre_runtime_suspend (host->card->q); +if (err) +return err; + err =_mmc_suspend (host, true);if (err)pr_err ("%s: error %d doing aggessive suspend\n" ,mmc_hostname (host), err); +blk_post_runtime_suspend (host->card->q, err); +return err; }@@ -1832,12 +1839,16 @@ static int mmc_runtime_resume(struct mmc_host *host)if (!(host->caps & (MMC_CAP_AGGRESSIVE_PM |MMC_CAP_RUNTIME_RESUME )))return 0 ; +blk_pre_runtime_resume (host->card->q); + err =_mmc_resume (host);if (err)pr_err ("%s: error %d doing aggessive resume\n" ,mmc_hostname (host), err); -return 0 ; +blk_post_runtime_resume (host->card->q, err); + +return err; }static int mmc_power_restore (struct mmc_host *host)include/linux/mmc/card.h +1
-0@@ -244,6 +244,7 @@ struct mmc_part {struct mmc_card {struct mmc_host *host;/* the host this device belongs to */ struct device dev;/* the device */ +struct request_queue *q;u32 ocr;/* the current OCR setting */ unsigned int rca;/* relative card address of device */ unsigned int type;/* card type */
Signature · 3 lines
Qualcomm Israel, on behalf of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project