linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V5] mmc:core: Avoid useless detecting task when card is busy
@ 2013-09-25  7:27 Haijun Zhang
  2013-09-25  8:31 ` Ulf Hansson
  0 siblings, 1 reply; 6+ messages in thread
From: Haijun Zhang @ 2013-09-25  7:27 UTC (permalink / raw)
  To: linux-mmc
  Cc: cbouatmailru, cjb, scottwood, X.Xie, ulf.hansson, Haijun Zhang,
	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: 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

Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
---
 drivers/mmc/card/block.c | 28 ++++++++++++++++++++++++++--
 drivers/mmc/core/core.c  |  5 +++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 1a3163f..988f16b 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1960,9 +1960,20 @@ 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);
+		}
+
 		/* claim host only for the first request */
 		mmc_get_card(card);
+	}
 
 	ret = mmc_blk_part_switch(card, md);
 	if (ret) {
@@ -1999,7 +2010,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 +2018,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;
 }
 
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index bf18b6b..9ab7020 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2400,6 +2400,7 @@ int mmc_detect_card_removed(struct mmc_host *host)
 {
 	struct mmc_card *card = host->card;
 	int ret;
+	unsigned long flags;
 
 	WARN_ON(!host->claimed);
 
@@ -2422,6 +2423,10 @@ int mmc_detect_card_removed(struct mmc_host *host)
 			 * Schedule a detect work as soon as possible to let a
 			 * rescan handle the card removal.
 			 */
+			spin_lock_irqsave(&host->lock, flags);
+			host->rescan_disable = 0;
+			spin_unlock_irqrestore(&host->lock, flags);
+
 			cancel_delayed_work(&host->detect);
 			mmc_detect_change(host, 0);
 		}
-- 
1.8.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH V5] mmc:core: Avoid useless detecting task when card is busy
  2013-09-25  7:27 [PATCH V5] mmc:core: Avoid useless detecting task when card is busy Haijun Zhang
@ 2013-09-25  8:31 ` Ulf Hansson
  2013-09-25  8:33   ` Zhang Haijun
  0 siblings, 1 reply; 6+ messages in thread
From: Ulf Hansson @ 2013-09-25  8:31 UTC (permalink / raw)
  To: Haijun Zhang; +Cc: linux-mmc, Anton Vorontsov, Chris Ball, scottwood, X.Xie

On 25 September 2013 09:27, Haijun Zhang <Haijun.Zhang@freescale.com> wrote:
> 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
>
> Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

> ---
>  drivers/mmc/card/block.c | 28 ++++++++++++++++++++++++++--
>  drivers/mmc/core/core.c  |  5 +++++
>  2 files changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 1a3163f..988f16b 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -1960,9 +1960,20 @@ 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);
> +               }
> +
>                 /* claim host only for the first request */
>                 mmc_get_card(card);
> +       }
>
>         ret = mmc_blk_part_switch(card, md);
>         if (ret) {
> @@ -1999,7 +2010,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 +2018,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;
>  }
>
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index bf18b6b..9ab7020 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2400,6 +2400,7 @@ int mmc_detect_card_removed(struct mmc_host *host)
>  {
>         struct mmc_card *card = host->card;
>         int ret;
> +       unsigned long flags;
>
>         WARN_ON(!host->claimed);
>
> @@ -2422,6 +2423,10 @@ int mmc_detect_card_removed(struct mmc_host *host)
>                          * Schedule a detect work as soon as possible to let a
>                          * rescan handle the card removal.
>                          */
> +                       spin_lock_irqsave(&host->lock, flags);
> +                       host->rescan_disable = 0;
> +                       spin_unlock_irqrestore(&host->lock, flags);
> +
>                         cancel_delayed_work(&host->detect);
>                         mmc_detect_change(host, 0);
>                 }
> --
> 1.8.0
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V5] mmc:core: Avoid useless detecting task when card is busy
  2013-09-25  8:31 ` Ulf Hansson
