* [PATCH 1/2] blk-mq: new busy request iterator for driver
2021-09-29 7:00 [PATCH 0/2] Fix UFS task management command timeout Po-Wen Kao
@ 2021-09-29 7:00 ` Po-Wen Kao
2021-09-29 7:08 ` Christoph Hellwig
2021-09-29 7:00 ` [PATCH 2/2] scsi: ufs: fix TM request timeout Po-Wen Kao
2021-09-29 7:39 ` [PATCH 0/2] Fix UFS task management command timeout Avri Altman
2 siblings, 1 reply; 6+ messages in thread
From: Po-Wen Kao @ 2021-09-29 7:00 UTC (permalink / raw)
To: linux-block, axboe, linux-kernel, stanley.chu, linux-scsi,
martin.petersen, avri.altman, alim.akhtar, jejb
Cc: peter.wang, chun-hung.wu, alice.chao, jonathan.hsu, powen.kao,
cc.chou, chaotian.jing, jiajie.hao, wsd_upstream, ed.tsai
Driver occasionally execute allocated request directly without
dispatching to block layer, thus request never appears in tags->rqs.
To allow driver to iterate through requests in static_rqs, a new
interface blk_mq_drv_tagset_busy_iter() is introduced.
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
---
block/blk-mq-tag.c | 36 ++++++++++++++++++++++++++++++------
include/linux/blk-mq.h | 4 ++++
2 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 86f87346232a..7723689e7714 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -365,6 +365,31 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
/**
* blk_mq_tagset_busy_iter - iterate over all started requests in a tag set
+ * Refer to __blk_mq_tagset_iter() for parameter details.
+ */
+void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
+ busy_tag_iter_fn *fn, void *priv)
+{
+ __blk_mq_tagset_iter(tagset, fn, priv,
+ BT_TAG_ITER_STARTED);
+}
+EXPORT_SYMBOL(blk_mq_tagset_busy_iter);
+
+/**
+ * blk_mq_drv_tagset_busy_iter - iterate over all started static requests
+ * in a tag set.
+ * Refer to __blk_mq_tagset_iter() for parameter details.
+ */
+void blk_mq_drv_tagset_busy_iter(struct blk_mq_tag_set *tagset,
+ busy_tag_iter_fn *fn, void *priv)
+{
+ __blk_mq_tagset_iter(tagset, fn, priv,
+ BT_TAG_ITER_STARTED | BT_TAG_ITER_STATIC_RQS);
+}
+EXPORT_SYMBOL(blk_mq_drv_tagset_busy_iter);
+
+/**
+ * blk_mq_tm_tagset_busy_iter - iterate over all requests in a tagset.
* @tagset: Tag set to iterate over.
* @fn: Pointer to the function that will be called for each started
* request. @fn will be called as follows: @fn(rq, @priv,
@@ -375,19 +400,18 @@ void blk_mq_all_tag_iter(struct blk_mq_tags *tags, busy_tag_iter_fn *fn,
*
* We grab one request reference before calling @fn and release it after
* @fn returns.
+ * @flags: BT_TAG_ITER_*
*/
-void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
- busy_tag_iter_fn *fn, void *priv)
+void __blk_mq_tagset_iter(struct blk_mq_tag_set *tagset,
+ busy_tag_iter_fn *fn, void *priv, unsigned int flags)
{
int i;
-
for (i = 0; i < tagset->nr_hw_queues; i++) {
if (tagset->tags && tagset->tags[i])
- __blk_mq_all_tag_iter(tagset->tags[i], fn, priv,
- BT_TAG_ITER_STARTED);
+ __blk_mq_all_tag_iter(tagset->tags[i], fn, priv, flags);
}
}
-EXPORT_SYMBOL(blk_mq_tagset_busy_iter);
+
static bool blk_mq_tagset_count_completed_rqs(struct request *rq,
void *data, bool reserved)
diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h
index 13ba1861e688..29c851192093 100644
--- a/include/linux/blk-mq.h
+++ b/include/linux/blk-mq.h
@@ -545,6 +545,10 @@ void blk_mq_run_hw_queues(struct request_queue *q, bool async);
void blk_mq_delay_run_hw_queues(struct request_queue *q, unsigned long msecs);
void blk_mq_tagset_busy_iter(struct blk_mq_tag_set *tagset,
busy_tag_iter_fn *fn, void *priv);
+void blk_mq_drv_tagset_busy_iter(struct blk_mq_tag_set *tagset,
+ busy_tag_iter_fn *fn, void *priv);
+void __blk_mq_tagset_iter(struct blk_mq_tag_set *tagset,
+ busy_tag_iter_fn *fn, void *priv, unsigned int flags);
void blk_mq_tagset_wait_completed_request(struct blk_mq_tag_set *tagset);
void blk_mq_freeze_queue(struct request_queue *q);
void blk_mq_unfreeze_queue(struct request_queue *q);
--
2.18.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] scsi: ufs: fix TM request timeout
2021-09-29 7:00 [PATCH 0/2] Fix UFS task management command timeout Po-Wen Kao
2021-09-29 7:00 ` [PATCH 1/2] blk-mq: new busy request iterator for driver Po-Wen Kao
@ 2021-09-29 7:00 ` Po-Wen Kao
2021-09-29 7:39 ` [PATCH 0/2] Fix UFS task management command timeout Avri Altman
2 siblings, 0 replies; 6+ messages in thread
From: Po-Wen Kao @ 2021-09-29 7:00 UTC (permalink / raw)
To: linux-block, axboe, linux-kernel, stanley.chu, linux-scsi,
martin.petersen, avri.altman, alim.akhtar, jejb
Cc: peter.wang, chun-hung.wu, alice.chao, jonathan.hsu, powen.kao,
cc.chou, chaotian.jing, jiajie.hao, wsd_upstream, ed.tsai
TM command issued by ufshcd_issue_tm_cmd() inevitably timeout since
interrupt handler iterates wrong request list for completion.
The issue is fixed by iterating static_rqs instead of rqs to find
requests with new interface blk_mq_drv_tagset_busy_iter().
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
---
drivers/scsi/ufs/ufshcd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index 3841ab49f556..7a1ea42302b8 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -6428,7 +6428,7 @@ static irqreturn_t ufshcd_tmc_handler(struct ufs_hba *hba)
spin_lock_irqsave(hba->host->host_lock, flags);
ci.pending = ufshcd_readl(hba, REG_UTP_TASK_REQ_DOOR_BELL);
- blk_mq_tagset_busy_iter(q->tag_set, ufshcd_compl_tm, &ci);
+ blk_mq_drv_tagset_busy_iter(q->tag_set, ufshcd_compl_tm, &ci);
spin_unlock_irqrestore(hba->host->host_lock, flags);
return ci.ncpl ? IRQ_HANDLED : IRQ_NONE;
--
2.18.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* RE: [PATCH 0/2] Fix UFS task management command timeout
2021-09-29 7:00 [PATCH 0/2] Fix UFS task management command timeout Po-Wen Kao
2021-09-29 7:00 ` [PATCH 1/2] blk-mq: new busy request iterator for driver Po-Wen Kao
2021-09-29 7:00 ` [PATCH 2/2] scsi: ufs: fix TM request timeout Po-Wen Kao
@ 2021-09-29 7:39 ` Avri Altman
2021-09-30 8:50 ` Po-Wen Kao
2 siblings, 1 reply; 6+ messages in thread
From: Avri Altman @ 2021-09-29 7:39 UTC (permalink / raw)
To: Po-Wen Kao, linux-block, axboe, linux-kernel, stanley.chu,
linux-scsi, martin.petersen, alim.akhtar, jejb
Cc: peter.wang, chun-hung.wu, alice.chao, jonathan.hsu, cc.chou,
chaotian.jing, jiajie.hao, wsd_upstream, ed.tsai
> On UTP_TASK_REQ_COMPL interrupt, ufshcd_tmc_handler() iterates through
> busy requests in tags->rqs and complete request if corresponding
> doorbell flag is reset.
> However, ufshcd_issue_tm_cmd() allocates requests from tags->static_rqs
> and trigger doorbell directly without dispatching request through block
> layer, thus requests can never be found in tags->rqs and completed
> properly. Any TM command issued by ufshcd_issue_tm_cmd() inevitably
> timeout and further leads to recovery flow failure when LU Reset or
> Abort Task is issued.
>
> In this patch, blk_mq_tagset_busy_iter() call in ufshcd_tmc_handler()
> is replaced with new interface, blk_mq_drv_tagset_busy_iter(), to
> allow completion of request allocted by driver. The new interface is
> introduced for driver to iterate through requests in static_rqs.
Is this the same issue that was addressed here - https://www.spinics.net/lists/linux-scsi/msg164520.html ?
Thanks,
Avri
>
> Po-Wen Kao (2):
> blk-mq: new busy request iterator for driver
> scsi: ufs: fix TM request timeout
>
> block/blk-mq-tag.c | 36 ++++++++++++++++++++++++++++++------
> drivers/scsi/ufs/ufshcd.c | 2 +-
> include/linux/blk-mq.h | 4 ++++
> 3 files changed, 35 insertions(+), 7 deletions(-)
>
> --
> 2.18.0
^ permalink raw reply [flat|nested] 6+ messages in thread