mmc: card: Fixup request missing in mmc_blk_issue_rw_rq
PATCH 1/1 mmc: card: Fixup request missing in mmc_blk_issue_rw_rq
From 05849da563c80c20597ab6275d5881a8ed426f96 Mon Sep 17 00:00:00 2001
From: justin.wang <[email protected]>
Date: Mon, 18 May 2015 20:14:15 +0800
Subject: [PATCH] mmc: card: Fixup request missing in mmc_blk_issue_rw_rq
The current handler of MMC_BLK_CMD_ERR in mmc_blk_issue_rw_rq function may cause new coming request permanent missing when the ongoing request (previoulsy started) complete end.
This would cause the process related to the missing request stay at 'D' state forever.
--- drivers/mmc/card/block.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/mmc/card/block.c +5 -3
@@ -1910,9 +1910,11 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)break ;case MMC_BLK_CMD_ERR : ret =mmc_blk_cmd_err (md, card, brq, req, ret); -if (!mmc_blk_reset (md, card->host, type)) -break ; - goto cmd_abort; +if (mmc_blk_reset (md, card->host, type)) + goto cmd_abort; +if (!ret) + goto start_new_req; +break ;case MMC_BLK_RETRY :if (retry++ <5 )break ;
Signature · 1 line
1.7.4.1
Quoted 8 lines · Justin Wang (王丁)
From
05849da563c80c20597ab6275d5881a8ed426f96Mon Sep 17 00:00:00 2001
From: justin.wang <[email protected]>
Date: Mon, 18 May 2015 20:14:15 +0800
Subject: [PATCH] mmc: card: Fixup request missing inmmc_blk_issue_rw_rqThe current handler of
MMC_BLK_CMD_ERRinmmc_blk_issue_rw_rqfunction may cause new coming request permanent missing when the ongoing request (previoulsy started) complete end.
I think you need to elaborate a bit more here. In exactly what scenario does this problem occur?
Quoted 3 lines
This would cause the process related to the missing request stay at 'D' state forever.
'D' state?
I suppose it waits for a response for its IO request. Doesn't also the block layer complain or timeout somehow? Would be interesting to know a bit more about what really happens when things goes wrong.
Quoted 1 line
Seems like we should have a fixes tag here as well, could you possibly try to find what commit that introduced this bug?
Quoted 25 lines
Signed-off-by Ding Wang <[email protected]>--- drivers/mmc/card/block.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)drivers/mmc/card/block.c +5
-4@@ -1910,9 +1910,11 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)break ;case MMC_BLK_CMD_ERR : ret =mmc_blk_cmd_err (md, card, brq, req, ret); -if (!mmc_blk_reset (md, card->host, type)) -break ; - goto cmd_abort; +if (mmc_blk_reset (md, card->host, type)) + goto cmd_abort; +if (!ret) + goto start_new_req; +break ;case MMC_BLK_RETRY :if (retry++ <5 )break ; --
Quoted 2 lines
1.7.4.1
Kind regards
Uffe
Quoted 20 lines
-----Original Message-----
From: Ulf Hansson [mailto:[email protected]]
Sent: Thursday, May 28, 2015 4:29 PM
To: Justin Wang (王丁)
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] mmc: card: Fixup request missing inmmc_blk_issue_rw_rq
Importance: HighQuoted 1 line · Justin Wang (王丁)
From
05849da563c80c20597ab6275d5881a8ed426f96Mon Sep 17 00:00:002001
Quoted 4 lines
From: justin.wang <[email protected]>
Date: Mon, 18 May 2015 20:14:15 +0800
Subject: [PATCH] mmc: card: Fixup request missing inmmc_blk_issue_rw_rq
Quoted 8 lines
Quoted 1 line
The current handler of
MMC_BLK_CMD_ERRinmmc_blk_issue_rw_rqfunction
Quoted 2 lines
may cause new coming request permanent missing when the ongoing request (previoulsy started) complete end.
I think you need to elaborate a bit more here. In exactly what scenario does this problem occur?
Thanks, I will give a detailed description next patch.
Quoted 10 lines
Quoted 3 lines
This would cause the process related to the missing request stay at 'D' state forever.
'D' state?
I suppose it waits for a response for its IO request. Doesn't also the block layer complain or timeout somehow? Would be interesting to know a bit more about what really happens when things goes wrong.
Yes, process will wait the missed request complete forever, no timeout in block layer. The related process will be blocked.
Quoted 37 lines
Quoted 1 line
Seems like we should have a fixes tag here as well, could you possibly try to find what commit that introduced this bug?
drivers/mmc/card/block.c static int mmc_blk_issue_rw_rq(struct
Quoted 10 lines
Signed-off-by Ding Wang <[email protected]>--- drivers/mmc/card/block.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)drivers/mmc/card/block.c +0
-0@@ -1910,9 +1910,11 @@ static int mmc_blk_issue_rw_rq(struct
mmc_queue*mq, struct request *rqc)drivers/mmc/card/block.c static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)
Quoted 3 lines
drivers/mmc/card/block.c +0
-0break ;case MMC_BLK_CMD_ERR : ret = mmc_blk_cmd_err(md, card, brq, req,ret);
Quoted 12 lines
drivers/mmc/card/block.c +5
-4-if (!mmc_blk_reset (md, card->host, type)) -break ; - goto cmd_abort; +if (mmc_blk_reset (md, card->host, type)) + goto cmd_abort; +if (!ret) + goto start_new_req; +break ;case MMC_BLK_RETRY :if (retry++ <5 )break ; --Quoted 2 lines
1.7.4.1
Kind regards
Uffe
PATCH v2 1/1 mmc: card: Fixup request missing in mmc_blk_issue_rw_rq
In reply to Justin Wang (王丁)From 0e01e7546745f39843d54810f74c198e01cb8226 Mon Sep 17 00:00:00 2001
From: justin.wang <[email protected]>
Date: Mon, 18 May 2015 20:14:15 +0800
Subject: [PATCH v2] mmc: card: Fixup request missing in mmc_blk_issue_rw_rq
The current handler of MMC_BLK_CMD_ERR in mmc_blk_issue_rw_rq function may cause new coming request permanent missing when the ongoing request (previoulsy started) complete end.
The problem scenario is as follows:
(1) Request A is ongoing;
(2) Request B arrived, and finally mmc_blk_issue_rw_rq() is called;
(3) Request A encounters the MMC_BLK_CMD_ERR error;
(4) In the error handling of MMC_BLK_CMD_ERR, suppose mmc_blk_cmd_err() end request A completed and return zero. Continue the error handling, suppose mmc_blk_reset() reset device success;
(5) Continue the execution, while loop completed because variable ret
is zero now;
(6) Finally, mmc_blk_issue_rw_rq() return without processing request B.
The process related to the missing request may wait that IO request complete forever, possibly crashing the application or hanging the system.
Fix this issue by starting new request when reset success.
--- drivers/mmc/card/block.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/mmc/card/block.c +5 -3
@@ -1910,9 +1910,11 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)break ;case MMC_BLK_CMD_ERR : ret =mmc_blk_cmd_err (md, card, brq, req, ret); -if (!mmc_blk_reset (md, card->host, type)) -break ; - goto cmd_abort; +if (mmc_blk_reset (md, card->host, type)) + goto cmd_abort; +if (!ret) + goto start_new_req; +break ;case MMC_BLK_RETRY :if (retry++ <5 )break ;
Signature · 1 line
1.7.4.1
Ulf Hansson
AppliedQuoted 18 lines · Justin Wang (王丁)
From
0e01e7546745f39843d54810f74c198e01cb8226Mon Sep 17 00:00:00 2001
From: justin.wang <[email protected]>
Date: Mon, 18 May 2015 20:14:15 +0800
Subject: [PATCH v2] mmc: card: Fixup request missing inmmc_blk_issue_rw_rqThe current handler of
MMC_BLK_CMD_ERRinmmc_blk_issue_rw_rqfunction may cause new coming request permanent missing when the ongoing request (previoulsy started) complete end.The problem scenario is as follows:
(1) Request A is ongoing;
(2) Request B arrived, and finallymmc_blk_issue_rw_rq()is called;
(3) Request A encounters theMMC_BLK_CMD_ERRerror;
(4) In the error handling ofMMC_BLK_CMD_ERR, supposemmc_blk_cmd_err()end request A completed and return zero. Continue the error handling, supposemmc_blk_reset()reset device success;
(5) Continue the execution, while loop completed because variable retis zero now;
Quoted 8 lines
(6) Finally,
mmc_blk_issue_rw_rq()return without processing request B.The process related to the missing request may wait that IO request complete forever, possibly crashing the application or hanging the system.
Fix this issue by starting new request when reset success.
Signed-off-by Ding Wang <[email protected]>
Thanks, applied for next.
I have added a the following fixes tag:
Fixes 67716327eec7 ("mmc: block: add eMMC hardware reset support") I am not sure, whether the bug were introduced even earlier than that, but I think $subject patch should be trivial to apply on top that one.
Kind regards
Uffe
Quoted 26 lines
--- drivers/mmc/card/block.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-)drivers/mmc/card/block.c +5
-4@@ -1910,9 +1910,11 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc)break ;case MMC_BLK_CMD_ERR : ret =mmc_blk_cmd_err (md, card, brq, req, ret); -if (!mmc_blk_reset (md, card->host, type)) -break ; - goto cmd_abort; +if (mmc_blk_reset (md, card->host, type)) + goto cmd_abort; +if (!ret) + goto start_new_req; +break ;case MMC_BLK_RETRY :if (retry++ <5 )break ; --1.7.4.1