@ 2013-09-25  8:33   ` Zhang Haijun
  0 siblings, 0 replies; 6+ messages in thread
From: Zhang Haijun @ 2013-09-25  8:33 UTC (permalink / raw)
  To: Ulf Hansson, Haijun Zhang
  Cc: linux-mmc, Anton Vorontsov, Chris Ball, scottwood, X.Xie

Thanks Ulf.

Regards

Haijun.

于 2013/9/25 16:31, Ulf Hansson 写道:
> On 25 September 2013 09:27, Haijun Zhang <Haijun.Zhang@freescale.com> wrote:
>> 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
>>
>> Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
> Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
>
>> ---
>>  drivers/mmc/card/block.c | 28 ++++++++++++++++++++++++++--
>>  drivers/mmc/core/core.c  |  5 +++++
>>  2 files changed, 31 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
>> index 1a3163f..988f16b 100644
>> --- a/drivers/mmc/card/block.c
>> +++ b/drivers/mmc/card/block.c
>> @@ -1960,9 +1960,20 @@ 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);
>> +               }
>> +
>>                 /* claim host only for the first request */
>>                 mmc_get_card(card);
>> +       }
>>
>>         ret = mmc_blk_part_switch(card, md);
>>         if (ret) {
>> @@ -1999,7 +2010,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 +2018,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;
>>  }
>>
>> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
>> index bf18b6b..9ab7020 100644
>> --- a/drivers/mmc/core/core.c
>> +++ b/drivers/mmc/core/core.c
>> @@ -2400,6 +2400,7 @@ int mmc_detect_card_removed(struct mmc_host *host)
>>  {
>>         struct mmc_card *card = host->card;
>>         int ret;
>> +       unsigned long flags;
>>
>>         WARN_ON(!host->claimed);
>>
>> @@ -2422,6 +2423,10 @@ int mmc_detect_card_removed(struct mmc_host *host)
>>                          * Schedule a detect work as soon as possible to let a
>>                          * rescan handle the card removal.
>>                          */
>> +                       spin_lock_irqsave(&host->lock, flags);
>> +                       host->rescan_disable = 0;
>> +                       spin_unlock_irqrestore(&host->lock, flags);
>> +
>>                         cancel_delayed_work(&host->detect);
>>                         mmc_detect_change(host, 0);
>>                 }
>> --
>> 1.8.0
>>
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

-- 
Thanks & Regards
Haijun.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH V5] mmc:core: Avoid useless detecting task when card is busy
@ 2013-09-26  2:56 Haijun Zhang
  2013-09-27  3:06 ` Zhang Haijun
  2013-10-21  9:16 ` Zhang Haijun
  0 siblings, 2 replies; 6+ messages in thread
From: Haijun Zhang @ 2013-09-26  2:56 UTC (permalink / raw)
  To: cjb
  Cc: linux-mmc, cbouatmailru, scottwood, X.Xie, ulf.hansson,
	Haijun Zhang, 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: 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

Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/mmc/card/block.c | 28 ++++++++++++++++++++++++++--
 drivers/mmc/core/core.c  |  5 +++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
index 1a3163f..988f16b 100644
--- a/drivers/mmc/card/block.c
+++ b/drivers/mmc/card/block.c
@@ -1960,9 +1960,20 @@ 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);
+		}
+
 		/* claim host only for the first request */
 		mmc_get_card(card);
+	}
 
 	ret = mmc_blk_part_switch(card, md);
 	if (ret) {
@@ -1999,7 +2010,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 +2018,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;
 }
 
diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
index bf18b6b..9ab7020 100644
--- a/drivers/mmc/core/core.c
+++ b/drivers/mmc/core/core.c
@@ -2400,6 +2400,7 @@ int mmc_detect_card_removed(struct mmc_host *host)
 {
 	struct mmc_card *card = host->card;
 	int ret;
+	unsigned long flags;
 
 	WARN_ON(!host->claimed);
 
@@ -2422,6 +2423,10 @@ int mmc_detect_card_removed(struct mmc_host *host)
 			 * Schedule a detect work as soon as possible to let a
 			 * rescan handle the card removal.
 			 */
+			spin_lock_irqsave(&host->lock, flags);
+			host->rescan_disable = 0;
+			spin_unlock_irqrestore(&host->lock, flags);
+
 			cancel_delayed_work(&host->detect);
 			mmc_detect_change(host, 0);
 		}
-- 
1.8.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH V5] mmc:core: Avoid useless detecting task when card is busy
  2013-09-26  2:56 Haijun Zhang
@ 2013-09-27  3:06 ` Zhang Haijun
  2013-10-21  9:16 ` Zhang Haijun
  1 sibling, 0 replies; 6+ messages in thread
From: Zhang Haijun @ 2013-09-27  3:06 UTC (permalink / raw)
  To: Haijun Zhang, cjb; +Cc: linux-mmc, cbouatmailru, scottwood, X.Xie, ulf.hansson

Hi, chris

This patch is Acked-by: Ulf

Could you help check on this?


于 2013/9/26 10:56, 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: 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
>
> Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
> Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/mmc/card/block.c | 28 ++++++++++++++++++++++++++--
>  drivers/mmc/core/core.c  |  5 +++++
>  2 files changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 1a3163f..988f16b 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -1960,9 +1960,20 @@ 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);
> +		}
> +
>  		/* claim host only for the first request */
>  		mmc_get_card(card);
> +	}
>  
>  	ret = mmc_blk_part_switch(card, md);
>  	if (ret) {
> @@ -1999,7 +2010,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 +2018,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;
>  }
>  
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index bf18b6b..9ab7020 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2400,6 +2400,7 @@ int mmc_detect_card_removed(struct mmc_host *host)
>  {
>  	struct mmc_card *card = host->card;
>  	int ret;
> +	unsigned long flags;
>  
>  	WARN_ON(!host->claimed);
>  
> @@ -2422,6 +2423,10 @@ int mmc_detect_card_removed(struct mmc_host *host)
>  			 * Schedule a detect work as soon as possible to let a
>  			 * rescan handle the card removal.
>  			 */
> +			spin_lock_irqsave(&host->lock, flags);
> +			host->rescan_disable = 0;
> +			spin_unlock_irqrestore(&host->lock, flags);
> +
>  			cancel_delayed_work(&host->detect);
>  			mmc_detect_change(host, 0);
>  		}

-- 
Thanks & Regards
Haijun.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH V5] mmc:core: Avoid useless detecting task when card is busy
  2013-09-26  2:56 Haijun Zhang
  2013-09-27  3:06 ` Zhang Haijun
