mmc: Add Command Queue support
Subsystems (4)
Adrian Hunter
maintainerv2 cover mmc: Add Command Queue support
Hi
Here are the hardware command queue patches without the software command queue patches or sdhci patches.
Changes since V1:
"Share mmc request array between partitions" is dependent on changes in "Introduce queue semantics", so added that and block fixes:
Added "Fix is_waiting_last_req set incorrectly" Added "Fix cmd error reset failure path" Added "Use local var for mqrq_cur" Added "Introduce queue semantics"
Changes since RFC:
Re-based on next.
Added comment about command queue priority. Added some acks and reviews.
Adrian Hunter (21):
mmc: block: Fix is_waiting_last_req set incorrectly
mmc: block: Fix cmd error reset failure path
mmc: block: Use local var for mqrq_cur
mmc: block: Introduce queue semantics
mmc: queue: Share mmc request array between partitions
mmc: mmc: Add functions to enable / disable the Command Queue
mmc: mmc_test: Disable Command Queue while mmc_test is used
mmc: block: Disable Command Queue while RPMB is used
mmc: block: Change mmc_apply_rel_rw() to get block address from the request
mmc: block: Factor out data preparation
mmc: core: Factor out debug prints from mmc_start_request()
mmc: core: Factor out mrq preparation from mmc_start_request()
mmc: core: Add mmc_retune_hold_now()
mmc: core: Add members to mmc_request and mmc_data for CQE's
mmc: host: Add CQE interface
mmc: core: Turn off CQE before sending commands
mmc: core: Add support for handling CQE requests
mmc: mmc: Enable Command Queuing
mmc: mmc: Enable CQE's
mmc: block: Prepare CQE data
mmc: block: Add CQE support
Venkat Gopalakrishnan (1):
mmc: cqhci: support for command queue enabled host
Documentation/mmc/mmc-dev-attrs.txt | 1 + drivers/mmc/core/block.c | 527 ++++++++++++---- drivers/mmc/core/block.h | 7 + drivers/mmc/core/bus.c | 7 + drivers/mmc/core/core.c | 203 ++++++- drivers/mmc/core/host.c | 6 + drivers/mmc/core/host.h | 1 + drivers/mmc/core/mmc.c | 39 +- drivers/mmc/core/mmc_ops.c | 28 + drivers/mmc/core/mmc_ops.h | 2 + drivers/mmc/core/mmc_test.c | 14 + drivers/mmc/core/queue.c | 607 ++++++++++++++---- drivers/mmc/core/queue.h | 55 +- drivers/mmc/host/Kconfig | 13 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/cqhci.c | 1148 +++++++++++++++++++++++++++++++++++ drivers/mmc/host/cqhci.h | 240 ++++++++ include/linux/mmc/card.h | 8 + include/linux/mmc/core.h | 19 +- include/linux/mmc/host.h | 24 + include/trace/events/mmc.h | 17 +- 21 files changed, 2694 insertions(+), 273 deletions(-) create mode 100644 drivers/mmc/host/cqhci.c create mode 100644 drivers/mmc/host/cqhci.h
Regards
Adrian
Adrian Hunter
maintainerPATCH v2 1/22 mmc: block: Fix is_waiting_last_req set incorrectly
Commit 15520111500c ("mmc: core: Further fix thread wake-up") allowed a queue to release the host with is_waiting_last_req set to true. A queue waiting to claim the host will not reset it, which can result in the queue getting stuck in a loop.
--- drivers/mmc/core/block.c | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/core/block.c +1 -0
@@ -1817,6 +1817,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)mmc_blk_issue_flush (mq, req); }else {mmc_blk_issue_rw_rq (mq, req); + card->host->context_info.is_waiting_last_req = false; } out:
Signature · 1 line
1.9.1
Ulf Hansson
AppliedRe: [PATCH V2 01/22] mmc: block: Fix is_waiting_last_req set incorrectly
Quoted 8 lines · Adrian Hunter
Commit
15520111500c("mmc: core: Further fix thread wake-up") allowed a queue to release the host withis_waiting_last_reqset to true. A queue waiting to claim the host will not reset it, which can result in the queue getting stuck in a loop.Fixes 15520111500c ("mmc: core: Further fix thread wake-up")Signed-off-by Adrian Hunter <[email protected]>Cc [email protected] # v4.10+
Thanks, applied for fixes!
Kind regards
Uffe
Quoted 19 lines
--- drivers/mmc/core/block.c | 1 + 1 file changed, 1 insertion(+)drivers/mmc/core/block.c +1
-1@@ -1817,6 +1817,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)mmc_blk_issue_flush (mq, req); }else {mmc_blk_issue_rw_rq (mq, req); + card->host->context_info.is_waiting_last_req = false; } out: --1.9.1
Adrian Hunter
maintainerPATCH v2 2/22 mmc: block: Fix cmd error reset failure path
In reply to Adrian HunterCommit 4e1f780032c5 ("mmc: block: break out mmc_blk_rw_cmd_abort()") assumed the request had not completed, but in one case it had. Fix that.
--- drivers/mmc/core/block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mmc/core/block.c +2 -1
@@ -1701,7 +1701,8 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)case MMC_BLK_CMD_ERR : req_pending =mmc_blk_rw_cmd_err (md, card, brq, old_req, req_pending);if (mmc_blk_reset (md, card->host, type)) { -mmc_blk_rw_cmd_abort (card, old_req); +if (req_pending) +mmc_blk_rw_cmd_abort (card, old_req);mmc_blk_rw_try_restart (mq, new_req);return ; }
Signature · 1 line
1.9.1
Ulf Hansson
AppliedRe: [PATCH V2 02/22] mmc: block: Fix cmd error reset failure path
Quoted 6 lines · Adrian Hunter
Commit
4e1f780032c5("mmc: block: break outmmc_blk_rw_cmd_abort()") assumed the request had not completed, but in one case it had. Fix that.Fixes 4e1f780032c5 ("mmc: block: break out mmc_blk_rw_cmd_abort()")Signed-off-by Adrian Hunter <[email protected]>Reviewed-by Linus Walleij <[email protected]>
Thanks, applied for fixes!
Kind regards
Uffe
Quoted 21 lines
--- drivers/mmc/core/block.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/mmc/core/block.c +2
-2@@ -1701,7 +1701,8 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)case MMC_BLK_CMD_ERR : req_pending =mmc_blk_rw_cmd_err (md, card, brq, old_req, req_pending);if (mmc_blk_reset (md, card->host, type)) { -mmc_blk_rw_cmd_abort (card, old_req); +if (req_pending) +mmc_blk_rw_cmd_abort (card, old_req);mmc_blk_rw_try_restart (mq, new_req);return ; } --1.9.1
Adrian Hunter
maintainerPATCH v2 3/22 mmc: block: Use local var for mqrq_cur
In reply to Adrian HunterA subsequent patch will remove 'mq->mqrq_cur'. Prepare for that by assigning it to a local variable.
--- drivers/mmc/core/block.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-)
drivers/mmc/core/block.c +14 -12
@@ -1600,7 +1600,8 @@ static void mmc_blk_rw_cmd_abort(struct mmc_card *card, struct request *req)* @mq: the queue with the card and host to restart * @req: a new request that want to be started after the current one */ -static void mmc_blk_rw_try_restart (struct mmc_queue *mq,struct request *req) +static void mmc_blk_rw_try_restart (struct mmc_queue *mq,struct request *req, +struct mmc_queue_req *mqrq) {if (!req)return ;
@@ -1614,8 +1615,8 @@ static void mmc_blk_rw_try_restart(struct mmc_queue *mq, struct request *req)return ; }/* Else proceed and try to restart the current async request */ -mmc_blk_rw_rq_prep (mq->mqrq_cur, mq->card,0 , mq); -mmc_start_areq (mq->card->host, &mq->mqrq_cur->areq,NULL ); +mmc_blk_rw_rq_prep (mqrq, mq->card,0 , mq); +mmc_start_areq (mq->card->host, &mqrq->areq,NULL ); }static void mmc_blk_issue_rw_rq (struct mmc_queue *mq,struct request *new_req)
@@ -1625,6 +1626,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)struct mmc_blk_request *brq;int disable_multi =0 , retry =0 , type, retune_retry_done =0 ;enum mmc_blk_status status; +struct mmc_queue_req *mqrq_cur = mq->mqrq_cur;struct mmc_queue_req *mq_rq;struct request *old_req;struct mmc_async_req *new_areq;
@@ -1648,8 +1650,8 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)return ; } -mmc_blk_rw_rq_prep (mq->mqrq_cur, card,0 , mq); - new_areq = &mq->mqrq_cur->areq; +mmc_blk_rw_rq_prep (mqrq_cur, card,0 , mq); + new_areq = &mqrq_cur->areq; }else new_areq =NULL ;
@@ -1703,11 +1705,11 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)if (mmc_blk_reset (md, card->host, type)) {if (req_pending)mmc_blk_rw_cmd_abort (card, old_req); -mmc_blk_rw_try_restart (mq, new_req); +mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ; }if (!req_pending) { -mmc_blk_rw_try_restart (mq, new_req); +mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ; }break ;
@@ -1720,7 +1722,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)if (!mmc_blk_reset (md, card->host, type))break ;mmc_blk_rw_cmd_abort (card, old_req); -mmc_blk_rw_try_restart (mq, new_req); +mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ;case MMC_BLK_DATA_ERR : {int err;
@@ -1730,7 +1732,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)break ;if (err == -ENODEV ) {mmc_blk_rw_cmd_abort (card, old_req); -mmc_blk_rw_try_restart (mq, new_req); +mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ; }/* Fall through */
@@ -1751,19 +1753,19 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) req_pending =blk_end_request (old_req, -EIO , brq->data.blksz);if (!req_pending) { -mmc_blk_rw_try_restart (mq, new_req); +mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ; }break ;case MMC_BLK_NOMEDIUM :mmc_blk_rw_cmd_abort (card, old_req); -mmc_blk_rw_try_restart (mq, new_req); +mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ;default :pr_err ("%s: Unhandled return value (%d)" , old_req->rq_disk->disk_name, status);mmc_blk_rw_cmd_abort (card, old_req); -mmc_blk_rw_try_restart (mq, new_req); +mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ; }
Signature · 1 line
1.9.1
Re: [PATCH V2 03/22] mmc: block: Use local var for mqrq_cur
Quoted 4 lines · Adrian Hunter
A subsequent patch will remove '
mq->mqrq_cur'. Prepare for that by assigning it to a local variable.Signed-off-by Adrian Hunter <[email protected]>
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v2 4/22 mmc: block: Introduce queue semantics
In reply to Adrian HunterChange from viewing the requests in progress as 'current' and 'previous', to viewing them as a queue. The current request is allocated to the first free slot. The presence of incomplete requests is determined from the count (mq->qcnt) of entries in the queue. Non-read-write requests (i.e. discards and flushes) are not added to the queue at all and require no special handling. Also no special handling is needed for the MMC_BLK_NEW_REQUEST case.
As well as allowing an arbitrarily sized queue, the queue thread function is significantly simpler.
--- drivers/mmc/core/block.c | 66 ++++++++++++++++++++++++++---------------- drivers/mmc/core/queue.c | 75 ++++++++++++++++++++++++++++++------------------ drivers/mmc/core/queue.h | 10 +++++-- 3 files changed, 95 insertions(+), 56 deletions(-)
drivers/mmc/core/block.c +41 -25
@@ -129,6 +129,13 @@ static inline int mmc_blk_part_switch(struct mmc_card *card, struct mmc_blk_data *md);static int get_card_status (struct mmc_card *card,u32 *status,int retries); +static void mmc_blk_requeue (struct request_queue *q,struct request *req) +{ +spin_lock_irq (q->queue_lock); +blk_requeue_request (q, req); +spin_unlock_irq (q->queue_lock); +} +static struct mmc_blk_data *mmc_blk_get (struct gendisk *disk) {struct mmc_blk_data *md;
@@ -1588,11 +1595,14 @@ static bool mmc_blk_rw_cmd_err(struct mmc_blk_data *md, struct mmc_card *card,return req_pending; } -static void mmc_blk_rw_cmd_abort (struct mmc_card *card,struct request *req) +static void mmc_blk_rw_cmd_abort (struct mmc_queue *mq,struct mmc_card *card, +struct request *req, +struct mmc_queue_req *mqrq) {if (mmc_card_removed (card)) req->rq_flags |=RQF_QUIET ;while (blk_end_request (req, -EIO ,blk_rq_cur_bytes (req))); +mmc_queue_req_free (mq, mqrq); }/**
@@ -1612,6 +1622,7 @@ static void mmc_blk_rw_try_restart(struct mmc_queue *mq, struct request *req,if (mmc_card_removed (mq->card)) { req->rq_flags |=RQF_QUIET ;blk_end_request_all (req, -EIO ); +mmc_queue_req_free (mq, mqrq);return ; }/* Else proceed and try to restart the current async request */
@@ -1626,14 +1637,23 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)struct mmc_blk_request *brq;int disable_multi =0 , retry =0 , type, retune_retry_done =0 ;enum mmc_blk_status status; -struct mmc_queue_req *mqrq_cur = mq->mqrq_cur; +struct mmc_queue_req *mqrq_cur =NULL ;struct mmc_queue_req *mq_rq;struct request *old_req;struct mmc_async_req *new_areq;struct mmc_async_req *old_areq;bool req_pending = true; -if (!new_req && !mq->mqrq_prev->req) +if (new_req) { + mqrq_cur =mmc_queue_req_find (mq, new_req); +if (!mqrq_cur) { +WARN_ON (1 ); +mmc_blk_requeue (mq->queue, new_req); + new_req =NULL ; + } + } + +if (!mq->qcnt)return ; do {
@@ -1646,7 +1666,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) !IS_ALIGNED(blk_rq_sectors(new_req), 8)) {pr_err ("%s: Transfer size is not 4KB sector size aligned\n" , new_req->rq_disk->disk_name); -mmc_blk_rw_cmd_abort (card, new_req); +mmc_blk_rw_cmd_abort (mq, card, new_req, mqrq_cur);return ; }
@@ -1662,8 +1682,6 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)* and there is nothing more to do until it is * complete. */ -if (status ==MMC_BLK_NEW_REQUEST ) - mq->new_request = true;return ; }
@@ -1696,7 +1714,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)pr_err ("%s BUG rq_tot %d d_xfer %d\n" , __func__,blk_rq_bytes (old_req), brq->data.bytes_xfered); -mmc_blk_rw_cmd_abort (card, old_req); +mmc_blk_rw_cmd_abort (mq, card, old_req, mq_rq);return ; }break ;
@@ -1704,11 +1722,14 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) req_pending =mmc_blk_rw_cmd_err (md, card, brq, old_req, req_pending);if (mmc_blk_reset (md, card->host, type)) {if (req_pending) -mmc_blk_rw_cmd_abort (card, old_req); +mmc_blk_rw_cmd_abort (mq, card, old_req, mq_rq); +else +mmc_queue_req_free (mq, mq_rq);mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ; }if (!req_pending) { +mmc_queue_req_free (mq, mq_rq);mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ; }
@@ -1721,7 +1742,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)case MMC_BLK_ABORT :if (!mmc_blk_reset (md, card->host, type))break ; -mmc_blk_rw_cmd_abort (card, old_req); +mmc_blk_rw_cmd_abort (mq, card, old_req, mq_rq);mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ;case MMC_BLK_DATA_ERR : {
@@ -1731,7 +1752,7 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req)if (!err)break ;if (err == -ENODEV ) { -mmc_blk_rw_cmd_abort (card, old_req); +mmc_blk_rw_cmd_abort (mq, card, old_req, mq_rq);mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ; }
@@ -1753,18 +1774,19 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) req_pending =blk_end_request (old_req, -EIO , brq->data.blksz);if (!req_pending) { +mmc_queue_req_free (mq, mq_rq);mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ; }break ;case MMC_BLK_NOMEDIUM : -mmc_blk_rw_cmd_abort (card, old_req); +mmc_blk_rw_cmd_abort (mq, card, old_req, mq_rq);mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ;default :pr_err ("%s: Unhandled return value (%d)" , old_req->rq_disk->disk_name, status); -mmc_blk_rw_cmd_abort (card, old_req); +mmc_blk_rw_cmd_abort (mq, card, old_req, mq_rq);mmc_blk_rw_try_restart (mq, new_req, mqrq_cur);return ; }
@@ -1781,6 +1803,8 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *new_req) mq_rq->brq.retune_retry_done = retune_retry_done; } }while (req_pending); + +mmc_queue_req_free (mq, mq_rq); }void mmc_blk_issue_rq (struct mmc_queue *mq,struct request *req)
@@ -1788,9 +1812,8 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)int ret;struct mmc_blk_data *md = mq->blkdata;struct mmc_card *card = md->queue.card; -bool req_is_special =mmc_req_is_special (req); -if (req && !mq->mqrq_prev->req) +if (req && !mq->qcnt)/* claim host only for the first request */ mmc_get_card (card);
@@ -1802,20 +1825,19 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) goto out; } - mq->new_request = false;if (req &&req_op (req) ==REQ_OP_DISCARD ) {/* complete ongoing async transfer before issuing discard */ -if (card->host->areq) +if (mq->qcnt)mmc_blk_issue_rw_rq (mq,NULL );mmc_blk_issue_discard_rq (mq, req); }else if (req &&req_op (req) ==REQ_OP_SECURE_ERASE ) {/* complete ongoing async transfer before issuing secure erase*/ -if (card->host->areq) +if (mq->qcnt)mmc_blk_issue_rw_rq (mq,NULL );mmc_blk_issue_secdiscard_rq (mq, req); }else if (req &&req_op (req) ==REQ_OP_FLUSH ) {/* complete ongoing async transfer before issuing flush */ -if (card->host->areq) +if (mq->qcnt)mmc_blk_issue_rw_rq (mq,NULL );mmc_blk_issue_flush (mq, req); }else {
@@ -1824,13 +1846,7 @@ void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) } out: -if ((!req && !mq->new_request) || req_is_special) -/* -* Release host when there are no more requests -* and after special request(discard, flush) is done. -* In case sepecial request, there is no reentry to -* the 'mmc_blk_issue_rq' with 'mqrq_prev->req'. -*/ +if (!mq->qcnt)mmc_put_card (card); }
drivers/mmc/core/queue.c +47 -28
116 lines not on this page · raw message
drivers/mmc/core/queue.h +7 -3
@@ -34,21 +34,21 @@ struct mmc_queue_req {struct scatterlist *bounce_sg;unsigned int bounce_sg_len;struct mmc_async_req areq; +int task_id; };struct mmc_queue {struct mmc_card *card;struct task_struct *thread;struct semaphore thread_sem; -bool new_request;bool suspended;bool asleep;struct mmc_blk_data *blkdata;struct request_queue *queue;struct mmc_queue_req *mqrq; -struct mmc_queue_req *mqrq_cur; -struct mmc_queue_req *mqrq_prev;int qdepth; +int qcnt; +unsigned long qslots; }; extern int mmc_init_queue(struct mmc_queue *, struct mmc_card *, spinlock_t *,
@@ -64,4 +64,8 @@ extern unsigned int mmc_queue_map_sg(struct mmc_queue *,extern int mmc_access_rpmb (struct mmc_queue *); +extern struct mmc_queue_req *mmc_queue_req_find (struct mmc_queue *, +struct request *); +extern void mmc_queue_req_free (struct mmc_queue *,struct mmc_queue_req *); +#endif
Signature · 1 line
1.9.1
Re: [PATCH V2 04/22] mmc: block: Introduce queue semantics
Quoted 8 lines · Adrian Hunter
Change from viewing the requests in progress as 'current' and 'previous', to viewing them as a queue. The current request is allocated to the first free slot. The presence of incomplete requests is determined from the count (
mq->qcnt) of entries in the queue. Non-read-write requests (i.e. discards and flushes) are not added to the queue at all and require no special handling. Also no special handling is needed for theMMC_BLK_NEW_REQUESTcase.
Quoted 4 lines
As well as allowing an arbitrarily sized queue, the queue thread function is significantly simpler.
Signed-off-by Adrian Hunter <[email protected]>
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v2 5/22 mmc: queue: Share mmc request array between partitions
In reply to Adrian HuntereMMC can have multiple internal partitions that are represented as separate disks / queues. However switching between partitions is only done when the queue is empty. Consequently the array of mmc requests that are queued can be shared between partitions saving memory.
Keep a pointer to the mmc request queue on the card, and use that instead of allocating a new one for each partition.
--- drivers/mmc/core/block.c | 11 ++- drivers/mmc/core/queue.c | 234 ++++++++++++++++++++++++++++------------------- drivers/mmc/core/queue.h | 2 + include/linux/mmc/card.h | 5 + 4 files changed, 156 insertions(+), 96 deletions(-)
drivers/mmc/core/block.c +10 -1
@@ -2126,6 +2126,7 @@ static int mmc_blk_probe(struct mmc_card *card) {struct mmc_blk_data *md, *part_md;char cap_str[10 ]; +int ret;/* * Check that the card supports the command class(es) we need.
@@ -2135,9 +2136,15 @@ static int mmc_blk_probe(struct mmc_card *card)mmc_fixup_device (card, mmc_blk_fixups); + ret =mmc_queue_alloc_shared_queue (card); +if (ret) +return ret; + md =mmc_blk_alloc (card); -if (IS_ERR (md)) +if (IS_ERR (md)) { +mmc_queue_free_shared_queue (card);return PTR_ERR (md); + }string_get_size ((u64 )get_capacity (md->disk),512 ,STRING_UNITS_2 , cap_str,sizeof (cap_str));
@@ -2175,6 +2182,7 @@ static int mmc_blk_probe(struct mmc_card *card) out:mmc_blk_remove_parts (card, md);mmc_blk_remove_req (md); +mmc_queue_free_shared_queue (card);return 0 ; }
@@ -2192,6 +2200,7 @@ static void mmc_blk_remove(struct mmc_card *card)pm_runtime_put_noidle (&card->dev);mmc_blk_remove_req (md);dev_set_drvdata (&card->dev,NULL ); +mmc_queue_free_shared_queue (card); }static int _mmc_blk_suspend (struct mmc_card *card)
drivers/mmc/core/queue.c +139 -95
323 lines not on this page · raw message
drivers/mmc/core/queue.h +2 -0
@@ -51,6 +51,8 @@ struct mmc_queue {unsigned long qslots; }; +extern int mmc_queue_alloc_shared_queue (struct mmc_card *card); +extern void mmc_queue_free_shared_queue (struct mmc_card *card);extern int mmc_init_queue (struct mmc_queue *,struct mmc_card *,spinlock_t *,const char *);extern void mmc_cleanup_queue (struct mmc_queue *);
include/linux/mmc/card.h +5 -0
@@ -208,6 +208,7 @@ struct sdio_cis {struct mmc_host ;struct sdio_func ;struct sdio_func_tuple ; +struct mmc_queue_req ;#define SDIO_MAX_FUNCS 7
@@ -300,6 +301,10 @@ struct mmc_card {struct dentry *debugfs_root;struct mmc_part part[MMC_NUM_PHY_PARTITION ];/* physical partitions */ unsigned int nr_parts; + +struct mmc_queue_req *mqrq;/* Shared queue structure */ +unsigned int bouncesz;/* Bounce buffer size */ +int qdepth;/* Shared queue depth */ };static inline bool mmc_large_sector (struct mmc_card *card)
Signature · 1 line
1.9.1
Re: [PATCH V2 05/22] mmc: queue: Share mmc request array between partitions
Quoted 9 lines · Adrian Hunter
eMMC can have multiple internal partitions that are represented as separate disks / queues. However switching between partitions is only done when the queue is empty. Consequently the array of mmc requests that are queued can be shared between partitions saving memory.
Keep a pointer to the mmc request queue on the card, and use that instead of allocating a new one for each partition.
Signed-off-by Adrian Hunter <[email protected]>
This is an especially nice patch, and even just merging this patch set to this point is already a significant improvement to the core code IMO.
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v2 6/22 mmc: mmc: Add functions to enable / disable the Command Queue
In reply to Adrian HunterAdd helper functions to enable or disable the Command Queue.
--- Documentation/mmc/mmc-dev-attrs.txt | 1 + drivers/mmc/core/mmc.c | 2 ++ drivers/mmc/core/mmc_ops.c | 28 ++++++++++++++++++++++++++++ drivers/mmc/core/mmc_ops.h | 2 ++ include/linux/mmc/card.h | 1 + 5 files changed, 34 insertions(+)
Documentation/mmc/mmc-dev-attrs.txt +1 -0
@@ -30,6 +30,7 @@ All attributes are read-only. rel_sectors Reliable write sector count ocr Operation Conditions Register dsr Driver Stage Register + cmdq_en Command Queue enabled: 1 => enabled, 0 => not enabled Note on Erase Size and Preferred Erase Size:
drivers/mmc/core/mmc.c +2 -0
@@ -790,6 +790,7 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width)MMC_DEV_ATTR (raw_rpmb_size_mult,"%#x\n" , card->ext_csd.raw_rpmb_size_mult);MMC_DEV_ATTR (rel_sectors,"%#x\n" , card->ext_csd.rel_sectors);MMC_DEV_ATTR (ocr,"%08x\n" , card->ocr); +MMC_DEV_ATTR (cmdq_en,"%d\n" , card->ext_csd.cmdq_en); static ssize_t mmc_fwrev_show(struct device *dev, struct device_attribute *attr,
@@ -845,6 +846,7 @@ static ssize_t mmc_dsr_show(struct device *dev, &dev_attr_rel_sectors.attr, &dev_attr_ocr.attr, &dev_attr_dsr.attr, + &dev_attr_cmdq_en.attr,NULL , };ATTRIBUTE_GROUPS (mmc_std);
drivers/mmc/core/mmc_ops.c +28 -0
@@ -838,3 +838,31 @@ int mmc_can_ext_csd(struct mmc_card *card) {return (card && card->csd.mmca_vsn >CSD_SPEC_VER_3 ); } + +static int mmc_cmdq_switch (struct mmc_card *card,bool enable) +{ +u8 val = enable ?EXT_CSD_CMDQ_MODE_ENABLED :0 ; +int err; + +if (!card->ext_csd.cmdq_support) +return -EOPNOTSUPP ; + + err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL ,EXT_CSD_CMDQ_MODE_EN , + val, card->ext_csd.generic_cmd6_time); +if (!err) + card->ext_csd.cmdq_en = enable; + +return err; +} + +int mmc_cmdq_enable (struct mmc_card *card) +{ +return mmc_cmdq_switch (card, true); +} +EXPORT_SYMBOL_GPL (mmc_cmdq_enable); + +int mmc_cmdq_disable (struct mmc_card *card) +{ +return mmc_cmdq_switch (card, false); +} +EXPORT_SYMBOL_GPL (mmc_cmdq_disable);
drivers/mmc/core/mmc_ops.h +2 -0
@@ -46,6 +46,8 @@ int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value,void mmc_start_bkops (struct mmc_card *card,bool from_exception);int mmc_can_reset (struct mmc_card *card);int mmc_flush_cache (struct mmc_card *card); +int mmc_cmdq_enable (struct mmc_card *card); +int mmc_cmdq_disable (struct mmc_card *card);#endif
include/linux/mmc/card.h +1 -0
@@ -89,6 +89,7 @@ struct mmc_ext_csd {unsigned int boot_ro_lock;/* ro lock support */ bool boot_ro_lockable;bool ffu_capable;/* Firmware upgrade support */ +bool cmdq_en;/* Command Queue enabled */ bool cmdq_support;/* Command Queue supported */ unsigned int cmdq_depth;/* Command Queue depth */ #define MMC_FIRMWARE_LEN 8
Signature · 1 line
1.9.1
Re: [PATCH V2 06/22] mmc: mmc: Add functions to enable / disable the Command Queue
Quoted 3 lines · Adrian Hunter
Add helper functions to enable or disable the Command Queue.
Signed-off-by Adrian Hunter <[email protected]>
Yours,
Linus Walleij
Re: [PATCH V2 06/22] mmc: mmc: Add functions to enable / disable the Command Queue
In reply to Adrian HunterQuoted 28 lines · Adrian Hunter
Add helper functions to enable or disable the Command Queue.
Signed-off-by Adrian Hunter <[email protected]>--- Documentation/mmc/mmc-dev-attrs.txt | 1 + drivers/mmc/core/mmc.c | 2 ++ drivers/mmc/core/mmc_ops.c | 28 ++++++++++++++++++++++++++++ drivers/mmc/core/mmc_ops.h | 2 ++ include/linux/mmc/card.h | 1 + 5 files changed, 34 insertions(+)Documentation/mmc/mmc-dev-attrs.txt +1
-0@@ -30,6 +30,7 @@ All attributes are read-only. rel_sectors Reliable write sector count ocr Operation Conditions Register dsr Driver Stage Register + cmdq_en Command Queue enabled: 1 => enabled, 0 => not enabled Note on Erase Size and Preferred Erase Size:drivers/mmc/core/mmc.c +0
-0
drivers/mmc/core/mmc.c static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) · line 793
Quoted 4 lines
drivers/mmc/core/mmc.c +1
-0@@ -790,6 +790,7 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width)MMC_DEV_ATTR (raw_rpmb_size_mult,"%#x\n" , card->ext_csd.raw_rpmb_size_mult);MMC_DEV_ATTR (rel_sectors,"%#x\n" , card->ext_csd.rel_sectors);MMC_DEV_ATTR (ocr,"%08x\n" , card->ocr); +MMC_DEV_ATTR (cmdq_en,"%d\n" , card->ext_csd.cmdq_en);
Why do we need to be able to change this from userspace?
[...]
Kind regards
Uffe
Adrian Hunter
maintainerRe: [PATCH V2 06/22] mmc: mmc: Add functions to enable / disable the Command Queue
Quoted 24 lines · Ulf Hansson
Quoted 23 lines · Adrian Hunter
Add helper functions to enable or disable the Command Queue.
Signed-off-by Adrian Hunter <[email protected]>--- Documentation/mmc/mmc-dev-attrs.txt | 1 + drivers/mmc/core/mmc.c | 2 ++ drivers/mmc/core/mmc_ops.c | 28 ++++++++++++++++++++++++++++ drivers/mmc/core/mmc_ops.h | 2 ++ include/linux/mmc/card.h | 1 + 5 files changed, 34 insertions(+)Documentation/mmc/mmc-dev-attrs.txt +1
-0@@ -30,6 +30,7 @@ All attributes are read-only. rel_sectors Reliable write sector count ocr Operation Conditions Register dsr Driver Stage Register + cmdq_en Command Queue enabled: 1 => enabled, 0 => not enabled Note on Erase Size and Preferred Erase Size:
Quoted 11 lines
drivers/mmc/core/mmc.c static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) · line 793
Quoted 9 lines
drivers/mmc/core/mmc.c +1
-0@@ -790,6 +790,7 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width)MMC_DEV_ATTR (raw_rpmb_size_mult,"%#x\n" , card->ext_csd.raw_rpmb_size_mult);MMC_DEV_ATTR (rel_sectors,"%#x\n" , card->ext_csd.rel_sectors);MMC_DEV_ATTR (ocr,"%08x\n" , card->ocr); +MMC_DEV_ATTR (cmdq_en,"%d\n" , card->ext_csd.cmdq_en);Why do we need to be able to change this from userspace?
MMC_DEV_ATTR makes it read-only, so it is just a way for userspace to see if command queue is enabled.
Re: [PATCH V2 06/22] mmc: mmc: Add functions to enable / disable the Command Queue
Quoted 37 lines · Adrian Hunter
Quoted 24 lines · Ulf Hansson
Quoted 23 lines · Adrian Hunter
Add helper functions to enable or disable the Command Queue.
Signed-off-by Adrian Hunter <[email protected]>--- Documentation/mmc/mmc-dev-attrs.txt | 1 + drivers/mmc/core/mmc.c | 2 ++ drivers/mmc/core/mmc_ops.c | 28 ++++++++++++++++++++++++++++ drivers/mmc/core/mmc_ops.h | 2 ++ include/linux/mmc/card.h | 1 + 5 files changed, 34 insertions(+)Documentation/mmc/mmc-dev-attrs.txt +1
-0@@ -30,6 +30,7 @@ All attributes are read-only. rel_sectors Reliable write sector count ocr Operation Conditions Register dsr Driver Stage Register + cmdq_en Command Queue enabled: 1 => enabled, 0 => not enabled Note on Erase Size and Preferred Erase Size:Quoted 11 lines
drivers/mmc/core/mmc.c static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width) · line 793
Quoted 9 lines
drivers/mmc/core/mmc.c +1
-0@@ -790,6 +790,7 @@ static int mmc_compare_ext_csds(struct mmc_card *card, unsigned bus_width)MMC_DEV_ATTR (raw_rpmb_size_mult,"%#x\n" , card->ext_csd.raw_rpmb_size_mult);MMC_DEV_ATTR (rel_sectors,"%#x\n" , card->ext_csd.rel_sectors);MMC_DEV_ATTR (ocr,"%08x\n" , card->ocr); +MMC_DEV_ATTR (cmdq_en,"%d\n" , card->ext_csd.cmdq_en);Why do we need to be able to change this from userspace?
Quoted 2 lines
MMC_DEV_ATTRmakes it read-only, so it is just a way for userspace to see if command queue is enabled.
Of course! Thanks for the clarification - and yes, that makes sense!
Kind regards
Uffe
Adrian Hunter
maintainerPATCH v2 7/22 mmc: mmc_test: Disable Command Queue while mmc_test is used
In reply to Adrian HunterNormal read and write commands may not be used while the command queue is enabled. Disable the Command Queue when mmc_test is probed and re-enable it when it is removed.
--- drivers/mmc/core/mmc.c | 7 +++++++ drivers/mmc/core/mmc_test.c | 14 ++++++++++++++ include/linux/mmc/card.h | 2 ++ 3 files changed, 23 insertions(+)
drivers/mmc/core/mmc.c +7 -0
@@ -1790,6 +1790,13 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, }/* +* In some cases (e.g. RPMB or mmc_test), the Command Queue must be +* disabled for a time, so a flag is needed to indicate to re-enable the +* Command Queue. +*/ + card->reenable_cmdq = card->ext_csd.cmdq_en; + +/* * The mandatory minimum values are defined for packed command. * read: 5, write: 3 */
drivers/mmc/core/mmc_test.c +14 -0
@@ -26,6 +26,7 @@#include "card.h" #include "host.h" #include "bus.h" +#include "mmc_ops.h" #define RESULT_OK 0#define RESULT_FAIL 1
@@ -3264,6 +3265,14 @@ static int mmc_test_probe(struct mmc_card *card)if (ret)return ret; +if (card->ext_csd.cmdq_en) { +mmc_claim_host (card->host); + ret =mmc_cmdq_disable (card); +mmc_release_host (card->host); +if (ret) +return ret; + } +dev_info (&card->dev,"Card claimed for testing.\n" );return 0 ;
@@ -3271,6 +3280,11 @@ static int mmc_test_probe(struct mmc_card *card)static void mmc_test_remove (struct mmc_card *card) { +if (card->reenable_cmdq) { +mmc_claim_host (card->host); +mmc_cmdq_enable (card); +mmc_release_host (card->host); + }mmc_test_free_result (card);mmc_test_free_dbgfs_file (card); }
include/linux/mmc/card.h +2 -0
@@ -269,6 +269,8 @@ struct mmc_card {#define MMC_QUIRK_TRIM_BROKEN (1<<12)/* Skip trim */ #define MMC_QUIRK_BROKEN_HPI (1<<13)/* Disable broken HPI support */ +bool reenable_cmdq;/* Re-enable Command Queue */ +unsigned int erase_size;/* erase size in sectors */ unsigned int erase_shift;/* if erase unit is power 2 */ unsigned int pref_erase;/* in sectors */
Signature · 1 line
1.9.1
Re: [PATCH V2 07/22] mmc: mmc_test: Disable Command Queue while mmc_test is used
Quoted 6 lines · Adrian Hunter
Normal read and write commands may not be used while the command queue is enabled. Disable the Command Queue when
mmc_testis probed and re-enable it when it is removed.Signed-off-by Adrian Hunter <[email protected]>Reviewed-by Harjani Ritesh <[email protected]>
Thugh if I get it right, there is no test for the command queue functionality then, really. The tests just test common stuff. So we would maybe want to add tests for CMDQ.
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v2 8/22 mmc: block: Disable Command Queue while RPMB is used
In reply to Adrian HunterRPMB does not allow Command Queue commands. Disable and re-enable the Command Queue when switching.
Note that the driver only switches partitions when the queue is empty.
--- drivers/mmc/core/block.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-)
drivers/mmc/core/block.c +38 -8
@@ -728,10 +728,41 @@ static int mmc_blk_compat_ioctl(struct block_device *bdev, fmode_t mode,#endif }; +static int mmc_blk_part_switch_pre (struct mmc_card *card, +unsigned int part_type) +{ +int ret =0 ; + +if (part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) { +if (card->ext_csd.cmdq_en) { + ret =mmc_cmdq_disable (card); +if (ret) +return ret; + } +mmc_retune_pause (card->host); + } + +return ret; +} + +static int mmc_blk_part_switch_post (struct mmc_card *card, +unsigned int part_type) +{ +int ret =0 ; + +if (part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) { +mmc_retune_unpause (card->host); +if (card->reenable_cmdq && !card->ext_csd.cmdq_en) + ret =mmc_cmdq_enable (card); + } + +return ret; +} +static inline int mmc_blk_part_switch (struct mmc_card *card,struct mmc_blk_data *md) { -int ret; +int ret =0 ;struct mmc_blk_data *main_md =dev_get_drvdata (&card->dev);if (main_md->part_curr == md->part_type)
@@ -740,8 +771,9 @@ static inline int mmc_blk_part_switch(struct mmc_card *card,if (mmc_card_mmc (card)) {u8 part_config = card->ext_csd.part_config; -if (md->part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) -mmc_retune_pause (card->host); + ret =mmc_blk_part_switch_pre (card, md->part_type); +if (ret) +return ret; part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK ; part_config |= md->part_type;
@@ -750,19 +782,17 @@ static inline int mmc_blk_part_switch(struct mmc_card *card,EXT_CSD_PART_CONFIG , part_config, card->ext_csd.part_time);if (ret) { -if (md->part_type ==EXT_CSD_PART_CONFIG_ACC_RPMB ) -mmc_retune_unpause (card->host); +mmc_blk_part_switch_post (card, md->part_type);return ret; } card->ext_csd.part_config = part_config; -if (main_md->part_curr ==EXT_CSD_PART_CONFIG_ACC_RPMB ) -mmc_retune_unpause (card->host); + ret =mmc_blk_part_switch_post (card, main_md->part_curr); } main_md->part_curr = md->part_type; -return 0 ; +return ret; }static int mmc_sd_num_wr_blocks (struct mmc_card *card,u32 *written_blocks)
Signature · 1 line
1.9.1
Re: [PATCH V2 08/22] mmc: block: Disable Command Queue while RPMB is used
Quoted 7 lines · Adrian Hunter
RPMB does not allow Command Queue commands. Disable and re-enable the Command Queue when switching.
Note that the driver only switches partitions when the queue is empty.
Signed-off-by Adrian Hunter <[email protected]>Reviewed-by Harjani Ritesh <[email protected]>
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v2 9/22 mmc: block: Change mmc_apply_rel_rw() to get block address from the request
In reply to Adrian Huntermmc_apply_rel_rw() will be used by Software Command Queuing also. In that case the command argument is not the block address so change mmc_apply_rel_rw() to get block address from the request.
--- drivers/mmc/core/block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/core/block.c +1 -1
@@ -1309,7 +1309,7 @@ static inline void mmc_apply_rel_rw(struct mmc_blk_request *brq, {if (!(card->ext_csd.rel_param &EXT_CSD_WR_REL_PARAM_EN )) {/* Legacy mode imposes restrictions on transfers. */ -if (!IS_ALIGNED (brq->cmd.arg, card->ext_csd.rel_sectors)) +if (!IS_ALIGNED (blk_rq_pos (req), card->ext_csd.rel_sectors)) brq->data.blocks =1 ;if (brq->data.blocks > card->ext_csd.rel_sectors)
Signature · 1 line
1.9.1
Re: [PATCH V2 09/22] mmc: block: Change mmc_apply_rel_rw() to get block address from the request
Quoted 5 lines · Adrian Hunter
mmc_apply_rel_rw()will be used by Software Command Queuing also. In that case the command argument is not the block address so changemmc_apply_rel_rw()to get block address from the request.Signed-off-by Adrian Hunter <[email protected]>
Plus it is a good readability change on its own merits.
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v2 10/22 mmc: block: Factor out data preparation
In reply to Adrian HunterFactor out data preparation into a separate function mmc_blk_data_prep() which can be re-used for command queuing.
--- drivers/mmc/core/block.c | 151 +++++++++++++++++++++++++---------------------- 1 file changed, 82 insertions(+), 69 deletions(-)
drivers/mmc/core/block.c +82 -69
@@ -1433,36 +1433,39 @@ static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card,return MMC_BLK_SUCCESS ; } -static void mmc_blk_rw_rq_prep (struct mmc_queue_req *mqrq, -struct mmc_card *card, -int disable_multi, -struct mmc_queue *mq) +static void mmc_blk_data_prep (struct mmc_queue *mq,struct mmc_queue_req *mqrq, +int disable_multi,bool *do_rel_wr, +bool *do_data_tag) { -u32 readcmd, writecmd; +struct mmc_blk_data *md = mq->blkdata; +struct mmc_card *card = md->queue.card;struct mmc_blk_request *brq = &mqrq->brq;struct request *req = mqrq->req; -struct mmc_blk_data *md = mq->blkdata; -bool do_data_tag;/* * Reliable writes are used to implement Forced Unit Access and * are supported only on MMCs. */ -bool do_rel_wr = (req->cmd_flags &REQ_FUA ) && - (rq_data_dir (req) ==WRITE ) && - (md->flags &MMC_BLK_REL_WR ); + *do_rel_wr = (req->cmd_flags &REQ_FUA ) && +rq_data_dir (req) ==WRITE && + (md->flags &MMC_BLK_REL_WR );memset (brq,0 ,sizeof (struct mmc_blk_request )); - brq->mrq.cmd = &brq->cmd; + brq->mrq.data = &brq->data; - brq->cmd.arg =blk_rq_pos (req); -if (!mmc_card_blockaddr (card)) - brq->cmd.arg <<=9 ; - brq->cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ; - brq->data.blksz =512 ; brq->stop.opcode =MMC_STOP_TRANSMISSION ; brq->stop.arg =0 ; + +if (rq_data_dir (req) ==READ ) { + brq->data.flags =MMC_DATA_READ ; + brq->stop.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_AC ; + }else { + brq->data.flags =MMC_DATA_WRITE ; + brq->stop.flags =MMC_RSP_SPI_R1B |MMC_RSP_R1B |MMC_CMD_AC ; + } + + brq->data.blksz =512 ; brq->data.blocks =blk_rq_sectors (req);/*
@@ -1493,6 +1496,68 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, brq->data.blocks); } +if (*do_rel_wr) +mmc_apply_rel_rw (brq, card, req); + +/* +* Data tag is used only during writing meta data to speed +* up write and any subsequent read of this meta data +*/ + *do_data_tag = card->ext_csd.data_tag_unit_size && + (req->cmd_flags &REQ_META ) && + (rq_data_dir (req) ==WRITE ) && + ((brq->data.blocks * brq->data.blksz) >= + card->ext_csd.data_tag_unit_size); + +mmc_set_data_timeout (&brq->data, card); + + brq->data.sg = mqrq->sg; + brq->data.sg_len =mmc_queue_map_sg (mq, mqrq); + +/* +* Adjust the sg list so it is the same size as the +* request. +*/ +if (brq->data.blocks !=blk_rq_sectors (req)) { +int i, data_size = brq->data.blocks <<9 ; +struct scatterlist *sg; + +for_each_sg (brq->data.sg, sg, brq->data.sg_len, i) { + data_size -= sg->length; +if (data_size <=0 ) { + sg->length += data_size; + i++; +break ; + } + } + brq->data.sg_len = i; + } + + mqrq->areq.mrq = &brq->mrq; + +mmc_queue_bounce_pre (mqrq); +} + +static void mmc_blk_rw_rq_prep (struct mmc_queue_req *mqrq, +struct mmc_card *card, +int disable_multi, +struct mmc_queue *mq) +{ +u32 readcmd, writecmd; +struct mmc_blk_request *brq = &mqrq->brq; +struct request *req = mqrq->req; +struct mmc_blk_data *md = mq->blkdata; +bool do_rel_wr, do_data_tag; + +mmc_blk_data_prep (mq, mqrq, disable_multi, &do_rel_wr, &do_data_tag); + + brq->mrq.cmd = &brq->cmd; + + brq->cmd.arg =blk_rq_pos (req); +if (!mmc_card_blockaddr (card)) + brq->cmd.arg <<=9 ; + brq->cmd.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 |MMC_CMD_ADTC ; +if (brq->data.blocks >1 || do_rel_wr) {/* SPI multiblock writes terminate using a special * token, not a STOP_TRANSMISSION request.
@@ -1507,32 +1572,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, readcmd =MMC_READ_SINGLE_BLOCK ; writecmd =MMC_WRITE_BLOCK ; } -if (rq_data_dir (req) ==READ ) { - brq->cmd.opcode = readcmd; - brq->data.flags =MMC_DATA_READ ; -if (brq->mrq.stop) - brq->stop.flags =MMC_RSP_SPI_R1 |MMC_RSP_R1 | -MMC_CMD_AC ; - }else { - brq->cmd.opcode = writecmd; - brq->data.flags =MMC_DATA_WRITE ; -if (brq->mrq.stop) - brq->stop.flags =MMC_RSP_SPI_R1B |MMC_RSP_R1B | -MMC_CMD_AC ; - } - -if (do_rel_wr) -mmc_apply_rel_rw (brq, card, req); - -/* -* Data tag is used only during writing meta data to speed -* up write and any subsequent read of this meta data -*/ - do_data_tag = (card->ext_csd.data_tag_unit_size) && - (req->cmd_flags &REQ_META ) && - (rq_data_dir (req) ==WRITE ) && - ((brq->data.blocks * brq->data.blksz) >= - card->ext_csd.data_tag_unit_size); + brq->cmd.opcode =rq_data_dir (req) ==READ ? readcmd : writecmd;/* * Pre-defined multi-block transfers are preferable to
@@ -1563,34 +1603,7 @@ static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, brq->mrq.sbc = &brq->sbc; } -mmc_set_data_timeout (&brq->data, card); - - brq->data.sg = mqrq->sg; - brq->data.sg_len =mmc_queue_map_sg (mq, mqrq); - -/* -* Adjust the sg list so it is the same size as the -* request. -*/ -if (brq->data.blocks !=blk_rq_sectors (req)) { -int i, data_size = brq->data.blocks <<9 ; -struct scatterlist *sg; - -for_each_sg (brq->data.sg, sg, brq->data.sg_len, i) { - data_size -= sg->length; -if (data_size <=0 ) { - sg->length += data_size; - i++; -break ; - } - } - brq->data.sg_len = i; - } - - mqrq->areq.mrq = &brq->mrq; mqrq->areq.err_check = mmc_blk_err_check; - -mmc_queue_bounce_pre (mqrq); } static bool mmc_blk_rw_cmd_err(struct mmc_blk_data *md, struct mmc_card *card,
Signature · 1 line
1.9.1
Re: [PATCH V2 10/22] mmc: block: Factor out data preparation
Quoted 4 lines · Adrian Hunter
Factor out data preparation into a separate function
mmc_blk_data_prep()which can be re-used for command queuing.Signed-off-by Adrian Hunter <[email protected]>
This change also stands nicely on its own for readability.
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v2 11/22 mmc: core: Factor out debug prints from mmc_start_request()
In reply to Adrian HunterIn preparation to reuse the code for CQE support.
--- drivers/mmc/core/core.c | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
drivers/mmc/core/core.c +20 -13
@@ -262,26 +262,19 @@ static void __mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) host->ops->request (host, mrq); } -static int mmc_start_request (struct mmc_host *host,struct mmc_request *mrq) +static void mmc_mrq_pr_debug (struct mmc_host *host,struct mmc_request *mrq) { -#ifdef CONFIG_MMC_DEBUG -unsigned int i, sz; -struct scatterlist *sg; -#endif -mmc_retune_hold (host); - -if (mmc_card_removed (host->card)) -return -ENOMEDIUM ; -if (mrq->sbc) {pr_debug ("<%s: starting CMD%u arg %08x flags %08x>\n" ,mmc_hostname (host), mrq->sbc->opcode, mrq->sbc->arg, mrq->sbc->flags); } -pr_debug ("%s: starting CMD%u arg %08x flags %08x\n" , -mmc_hostname (host), mrq->cmd->opcode, - mrq->cmd->arg, mrq->cmd->flags); +if (mrq->cmd) { +pr_debug ("%s: starting CMD%u arg %08x flags %08x\n" , +mmc_hostname (host), mrq->cmd->opcode, mrq->cmd->arg, + mrq->cmd->flags); + }if (mrq->data) { pr_debug("%s: blksz %d blocks %d flags %08x "
@@ -297,6 +290,20 @@ static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)mmc_hostname (host), mrq->stop->opcode, mrq->stop->arg, mrq->stop->flags); } +} + +static int mmc_start_request (struct mmc_host *host,struct mmc_request *mrq) +{ +#ifdef CONFIG_MMC_DEBUG +unsigned int i, sz; +struct scatterlist *sg; +#endif +mmc_retune_hold (host); + +if (mmc_card_removed (host->card)) +return -ENOMEDIUM ; + +mmc_mrq_pr_debug (host, mrq);WARN_ON (!host->claimed);
Signature · 1 line
1.9.1
Re: [PATCH V2 11/22] mmc: core: Factor out debug prints from mmc_start_request()
Quoted 3 lines · Adrian Hunter
In preparation to reuse the code for CQE support.
Signed-off-by Adrian Hunter <[email protected]>
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v2 12/22 mmc: core: Factor out mrq preparation from mmc_start_request()
In reply to Adrian HunterIn preparation to reuse the code for CQE support.
--- drivers/mmc/core/core.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-)
drivers/mmc/core/core.c +27 -13
@@ -292,23 +292,18 @@ static void mmc_mrq_pr_debug(struct mmc_host *host, struct mmc_request *mrq) } } -static int mmc_start_request (struct mmc_host *host,struct mmc_request *mrq) +static int mmc_mrq_prep (struct mmc_host *host,struct mmc_request *mrq) {#ifdef CONFIG_MMC_DEBUG unsigned int i, sz;struct scatterlist *sg;#endif -mmc_retune_hold (host); - -if (mmc_card_removed (host->card)) -return -ENOMEDIUM ; - -mmc_mrq_pr_debug (host, mrq); - -WARN_ON (!host->claimed); - mrq->cmd->error =0 ; - mrq->cmd->mrq = mrq; +if (mrq->cmd) { + mrq->cmd->error =0 ; + mrq->cmd->mrq = mrq; + mrq->cmd->data = mrq->data; + }if (mrq->sbc) { mrq->sbc->error =0 ; mrq->sbc->mrq = mrq;
@@ -325,8 +320,6 @@ static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)if (sz != mrq->data->blocks * mrq->data->blksz)return -EINVAL ;#endif - - mrq->cmd->data = mrq->data; mrq->data->error =0 ; mrq->data->mrq = mrq;if (mrq->stop) {
@@ -335,6 +328,27 @@ static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) mrq->stop->mrq = mrq; } } + +return 0 ; +} + +static int mmc_start_request (struct mmc_host *host,struct mmc_request *mrq) +{ +int err; + +mmc_retune_hold (host); + +if (mmc_card_removed (host->card)) +return -ENOMEDIUM ; + +mmc_mrq_pr_debug (host, mrq); + +WARN_ON (!host->claimed); + + err =mmc_mrq_prep (host, mrq); +if (err) +return err; +led_trigger_event (host->led,LED_FULL );__mmc_start_request (host, mrq);
Signature · 1 line
1.9.1
Re: [PATCH V2 12/22] mmc: core: Factor out mrq preparation from mmc_start_request()
Quoted 3 lines · Adrian Hunter
In preparation to reuse the code for CQE support.
Signed-off-by Adrian Hunter <[email protected]>
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v2 13/22 mmc: core: Add mmc_retune_hold_now()
In reply to Adrian HunterIn preparation for CQE support.
--- drivers/mmc/core/host.c | 6 ++++++ drivers/mmc/core/host.h | 1 + 2 files changed, 7 insertions(+)
drivers/mmc/core/host.c +6 -0
@@ -110,6 +110,12 @@ void mmc_retune_hold(struct mmc_host *host) host->hold_retune +=1 ; } +void mmc_retune_hold_now (struct mmc_host *host) +{ + host->retune_now =0 ; + host->hold_retune +=1 ; +} +void mmc_retune_release (struct mmc_host *host) {if (host->hold_retune)
drivers/mmc/core/host.h +1 -0
@@ -19,6 +19,7 @@void mmc_retune_enable (struct mmc_host *host);void mmc_retune_disable (struct mmc_host *host);void mmc_retune_hold (struct mmc_host *host); +void mmc_retune_hold_now (struct mmc_host *host);void mmc_retune_release (struct mmc_host *host);int mmc_retune (struct mmc_host *host);void mmc_retune_pause (struct mmc_host *host);
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v2 14/22 mmc: core: Add members to mmc_request and mmc_data for CQE's
In reply to Adrian HunterMost of the information needed to issue requests to a CQE is already in struct mmc_request and struct mmc_data. Add data block address, some flags, and the task id (tag).
--- include/linux/mmc/core.h | 13 +++++++++++-- include/trace/events/mmc.h | 17 ++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-)
include/linux/mmc/core.h +11 -2
@@ -122,11 +122,18 @@ struct mmc_data {unsigned int timeout_clks;/* data timeout (in clocks) */ unsigned int blksz;/* data block size */ unsigned int blocks;/* number of blocks */ +unsigned int blk_addr;/* block address */ int error;/* data error */ unsigned int flags; -#define MMC_DATA_WRITE (1 << 8) -#define MMC_DATA_READ (1 << 9) +#define MMC_DATA_WRITE BIT(8) +#define MMC_DATA_READ BIT(9) +/* Extra flags used by CQE */ +#define MMC_DATA_QBR BIT(10)/* CQE queue barrier*/ +#define MMC_DATA_PRIO BIT(11)/* CQE high priority */ +#define MMC_DATA_REL_WR BIT(12)/* Reliable write */ +#define MMC_DATA_DAT_TAG BIT(13)/* Tag request */ +#define MMC_DATA_FORCED_PRG BIT(14)/* Forced programming */ unsigned int bytes_xfered;
@@ -153,6 +160,8 @@ struct mmc_request {/* Allow other commands during this ongoing data transfer or busy wait */ bool cap_cmd_during_tfr; + +int tag; };struct mmc_card ;
include/trace/events/mmc.h +12 -5
@@ -29,8 +29,10 @@ __field(unsigned int, sbc_flags) __field(unsigned int, sbc_retries) __field(unsigned int, blocks) + __field(unsigned int, blk_addr) __field(unsigned int, blksz) __field(unsigned int, data_flags) + __field(int, tag) __field(unsigned int, can_retune) __field(unsigned int, doing_retune) __field(unsigned int, retune_now)
@@ -56,7 +58,9 @@ __entry->sbc_retries = mrq->sbc ? mrq->sbc->retries :0 ; __entry->blksz = mrq->data ? mrq->data->blksz :0 ; __entry->blocks = mrq->data ? mrq->data->blocks :0 ; + __entry->blk_addr = mrq->data ? mrq->data->blk_addr :0 ; __entry->data_flags = mrq->data ? mrq->data->flags :0 ; + __entry->tag = mrq->tag; __entry->can_retune = host->can_retune; __entry->doing_retune = host->doing_retune; __entry->retune_now = host->retune_now;
@@ -71,8 +75,8 @@"cmd_opcode=%u cmd_arg=0x%x cmd_flags=0x%x cmd_retries=%u " "stop_opcode=%u stop_arg=0x%x stop_flags=0x%x stop_retries=%u " "sbc_opcode=%u sbc_arg=0x%x sbc_flags=0x%x sbc_retires=%u " -"blocks=%u block_size=%u data_flags=0x%x " -"can_retune=%u doing_retune=%u retune_now=%u " +"blocks=%u block_size=%u blk_addr=%u data_flags=0x%x " +"tag=%d can_retune=%u doing_retune=%u retune_now=%u " "need_retune=%d hold_retune=%d retune_period=%u" ,__get_str (name), __entry->mrq, __entry->cmd_opcode, __entry->cmd_arg,
@@ -81,7 +85,8 @@ __entry->stop_flags, __entry->stop_retries, __entry->sbc_opcode, __entry->sbc_arg, __entry->sbc_flags, __entry->sbc_retries, - __entry->blocks, __entry->blksz, __entry->data_flags, + __entry->blocks, __entry->blk_addr, + __entry->blksz, __entry->data_flags, __entry->tag, __entry->can_retune, __entry->doing_retune, __entry->retune_now, __entry->need_retune, __entry->hold_retune, __entry->retune_period)
@@ -108,6 +113,7 @@ __field(unsigned int, sbc_retries) __field(unsigned int, bytes_xfered) __field(int, data_err) + __field(int, tag) __field(unsigned int, can_retune) __field(unsigned int, doing_retune) __field(unsigned int, retune_now)
@@ -139,6 +145,7 @@ __entry->sbc_retries = mrq->sbc ? mrq->sbc->retries :0 ; __entry->bytes_xfered = mrq->data ? mrq->data->bytes_xfered :0 ; __entry->data_err = mrq->data ? mrq->data->error :0 ; + __entry->tag = mrq->tag; __entry->can_retune = host->can_retune; __entry->doing_retune = host->doing_retune; __entry->retune_now = host->retune_now;
@@ -154,7 +161,7 @@"cmd_retries=%u stop_opcode=%u stop_err=%d " "stop_resp=0x%x 0x%x 0x%x 0x%x stop_retries=%u " "sbc_opcode=%u sbc_err=%d sbc_resp=0x%x 0x%x 0x%x 0x%x " -"sbc_retries=%u bytes_xfered=%u data_err=%d " +"sbc_retries=%u bytes_xfered=%u data_err=%d tag=%d " "can_retune=%u doing_retune=%u retune_now=%u need_retune=%d " "hold_retune=%d retune_period=%u" , __get_str(name), __entry->mrq,
@@ -170,7 +177,7 @@ __entry->sbc_resp[0 ], __entry->sbc_resp[1 ], __entry->sbc_resp[2 ], __entry->sbc_resp[3 ], __entry->sbc_retries, - __entry->bytes_xfered, __entry->data_err, + __entry->bytes_xfered, __entry->data_err, __entry->tag, __entry->can_retune, __entry->doing_retune, __entry->retune_now, __entry->need_retune, __entry->hold_retune, __entry->retune_period)
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v2 15/22 mmc: host: Add CQE interface
In reply to Adrian HunterAdd CQE host operations, capabilities, and host members.
--- include/linux/mmc/host.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
include/linux/mmc/host.h +24 -0
@@ -160,6 +160,19 @@ struct mmc_host_ops { unsigned int direction, int blk_size); }; +struct mmc_cqe_ops { +int (*cqe_enable)(struct mmc_host *host,struct mmc_card *card); +void (*cqe_disable)(struct mmc_host *host); +int (*cqe_request)(struct mmc_host *host,struct mmc_request *mrq); +void (*cqe_post_req)(struct mmc_host *host,struct mmc_request *mrq); +void (*cqe_off)(struct mmc_host *host); +int (*cqe_wait_for_idle)(struct mmc_host *host); +bool (*cqe_timeout)(struct mmc_host *host,struct mmc_request *mrq, +bool *recovery_needed); +void (*cqe_recovery_start)(struct mmc_host *host); +void (*cqe_recovery_finish)(struct mmc_host *host,bool forget_reqs); +}; +struct mmc_async_req {/* active mmc request */ struct mmc_request *mrq;
@@ -303,6 +316,8 @@ struct mmc_host {#define MMC_CAP2_HS400_ES (1 << 20)/* Host supports enhanced strobe */ #define MMC_CAP2_NO_SD (1 << 21)/* Do not send SD commands during initialization */ #define MMC_CAP2_NO_MMC (1 << 22)/* Do not send (e)MMC commands during initialization */ +#define MMC_CAP2_CQE (1 << 23)/* Has eMMC command queue engine */ +#define MMC_CAP2_CQE_DCMD (1 << 24)/* CQE can issue a direct command */ mmc_pm_flag_t pm_caps;/* supported pm features */
@@ -388,6 +403,15 @@ struct mmc_host {int dsr_req;/* DSR value is valid */ u32 dsr;/* optional driver stage (DSR) value */ +/* Command Queue Engine (CQE) support */ +const struct mmc_cqe_ops *cqe_ops; +void *cqe_private; +void (*cqe_recovery_notifier)(struct mmc_host *, +struct mmc_request *); +int cqe_qdepth; +bool cqe_enabled; +bool cqe_on; +unsigned long private[0 ]____cacheline_aligned ; };
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v2 16/22 mmc: core: Turn off CQE before sending commands
In reply to Adrian HunterTurn off the CQE before sending commands, and ensure it is off in any reset or power management paths, or re-tuning.
--- drivers/mmc/core/core.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/mmc/core/core.c +9 -0
@@ -259,6 +259,9 @@ static void __mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)trace_mmc_request_start (host, mrq); +if (host->cqe_on) + host->cqe_ops->cqe_off (host); + host->ops->request (host, mrq); }
@@ -1184,6 +1187,9 @@ int mmc_execute_tuning(struct mmc_card *card)if (!host->ops->execute_tuning)return 0 ; +if (host->cqe_on) + host->cqe_ops->cqe_off (host); +if (mmc_card_mmc (card)) opcode =MMC_SEND_TUNING_BLOCK_HS200 ;else
@@ -1223,6 +1229,9 @@ void mmc_set_bus_width(struct mmc_host *host, unsigned int width)*/ void mmc_set_initial_state (struct mmc_host *host) { +if (host->cqe_on) + host->cqe_ops->cqe_off (host); +mmc_retune_disable (host);if (mmc_host_is_spi (host))
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v2 17/22 mmc: core: Add support for handling CQE requests
In reply to Adrian HunterAdd core support for handling CQE requests, including starting, completing and recovering.
--- drivers/mmc/core/core.c | 147 +++++++++++++++++++++++++++++++++++++++++++++-- include/linux/mmc/core.h | 6 ++ 2 files changed, 148 insertions(+), 5 deletions(-)
drivers/mmc/core/core.c +142 -5
@@ -265,7 +265,8 @@ static void __mmc_start_request(struct mmc_host *host, struct mmc_request *mrq) host->ops->request (host, mrq); } -static void mmc_mrq_pr_debug (struct mmc_host *host,struct mmc_request *mrq) +static void mmc_mrq_pr_debug (struct mmc_host *host,struct mmc_request *mrq, +bool cqe) {if (mrq->sbc) { pr_debug("<%s: starting CMD%u arg %08x flags %08x>\n",
@@ -274,9 +275,12 @@ static void mmc_mrq_pr_debug(struct mmc_host *host, struct mmc_request *mrq) }if (mrq->cmd) { -pr_debug ("%s: starting CMD%u arg %08x flags %08x\n" , -mmc_hostname (host), mrq->cmd->opcode, mrq->cmd->arg, - mrq->cmd->flags); +pr_debug ("%s: starting %sCMD%u arg %08x flags %08x\n" , +mmc_hostname (host), cqe ?"CQE direct " :"" , + mrq->cmd->opcode, mrq->cmd->arg, mrq->cmd->flags); + }else if (cqe) { +pr_debug ("%s: starting CQE transfer for tag %d blkaddr %u\n" , +mmc_hostname (host), mrq->tag, mrq->data->blk_addr); }if (mrq->data) {
@@ -344,7 +348,7 @@ static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)if (mmc_card_removed (host->card))return -ENOMEDIUM ; -mmc_mrq_pr_debug (host, mrq); +mmc_mrq_pr_debug (host, mrq, false);WARN_ON (!host->claimed);
@@ -358,6 +362,139 @@ static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)return 0 ; } +int mmc_cqe_start_req (struct mmc_host *host,struct mmc_request *mrq) +{ +int err; + +/* Caller must hold retuning while CQE is in use */ + err =mmc_retune (host); +if (err) + goto out_err; + + mrq->host = host; + +mmc_mrq_pr_debug (host, mrq, true); + + err =mmc_mrq_prep (host, mrq); +if (err) + goto out_err; + + err = host->cqe_ops->cqe_request (host, mrq); +if (err) + goto out_err; + +trace_mmc_request_start (host, mrq); + +return 0 ; + +out_err: +if (mrq->cmd) { +pr_debug ("%s: failed to start CQE direct CMD%u, error %d\n" , +mmc_hostname (host), mrq->cmd->opcode, err); + }else { +pr_debug ("%s: failed to start CQE transfer for tag %d, error %d\n" , +mmc_hostname (host), mrq->tag, err); + } +return err; +} +EXPORT_SYMBOL (mmc_cqe_start_req); + +void __mmc_cqe_request_done (struct mmc_host *host,struct mmc_request *mrq) +{ +mmc_should_fail_request (host, mrq); + +/* Flag re-tuning needed on CRC errors */ +if ((mrq->cmd && mrq->cmd->error == -EILSEQ ) || + (mrq->data && mrq->data->error == -EILSEQ )) +mmc_retune_needed (host); + +trace_mmc_request_done (host, mrq); + +if (mrq->cmd) { +pr_debug ("%s: CQE req done (direct CMD%u): %d\n" , +mmc_hostname (host), mrq->cmd->opcode, mrq->cmd->error); + }else { +pr_debug ("%s: CQE transfer done tag %d\n" , +mmc_hostname (host), mrq->tag); + } + +if (mrq->data) { +pr_debug ("%s: %d bytes transferred: %d\n" , +mmc_hostname (host), + mrq->data->bytes_xfered, mrq->data->error); + } +} +EXPORT_SYMBOL (__mmc_cqe_request_done); + +/** +* mmc_cqe_request_done - CQE has finished processing an MMC request +* @host: MMC host which completed request +* @mrq: MMC request which completed +* +* CQE drivers should call this function when they have completed +* their processing of a request. +*/ +void mmc_cqe_request_done (struct mmc_host *host,struct mmc_request *mrq) +{ +__mmc_cqe_request_done (host, mrq); + + mrq->done (mrq); +} +EXPORT_SYMBOL (mmc_cqe_request_done); + +/** +* mmc_cqe_post_req - CQE post process of a completed MMC request +* @host: MMC host +* @mrq: MMC request to be processed +*/ +void mmc_cqe_post_req (struct mmc_host *host,struct mmc_request *mrq) +{ +if (host->cqe_ops->cqe_post_req) + host->cqe_ops->cqe_post_req (host, mrq); +} +EXPORT_SYMBOL (mmc_cqe_post_req); + +/* Arbitrary 1 second timeout */ +#define MMC_CQE_RECOVERY_TIMEOUT 1000 + +int mmc_cqe_recovery (struct mmc_host *host,bool forget_reqs) +{ +struct mmc_command cmd; +int err; + +mmc_retune_hold_now (host); + +/* +* Recovery is expected seldom, if at all, but it reduces performance, +* so make sure it is not completely silent. +*/ +pr_warn ("%s: running CQE recovery\n" ,mmc_hostname (host)); + + host->cqe_ops->cqe_recovery_start (host); + +memset (&cmd,0 ,sizeof (cmd)); + cmd.opcode =MMC_STOP_TRANSMISSION , + cmd.flags =MMC_RSP_R1B |MMC_CMD_AC , + cmd.flags &= ~MMC_RSP_CRC ;/* Ignore CRC */ + cmd.busy_timeout =MMC_CQE_RECOVERY_TIMEOUT , +mmc_wait_for_cmd (host, &cmd,0 ); + +memset (&cmd,0 ,sizeof (cmd)); + cmd.opcode =MMC_CMDQ_TASK_MGMT ; + cmd.arg =1 ;/* Discard entire queue */ + cmd.flags =MMC_RSP_R1B |MMC_CMD_AC ; + cmd.flags &= ~MMC_RSP_CRC ;/* Ignore CRC */ + cmd.busy_timeout =MMC_CQE_RECOVERY_TIMEOUT , + err =mmc_wait_for_cmd (host, &cmd,0 ); + + host->cqe_ops->cqe_recovery_finish (host, forget_reqs); + +mmc_retune_release (host); + +return err; +} +EXPORT_SYMBOL (mmc_cqe_recovery); +/** * mmc_start_bkops - start BKOPS for supported cards * @card: MMC card to start BKOPS
include/linux/mmc/core.h +6 -0
@@ -174,6 +174,12 @@ struct mmc_async_req *mmc_start_areq(struct mmc_host *host,int mmc_wait_for_cmd (struct mmc_host *host,struct mmc_command *cmd,int retries); +int mmc_cqe_start_req (struct mmc_host *host,struct mmc_request *mrq); +void __mmc_cqe_request_done (struct mmc_host *host,struct mmc_request *mrq); +void mmc_cqe_request_done (struct mmc_host *host,struct mmc_request *mrq); +void mmc_cqe_post_req (struct mmc_host *host,struct mmc_request *mrq); +int mmc_cqe_recovery (struct mmc_host *host,bool forget_reqs); +int mmc_hw_reset (struct mmc_host *host);void mmc_set_data_timeout (struct mmc_data *data,const struct mmc_card *card);
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v2 18/22 mmc: mmc: Enable Command Queuing
In reply to Adrian HunterEnable the Command Queue if the host controller supports i a command queue engine. It is not compatible with Packed Commands, so do not enable that at the same time.
--- drivers/mmc/core/mmc.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-)
drivers/mmc/core/mmc.c +16 -1
@@ -1789,6 +1789,20 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, } } +/* Enable Command Queue if supported */ + card->ext_csd.cmdq_en = false; +if (card->ext_csd.cmdq_support && host->caps2 &MMC_CAP2_CQE ) { + err =mmc_cmdq_enable (card); +if (err && err != -EBADMSG ) + goto free_card; +if (err) { +pr_warn ("%s: Enabling CMDQ failed\n" , +mmc_hostname (card->host)); + card->ext_csd.cmdq_support = false; + card->ext_csd.cmdq_depth =0 ; + err =0 ; + } + }/* * In some cases (e.g. RPMB or mmc_test), the Command Queue must be * disabled for a time, so a flag is needed to indicate to re-enable the
@@ -1802,7 +1816,8 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,*/ if (card->ext_csd.max_packed_writes >=3 && card->ext_csd.max_packed_reads >=5 && - host->caps2 &MMC_CAP2_PACKED_CMD ) { + host->caps2 &MMC_CAP2_PACKED_CMD && + !card->ext_csd.cmdq_en) { err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_EXP_EVENTS_CTRL, EXT_CSD_PACKED_EVENT_EN,
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v2 19/22 mmc: mmc: Enable CQE's
In reply to Adrian HunterEnable or disable CQE when a card is added or removed respectively.
--- drivers/mmc/core/bus.c | 7 +++++++ drivers/mmc/core/mmc.c | 13 +++++++++++++ 2 files changed, 20 insertions(+)
drivers/mmc/core/bus.c +7 -0
@@ -369,10 +369,17 @@ int mmc_add_card(struct mmc_card *card)*/ void mmc_remove_card (struct mmc_card *card) { +struct mmc_host *host = card->host; +#ifdef CONFIG_DEBUG_FS mmc_remove_card_debugfs (card);#endif +if (host->cqe_enabled) { + host->cqe_ops->cqe_disable (host); + host->cqe_enabled = false; + } +if (mmc_card_present (card)) {if (mmc_host_is_spi (card->host)) { pr_info("%s: SPI card removed\n",
drivers/mmc/core/mmc.c +13 -0
@@ -1810,6 +1810,19 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,*/ card->reenable_cmdq = card->ext_csd.cmdq_en; +if (card->ext_csd.cmdq_en && (host->caps2 &MMC_CAP2_CQE ) && + !host->cqe_enabled) { + err = host->cqe_ops->cqe_enable (host, card); +if (err) { +pr_err ("%s: Failed to enable CQE, error %d\n" , +mmc_hostname (host), err); + }else { + host->cqe_enabled = true; +pr_info ("%s: Command Queue Engine enabled\n" , +mmc_hostname (host)); + } + } +/* * The mandatory minimum values are defined for packed command. * read: 5, write: 3
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v2 20/22 mmc: block: Prepare CQE data
In reply to Adrian HunterEnhance mmc_blk_data_prep() to support CQE requests.
--- drivers/mmc/core/block.c | 45 ++++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 11 deletions(-)
drivers/mmc/core/block.c +34 -11
@@ -36,6 +36,7 @@#include <linux/compat.h> #include <linux/pm_runtime.h> #include <linux/idr.h> +#include <linux/ioprio.h> #include <linux/mmc/ioctl.h> #include <linux/mmc/card.h>
@@ -1434,25 +1435,27 @@ static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card, }static void mmc_blk_data_prep (struct mmc_queue *mq,struct mmc_queue_req *mqrq, -int disable_multi,bool *do_rel_wr, -bool *do_data_tag) +int disable_multi,bool *do_rel_wr_p, +bool *do_data_tag_p) {struct mmc_blk_data *md = mq->blkdata;struct mmc_card *card = md->queue.card;struct mmc_blk_request *brq = &mqrq->brq;struct request *req = mqrq->req; +bool do_rel_wr, do_data_tag;/* * Reliable writes are used to implement Forced Unit Access and * are supported only on MMCs. */ - *do_rel_wr = (req->cmd_flags &REQ_FUA ) && -rq_data_dir (req) ==WRITE && - (md->flags &MMC_BLK_REL_WR ); + do_rel_wr = (req->cmd_flags &REQ_FUA ) && +rq_data_dir (req) ==WRITE && + (md->flags &MMC_BLK_REL_WR );memset (brq,0 ,sizeof (struct mmc_blk_request )); brq->mrq.data = &brq->data; + brq->mrq.tag = req->tag; brq->stop.opcode =MMC_STOP_TRANSMISSION ; brq->stop.arg =0 ;
@@ -1467,6 +1470,15 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, brq->data.blksz =512 ; brq->data.blocks =blk_rq_sectors (req); + brq->data.blk_addr =blk_rq_pos (req); + +/* +* The command queue supports 2 priorities: "high" (1) and "simple" (0). +* The eMMC will give "high" priority tasks priority over "simple" +* priority tasks. Here we give priority to IOPRIO_CLASS_RT. +*/ +if (IOPRIO_PRIO_CLASS (req_get_ioprio (req)) ==IOPRIO_CLASS_RT ) + brq->data.flags |=MMC_DATA_PRIO ;/* * The block layer doesn't support all sector count
@@ -1496,18 +1508,23 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, brq->data.blocks); } -if (*do_rel_wr) +if (do_rel_wr) {mmc_apply_rel_rw (brq, card, req); + brq->data.flags |=MMC_DATA_REL_WR ; + }/* * Data tag is used only during writing meta data to speed * up write and any subsequent read of this meta data */ - *do_data_tag = card->ext_csd.data_tag_unit_size && - (req->cmd_flags &REQ_META ) && - (rq_data_dir (req) ==WRITE ) && - ((brq->data.blocks * brq->data.blksz) >= - card->ext_csd.data_tag_unit_size); + do_data_tag = card->ext_csd.data_tag_unit_size && + (req->cmd_flags &REQ_META ) && + (rq_data_dir (req) ==WRITE ) && + ((brq->data.blocks * brq->data.blksz) >= + card->ext_csd.data_tag_unit_size); + +if (do_data_tag) + brq->data.flags |=MMC_DATA_DAT_TAG ;mmc_set_data_timeout (&brq->data, card);
@@ -1536,6 +1553,12 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, mqrq->areq.mrq = &brq->mrq;mmc_queue_bounce_pre (mqrq); + +if (do_rel_wr_p) + *do_rel_wr_p = do_rel_wr; + +if (do_data_tag_p) + *do_data_tag_p = do_data_tag; } static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq,
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v2 21/22 mmc: block: Add CQE support
In reply to Adrian HunterAdd CQE support to the block driver, including:
- optionally using DCMD for flush requests
- manually issuing discard requests
- issuing read / write requests to the CQE
- supporting block-layer timeouts
- handling recovery
- supporting re-tuning
--- drivers/mmc/core/block.c | 202 ++++++++++++++++++++++++++++++- drivers/mmc/core/block.h | 7 ++ drivers/mmc/core/queue.c | 300 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/mmc/core/queue.h | 43 ++++++- 4 files changed, 545 insertions(+), 7 deletions(-)
drivers/mmc/core/block.c +201 -1
@@ -109,6 +109,7 @@ struct mmc_blk_data {#define MMC_BLK_WRITE BIT(1)#define MMC_BLK_DISCARD BIT(2)#define MMC_BLK_SECDISCARD BIT(3) +#define MMC_BLK_CQE_RECOVERY BIT(4)/* * Only set in main mmc_blk_data associated
@@ -1561,6 +1562,205 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, *do_data_tag_p = do_data_tag; } +#define MMC_CQE_RETRIES 2 + +void mmc_blk_cqe_complete_rq (struct request *req) +{ +struct mmc_queue_req *mqrq = req->special; +struct mmc_request *mrq = &mqrq->brq.mrq; +struct request_queue *q = req->q; +struct mmc_queue *mq = q->queuedata; +struct mmc_host *host = mq->card->host; +unsigned long flags; +bool put_card; +int err; + +mmc_cqe_post_req (host, mrq); + +spin_lock_irqsave (q->queue_lock, flags); + + mq->cqe_in_flight[mmc_cqe_issue_type (host, req)] -=1 ; + + put_card =mmc_cqe_tot_in_flight (mq) ==0 ; + +mmc_queue_clr_special (req); + +if (mrq->cmd && mrq->cmd->error) + err = mrq->cmd->error; +else if (mrq->data && mrq->data->error) + err = mrq->data->error; +else + err =0 ; + +if (err) { +/* +* !req->retries means we have not seen this request before, so +* we add 1 to the number of retries and compare to 1 to decide +* whether or not to retry. +*/ +if (!req->retries) + req->retries =MMC_CQE_RETRIES +1 ; +if (--req->retries >=1 ) +blk_requeue_request (q, req); +else +__blk_end_request_all (req, -EIO ); + }else if (mrq->data) { +if (__blk_end_request (req,0 , mrq->data->bytes_xfered)) +blk_requeue_request (q, req); + }else { +__blk_end_request_all (req,0 ); + } + +mmc_cqe_kick_queue (mq); + +spin_unlock_irqrestore (q->queue_lock, flags); + +if (put_card) +mmc_put_card (mq->card); +} + +void mmc_blk_cqe_recovery (struct mmc_queue *mq) +{ +struct mmc_card *card = mq->card; +struct mmc_host *host = card->host; +int err, i; + +mmc_get_card (card); + +pr_debug ("%s: CQE recovery start\n" ,mmc_hostname (host)); + +/* +* Block layer timeouts race with completions which means the normal +* completion path cannot be used so tell CQE to forget the requests. +*/ + err =mmc_cqe_recovery (host, true); + +/* Then complete all requests directly */ +for (i =0 ; i < mq->qdepth; i++) { +struct mmc_queue_req *mqrq = &mq->mqrq[i]; + +if (mqrq->req) { +__mmc_cqe_request_done (host, &mqrq->brq.mrq); +mmc_blk_cqe_complete_rq (mqrq->req); + } + } + +if (err) +mmc_blk_reset (mq->blkdata, host,MMC_BLK_CQE_RECOVERY ); +else +mmc_blk_reset_success (mq->blkdata,MMC_BLK_CQE_RECOVERY ); + +pr_debug ("%s: CQE recovery done\n" ,mmc_hostname (host)); + +mmc_put_card (card); +} + +static void mmc_blk_cqe_req_done (struct mmc_request *mrq) +{ + struct mmc_queue_req *mqrq = container_of(mrq, struct mmc_queue_req, + brq.mrq); + +blk_complete_request (mqrq->req); +} + +static int mmc_blk_cqe_start_req (struct mmc_host *host,struct mmc_request *mrq) +{ + mrq->done = mmc_blk_cqe_req_done; +return mmc_cqe_start_req (host, mrq); +} + +static struct mmc_request *mmc_blk_cqe_prep_dcmd (struct mmc_queue_req *mqrq) +{ +struct mmc_blk_request *brq = &mqrq->brq; + +memset (brq,0 ,sizeof (*brq)); + + brq->mrq.cmd = &brq->cmd; + brq->mrq.tag = mqrq->req->tag; + +return &brq->mrq; +} + +static int mmc_blk_cqe_issue_flush (struct mmc_queue *mq,struct request *req) +{ +struct mmc_queue_req *mqrq = req->special; +struct mmc_request *mrq =mmc_blk_cqe_prep_dcmd (mqrq); + + mrq->cmd->opcode =MMC_SWITCH ; + mrq->cmd->arg = (MMC_SWITCH_MODE_WRITE_BYTE <<24 ) | + (EXT_CSD_FLUSH_CACHE <<16 ) | + (1 <<8 ) | +EXT_CSD_CMD_SET_NORMAL ; + mrq->cmd->flags =MMC_CMD_AC |MMC_RSP_R1B ; + +return mmc_blk_cqe_start_req (mq->card->host, mrq); +} + +static int mmc_blk_cqe_issue_rw_rq (struct mmc_queue *mq,struct request *req) +{ +struct mmc_queue_req *mqrq = req->special; + +mmc_blk_data_prep (mq, mqrq,0 ,NULL ,NULL ); + +return mmc_blk_cqe_start_req (mq->card->host, &mqrq->brq.mrq); +} + +enum mmc_issued mmc_blk_cqe_issue_rq (struct mmc_queue *mq,struct request *req) +{ +struct mmc_blk_data *md = mq->blkdata; +struct mmc_card *card = md->queue.card; +struct mmc_host *host = card->host; +int ret; + + ret =mmc_blk_part_switch (card, md); +if (ret) +return MMC_REQ_FAILED_TO_START ; + +switch (mmc_cqe_issue_type (host, req)) { +case MMC_ISSUE_SYNC : + ret = host->cqe_ops->cqe_wait_for_idle (host); +if (ret) +return MMC_REQ_BUSY ; +switch (req_op (req)) { +case REQ_OP_DISCARD : +mmc_blk_issue_discard_rq (mq, req); +break ; +case REQ_OP_SECURE_ERASE : +mmc_blk_issue_secdiscard_rq (mq, req); +break ; +case REQ_OP_FLUSH : +mmc_blk_issue_flush (mq, req); +break ; +default : +WARN_ON_ONCE (1 ); +return MMC_REQ_FAILED_TO_START ; + } +return MMC_REQ_FINISHED ; +case MMC_ISSUE_DCMD : +case MMC_ISSUE_ASYNC : +mmc_queue_set_special (mq, req); +switch (req_op (req)) { +case REQ_OP_FLUSH : + ret =mmc_blk_cqe_issue_flush (mq, req); +break ; +case REQ_OP_READ : +case REQ_OP_WRITE : + ret =mmc_blk_cqe_issue_rw_rq (mq, req); +break ; +default : +WARN_ON_ONCE (1 ); + ret = -EINVAL ; + } +if (!ret) +return MMC_REQ_STARTED ; +mmc_queue_clr_special (req); +return ret == -EBUSY ?MMC_REQ_BUSY :MMC_REQ_FAILED_TO_START ; +default : +WARN_ON_ONCE (1 ); +return MMC_REQ_FAILED_TO_START ; + } +} + static void mmc_blk_rw_rq_prep(struct mmc_queue_req *mqrq, struct mmc_card *card, int disable_multi,
@@ -1960,7 +2160,7 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card,INIT_LIST_HEAD (&md->part); md->usage =1 ; - ret =mmc_init_queue (&md->queue, card, &md->lock, subname); + ret =mmc_init_queue (&md->queue, card, &md->lock, subname, area_type);if (ret) goto err_putdisk;
drivers/mmc/core/block.h +7 -0
@@ -6,4 +6,11 @@void mmc_blk_issue_rq (struct mmc_queue *mq,struct request *req); +enum mmc_issued ; + +enum mmc_issued mmc_blk_cqe_issue_rq (struct mmc_queue *mq, +struct request *req); +void mmc_blk_cqe_complete_rq (struct request *rq); +void mmc_blk_cqe_recovery (struct mmc_queue *mq); +#endif
drivers/mmc/core/queue.c +295 -5
330 lines not on this page · raw message
drivers/mmc/core/queue.h +42 -1
70 lines not on this page · raw message
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v2 22/22 mmc: cqhci: support for command queue enabled host
In reply to Adrian HunterFrom: Venkat Gopalakrishnan <[email protected]>
This patch adds CMDQ support for command-queue compatible hosts.
Command queue is added in eMMC-5.1 specification. This enables the controller to process upto 32 requests at a time.
Adrian Hunter contributed renaming to cqhci, recovery, suspend and resume, cqhci_off, cqhci_wait_for_idle, and external timeout handling.
--- drivers/mmc/host/Kconfig | 13 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/cqhci.c | 1148 +++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/host/cqhci.h | 240 ++++++++++ 4 files changed, 1402 insertions(+) create mode 100644 drivers/mmc/host/cqhci.c create mode 100644 drivers/mmc/host/cqhci.h
drivers/mmc/host/Kconfig +13 -0
@@ -794,6 +794,19 @@ config MMC_SUNXI This selects support for the SD/MMC Host Controller on Allwinner sunxi SoCs. +config MMC_CQHCI + tristate "Command Queue Host Controller Interface support" + depends on HAS_DMA + help + This selects the Command Queue Host Controller Interface (CQHCI) + support present in host controllers of Qualcomm Technologies, Inc + amongst others. + This controller supports eMMC devices with command queue support. + + If you have a controller with this interface, say Y or M here. + + If unsure, say N. + config MMC_TOSHIBA_PCI tristate "Toshiba Type A SD/MMC Card Interface Driver" depends on PCI
drivers/mmc/host/Makefile +1 -0
@@ -79,6 +79,7 @@ obj-$(CONFIG_MMC_SDHCI_MSM) += sdhci-msm.o obj-$(CONFIG_MMC_SDHCI_ST) += sdhci-st.o obj-$(CONFIG_MMC_SDHCI_MICROCHIP_PIC32) += sdhci-pic32.o obj-$(CONFIG_MMC_SDHCI_BRCMSTB) += sdhci-brcmstb.o +obj-$(CONFIG_MMC_CQHCI) += cqhci.o ifeq ($(CONFIG_CB710_DEBUG),y) CFLAGS-cb710-mmc += -DDEBUG
drivers/mmc/host/cqhci.c new file +1148 -0
1,148 lines not on this page · raw message
drivers/mmc/host/cqhci.h new file +240 -0
240 lines not on this page · raw message
Signature · 1 line
1.9.1
Quoted 2 lines · Adrian Hunter
Here are the hardware command queue patches without the software command queue patches or sdhci patches.
I think we have to merge at least a bunch of these patches, there is evidently a bunch of stuff in the beginning of the series at least that I have nothing against.
They will royally screw up my patch stack for MQ but that is not a technical argument, just work.
I will try to to go in and provide Reviewed-by tags for all stuff I consider merge material.
Yours,
Linus Walleij
Quoted 75 lines · Adrian Hunter
Hi
Here are the hardware command queue patches without the software command queue patches or sdhci patches.
Changes since V1:
"Share mmc request array between partitions" is dependent on changes in "Introduce queue semantics", so added that and block fixes:
Added "Fix
is_waiting_last_reqset incorrectly" Added "Fix cmd error reset failure path" Added "Use local var formqrq_cur" Added "Introduce queue semantics"Changes since RFC:
Re-based on next.
Added comment about command queue priority. Added some acks and reviews.Adrian Hunter (21):
mmc: block: Fixis_waiting_last_reqset incorrectly
mmc: block: Fix cmd error reset failure path
mmc: block: Use local var formqrq_cur
mmc: block: Introduce queue semantics
mmc: queue: Share mmc request array between partitions
mmc: mmc: Add functions to enable / disable the Command Queue
mmc:mmc_test: Disable Command Queue whilemmc_testis used
mmc: block: Disable Command Queue while RPMB is used
mmc: block: Changemmc_apply_rel_rw()to get block address from the request
mmc: block: Factor out data preparation
mmc: core: Factor out debug prints frommmc_start_request()
mmc: core: Factor out mrq preparation frommmc_start_request()
mmc: core: Addmmc_retune_hold_now()
mmc: core: Add members tommc_requestandmmc_datafor CQE's
mmc: host: Add CQE interface
mmc: core: Turn off CQE before sending commands
mmc: core: Add support for handling CQE requests
mmc: mmc: Enable Command Queuing
mmc: mmc: Enable CQE's
mmc: block: Prepare CQE data
mmc: block: Add CQE supportVenkat Gopalakrishnan (1):
mmc: cqhci: support for command queue enabled hostDocumentation/mmc/mmc-dev-attrs.txt | 1 + drivers/mmc/core/block.c | 527 ++++++++++++---- drivers/mmc/core/block.h | 7 + drivers/mmc/core/bus.c | 7 + drivers/mmc/core/core.c | 203 ++++++- drivers/mmc/core/host.c | 6 + drivers/mmc/core/host.h | 1 + drivers/mmc/core/mmc.c | 39 +- drivers/mmc/core/mmc_ops.c | 28 + drivers/mmc/core/mmc_ops.h | 2 + drivers/mmc/core/mmc_test.c | 14 + drivers/mmc/core/queue.c | 607 ++++++++++++++---- drivers/mmc/core/queue.h | 55 +- drivers/mmc/host/Kconfig | 13 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/cqhci.c | 1148 +++++++++++++++++++++++++++++++++++ drivers/mmc/host/cqhci.h | 240 ++++++++ include/linux/mmc/card.h | 8 + include/linux/mmc/core.h | 19 +- include/linux/mmc/host.h | 24 + include/trace/events/mmc.h | 17 +- 21 files changed, 2694 insertions(+), 273 deletions(-) create mode 100644 drivers/mmc/host/cqhci.c create mode 100644 drivers/mmc/host/cqhci.h
Quoted 2 lines
Regards
Adrian
Sorry for the delay!
I have looked through parts of the new version of the series, just reached to patch12. Before I continue, but also to move forward, I have picked up patch 3 -> 12 (including 12). Patch 1 and 2, went as fixes earlier.
Kind regards
Uffe
Adrian Hunter
maintainerQuoted 79 lines · Ulf Hansson
Quoted 75 lines · Adrian Hunter
Hi
Here are the hardware command queue patches without the software command queue patches or sdhci patches.
Changes since V1:
"Share mmc request array between partitions" is dependent on changes in "Introduce queue semantics", so added that and block fixes:
Added "Fix
is_waiting_last_reqset incorrectly" Added "Fix cmd error reset failure path" Added "Use local var formqrq_cur" Added "Introduce queue semantics"Changes since RFC:
Re-based on next.
Added comment about command queue priority. Added some acks and reviews.Adrian Hunter (21):
mmc: block: Fixis_waiting_last_reqset incorrectly
mmc: block: Fix cmd error reset failure path
mmc: block: Use local var formqrq_cur
mmc: block: Introduce queue semantics
mmc: queue: Share mmc request array between partitions
mmc: mmc: Add functions to enable / disable the Command Queue
mmc:mmc_test: Disable Command Queue whilemmc_testis used
mmc: block: Disable Command Queue while RPMB is used
mmc: block: Changemmc_apply_rel_rw()to get block address from the request
mmc: block: Factor out data preparation
mmc: core: Factor out debug prints frommmc_start_request()
mmc: core: Factor out mrq preparation frommmc_start_request()
mmc: core: Addmmc_retune_hold_now()
mmc: core: Add members tommc_requestandmmc_datafor CQE's
mmc: host: Add CQE interface
mmc: core: Turn off CQE before sending commands
mmc: core: Add support for handling CQE requests
mmc: mmc: Enable Command Queuing
mmc: mmc: Enable CQE's
mmc: block: Prepare CQE data
mmc: block: Add CQE supportVenkat Gopalakrishnan (1):
mmc: cqhci: support for command queue enabled hostDocumentation/mmc/mmc-dev-attrs.txt | 1 + drivers/mmc/core/block.c | 527 ++++++++++++---- drivers/mmc/core/block.h | 7 + drivers/mmc/core/bus.c | 7 + drivers/mmc/core/core.c | 203 ++++++- drivers/mmc/core/host.c | 6 + drivers/mmc/core/host.h | 1 + drivers/mmc/core/mmc.c | 39 +- drivers/mmc/core/mmc_ops.c | 28 + drivers/mmc/core/mmc_ops.h | 2 + drivers/mmc/core/mmc_test.c | 14 + drivers/mmc/core/queue.c | 607 ++++++++++++++---- drivers/mmc/core/queue.h | 55 +- drivers/mmc/host/Kconfig | 13 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/cqhci.c | 1148 +++++++++++++++++++++++++++++++++++ drivers/mmc/host/cqhci.h | 240 ++++++++ include/linux/mmc/card.h | 8 + include/linux/mmc/core.h | 19 +- include/linux/mmc/host.h | 24 + include/trace/events/mmc.h | 17 +- 21 files changed, 2694 insertions(+), 273 deletions(-) create mode 100644 drivers/mmc/host/cqhci.c create mode 100644 drivers/mmc/host/cqhci.hQuoted 2 lines
Regards
Adrian
Quoted 6 lines
Sorry for the delay!
I have looked through parts of the new version of the series, just reached to patch12. Before I continue, but also to move forward, I have picked up patch 3 -> 12 (including 12). Patch 1 and 2, went as fixes earlier.
Ulf and Linus have been doing a great job of keeping this moving, but it would be nice to see some others taking more interest. The first command queue patches were posted in February 2014, over 3 years ago!
Quoted 3 lines · Adrian Hunter
Ulf and Linus have been doing a great job of keeping this moving, but it would be nice to see some others taking more interest. The first command queue patches were posted in February 2014, over 3 years ago!
I agree.
I think both me & Ulf would also be doing more work if we had easily accessible hardware with upstream host controller support for native command queueing. (Hm, was just reading in libata about NCQ ... déja vu ... https://en.wikipedia.org/wiki/Native_Command_Queuing)
Do we have some hardware with host-backed command queueing out there that is easily obtained and has upstream support for the basic system?
Yours,
Linus Walleij
Quoted 26 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Linus Walleij
Sent: Monday, April 24, 2017 4:13 PM
To: Adrian Hunter <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 3 lines · Adrian Hunter
Ulf and Linus have been doing a great job of keeping this moving, but it would be nice to see some others taking more interest. The first command queue patches were posted in February 2014, over 3 years ago!
I agree.
Quoted 8 lines
I think both me & Ulf would also be doing more work if we had easily accessible hardware with upstream host controller support for native command queueing. (Hm, was just reading in libata about NCQ ...
déja vu ... https://en.wikipedia.org/wiki/Native_Command_Queuing)Do we have some hardware with host-backed command queueing out there that is easily obtained and has upstream support for the basic system?
The coming i.MX8 support hardware CMDQ, I will have a try when I get one on May or June.
BR,
Haibo
Quoted 6 lines
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html
Adrian Hunter
maintainerQuoted 31 lines · Bough Chen
Quoted 31 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Linus Walleij
Sent: Monday, April 24, 2017 4:13 PM
To: Adrian Hunter <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 3 lines · Adrian Hunter
Ulf and Linus have been doing a great job of keeping this moving, but it would be nice to see some others taking more interest. The first command queue patches were posted in February 2014, over 3 years ago!
I agree.
I think both me & Ulf would also be doing more work if we had easily accessible hardware with upstream host controller support for native command queueing. (Hm, was just reading in libata about NCQ ...
déja vu ... https://en.wikipedia.org/wiki/Native_Command_Queuing)
Quoted 5 lines
Quoted 3 lines
Do we have some hardware with host-backed command queueing out there that is easily obtained and has upstream support for the basic system?
The coming i.MX8 support hardware CMDQ, I will have a try when I get one on May or June.
I have sent updated patches. Will you have a chance to test hardware CMDQ?
Quoted 53 lines
-----Original Message-----
From: Adrian Hunter [mailto:[email protected]]
Sent: Thursday, June 15, 2017 7:38 PM
To: Bough Chen <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 17 lines · Bough Chen
Quoted 17 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Linus Walleij
Sent: Monday, April 24, 2017 4:13 PM
To: Adrian Hunter <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 7 lines
Quoted 7 lines
Quoted 3 lines · Adrian Hunter
Ulf and Linus have been doing a great job of keeping this moving, but it would be nice to see some others taking more interest. The first command queue patches were posted in February 2014, over 3 years
ago!
Quoted 5 lines
Quoted 5 lines
I agree.
I think both me & Ulf would also be doing more work if we had easily accessible hardware with upstream host controller support for native
command queueing.
Quoted 4 lines
Quoted 4 lines
(Hm, was just reading in libata about NCQ ...
déja vu ... https://en.wikipedia.org/wiki/Native_Command_Queuing)Do we have some hardware with host-backed command queueing out
Quoted 8 lines
there
Quoted 4 lines
Quoted 2 lines
that is easily obtained and has upstream support for the basic system?
The coming i.MX8 support hardware CMDQ, I will have a try when I get one
on May or June.
I have sent updated patches. Will you have a chance to test hardware CMDQ?
Yes, I will try to apply these patches on our local 4.9 branch. Will give you the test result.
Best Regards,
Haibo Chen
Quoted 79 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Bough Chen
Sent: Thursday, June 15, 2017 7:50 PM
To: Adrian Hunter <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: RE: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 7 lines
-----Original Message-----
From: Adrian Hunter [mailto:[email protected]]
Sent: Thursday, June 15, 2017 7:38 PM
To: Bough Chen <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>;Mateusz
Quoted 53 lines
Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 18 lines · Bough Chen
Quoted 18 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Linus Walleij
Sent: Monday, April 24, 2017 4:13 PM
To: Adrian Hunter <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 8 lines
Quoted 8 lines
Quoted 4 lines · Adrian Hunter
Ulf and Linus have been doing a great job of keeping this moving, but it would be nice to see some others taking more interest. The first command queue patches were posted in February 2014, over 3 years
ago!
Quoted 6 lines
Quoted 6 lines
I agree.
I think both me & Ulf would also be doing more work if we had easily accessible hardware with upstream host controller support for native
command queueing.
Quoted 4 lines
Quoted 4 lines
(Hm, was just reading in libata about NCQ ...
déja vu ... https://en.wikipedia.org/wiki/Native_Command_Queuing)Do we have some hardware with host-backed command queueing out
there
Quoted 3 lines
Quoted 2 lines
that is easily obtained and has upstream support for the basic system?
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
The coming i.MX8 support hardware CMDQ, I will have a try when I get one
on May or June.
I have sent updated patches. Will you have a chance to test hardware CMDQ?
Yes, I will try to apply these patches on our local 4.9 branch. Will give you the test result.
Hi Adrian,
i.MX8 still not upstream, and just work on our local 4.9 branch, to test your branch, I need to cherry pick some mmc patches and block layer patches, I'm doing this now, but need some time.
Quoted 4 lines
Best Regards,
Haibo Chen
칻 & ~ & +- ݶ w ˛ m b f ȧ ܨ} Ơz &j:+v zZ+ +zf h ~ i z w ?
& )ߢf
Adrian Hunter
maintainerQuoted 85 lines · Bough Chen
Quoted 85 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Bough Chen
Sent: Thursday, June 15, 2017 7:50 PM
To: Adrian Hunter <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: RE: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 7 lines
-----Original Message-----
From: Adrian Hunter [mailto:[email protected]]
Sent: Thursday, June 15, 2017 7:38 PM
To: Bough Chen <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>;Mateusz
Quoted 58 lines
Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 18 lines · Bough Chen
Quoted 18 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Linus Walleij
Sent: Monday, April 24, 2017 4:13 PM
To: Adrian Hunter <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 8 lines
Quoted 8 lines
Quoted 4 lines · Adrian Hunter
Ulf and Linus have been doing a great job of keeping this moving, but it would be nice to see some others taking more interest. The first command queue patches were posted in February 2014, over 3 years
ago!
Quoted 6 lines
Quoted 6 lines
I agree.
I think both me & Ulf would also be doing more work if we had easily accessible hardware with upstream host controller support for native
command queueing.
Quoted 4 lines
Quoted 4 lines
(Hm, was just reading in libata about NCQ ...
déja vu ... https://en.wikipedia.org/wiki/Native_Command_Queuing)Do we have some hardware with host-backed command queueing out
there
Quoted 5 lines
Quoted 2 lines
that is easily obtained and has upstream support for the basic system?
The coming i.MX8 support hardware CMDQ, I will have a try when I get one
on May or June.
I have sent updated patches. Will you have a chance to test hardware CMDQ?
Quoted 8 lines
Quoted 3 lines
Yes, I will try to apply these patches on our local 4.9 branch. Will give you the test result.
Hi Adrian,
i.MX8 still not upstream, and just work on our local 4.9 branch, to test your branch, I need to cherry pick some mmc patches and block layer patches, I'm doing this now, but need some time.
Thanks for the update. I realize backporting anything related to mmc block is now a big task.
Quoted 6 lines
Quoted 6 lines
Best Regards,
Haibo Chen
칻 & ~ & +- ݶ w ˛ m b f ȧ ܨ} Ơz &j:+v zZ+ +zf h ~ i z w ?
& )ߢf
Quoted 110 lines
-----Original Message-----
From: Adrian Hunter [mailto:[email protected]]
Sent: Tuesday, June 20, 2017 5:05 PM
To: Bough Chen <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 38 lines · Bough Chen
Quoted 38 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Bough Chen
Sent: Thursday, June 15, 2017 7:50 PM
To: Adrian Hunter <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: RE: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 7 lines
-----Original Message-----
From: Adrian Hunter [mailto:[email protected]]
Sent: Thursday, June 15, 2017 7:38 PM
To: Bough Chen <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>;Mateusz
Quoted 12 lines
Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportOn 24/04/17 12:14, Bough Chen wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Linus Walleij
Sent: Monday, April 24, 2017 4:13 PM
To: Adrian Hunter <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>;Das
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 8 lines
Quoted 8 lines
Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 8 lines
Quoted 8 lines
Quoted 4 lines · Adrian Hunter
Ulf and Linus have been doing a great job of keeping this moving, but it would be nice to see some others taking more interest. The first command queue patches were posted in February 2014, over 3 years
ago!
Quoted 6 lines
Quoted 6 lines
I agree.
I think both me & Ulf would also be doing more work if we had easily accessible hardware with upstream host controller support for native
command queueing.
Quoted 4 lines
Quoted 4 lines
(Hm, was just reading in libata about NCQ ...
déja vu ... https://en.wikipedia.org/wiki/Native_Command_Queuing)Do we have some hardware with host-backed command queueing out
there
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
that is easily obtained and has upstream support for the basic system?
The coming i.MX8 support hardware CMDQ, I will have a try when I get one
on May or June.
I have sent updated patches. Will you have a chance to test hardware
CMDQ?
Quoted 5 lines
Quoted 4 lines
Yes, I will try to apply these patches on our local 4.9 branch. Will give you the test result.
Quoted 9 lines
Quoted 4 lines
Hi Adrian,
i.MX8 still not upstream, and just work on our local 4.9 branch, to test your branch, I need to cherry pick some mmc patches and block layer
patches, I'm doing this now, but need some time.
Thanks for the update. I realize backporting anything related to mmc block is now a big task.
Hi Adrian,
I finish backporting, and have a try on our i.MX8 platform, seems it is easy to see the timeout error. I will try to dig it out. Here I attach the detail log:
root@imx8qxplpddr4arm2:~# dd if=/dev/mmcblk0 of=/dev/null bs=1M count=200 [ 41.846693] mmc0: starting CQE transfer for tag 1 blkaddr 0 [ 41.852310] mmc0: blksz 512 blocks 512 flags 00000200 tsac 150 ms nsac 0 [ 41.859396] mmc0: cqhci: tag 1 task descriptor 0x016200102f [ 68.665171] mmc0: cqhci: recovery needed [ 68.669108] mmc0: cqhci: timeout for tag 0 [ 68.673205] mmc0: cqhci: ============ CQHCI REGISTER DUMP =========== [ 68.679644] mmc0: cqhci: Caps: 0x0000310a | Version: 0x00000510 [ 68.686089] mmc0: cqhci: Config: 0x00000001 | Control: 0x00000000 [ 68.692527] mmc0: cqhci: Int stat: 0x00000000 | Int enab: 0x00000006 [ 68.698964] mmc0: cqhci: Int sig: 0x00000006 | Int Coal: 0x00000000 [ 68.705402] mmc0: cqhci: TDL base: 0xd807a000 | TDL up32: 0x00000000 [ 68.711839] mmc0: cqhci: Doorbell: 0x00000003 | TCN: 0x00000000 [ 68.718277] mmc0: cqhci: Dev queue: 0x00000001 | Dev Pend: 0x00000001 [ 68.724714] mmc0: cqhci: Task clr: 0x00000000 | SSC1: 0x00011000 [ 68.731152] mmc0: cqhci: SSC2: 0x00000001 | DCMD rsp: 0x00000000 [ 68.737589] mmc0: cqhci: RED mask: 0xfdf9a080 | TERRI: 0x00000000 [ 68.744026] mmc0: cqhci: Resp idx: 0x0000002e | Resp arg: 0x00000900 [ 68.750463] mmc0: sdhci: ============ SDHCI REGISTER DUMP =========== [ 68.756903] mmc0: sdhci: Sys addr: 0xd5ccc000 | Version: 0x00000002 [ 68.763348] mmc0: sdhci: Blk size: 0x00000200 | Blk cnt: 0x00000001 [ 68.769786] mmc0: sdhci: Argument: 0x40010200 | Trn mode: 0x00000030 [ 68.776231] mmc0: sdhci: Present: 0x010d8a8f | Host ctl: 0x00000030 [ 68.782668] mmc0: sdhci: Power: 0x00000002 | Blk gap: 0x00000080 [ 68.789106] mmc0: sdhci: Wake-up: 0x00000008 | Clock: 0x0000000f [ 68.795543] mmc0: sdhci: Timeout: 0x0000000e | Int stat: 0x00000000 [ 68.801981] mmc0: sdhci: Int enab: 0x107f4000 | Sig enab: 0x107f4000 [ 68.808418] mmc0: sdhci: AC12 err: 0x00000000 | Slot int: 0x00000502 [ 68.814856] mmc0: sdhci: Caps: 0x07eb0000 | Caps_1: 0x8000b407 [ 68.821293] mmc0: sdhci: Cmd: 0x00002c1a | Max curr: 0x00ffffff [ 68.827730] mmc0: sdhci: Resp[0]: 0x00000900 | Resp[1]: 0xffffffff [ 68.834168] mmc0: sdhci: Resp[2]: 0x328f5903 | Resp[3]: 0x00d02700 [ 68.840605] mmc0: sdhci: Host ctl2: 0x00000000 [ 68.845046] mmc0: sdhci: ADMA Err: 0x00000003 | ADMA Ptr: 0xd8098004 [ 68.851481] mmc0: sdhci: ============================================ [ 68.857936] mmc0: CQE recovery start [ 68.861554] mmc0: running CQE recovery [ 68.865326] mmc0: cqhci: cqhci_recovery_start [ 68.885159] mmc0: cqhci: Failed to halt [ 68.889004] mmc0: sdhci: CQE off, IRQ mask 0xff1003, IRQ status 0x4000 [ 68.895574] mmc0: starting CMD12 arg 00000000 flags 00000019 [ 78.905144] mmc0: Timeout waiting for hardware interrupt. [ 78.910558] mmc0: sdhci: ============ SDHCI REGISTER DUMP =========== [ 78.917003] mmc0: sdhci: Sys addr: 0x00000000 | Version: 0x00000002 [ 78.923440] mmc0: sdhci: Blk size: 0x00000200 | Blk cnt: 0x00000001 [ 78.929877] mmc0: sdhci: Argument: 0x00000000 | Trn mode: 0x00000030 [ 78.936315] mmc0: sdhci: Present: 0x01fd8009 | Host ctl: 0x00000031 [ 78.942752] mmc0: sdhci: Power: 0x00000002 | Blk gap: 0x00000080 [ 78.949189] mmc0: sdhci: Wake-up: 0x00000008 | Clock: 0x0000000f [ 78.955627] mmc0: sdhci: Timeout: 0x0000000f | Int stat: 0x00004000 [ 78.962064] mmc0: sdhci: Int enab: 0x007f1003 | Sig enab: 0x007f1003 [ 78.968501] mmc0: sdhci: AC12 err: 0x00000000 | Slot int: 0x00000502 [ 78.974939] mmc0: sdhci: Caps: 0x07eb0000 | Caps_1: 0x8000b407 [ 78.981376] mmc0: sdhci: Cmd: 0x00000cd3 | Max curr: 0x00ffffff [ 78.987814] mmc0: sdhci: Resp[0]: 0x00000900 | Resp[1]: 0xffffffff [ 78.994251] mmc0: sdhci: Resp[2]: 0x328f5903 | Resp[3]: 0x00d02700 [ 79.000688] mmc0: sdhci: Host ctl2: 0x00000000 [ 79.005129] mmc0: sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x00000000 [ 79.011564] mmc0: sdhci: ============================================ [ 79.018522] mmc0: req done (CMD12): -110: 00000000 00000000 00000000 00000000 [ 79.025713] mmc0: starting CMD48 arg 00000001 flags 00000019 [ 79.031424] mmc0: sdhci: IRQ status 0x00004001 [ 79.035868] mmc0: sdhci: IRQ status 0x00004000 [ 79.040312] mmc0: sdhci: IRQ status 0x00004000 [ 79.044751] mmc0: sdhci: IRQ status 0x00004000 [ 79.049190] mmc0: sdhci: IRQ status 0x00004000 [ 79.053630] mmc0: sdhci: IRQ status 0x00004000 [ 79.058069] mmc0: sdhci: IRQ status 0x00004000 [ 79.062508] mmc0: sdhci: IRQ status 0x00004000 [ 79.066948] mmc0: sdhci: IRQ status 0x00004000 [ 79.071387] mmc0: sdhci: IRQ status 0x00004000 [ 79.075827] mmc0: sdhci: IRQ status 0x00004000 [ 79.080266] mmc0: sdhci: IRQ status 0x00004000 [ 79.084705] mmc0: sdhci: IRQ status 0x00004000 [ 79.089144] mmc0: sdhci: IRQ status 0x00004000 [ 79.093583] mmc0: sdhci: IRQ status 0x00004000 [ 79.098023] mmc0: sdhci: IRQ status 0x00004000 [ 79.102463] mmc0: Unexpected interrupt 0x00004000. [ 79.107248] mmc0: sdhci: ============ SDHCI REGISTER DUMP =========== [ 79.113687] mmc0: sdhci: Sys addr: 0x00000000 | Version: 0x00000002 [ 79.120125] mmc0: sdhci: Blk size: 0x00000200 | Blk cnt: 0x00000001 [ 79.126562] mmc0: sdhci: Argument: 0x00000000 | Trn mode: 0x00000030 [ 79.133000] mmc0: sdhci: Present: 0x01fd8009 | Host ctl: 0x00000031 [ 79.139436] mmc0: sdhci: Power: 0x00000002 | Blk gap: 0x00000080 [ 79.145874] mmc0: sdhci: Wake-up: 0x00000008 | Clock: 0x0000000f [ 79.152312] mmc0: sdhci: Timeout: 0x0000000f | Int stat: 0x00004000 [ 79.158749] mmc0: sdhci: Int enab: 0x007f1003 | Sig enab: 0x007f1003 [ 79.165186] mmc0: sdhci: AC12 err: 0x00000000 | Slot int: 0x00000502 [ 79.171624] mmc0: sdhci: Caps: 0x07eb0000 | Caps_1: 0x8000b407 [ 79.178061] mmc0: sdhci: Cmd: 0x00002d12 | Max curr: 0x00ffffff [ 79.184499] mmc0: sdhci: Resp[0]: 0x00400800 | Resp[1]: 0xffffffff [ 79.190936] mmc0: sdhci: Resp[2]: 0x328f5903 | Resp[3]: 0x00d02700 [ 79.197373] mmc0: sdhci: Host ctl2: 0x00000000 [ 79.201814] mmc0: sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x00000000 [ 79.208249] mmc0: sdhci: ============================================ [ 79.214737] mmc0: req done (CMD48): 0: 00400800 00000000 00000000 00000000 [ 79.221722] mmc0: cqhci: cqhci_recovery_finish [ 79.226198] mmc0: CQE transfer done tag 0 [ 79.230223] mmc0: 0 bytes transferred: -110 [ 79.234796] mmc0: CQE transfer done tag 1 [ 79.238828] mmc0: 0 bytes transferred: 0 [ 79.243364] mmc0: cqhci: recovery done [ 79.247146] mmc0: CQE recovery done [ 79.250699] mmc0: starting CQE transfer for tag 0 blkaddr 0 [ 79.256299] mmc0: blksz 512 blocks 512 flags 00000200 tsac 150 ms nsac 0 [ 79.263368] mmc0: cqhci: CQE on [ 79.266540] mmc0: sdhci: CQE on, IRQ mask 0x2ff4000, IRQ status 0x4000 [ 79.273074] mmc0: sdhci: IRQ status 0x00004000 [ 79.277517] mmc0: cqhci: IRQ status: 0x00000006 [ 79.282043] mmc0: cqhci: error IRQ status: 0x00000006 cmd error 0 data error 0 TERRI: 0x00000000 [ 79.290835] mmc0: cqhci: error when idle. IRQ status: 0x00000006 cmd error 0 data error 0 TERRI: 0x00000000 [ 79.300621] ------------[ cut here ]------------ [ 79.305251] WARNING: CPU: 0 PID: 1273 at drivers/mmc/host/cqhci.c:671 cqhci_irq+0x1d0/0x4d0 [ 79.313603] Modules linked in: [ 79.316660] [ 79.318151] CPU: 0 PID: 1273 Comm: mmcqd/0 Not tainted 4.9.11-02713-g0aa36a6-dirty #659 [ 79.326156] Hardware name: Freescale i.MX8QXP LPDDR4 ARM2 (DT) [ 79.329154] fec 5b040000.ethernet eth0: MDIO read timeout [ 79.337381] task: ffff80083a1a6400 task.stack: ffff80083ae18000 [ 79.343299] PC is at cqhci_irq+0x1d0/0x4d0 [ 79.347399] LR is at cqhci_irq+0x1d0/0x4d0 [ 79.351490] pc : [<ffff0000087f6070>] lr : [<ffff0000087f6070>] pstate: 800001c5 [ 79.358882] sp : ffff80083ff6edc0 [ 79.362192] x29: ffff80083ff6edc0 x28: 0000000000004000 [ 79.367517] x27: ffff80083a807318 x26: ffff80083a807330 [ 79.372842] x25: ffff80083a36a008 x24: 0000000000000000 [ 79.378167] x23: 0000000000000000 x22: ffff80083a36a000 [ 79.383493] x21: ffff80083a807318 x20: 0000000000000000 [ 79.388818] x19: 0000000000000006 x18: 0000000000000006 [ 79.394144] x17: 0000ffff9792db60 x16: ffff0000081dcef8 [ 79.399469] x15: ffff000009083bb5 x14: 20726f7272652061 [ 79.404795] x13: 746164203020726f x12: 72726520646d6320 [ 79.410120] x11: 3630303030303030 x10: 0000000000000294 [ 79.415446] x9 : 747320515249202e x8 : 3030303030783020 [ 79.420771] x7 : 3a49525245542030 x6 : ffff000009083c16 [ 79.426097] x5 : ffff80083ff6fbb8 x4 : 0000000000000001 [ 79.431422] x3 : 0000000000000007 x2 : 0000000000000006 [ 79.436748] x1 : ffff80083ae18000 x0 : 000000000000005f [ 79.442072] [ 79.443559] ---[ end trace b7a758ac7d743c5f ]--- [ 79.448172] Call trace: [ 79.450616] Exception stack(0xffff80083ff6ebf0 to 0xffff80083ff6ed20) [ 79.457062] ebe0: 0000000000000006 0001000000000000 [ 79.472735] ec20: ffff80083ff6ec40 ffff000008d20fa8 ffff000009083000 0000000108f9e118 [ 79.480571] ec40: ffff80083ff6ece0 ffff000008100038 0000000000000006 0000000000000000 [ 79.488407] ec60: ffff80083a807318 ffff80083a36a000 0000000000000000 0000000000000000 [ 79.496243] ec80: ffff80083a36a008 ffff80083a807330 000000000000005f ffff80083ae18000 [ 79.504079] eca0: 0000000000000006 0000000000000007 0000000000000001 ffff80083ff6fbb8 [ 79.511916] ecc0: ffff000009083c16 3a49525245542030 3030303030783020 747320515249202e [ 79.519752] ece0: 0000000000000294 3630303030303030 72726520646d6320 746164203020726f [ 79.527588] ed00: 20726f7272652061 ffff000009083bb5 ffff0000081dcef8 0000ffff9792db60 [ 79.535424] [<ffff0000087f6070>] cqhci_irq+0x1d0/0x4d0 [ 79.540567] [<ffff0000087f3a30>] esdhc_cqhci_irq+0x50/0x60 [ 79.546057] [<ffff0000087e91a8>] sdhci_irq+0xe8/0xbe0 [ 79.551116] [<ffff0000081022ec>] __handle_irq_event_percpu+0x9c/0x128 [ 79.557559] [<ffff000008102394>] handle_irq_event_percpu+0x1c/0x58 [ 79.563744] [<ffff000008102418>] handle_irq_event+0x48/0x78 [ 79.569314] [<ffff000008105d28>] handle_fasteoi_irq+0xb8/0x1b0 [ 79.575151] [<ffff0000081013e4>] generic_handle_irq+0x24/0x38 [ 79.580902] [<ffff000008101a5c>] __handle_domain_irq+0x5c/0xb8 [ 79.586742] [<ffff000008081650>] gic_handle_irq+0xc0/0x160 [ 79.592229] Exception stack(0xffff80083ae1bb20 to 0xffff80083ae1bc50) [ 79.598669] bb20: ffff80083a36a7b8 0000000000000140 000000000000010c 0000000000000007 [ 79.606505] bb40: 0000000000000001 ffff80083ff6fbb8 ffff000009083bf1 515249202c303030 [ 79.614341] bb60: 2073757461747320 ffff80083ae1b9b0 0000000000000290 0000000000000006 [ 79.622177] bb80: 0000000005f5e0ff 0000000000000000 000000000000028f ffff000009083bb5 [ 79.630013] bba0: ffff0000081dcef8 0000ffff9792db60 0000000000000006 ffff80083a36a580 [ 79.637850] bbc0: ffff80083a36a7b8 0000000000000140 ffff80083a36a000 ffff80083a5df880 [ 79.645686] bbe0: ffff80083b00bd78 0000000000000000 ffff80083ab05720 ffff80083ae18000 [ 79.653522] bc00: ffff80083ab05718 ffff80083ae1bc50 ffff0000087e5778 ffff80083ae1bc50 [ 79.661358] bc20: ffff0000089f44a8 0000000080000145 ffff80083a36aa00 0000000000000000 [ 79.669192] bc40: ffffffffffffffff 00000000000f000f [ 79.674067] [<ffff0000080827b0>] el1_irq+0xb0/0x124 [ 79.678952] [<ffff0000089f44a8>] _raw_spin_unlock_irqrestore+0x10/0x48 [ 79.685483] [<ffff0000087f3914>] esdhc_cqe_enable+0x74/0x90 [ 79.691060] [<ffff0000087f6c58>] cqhci_request+0x588/0x5d0 [ 79.696552] [<ffff0000087cccdc>] mmc_cqe_start_req+0x9c/0xf0 [ 79.702217] [<ffff0000087e0730>] mmc_blk_cqe_issue_rq+0x1a8/0x290 [ 79.708314] [<ffff0000087e10e8>] mmc_cqe_thread+0x1f0/0x330 [ 79.713893] [<ffff0000080d9cf8>] kthread+0xd0/0xe8 [ 79.718686] [<ffff000008082e80>] ret_from_fork+0x10/0x50 [ 79.724002] mmc0: cqhci: TCN: 0x00000000 [ 79.727954] random: crng init done [ 79.731484] mmc0: cqhci: tag 0 task descriptor 0x016200102f [ 79.737157] mmc0: starting CQE transfer for tag 1 blkaddr 61071232 [ 79.743356] mmc0: blksz 512 blocks 8 flags 00000200 tsac 150 ms nsac 0 [ 79.750260] mmc0: cqhci: tag 1 task descriptor 0x0163a3df800008102f
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Best Regards,
Haibo Chen
Adrian Hunter
maintainerQuoted 140 lines · Bough Chen
Quoted 110 lines
-----Original Message-----
From: Adrian Hunter [mailto:[email protected]]
Sent: Tuesday, June 20, 2017 5:05 PM
To: Bough Chen <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 38 lines · Bough Chen
Quoted 38 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Bough Chen
Sent: Thursday, June 15, 2017 7:50 PM
To: Adrian Hunter <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: RE: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 7 lines
-----Original Message-----
From: Adrian Hunter [mailto:[email protected]]
Sent: Thursday, June 15, 2017 7:38 PM
To: Bough Chen <[email protected]>; Linus Walleij <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>;Mateusz
Quoted 12 lines
Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>; Das Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportOn 24/04/17 12:14, Bough Chen wrote:
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Linus Walleij
Sent: Monday, April 24, 2017 4:13 PM
To: Adrian Hunter <[email protected]>
Cc: Ulf Hansson <[email protected]>; linux-mmc <linux- [email protected]>; Alex Lemberg <[email protected]>; Mateusz Nowak <[email protected]>; Yuliy Izrailov <[email protected]>; Jaehoon Chung <[email protected]>; Dong Aisheng <[email protected]>;Das
Quoted 29 lines
Quoted 29 lines
Quoted 29 lines
Quoted 8 lines
Quoted 8 lines
Asutosh <[email protected]>; Zhangfei Gao <[email protected]>; Dorfman Konstantin <[email protected]>; David Griego <[email protected]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Shawn Lin <[email protected]>
Subject: Re: [PATCH V2 00/22] mmc: Add Command Queue supportQuoted 8 lines
Quoted 8 lines
Quoted 4 lines · Adrian Hunter
Ulf and Linus have been doing a great job of keeping this moving, but it would be nice to see some others taking more interest. The first command queue patches were posted in February 2014, over 3 years
ago!
Quoted 6 lines
Quoted 6 lines
I agree.
I think both me & Ulf would also be doing more work if we had easily accessible hardware with upstream host controller support for native
command queueing.
Quoted 4 lines
Quoted 4 lines
(Hm, was just reading in libata about NCQ ...
déja vu ... https://en.wikipedia.org/wiki/Native_Command_Queuing)Do we have some hardware with host-backed command queueing out
there
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
that is easily obtained and has upstream support for the basic system?
The coming i.MX8 support hardware CMDQ, I will have a try when I get one
on May or June.
I have sent updated patches. Will you have a chance to test hardware
CMDQ?
Quoted 5 lines
Quoted 4 lines
Yes, I will try to apply these patches on our local 4.9 branch. Will give you the test result.
Quoted 9 lines
Quoted 4 lines
Hi Adrian,
i.MX8 still not upstream, and just work on our local 4.9 branch, to test your branch, I need to cherry pick some mmc patches and block layer
patches, I'm doing this now, but need some time.
Thanks for the update. I realize backporting anything related to mmc block is now a big task.
Hi Adrian,
I finish backporting, and have a try on our i.MX8 platform, seems it is easy to see the timeout error. I will try to dig it out. Here I attach the detail log:
root@imx8qxplpddr4arm2:~# dd if=/dev/mmcblk0 of=/dev/null bs=1M count=200 [ 41.846693] mmc0: starting CQE transfer for tag 1 blkaddr 0 [ 41.852310] mmc0: blksz 512 blocks 512 flags 00000200 tsac 150 ms nsac 0 [ 41.859396] mmc0: cqhci: tag 1 task descriptor 0x016200102f [ 68.665171] mmc0: cqhci: recovery needed [ 68.669108] mmc0: cqhci: timeout for tag 0 [ 68.673205] mmc0: cqhci: ============ CQHCI REGISTER DUMP =========== [ 68.679644] mmc0: cqhci: Caps: 0x0000310a | Version: 0x00000510 [ 68.686089] mmc0: cqhci: Config: 0x00000001 | Control: 0x00000000 [ 68.692527] mmc0: cqhci: Int stat: 0x00000000 | Int enab: 0x00000006 [ 68.698964] mmc0: cqhci: Int sig: 0x00000006 | Int Coal: 0x00000000 [ 68.705402] mmc0: cqhci: TDL base: 0xd807a000 | TDL up32: 0x00000000 [ 68.711839] mmc0: cqhci: Doorbell: 0x00000003 | TCN: 0x00000000 [ 68.718277] mmc0: cqhci: Dev queue: 0x00000001 | Dev Pend: 0x00000001 [ 68.724714] mmc0: cqhci: Task clr: 0x00000000 | SSC1: 0x00011000
Quoted 8 lines
[ 68.731152] mmc0: cqhci: SSC2: 0x00000001 | DCMD rsp: 0x00000000 [ 68.737589] mmc0: cqhci: RED mask: 0xfdf9a080 | TERRI: 0x00000000 [ 68.744026] mmc0: cqhci: Resp idx: 0x0000002e | Resp arg: 0x00000900 [ 68.750463] mmc0: sdhci: ============ SDHCI REGISTER DUMP =========== [ 68.756903] mmc0: sdhci: Sys addr: 0xd5ccc000 | Version: 0x00000002 [ 68.763348] mmc0: sdhci: Blk size: 0x00000200 | Blk cnt: 0x00000001 [ 68.769786] mmc0: sdhci: Argument: 0x40010200 | Trn mode: 0x00000030 [ 68.776231] mmc0: sdhci: Present: 0x010d8a8f | Host ctl: 0x00000030
We had a problem with CQE getting stuck if bit-11 was set in present state. Refer glk_cqe_enable() in sdhci-pci-core.c.
Quoted 170 lines
[ 68.782668] mmc0: sdhci: Power: 0x00000002 | Blk gap: 0x00000080 [ 68.789106] mmc0: sdhci: Wake-up: 0x00000008 | Clock: 0x0000000f [ 68.795543] mmc0: sdhci: Timeout: 0x0000000e | Int stat: 0x00000000 [ 68.801981] mmc0: sdhci: Int enab: 0x107f4000 | Sig enab: 0x107f4000 [ 68.808418] mmc0: sdhci: AC12 err: 0x00000000 | Slot int: 0x00000502 [ 68.814856] mmc0: sdhci: Caps: 0x07eb0000 | Caps_1: 0x8000b407 [ 68.821293] mmc0: sdhci: Cmd: 0x00002c1a | Max curr: 0x00ffffff [ 68.827730] mmc0: sdhci: Resp[0]: 0x00000900 | Resp[1]: 0xffffffff [ 68.834168] mmc0: sdhci: Resp[2]: 0x328f5903 | Resp[3]: 0x00d02700 [ 68.840605] mmc0: sdhci: Host ctl2: 0x00000000 [ 68.845046] mmc0: sdhci: ADMA Err: 0x00000003 | ADMA Ptr: 0xd8098004 [ 68.851481] mmc0: sdhci: ============================================ [ 68.857936] mmc0: CQE recovery start [ 68.861554] mmc0: running CQE recovery [ 68.865326] mmc0: cqhci: cqhci_recovery_start [ 68.885159] mmc0: cqhci: Failed to halt [ 68.889004] mmc0: sdhci: CQE off, IRQ mask 0xff1003, IRQ status 0x4000 [ 68.895574] mmc0: starting CMD12 arg 00000000 flags 00000019 [ 78.905144] mmc0: Timeout waiting for hardware interrupt. [ 78.910558] mmc0: sdhci: ============ SDHCI REGISTER DUMP =========== [ 78.917003] mmc0: sdhci: Sys addr: 0x00000000 | Version: 0x00000002 [ 78.923440] mmc0: sdhci: Blk size: 0x00000200 | Blk cnt: 0x00000001 [ 78.929877] mmc0: sdhci: Argument: 0x00000000 | Trn mode: 0x00000030 [ 78.936315] mmc0: sdhci: Present: 0x01fd8009 | Host ctl: 0x00000031 [ 78.942752] mmc0: sdhci: Power: 0x00000002 | Blk gap: 0x00000080 [ 78.949189] mmc0: sdhci: Wake-up: 0x00000008 | Clock: 0x0000000f [ 78.955627] mmc0: sdhci: Timeout: 0x0000000f | Int stat: 0x00004000 [ 78.962064] mmc0: sdhci: Int enab: 0x007f1003 | Sig enab: 0x007f1003 [ 78.968501] mmc0: sdhci: AC12 err: 0x00000000 | Slot int: 0x00000502 [ 78.974939] mmc0: sdhci: Caps: 0x07eb0000 | Caps_1: 0x8000b407 [ 78.981376] mmc0: sdhci: Cmd: 0x00000cd3 | Max curr: 0x00ffffff [ 78.987814] mmc0: sdhci: Resp[0]: 0x00000900 | Resp[1]: 0xffffffff [ 78.994251] mmc0: sdhci: Resp[2]: 0x328f5903 | Resp[3]: 0x00d02700 [ 79.000688] mmc0: sdhci: Host ctl2: 0x00000000 [ 79.005129] mmc0: sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x00000000 [ 79.011564] mmc0: sdhci: ============================================ [ 79.018522] mmc0: req done (CMD12): -110: 00000000 00000000 00000000 00000000 [ 79.025713] mmc0: starting CMD48 arg 00000001 flags 00000019 [ 79.031424] mmc0: sdhci: IRQ status 0x00004001 [ 79.035868] mmc0: sdhci: IRQ status 0x00004000 [ 79.040312] mmc0: sdhci: IRQ status 0x00004000 [ 79.044751] mmc0: sdhci: IRQ status 0x00004000 [ 79.049190] mmc0: sdhci: IRQ status 0x00004000 [ 79.053630] mmc0: sdhci: IRQ status 0x00004000 [ 79.058069] mmc0: sdhci: IRQ status 0x00004000 [ 79.062508] mmc0: sdhci: IRQ status 0x00004000 [ 79.066948] mmc0: sdhci: IRQ status 0x00004000 [ 79.071387] mmc0: sdhci: IRQ status 0x00004000 [ 79.075827] mmc0: sdhci: IRQ status 0x00004000 [ 79.080266] mmc0: sdhci: IRQ status 0x00004000 [ 79.084705] mmc0: sdhci: IRQ status 0x00004000 [ 79.089144] mmc0: sdhci: IRQ status 0x00004000 [ 79.093583] mmc0: sdhci: IRQ status 0x00004000 [ 79.098023] mmc0: sdhci: IRQ status 0x00004000 [ 79.102463] mmc0: Unexpected interrupt 0x00004000. [ 79.107248] mmc0: sdhci: ============ SDHCI REGISTER DUMP =========== [ 79.113687] mmc0: sdhci: Sys addr: 0x00000000 | Version: 0x00000002 [ 79.120125] mmc0: sdhci: Blk size: 0x00000200 | Blk cnt: 0x00000001 [ 79.126562] mmc0: sdhci: Argument: 0x00000000 | Trn mode: 0x00000030 [ 79.133000] mmc0: sdhci: Present: 0x01fd8009 | Host ctl: 0x00000031 [ 79.139436] mmc0: sdhci: Power: 0x00000002 | Blk gap: 0x00000080 [ 79.145874] mmc0: sdhci: Wake-up: 0x00000008 | Clock: 0x0000000f [ 79.152312] mmc0: sdhci: Timeout: 0x0000000f | Int stat: 0x00004000 [ 79.158749] mmc0: sdhci: Int enab: 0x007f1003 | Sig enab: 0x007f1003 [ 79.165186] mmc0: sdhci: AC12 err: 0x00000000 | Slot int: 0x00000502 [ 79.171624] mmc0: sdhci: Caps: 0x07eb0000 | Caps_1: 0x8000b407 [ 79.178061] mmc0: sdhci: Cmd: 0x00002d12 | Max curr: 0x00ffffff [ 79.184499] mmc0: sdhci: Resp[0]: 0x00400800 | Resp[1]: 0xffffffff [ 79.190936] mmc0: sdhci: Resp[2]: 0x328f5903 | Resp[3]: 0x00d02700 [ 79.197373] mmc0: sdhci: Host ctl2: 0x00000000 [ 79.201814] mmc0: sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x00000000 [ 79.208249] mmc0: sdhci: ============================================ [ 79.214737] mmc0: req done (CMD48): 0: 00400800 00000000 00000000 00000000 [ 79.221722] mmc0: cqhci: cqhci_recovery_finish [ 79.226198] mmc0: CQE transfer done tag 0 [ 79.230223] mmc0: 0 bytes transferred: -110 [ 79.234796] mmc0: CQE transfer done tag 1 [ 79.238828] mmc0: 0 bytes transferred: 0 [ 79.243364] mmc0: cqhci: recovery done [ 79.247146] mmc0: CQE recovery done [ 79.250699] mmc0: starting CQE transfer for tag 0 blkaddr 0 [ 79.256299] mmc0: blksz 512 blocks 512 flags 00000200 tsac 150 ms nsac 0 [ 79.263368] mmc0: cqhci: CQE on [ 79.266540] mmc0: sdhci: CQE on, IRQ mask 0x2ff4000, IRQ status 0x4000 [ 79.273074] mmc0: sdhci: IRQ status 0x00004000 [ 79.277517] mmc0: cqhci: IRQ status: 0x00000006 [ 79.282043] mmc0: cqhci: error IRQ status: 0x00000006 cmd error 0 data error 0 TERRI: 0x00000000 [ 79.290835] mmc0: cqhci: error when idle. IRQ status: 0x00000006 cmd error 0 data error 0 TERRI: 0x00000000 [ 79.300621] ------------[ cut here ]------------ [ 79.305251] WARNING: CPU: 0 PID: 1273 at drivers/mmc/host/cqhci.c:671 cqhci_irq+0x1d0/0x4d0 [ 79.313603] Modules linked in: [ 79.316660] [ 79.318151] CPU: 0 PID: 1273 Comm: mmcqd/0 Not tainted 4.9.11-02713-g0aa36a6-dirty #659 [ 79.326156] Hardware name: Freescale i.MX8QXP LPDDR4 ARM2 (DT) [ 79.329154] fec 5b040000.ethernet eth0: MDIO read timeout [ 79.337381] task: ffff80083a1a6400 task.stack: ffff80083ae18000 [ 79.343299] PC is at cqhci_irq+0x1d0/0x4d0 [ 79.347399] LR is at cqhci_irq+0x1d0/0x4d0 [ 79.351490] pc : [<ffff0000087f6070>] lr : [<ffff0000087f6070>] pstate: 800001c5 [ 79.358882] sp : ffff80083ff6edc0 [ 79.362192] x29: ffff80083ff6edc0 x28: 0000000000004000 [ 79.367517] x27: ffff80083a807318 x26: ffff80083a807330 [ 79.372842] x25: ffff80083a36a008 x24: 0000000000000000 [ 79.378167] x23: 0000000000000000 x22: ffff80083a36a000 [ 79.383493] x21: ffff80083a807318 x20: 0000000000000000 [ 79.388818] x19: 0000000000000006 x18: 0000000000000006 [ 79.394144] x17: 0000ffff9792db60 x16: ffff0000081dcef8 [ 79.399469] x15: ffff000009083bb5 x14: 20726f7272652061 [ 79.404795] x13: 746164203020726f x12: 72726520646d6320 [ 79.410120] x11: 3630303030303030 x10: 0000000000000294 [ 79.415446] x9 : 747320515249202e x8 : 3030303030783020 [ 79.420771] x7 : 3a49525245542030 x6 : ffff000009083c16 [ 79.426097] x5 : ffff80083ff6fbb8 x4 : 0000000000000001 [ 79.431422] x3 : 0000000000000007 x2 : 0000000000000006 [ 79.436748] x1 : ffff80083ae18000 x0 : 000000000000005f [ 79.442072] [ 79.443559] ---[ end trace b7a758ac7d743c5f ]--- [ 79.448172] Call trace: [ 79.450616] Exception stack(0xffff80083ff6ebf0 to 0xffff80083ff6ed20) [ 79.457062] ebe0: 0000000000000006 0001000000000000 [ 79.472735] ec20: ffff80083ff6ec40 ffff000008d20fa8 ffff000009083000 0000000108f9e118 [ 79.480571] ec40: ffff80083ff6ece0 ffff000008100038 0000000000000006 0000000000000000 [ 79.488407] ec60: ffff80083a807318 ffff80083a36a000 0000000000000000 0000000000000000 [ 79.496243] ec80: ffff80083a36a008 ffff80083a807330 000000000000005f ffff80083ae18000 [ 79.504079] eca0: 0000000000000006 0000000000000007 0000000000000001 ffff80083ff6fbb8 [ 79.511916] ecc0: ffff000009083c16 3a49525245542030 3030303030783020 747320515249202e [ 79.519752] ece0: 0000000000000294 3630303030303030 72726520646d6320 746164203020726f [ 79.527588] ed00: 20726f7272652061 ffff000009083bb5 ffff0000081dcef8 0000ffff9792db60 [ 79.535424] [<ffff0000087f6070>] cqhci_irq+0x1d0/0x4d0 [ 79.540567] [<ffff0000087f3a30>] esdhc_cqhci_irq+0x50/0x60 [ 79.546057] [<ffff0000087e91a8>] sdhci_irq+0xe8/0xbe0 [ 79.551116] [<ffff0000081022ec>] __handle_irq_event_percpu+0x9c/0x128 [ 79.557559] [<ffff000008102394>] handle_irq_event_percpu+0x1c/0x58 [ 79.563744] [<ffff000008102418>] handle_irq_event+0x48/0x78 [ 79.569314] [<ffff000008105d28>] handle_fasteoi_irq+0xb8/0x1b0 [ 79.575151] [<ffff0000081013e4>] generic_handle_irq+0x24/0x38 [ 79.580902] [<ffff000008101a5c>] __handle_domain_irq+0x5c/0xb8 [ 79.586742] [<ffff000008081650>] gic_handle_irq+0xc0/0x160 [ 79.592229] Exception stack(0xffff80083ae1bb20 to 0xffff80083ae1bc50) [ 79.598669] bb20: ffff80083a36a7b8 0000000000000140 000000000000010c 0000000000000007 [ 79.606505] bb40: 0000000000000001 ffff80083ff6fbb8 ffff000009083bf1 515249202c303030 [ 79.614341] bb60: 2073757461747320 ffff80083ae1b9b0 0000000000000290 0000000000000006 [ 79.622177] bb80: 0000000005f5e0ff 0000000000000000 000000000000028f ffff000009083bb5 [ 79.630013] bba0: ffff0000081dcef8 0000ffff9792db60 0000000000000006 ffff80083a36a580 [ 79.637850] bbc0: ffff80083a36a7b8 0000000000000140 ffff80083a36a000 ffff80083a5df880 [ 79.645686] bbe0: ffff80083b00bd78 0000000000000000 ffff80083ab05720 ffff80083ae18000 [ 79.653522] bc00: ffff80083ab05718 ffff80083ae1bc50 ffff0000087e5778 ffff80083ae1bc50 [ 79.661358] bc20: ffff0000089f44a8 0000000080000145 ffff80083a36aa00 0000000000000000 [ 79.669192] bc40: ffffffffffffffff 00000000000f000f [ 79.674067] [<ffff0000080827b0>] el1_irq+0xb0/0x124 [ 79.678952] [<ffff0000089f44a8>] _raw_spin_unlock_irqrestore+0x10/0x48 [ 79.685483] [<ffff0000087f3914>] esdhc_cqe_enable+0x74/0x90 [ 79.691060] [<ffff0000087f6c58>] cqhci_request+0x588/0x5d0 [ 79.696552] [<ffff0000087cccdc>] mmc_cqe_start_req+0x9c/0xf0 [ 79.702217] [<ffff0000087e0730>] mmc_blk_cqe_issue_rq+0x1a8/0x290 [ 79.708314] [<ffff0000087e10e8>] mmc_cqe_thread+0x1f0/0x330 [ 79.713893] [<ffff0000080d9cf8>] kthread+0xd0/0xe8 [ 79.718686] [<ffff000008082e80>] ret_from_fork+0x10/0x50 [ 79.724002] mmc0: cqhci: TCN: 0x00000000 [ 79.727954] random: crng init done [ 79.731484] mmc0: cqhci: tag 0 task descriptor 0x016200102f [ 79.737157] mmc0: starting CQE transfer for tag 1 blkaddr 61071232 [ 79.743356] mmc0: blksz 512 blocks 8 flags 00000200 tsac 150 ms nsac 0 [ 79.750260] mmc0: cqhci: tag 1 task descriptor 0x0163a3df800008102fQuoted 4 lines
Quoted 4 lines
Quoted 4 lines
Best Regards,
Haibo Chen
Quoted 9 lines
Il giorno 24 apr 2017, alle ore 10:12, Linus Walleij <[email protected]> ha scritto:
Quoted 3 lines · Adrian Hunter
Ulf and Linus have been doing a great job of keeping this moving, but it would be nice to see some others taking more interest. The first command queue patches were posted in February 2014, over 3 years ago!
Quoted 7 lines
I agree.
I think both me & Ulf would also be doing more work if we had easily accessible hardware with upstream host controller support for native command queueing. (Hm, was just reading in libata about NCQ ... déja vu ... https://en.wikipedia.org/wiki/Native_Command_Queuing)
That would allow me too to run some test with BFQ and MMC ...
Thanks,
Paolo
Quoted 10 lines
Do we have some hardware with host-backed command queueing out there that is easily obtained and has upstream support for the basic system?
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html