mmc:core: Avoid useless detecting task when card is busy
PATCH v3 1/1 mmc:core: Avoid useless detecting task when card is busy
When card is in cpu polling mode to detect card present. Card detecting task will be scheduled about once every second. When card is busy in large file transfer, detecting task will be hang and call trace will be prompt. When handling the request, CMD13 is always followed by every command when it was complete. So assume that card is present to avoid this duplicate detecting. Only polling card when card is free to reduce conflict with data transfer.
<7>mmc0: req done (CMD13): 0: 00000e00 00000000 00000000 00000000
INFO: task kworker/u:1:12 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/u:1 D 00000000 0 12 2 0x00000000 Call Trace:
[ee06dd50] [44042028] 0x44042028
(unreliable)
[ee06de10] [c0007a0c] __switch_to+0xa0/0xf0
[ee06de30] [c04dd50c] __schedule+0x1f8/0x4a4
[ee06dea0] [c04dd898] schedule+0x30/0xbc
[ee06deb0] [c03816a4] __mmc_claim_host+0x98/0x19c
[ee06df00] [c0385f88] mmc_sd_detect+0x38/0xc0
[ee06df10] [c0382b0c] mmc_rescan+0x294/0x2e0 [ee06df40] [c00661cc] process_one_work+0x140/0x3e0
[ee06df70] [c0066bf8] worker_thread+0x18c/0x36c
[ee06dfb0] [c006bf10] kthread+0x7c/0x80
[ee06dff0] [c000de58] kernel_thread+0x4c/0x68 <7>sdhci [sdhci_irq()]: *** mmc0 got interrupt: 0x00000001
---
changes for V3:
- Remove mmc_try_claim_host.
changes for V2:
- Add card detecting once the last request is done.
drivers/mmc/card/block.c | 29 +++++++++++++++++++++++++++-- drivers/mmc/core/mmc.c | 5 +++++ drivers/mmc/core/sd.c | 5 +++++ drivers/mmc/core/sdio.c | 5 +++++ 4 files changed, 42 insertions(+), 2 deletions(-)
drivers/mmc/card/block.c +27 -2
@@ -1960,9 +1960,21 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)struct mmc_host *host = card->host;unsigned long flags; -if (req && !mq->mqrq_prev->req) +if (req && !mq->mqrq_prev->req) { +/* +* When we are here, card polling task will be blocked. +* So disable it to avoid this useless schedule. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =1 ; +spin_unlock_irqrestore (&host->lock, flags); +cancel_delayed_work (&host->detect); + } +/* claim host only for the first request */ mmc_get_card (card); + } ret =mmc_blk_part_switch (card, md);if (ret) {
@@ -1999,7 +2011,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) out:if ((!req && !(mq->flags &MMC_QUEUE_NEW_REQUEST )) || - (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) + (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) {/* * Release host when there are no more requests * and after special request(discard, flush) is done.
@@ -2007,6 +2019,19 @@ out:* the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. */ mmc_put_card (card); + +/* +* Detecting card status immediately in case card being +* removed just after the request is complete. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_detect_change (host,0 ); + } + } +return ret; }
drivers/mmc/core/mmc.c +5 -0
@@ -1443,6 +1443,7 @@ static int mmc_alive(struct mmc_host *host)static void mmc_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);
@@ -1457,6 +1458,10 @@ static void mmc_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_remove (host);mmc_claim_host (host);
drivers/mmc/core/sd.c +5 -0
@@ -1041,6 +1041,7 @@ static int mmc_sd_alive(struct mmc_host *host)static void mmc_sd_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);
@@ -1055,6 +1056,10 @@ static void mmc_sd_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sd_remove (host);mmc_claim_host (host);
drivers/mmc/core/sdio.c +5 -0
@@ -862,6 +862,7 @@ static int mmc_sdio_alive(struct mmc_host *host)static void mmc_sdio_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);
@@ -900,6 +901,10 @@ static void mmc_sdio_detect(struct mmc_host *host) out:if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sdio_remove (host);mmc_claim_host (host);
Signature · 1 line
1.8.0
Hi, Ulf
I had update the patch according to your suggestion. I test on my platform during last night.
About 200G random continuous data was written to 32G SDHC Card. No call trace was encountered.
I think it can meet with your demand and solve the problem.
Quoted 171 lines · Haijun Zhang
When card is in cpu polling mode to detect card present. Card detecting task will be scheduled about once every second. When card is busy in large file transfer, detecting task will be hang and call trace will be prompt. When handling the request, CMD13 is always followed by every command when it was complete. So assume that card is present to avoid this duplicate detecting. Only polling card when card is free to reduce conflict with data transfer.
<7>mmc0: req done (CMD13): 0:
00000e0000000000 00000000 00000000INFO: task kworker/u:1:12 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/u:1 D 00000000 0 12 2 0x00000000 Call Trace:[
ee06dd50] [44042028]0x44042028
(unreliable)
[ee06de10] [c0007a0c]__switch_to+0xa0/0xf0
[ee06de30] [c04dd50c]__schedule+0x1f8/0x4a4[
ee06dea0] [c04dd898]schedule+0x30/0xbc[
ee06deb0] [c03816a4]__mmc_claim_host+0x98/0x19c[
ee06df00] [c0385f88]mmc_sd_detect+0x38/0xc0[
ee06df10] [c0382b0c]mmc_rescan+0x294/0x2e0[ee06df40] [c00661cc]process_one_work+0x140/0x3e0[
ee06df70] [c0066bf8]worker_thread+0x18c/0x36c
[ee06dfb0] [c006bf10]kthread+0x7c/0x80[
ee06dff0] [c000de58]kernel_thread+0x4c/0x68<7>sdhci [sdhci_irq()]: *** mmc0 got interrupt:0x00000001Signed-off-by Haijun Zhang <[email protected]>---
changes for V3:
- Removemmc_try_claim_host.
changes for V2:
- Add card detecting once the last request is done.drivers/mmc/card/block.c | 29 +++++++++++++++++++++++++++-- drivers/mmc/core/mmc.c | 5 +++++ drivers/mmc/core/sd.c | 5 +++++ drivers/mmc/core/sdio.c | 5 +++++ 4 files changed, 42 insertions(+), 2 deletions(-)drivers/mmc/card/block.c +27
-2@@ -1960,9 +1960,21 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)struct mmc_host *host = card->host;unsigned long flags; -if (req && !mq->mqrq_prev->req) +if (req && !mq->mqrq_prev->req) { +/* +* When we are here, card polling task will be blocked. +* So disable it to avoid this useless schedule. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =1 ; +spin_unlock_irqrestore (&host->lock, flags); +cancel_delayed_work (&host->detect); + } +/* claim host only for the first request */ mmc_get_card (card); + } ret =mmc_blk_part_switch (card, md);if (ret) {@@ -1999,7 +2011,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) out:if ((!req && !(mq->flags &MMC_QUEUE_NEW_REQUEST )) || - (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) + (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) {/* * Release host when there are no more requests * and after special request(discard, flush) is done. @@ -2007,6 +2019,19 @@ out:* the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. */ mmc_put_card (card); + +/* +* Detecting card status immediately in case card being +* removed just after the request is complete. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_detect_change (host,0 ); + } + } +return ret; }drivers/mmc/core/mmc.c +5
-0@@ -1443,6 +1443,7 @@ static int mmc_alive(struct mmc_host *host)static void mmc_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -1457,6 +1458,10 @@ static void mmc_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_remove (host);mmc_claim_host (host);drivers/mmc/core/sd.c +5
-0@@ -1041,6 +1041,7 @@ static int mmc_sd_alive(struct mmc_host *host)static void mmc_sd_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -1055,6 +1056,10 @@ static void mmc_sd_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sd_remove (host);mmc_claim_host (host);drivers/mmc/core/sdio.c +5
-0@@ -862,6 +862,7 @@ static int mmc_sdio_alive(struct mmc_host *host)static void mmc_sdio_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -900,6 +901,10 @@ static void mmc_sdio_detect(struct mmc_host *host) out:if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sdio_remove (host);mmc_claim_host (host);
Signature · 2 lines
Thanks & Regards Haijun.
Hi Haijun,
Quoted 7 lines · Zhang Haijun
Hi, Ulf
I had update the patch according to your suggestion. I test on my platform during last night.
About 200G random continuous data was written to 32G SDHC Card. No call trace was encountered.
I think it can meet with your demand and solve the problem.
Sounds promising. :-)
Quoted 173 lines
Quoted 170 lines · Haijun Zhang
When card is in cpu polling mode to detect card present. Card detecting task will be scheduled about once every second. When card is busy in large file transfer, detecting task will be hang and call trace will be prompt. When handling the request, CMD13 is always followed by every command when it was complete. So assume that card is present to avoid this duplicate detecting. Only polling card when card is free to reduce conflict with data transfer.
<7>mmc0: req done (CMD13): 0:
00000e0000000000 00000000 00000000INFO: task kworker/u:1:12 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/u:1 D 00000000 0 12 2 0x00000000 Call Trace:[
ee06dd50] [44042028]0x44042028
(unreliable)
[ee06de10] [c0007a0c]__switch_to+0xa0/0xf0
[ee06de30] [c04dd50c]__schedule+0x1f8/0x4a4[
ee06dea0] [c04dd898]schedule+0x30/0xbc[
ee06deb0] [c03816a4]__mmc_claim_host+0x98/0x19c[
ee06df00] [c0385f88]mmc_sd_detect+0x38/0xc0[
ee06df10] [c0382b0c]mmc_rescan+0x294/0x2e0[ee06df40] [c00661cc]process_one_work+0x140/0x3e0[
ee06df70] [c0066bf8]worker_thread+0x18c/0x36c
[ee06dfb0] [c006bf10]kthread+0x7c/0x80[
ee06dff0] [c000de58]kernel_thread+0x4c/0x68<7>sdhci [sdhci_irq()]: *** mmc0 got interrupt:0x00000001Signed-off-by Haijun Zhang <[email protected]>---
changes for V3:
- Removemmc_try_claim_host.
changes for V2:
- Add card detecting once the last request is done.drivers/mmc/card/block.c | 29 +++++++++++++++++++++++++++-- drivers/mmc/core/mmc.c | 5 +++++ drivers/mmc/core/sd.c | 5 +++++ drivers/mmc/core/sdio.c | 5 +++++ 4 files changed, 42 insertions(+), 2 deletions(-)drivers/mmc/card/block.c +27
-2@@ -1960,9 +1960,21 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)struct mmc_host *host = card->host;unsigned long flags; -if (req && !mq->mqrq_prev->req) +if (req && !mq->mqrq_prev->req) { +/* +* When we are here, card polling task will be blocked. +* So disable it to avoid this useless schedule. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =1 ; +spin_unlock_irqrestore (&host->lock, flags); +cancel_delayed_work (&host->detect); + } +/* claim host only for the first request */ mmc_get_card (card); + } ret =mmc_blk_part_switch (card, md);if (ret) {@@ -1999,7 +2011,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) out:if ((!req && !(mq->flags &MMC_QUEUE_NEW_REQUEST )) || - (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) + (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) {/* * Release host when there are no more requests * and after special request(discard, flush) is done. @@ -2007,6 +2019,19 @@ out:* the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. */ mmc_put_card (card); + +/* +* Detecting card status immediately in case card being +* removed just after the request is complete. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_detect_change (host,0 ); + } + } +return ret; }drivers/mmc/core/mmc.c +5
-0@@ -1443,6 +1443,7 @@ static int mmc_alive(struct mmc_host *host)static void mmc_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -1457,6 +1458,10 @@ static void mmc_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_remove (host);mmc_claim_host (host);drivers/mmc/core/sd.c +5
-0@@ -1041,6 +1041,7 @@ static int mmc_sd_alive(struct mmc_host *host)static void mmc_sd_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -1055,6 +1056,10 @@ static void mmc_sd_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sd_remove (host);mmc_claim_host (host);drivers/mmc/core/sdio.c +5
-0@@ -862,6 +862,7 @@ static int mmc_sdio_alive(struct mmc_host *host)static void mmc_sdio_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -900,6 +901,10 @@ static void mmc_sdio_detect(struct mmc_host *host) out:if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sdio_remove (host);
Quoted 2 lines
drivers/mmc/core/sdio.c static void mmc_sdio_detect(struct mmc_host *host) · line 910
Quoted 1 line
drivers/mmc/core/sdio.c +0
-0mmc_claim_host (host);
Re-enabling the rescan, like "host->rescan_disable = 0" shall be done from mmc_detect_card_removed function instead of from mmc_detect, mmc_sd_detect mmc_sdio_detect.
Look into the mmc_detect_card_removed and where specific error handling is done for MMC_CAP_NEEDS_POLL.
Kind regards
Ulf Hansson
Quoted 5 lines
--
Thanks & Regards
Haijun.
Hi, Ulf
Kindly refer to my inline comment.
Quoted 185 lines · Ulf Hansson
Hi Haijun,
Quoted 7 lines · Zhang Haijun
Hi, Ulf
I had update the patch according to your suggestion. I test on my platform during last night.
About 200G random continuous data was written to 32G SDHC Card. No call trace was encountered.
I think it can meet with your demand and solve the problem.Sounds promising. :-)
Quoted 172 lines
Quoted 170 lines · Haijun Zhang
When card is in cpu polling mode to detect card present. Card detecting task will be scheduled about once every second. When card is busy in large file transfer, detecting task will be hang and call trace will be prompt. When handling the request, CMD13 is always followed by every command when it was complete. So assume that card is present to avoid this duplicate detecting. Only polling card when card is free to reduce conflict with data transfer.
<7>mmc0: req done (CMD13): 0:
00000e0000000000 00000000 00000000INFO: task kworker/u:1:12 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/u:1 D 00000000 0 12 2 0x00000000 Call Trace:[
ee06dd50] [44042028]0x44042028
(unreliable)
[ee06de10] [c0007a0c]__switch_to+0xa0/0xf0
[ee06de30] [c04dd50c]__schedule+0x1f8/0x4a4[
ee06dea0] [c04dd898]schedule+0x30/0xbc[
ee06deb0] [c03816a4]__mmc_claim_host+0x98/0x19c[
ee06df00] [c0385f88]mmc_sd_detect+0x38/0xc0[
ee06df10] [c0382b0c]mmc_rescan+0x294/0x2e0[ee06df40] [c00661cc]process_one_work+0x140/0x3e0[
ee06df70] [c0066bf8]worker_thread+0x18c/0x36c
[ee06dfb0] [c006bf10]kthread+0x7c/0x80[
ee06dff0] [c000de58]kernel_thread+0x4c/0x68<7>sdhci [sdhci_irq()]: *** mmc0 got interrupt:0x00000001Signed-off-by Haijun Zhang <[email protected]>---
changes for V3:
- Removemmc_try_claim_host.
changes for V2:
- Add card detecting once the last request is done.drivers/mmc/card/block.c | 29 +++++++++++++++++++++++++++-- drivers/mmc/core/mmc.c | 5 +++++ drivers/mmc/core/sd.c | 5 +++++ drivers/mmc/core/sdio.c | 5 +++++ 4 files changed, 42 insertions(+), 2 deletions(-)drivers/mmc/card/block.c +27
-2@@ -1960,9 +1960,21 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)struct mmc_host *host = card->host;unsigned long flags; -if (req && !mq->mqrq_prev->req) +if (req && !mq->mqrq_prev->req) { +/* +* When we are here, card polling task will be blocked. +* So disable it to avoid this useless schedule. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =1 ; +spin_unlock_irqrestore (&host->lock, flags); +cancel_delayed_work (&host->detect); + } +/* claim host only for the first request */ mmc_get_card (card); + } ret =mmc_blk_part_switch (card, md);if (ret) {@@ -1999,7 +2011,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) out:if ((!req && !(mq->flags &MMC_QUEUE_NEW_REQUEST )) || - (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) + (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) {/* * Release host when there are no more requests * and after special request(discard, flush) is done. @@ -2007,6 +2019,19 @@ out:* the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. */ mmc_put_card (card); + +/* +* Detecting card status immediately in case card being +* removed just after the request is complete. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_detect_change (host,0 ); + } + } +return ret; }drivers/mmc/core/mmc.c +5
-0@@ -1443,6 +1443,7 @@ static int mmc_alive(struct mmc_host *host)static void mmc_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -1457,6 +1458,10 @@ static void mmc_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_remove (host);mmc_claim_host (host);drivers/mmc/core/sd.c +5
-0@@ -1041,6 +1041,7 @@ static int mmc_sd_alive(struct mmc_host *host)static void mmc_sd_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -1055,6 +1056,10 @@ static void mmc_sd_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sd_remove (host);mmc_claim_host (host);drivers/mmc/core/sdio.c +5
-0@@ -862,6 +862,7 @@ static int mmc_sdio_alive(struct mmc_host *host)static void mmc_sdio_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -900,6 +901,10 @@ static void mmc_sdio_detect(struct mmc_host *host) out:if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sdio_remove (host);
Quoted 7 lines
Quoted 1 line
drivers/mmc/core/sdio.c static void mmc_sdio_detect(struct mmc_host *host) · line 910
Quoted 1 line
drivers/mmc/core/sdio.c +0
-0mmc_claim_host (host);Re-enabling the rescan, like "
host->rescan_disable= 0" shall be done frommmc_detect_card_removedfunction instead of frommmc_detect,mmc_sd_detectmmc_sdio_detect.Look into the
mmc_detect_card_removedand where specific error handling is done forMMC_CAP_NEEDS_POLL.
Thanks, Ulf
Whether the detect task need to be scheduled was decided in mmc_detect_card_removed function. I enable rescan_disable here, just make sure the rescan task can be scheduled next time before card was really removed.
Both interrupt mode and polling mode need the detect task to setup the card for the fist time.
Or I miss something? :-)
Quoted 9 lines
Kind regards
Ulf HanssonQuoted 5 lines
--
Thanks & Regards
Haijun.
Signature · 2 lines
Thanks & Regards Haijun.
Quoted 211 lines · Zhang Haijun
Hi, Ulf
Kindly refer to my inline comment.
Quoted 195 lines · Ulf Hansson
Hi Haijun,
Quoted 8 lines · Zhang Haijun
Hi, Ulf
I had update the patch according to your suggestion. I test on my platform during last night.
About 200G random continuous data was written to 32G SDHC Card. No call trace was encountered.
I think it can meet with your demand and solve the problem.Sounds promising. :-)
Quoted 180 lines
Quoted 178 lines · Haijun Zhang
When card is in cpu polling mode to detect card present. Card detecting task will be scheduled about once every second. When card is busy in large
file transfer, detecting task will be hang and call trace will be prompt.
When handling the request, CMD13 is always followed by every command when
it was complete. So assume that card is present to avoid this duplicate detecting. Only polling card when card is free to reduce conflict with data transfer.<7>mmc0: req done (CMD13): 0:
00000e0000000000 00000000 00000000INFO: task kworker/u:1:12 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/u:1 D 00000000 0 12 2 0x00000000 Call Trace:[
ee06dd50] [44042028]0x44042028
(unreliable)
[ee06de10] [c0007a0c]__switch_to+0xa0/0xf0
[ee06de30] [c04dd50c]__schedule+0x1f8/0x4a4[
ee06dea0] [c04dd898]schedule+0x30/0xbc[
ee06deb0] [c03816a4]__mmc_claim_host+0x98/0x19c[
ee06df00] [c0385f88]mmc_sd_detect+0x38/0xc0[
ee06df10] [c0382b0c]mmc_rescan+0x294/0x2e0[ee06df40] [c00661cc]process_one_work+0x140/0x3e0[
ee06df70] [c0066bf8]worker_thread+0x18c/0x36c
[ee06dfb0] [c006bf10]kthread+0x7c/0x80[
ee06dff0] [c000de58]kernel_thread+0x4c/0x68<7>sdhci [sdhci_irq()]: *** mmc0 got interrupt:0x00000001Signed-off-by Haijun Zhang <[email protected]>---
changes for V3:
- Removemmc_try_claim_host.
changes for V2:
- Add card detecting once the last request is done.drivers/mmc/card/block.c | 29 +++++++++++++++++++++++++++-- drivers/mmc/core/mmc.c | 5 +++++ drivers/mmc/core/sd.c | 5 +++++ drivers/mmc/core/sdio.c | 5 +++++ 4 files changed, 42 insertions(+), 2 deletions(-)drivers/mmc/card/block.c +13
-1@@ -1960,9 +1960,21 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)struct mmc_host *host = card->host;unsigned long flags; -if (req && !mq->mqrq_prev->req) +if (req && !mq->mqrq_prev->req) { +/* +* When we are here, card polling task will be blocked. +* So disable it to avoid this useless schedule. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =1 ; +spin_unlock_irqrestore (&host->lock, flags); +cancel_delayed_work (&host->detect); + } +/* claim host only for the first request */ mmc_get_card (card); + } ret =mmc_blk_part_switch (card, md);if (ret) {drivers/mmc/card/block.c +1
-1@@ -1999,7 +2011,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) out:if ((!req && !(mq->flags &MMC_QUEUE_NEW_REQUEST )) || - (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) + (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) {/* * Release host when there are no more requests
* and after specialrequest(discard, flush)is done.drivers/mmc/card/block.c +13
-0@@ -2007,6 +2019,19 @@ out:* the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. */ mmc_put_card (card); + +/* +* Detecting card status immediately in case card being +* removed just after the request is complete. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_detect_change (host,0 ); + } + } +return ret; }drivers/mmc/core/mmc.c +5
-0@@ -1443,6 +1443,7 @@ static int mmc_alive(struct mmc_host *host)static void mmc_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -1457,6 +1458,10 @@ static void mmc_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_remove (host);mmc_claim_host (host);drivers/mmc/core/sd.c +5
-0@@ -1041,6 +1041,7 @@ static int mmc_sd_alive(struct mmc_host *host)static void mmc_sd_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -1055,6 +1056,10 @@ static void mmc_sd_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sd_remove (host);mmc_claim_host (host);drivers/mmc/core/sdio.c +5
-0@@ -862,6 +862,7 @@ static int mmc_sdio_alive(struct mmc_host *host)static void mmc_sdio_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -900,6 +901,10 @@ static void mmc_sdio_detect(struct mmc_host *host) out:if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sdio_remove (host);Quoted 8 lines
Quoted 1 line
drivers/mmc/core/sdio.c static void mmc_sdio_detect(struct mmc_host *host) · line 910
Quoted 1 line
drivers/mmc/core/sdio.c +0
-0mmc_claim_host (host);Re-enabling the rescan, like "
host->rescan_disable= 0" shall be done frommmc_detect_card_removedfunction instead of frommmc_detect,mmc_sd_detectmmc_sdio_detect.Look into the
mmc_detect_card_removedand where specific error handling is done forMMC_CAP_NEEDS_POLL.
Quoted 7 lines
Thanks, Ulf
Whether the detect task need to be scheduled was decided in
mmc_detect_card_removedfunction.
I enablerescan_disablehere, just make sure the rescan task can be scheduled next time before card was
really removed.
The *detect functions are executed from rescan, and only from here. Thus "rescan_disable" does already has 0 as the present value when executing this path.
Quoted 3 lines
Both interrupt mode and polling mode need the detect task to setup the card for the fist time.
You have only set rescan_disable to 1 for polling mode. I can't see how this should affect irq mode?
Kind regards
Ulf Hansson
Quoted 18 lines
Or I miss something? :-)
Quoted 9 lines
Kind regards
Ulf HanssonQuoted 5 lines
--
Thanks & Regards
Haijun.--
Thanks & Regards
Haijun.
Quoted 208 lines · Ulf Hansson
Quoted 207 lines · Zhang Haijun
Hi, Ulf
Kindly refer to my inline comment.
Quoted 191 lines · Ulf Hansson
Hi Haijun,
Quoted 7 lines · Zhang Haijun
Hi, Ulf
I had update the patch according to your suggestion. I test on my platform during last night.
About 200G random continuous data was written to 32G SDHC Card. No call trace was encountered.
I think it can meet with your demand and solve the problem.Sounds promising. :-)
Quoted 178 lines
Quoted 177 lines · Haijun Zhang
When card is in cpu polling mode to detect card present. Card detecting task will be scheduled about once every second. When card is busy in large
file transfer, detecting task will be hang and call trace will be prompt.
When handling the request, CMD13 is always followed by every command when
it was complete. So assume that card is present to avoid this duplicate detecting. Only polling card when card is free to reduce conflict with data transfer.<7>mmc0: req done (CMD13): 0:
00000e0000000000 00000000 00000000INFO: task kworker/u:1:12 blocked for more than 120 seconds. "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. kworker/u:1 D 00000000 0 12 2 0x00000000 Call Trace:[
ee06dd50] [44042028]0x44042028
(unreliable)
[ee06de10] [c0007a0c]__switch_to+0xa0/0xf0
[ee06de30] [c04dd50c]__schedule+0x1f8/0x4a4[
ee06dea0] [c04dd898]schedule+0x30/0xbc[
ee06deb0] [c03816a4]__mmc_claim_host+0x98/0x19c[
ee06df00] [c0385f88]mmc_sd_detect+0x38/0xc0[
ee06df10] [c0382b0c]mmc_rescan+0x294/0x2e0[ee06df40] [c00661cc]process_one_work+0x140/0x3e0[
ee06df70] [c0066bf8]worker_thread+0x18c/0x36c
[ee06dfb0] [c006bf10]kthread+0x7c/0x80[
ee06dff0] [c000de58]kernel_thread+0x4c/0x68<7>sdhci [sdhci_irq()]: *** mmc0 got interrupt:0x00000001Signed-off-by Haijun Zhang <[email protected]>---
changes for V3:
- Removemmc_try_claim_host.
changes for V2:
- Add card detecting once the last request is done.drivers/mmc/card/block.c | 29 +++++++++++++++++++++++++++-- drivers/mmc/core/mmc.c | 5 +++++ drivers/mmc/core/sd.c | 5 +++++ drivers/mmc/core/sdio.c | 5 +++++ 4 files changed, 42 insertions(+), 2 deletions(-)drivers/mmc/card/block.c +13
-1@@ -1960,9 +1960,21 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)struct mmc_host *host = card->host;unsigned long flags; -if (req && !mq->mqrq_prev->req) +if (req && !mq->mqrq_prev->req) { +/* +* When we are here, card polling task will be blocked. +* So disable it to avoid this useless schedule. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =1 ; +spin_unlock_irqrestore (&host->lock, flags); +cancel_delayed_work (&host->detect); + } +/* claim host only for the first request */ mmc_get_card (card); + } ret =mmc_blk_part_switch (card, md);if (ret) {drivers/mmc/card/block.c +1
-1@@ -1999,7 +2011,7 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) out:if ((!req && !(mq->flags &MMC_QUEUE_NEW_REQUEST )) || - (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) + (req && (req->cmd_flags &MMC_REQ_SPECIAL_MASK ))) {/* * Release host when there are no more requests
* and after specialrequest(discard, flush)is done.drivers/mmc/card/block.c +13
-0@@ -2007,6 +2019,19 @@ out:* the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. */ mmc_put_card (card); + +/* +* Detecting card status immediately in case card being +* removed just after the request is complete. +*/ +if (host->caps &MMC_CAP_NEEDS_POLL ) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_detect_change (host,0 ); + } + } +return ret; }drivers/mmc/core/mmc.c +5
-0@@ -1443,6 +1443,7 @@ static int mmc_alive(struct mmc_host *host)static void mmc_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -1457,6 +1458,10 @@ static void mmc_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_remove (host);mmc_claim_host (host);drivers/mmc/core/sd.c +5
-0@@ -1041,6 +1041,7 @@ static int mmc_sd_alive(struct mmc_host *host)static void mmc_sd_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -1055,6 +1056,10 @@ static void mmc_sd_detect(struct mmc_host *host)mmc_put_card (host->card);if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sd_remove (host);mmc_claim_host (host);drivers/mmc/core/sdio.c +5
-0@@ -862,6 +862,7 @@ static int mmc_sdio_alive(struct mmc_host *host)static void mmc_sdio_detect (struct mmc_host *host) {int err; +unsigned long flags;BUG_ON (!host);BUG_ON (!host->card);@@ -900,6 +901,10 @@ static void mmc_sdio_detect(struct mmc_host *host) out:if (err) { +spin_lock_irqsave (&host->lock, flags); + host->rescan_disable =0 ; +spin_unlock_irqrestore (&host->lock, flags); +mmc_sdio_remove (host);Quoted 7 lines
Quoted 1 line
drivers/mmc/core/sdio.c static void mmc_sdio_detect(struct mmc_host *host) · line 910
Quoted 1 line
drivers/mmc/core/sdio.c +0
-0mmc_claim_host (host);Re-enabling the rescan, like "
host->rescan_disable= 0" shall be done frommmc_detect_card_removedfunction instead of frommmc_detect,mmc_sd_detectmmc_sdio_detect.Look into the
mmc_detect_card_removedand where specific error handling is done forMMC_CAP_NEEDS_POLL.Thanks, Ulf
Quoted 8 lines
Quoted 5 lines
Whether the detect task need to be scheduled was decided in
mmc_detect_card_removedfunction.
I enablerescan_disablehere, just make sure the rescan task can be scheduled next time before card was
really removed.The *detect functions are executed from rescan, and only from here. Thus "
rescan_disable" does already has 0 as the present value when executing this path.
Yes, you are right. This is a redundant code. I just want to make sure there is no other unexpect reason to break this.
Seemed no need. I'll remove this.
Quoted 5 lines
Quoted 3 lines
Both interrupt mode and polling mode need the detect task to setup the card for the fist time.
You have only set
rescan_disableto 1 for polling mode. I can't see how this should affect irq mode?
Redundant check. Not only for polling mode.
So, remove this.
Thanks Ulf.
Quoted 19 lines
Kind regards
Ulf HanssonQuoted 15 lines
Or I miss something? :-)
Quoted 8 lines
Kind regards
Ulf HanssonQuoted 5 lines
--
Thanks & Regards
Haijun.--
Thanks & Regards
Haijun.
Signature · 2 lines
Thanks & Regards Haijun.