@ 2013-10-21  9:16 ` Zhang Haijun
  1 sibling, 0 replies; 6+ messages in thread
From: Zhang Haijun @ 2013-10-21  9:16 UTC (permalink / raw)
  To: Haijun Zhang, cjb; +Cc: linux-mmc, cbouatmailru, scottwood, X.Xie, ulf.hansson

Hi, chris

The patch is acked by Ulf.

Could you give some advice?

Thanks.

于 2013/9/26 10:56, 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: 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
>
> Signed-off-by: Haijun Zhang <haijun.zhang@freescale.com>
> Acked-by: Ulf Hansson <ulf.hansson@linaro.org>
> ---
>  drivers/mmc/card/block.c | 28 ++++++++++++++++++++++++++--
>  drivers/mmc/core/core.c  |  5 +++++
>  2 files changed, 31 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c
> index 1a3163f..988f16b 100644
> --- a/drivers/mmc/card/block.c
> +++ b/drivers/mmc/card/block.c
> @@ -1960,9 +1960,20 @@ 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);
> +		}
> +
>  		/* claim host only for the first request */
>  		mmc_get_card(card);
> +	}
>  
>  	ret = mmc_blk_part_switch(card, md);
>  	if (ret) {
> @@ -1999,7 +2010,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 +2018,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;
>  }
>  
> diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c
> index bf18b6b..9ab7020 100644
> --- a/drivers/mmc/core/core.c
> +++ b/drivers/mmc/core/core.c
> @@ -2400,6 +2400,7 @@ int mmc_detect_card_removed(struct mmc_host *host)
>  {
>  	struct mmc_card *card = host->card;
>  	int ret;
> +	unsigned long flags;
>  
>  	WARN_ON(!host->claimed);
>  
> @@ -2422,6 +2423,10 @@ int mmc_detect_card_removed(struct mmc_host *host)
>  			 * Schedule a detect work as soon as possible to let a
>  			 * rescan handle the card removal.
>  			 */
> +			spin_lock_irqsave(&host->lock, flags);
> +			host->rescan_disable = 0;
> +			spin_unlock_irqrestore(&host->lock, flags);
> +
>  			cancel_delayed_work(&host->detect);
>  			mmc_detect_change(host, 0);
>  		}

-- 
Thanks & Regards
Haijun.



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-10-21  9:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-25  7:27 [PATCH V5] mmc:core: Avoid useless detecting task when card is busy Haijun Zhang
2013-09-25  8:31 ` Ulf Hansson
2013-09-25  8:33   ` Zhang Haijun
  -- strict thread matches above, loose matches on Subject: below --
2013-09-26  2:56 Haijun Zhang
2013-09-27  3:06 ` Zhang Haijun
2013-10-21  9:16 ` Zhang Haijun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).