mmc: Add Command Queue support
Subsystems (4)
Adrian Hunter
maintainerv7 cover mmc: Add Command Queue support
Hi
Here is V7 of the hardware command queue patches without the software command queue patches, now using blk-mq.
HW CMDQ offers 25% - 50% better random multi-threaded I/O. I see a slight 2% drop in sequential read speed but no change to sequential write.
Changes since V6:
mmc: core: Introduce host claiming by context
New patch.
mmc: core: Move mmc_start_areq() declaration
Dropped because it has been applied
mmc: block: Fix block status codes
Dropped because it has been applied
mmc: host: Add CQE interface
Dropped because it has been applied
mmc: core: Turn off CQE before sending commands
Dropped because it has been applied
mmc: block: Factor out mmc_setup_queue()
New patch.
mmc: block: Add CQE support
Drop legacy support and add blk-mq support
Changes since V5:
Re-based
mmc: core: Add mmc_retune_hold_now()
Dropped because it has been applied
mmc: core: Add members to mmc_request and mmc_data for CQE's
Dropped because it has been applied
mmc: core: Move mmc_start_areq() declaration
New patch at Ulf's request
mmc: block: Fix block status codes
Another un-related patch
mmc: host: Add CQE interface
Move recovery_notifier() callback to struct mmc_request
mmc: core: Add support for handling CQE requests
Roll __mmc_cqe_request_done() into mmc_cqe_request_done() Move function declarations requested by Ulf
mmc: core: Remove unused MMC_CAP2_PACKED_CMD
Dropped because it has been applied
mmc: block: Add CQE support
Add explanation to commit message
Adjustment for changed recovery_notifier() callback
mmc: cqhci: support for command queue enabled host
Adjustment for changed recovery_notifier() callback
mmc: sdhci-pci: Add CQHCI support for Intel GLK
Add DCMD capability for Intel controllers except GLK
Changes since V4:
mmc: core: Add mmc_retune_hold_now()
Add explanation to commit message.
mmc: host: Add CQE interface
Add comments to callback declarations.
mmc: core: Turn off CQE before sending commands
Add explanation to commit message.
mmc: core: Add support for handling CQE requests
Add comments as requested by Ulf.
mmc: core: Remove unused MMC_CAP2_PACKED_CMD
New patch.
mmc: mmc: Enable Command Queuing
Adjust for removal of MMC_CAP2_PACKED_CMD.
Add a comment about Packed Commands.
mmc: mmc: Enable CQE's
Remove un-necessary check for MMC_CAP2_CQE
mmc: block: Use local variables in mmc_blk_data_prep()
New patch.
mmc: block: Prepare CQE data
Adjust due to "mmc: block: Use local variables in mmc_blk_data_prep()" Remove priority setting.
Add explanation to commit message.
mmc: cqhci: support for command queue enabled host
Fix transfer descriptor setting in cqhci_set_tran_desc() for 32-bit DMA
Changes since V3:
Adjusted ...blk_end_request...() for new block status codes Fixed CQHCI transaction descriptor for "no DCMD" case
Changes since V2:
Dropped patches that have been applied. Re-based
Added "mmc: sdhci-pci: Add CQHCI support for Intel GLK"
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 (9):
mmc: core: Introduce host claiming by context
mmc: core: Add support for handling CQE requests
mmc: mmc: Enable Command Queuing
mmc: mmc: Enable CQE's
mmc: block: Use local variables in mmc_blk_data_prep()
mmc: block: Prepare CQE data
mmc: block: Factor out mmc_setup_queue()
mmc: block: Add CQE support
mmc: sdhci-pci: Add CQHCI support for Intel GLK
Venkat Gopalakrishnan (1):
mmc: cqhci: support for command queue enabled host
drivers/mmc/core/block.c | 260 ++++++++- drivers/mmc/core/block.h | 7 + drivers/mmc/core/bus.c | 7 + drivers/mmc/core/core.c | 272 ++++++++- drivers/mmc/core/core.h | 12 + drivers/mmc/core/mmc.c | 29 + drivers/mmc/core/queue.c | 438 ++++++++++++-- drivers/mmc/core/queue.h | 46 +- drivers/mmc/host/Kconfig | 14 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/cqhci.c | 1154 +++++++++++++++++++++++++++++++++++++ drivers/mmc/host/cqhci.h | 240 ++++++++ drivers/mmc/host/sdhci-pci-core.c | 154 ++++- include/linux/mmc/host.h | 9 +- 14 files changed, 2567 insertions(+), 76 deletions(-) create mode 100644 drivers/mmc/host/cqhci.c create mode 100644 drivers/mmc/host/cqhci.h
Regards
Adrian
Adrian Hunter
maintainerPATCH v7 1/10 mmc: core: Introduce host claiming by context
Currently the host can be claimed by a task. Change this so that the host can be claimed by a context that may or may not be a task. This provides for the host to be claimed by a block driver queue to support blk-mq, while maintaining compatibility with the existing use of mmc_claim_host().
--- drivers/mmc/core/core.c | 109 ++++++++++++++++++++++++++++++++++++++++++++--- drivers/mmc/core/core.h | 8 ++++ include/linux/mmc/host.h | 7 ++- 3 files changed, 116 insertions(+), 8 deletions(-)
drivers/mmc/core/core.c +102 -7
@@ -832,9 +832,38 @@ unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz) }EXPORT_SYMBOL (mmc_align_data_size); +/* +* Allow claiming an already claimed host if the context is the same or there is +* no context but the task is the same. +*/ +static inline bool mmc_ctx_matches (struct mmc_host *host,struct mmc_ctx *ctx, +struct task_struct *task) +{ +return host->claimer == ctx || + (!ctx && task && host->claimer->task == task); +} + +static inline void mmc_ctx_set_claimer (struct mmc_host *host, +struct mmc_ctx *ctx, +struct task_struct *task) +{ +if (!host->claimer) { +if (ctx) + host->claimer = ctx; +else + host->claimer = &host->default_ctx; + } +if (task) + host->claimer->task = task; +} +/** -* __mmc_claim_host - exclusively claim a host +* __mmc_ctx_task_claim_host - exclusively claim a host * @host: mmc host to claim +* @ctx: context that claims the host or NULL in which case the default +* context will be used +* @task: task that claims the host or NULL in which case @ctx must be +* provided * @abort: whether or not the operation should be aborted * * Claim a host for a set of operations. If @abort is non null and
@@ -842,7 +871,8 @@ unsigned int mmc_align_data_size(struct mmc_card *card, unsigned int sz)* that non-zero value without acquiring the lock. Returns zero * with the lock held otherwise. */ -int __mmc_claim_host (struct mmc_host *host,atomic_t *abort) +static int __mmc_ctx_task_claim_host (struct mmc_host *host,struct mmc_ctx *ctx, +struct task_struct *task,atomic_t *abort) {DECLARE_WAITQUEUE (wait, current);unsigned long flags;
@@ -856,7 +886,7 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)while (1 ) {set_current_state (TASK_UNINTERRUPTIBLE ); stop = abort ?atomic_read (abort) :0 ; -if (stop || !host->claimed || host->claimer == current) +if (stop || !host->claimed ||mmc_ctx_matches (host, ctx, task))break ;spin_unlock_irqrestore (&host->lock, flags);schedule ();
@@ -865,7 +895,7 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)set_current_state (TASK_RUNNING );if (!stop) { host->claimed =1 ; - host->claimer = current; +mmc_ctx_set_claimer (host, ctx, task); host->claim_cnt +=1 ;if (host->claim_cnt ==1 ) pm = true;
@@ -879,8 +909,25 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)return stop; } + +int __mmc_claim_host (struct mmc_host *host,atomic_t *abort) +{ +return __mmc_ctx_task_claim_host (host,NULL , current, abort); +}EXPORT_SYMBOL (__mmc_claim_host); +void mmc_ctx_claim_host (struct mmc_host *host,struct mmc_ctx *ctx) +{ +__mmc_ctx_task_claim_host (host, ctx,NULL ,NULL ); +} +EXPORT_SYMBOL (mmc_ctx_claim_host); + +void mmc_ctx_task_claim_host (struct mmc_host *host,struct mmc_ctx *ctx) +{ +__mmc_ctx_task_claim_host (host, ctx, current,NULL ); +} +EXPORT_SYMBOL (mmc_ctx_task_claim_host); +/** * mmc_release_host - release a host * @host: mmc host to release
@@ -888,18 +935,19 @@ int __mmc_claim_host(struct mmc_host *host, atomic_t *abort)* Release a MMC host, allowing others to claim the host * for their operations. */ -void mmc_release_host (struct mmc_host *host) +static void __mmc_release_host (struct mmc_host *host,bool task_release) {unsigned long flags; -WARN_ON (!host->claimed); -spin_lock_irqsave (&host->lock, flags);if (--host->claim_cnt) {/* Release for nested claim */ +if (task_release) + host->claimer->task =NULL ;spin_unlock_irqrestore (&host->lock, flags); }else { host->claimed =0 ; + host->claimer->task =NULL ; host->claimer =NULL ;spin_unlock_irqrestore (&host->lock, flags);wake_up (&host->wq);
@@ -907,8 +955,32 @@ void mmc_release_host(struct mmc_host *host)pm_runtime_put_autosuspend (mmc_dev (host)); } } + +void mmc_release_host (struct mmc_host *host) +{ +WARN_ON (!host->claimed); + +__mmc_release_host (host, false); +}EXPORT_SYMBOL (mmc_release_host); +void mmc_ctx_release_host (struct mmc_host *host,struct mmc_ctx *ctx) +{ +WARN_ON (!host->claimed || host->claimer != ctx); + +__mmc_release_host (host, false); +} +EXPORT_SYMBOL (mmc_ctx_release_host); + +void mmc_ctx_task_release_host (struct mmc_host *host,struct mmc_ctx *ctx) +{ +WARN_ON (!host->claimed || host->claimer != ctx || + host->claimer->task != current); + +__mmc_release_host (host, true); +} +EXPORT_SYMBOL (mmc_ctx_task_release_host); +/* * This is a helper function, which fetches a runtime pm reference for the * card device and also claims the host.
@@ -921,6 +993,17 @@ void mmc_get_card(struct mmc_card *card)EXPORT_SYMBOL (mmc_get_card);/* +* This is a helper function, which fetches a runtime pm reference for the +* card device and also claims the host for the mmc context. +*/ +void mmc_ctx_get_card (struct mmc_card *card,struct mmc_ctx *ctx) +{ +pm_runtime_get_sync (&card->dev); +mmc_ctx_claim_host (card->host, ctx); +} +EXPORT_SYMBOL (mmc_ctx_get_card); + +/* * This is a helper function, which releases the host and drops the runtime * pm reference for the card device. */
@@ -933,6 +1016,18 @@ void mmc_put_card(struct mmc_card *card)EXPORT_SYMBOL (mmc_put_card);/* +* This is a helper function, which releases the host and drops the runtime +* pm reference for the card device. +*/ +void mmc_ctx_put_card (struct mmc_card *card,struct mmc_ctx *ctx) +{ +mmc_ctx_release_host (card->host, ctx); +pm_runtime_mark_last_busy (&card->dev); +pm_runtime_put_autosuspend (&card->dev); +} +EXPORT_SYMBOL (mmc_ctx_put_card); + +/* * Internal function that does the actual ios call to the host driver, * optionally printing some debug output. */
drivers/mmc/core/core.h +8 -0
@@ -144,4 +144,12 @@ static inline void mmc_claim_host(struct mmc_host *host) __mmc_claim_host(host, NULL); } +void mmc_ctx_claim_host (struct mmc_host *host,struct mmc_ctx *ctx); +void mmc_ctx_release_host (struct mmc_host *host,struct mmc_ctx *ctx); +void mmc_ctx_task_claim_host (struct mmc_host *host,struct mmc_ctx *ctx); +void mmc_ctx_task_release_host (struct mmc_host *host,struct mmc_ctx *ctx); + +void mmc_ctx_get_card (struct mmc_card *card,struct mmc_ctx *ctx); +void mmc_ctx_put_card (struct mmc_card *card,struct mmc_ctx *ctx); +#endif
include/linux/mmc/host.h +6 -1
@@ -255,6 +255,10 @@ struct mmc_supply {struct regulator *vqmmc;/* Optional Vccq supply */ }; +struct mmc_ctx { +struct task_struct *task; +}; +struct mmc_host {struct device *parent;struct device class_dev;
@@ -388,8 +392,9 @@ struct mmc_host {struct mmc_card *card;/* device attached to this host */ wait_queue_head_t wq; -struct task_struct *claimer;/* task that has host claimed */ +struct mmc_ctx *claimer;/* context that has host claimed */ int claim_cnt;/* "claim" nesting count */ +struct mmc_ctx default_ctx;/* default context */ struct delayed_work detect;int detect_change;/* card detect flag */
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v7 2/10 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 | 163 +++++++++++++++++++++++++++++++++++++++++++++-- drivers/mmc/core/core.h | 4 ++ include/linux/mmc/host.h | 2 + 3 files changed, 164 insertions(+), 5 deletions(-)
drivers/mmc/core/core.c +158 -5
@@ -266,7 +266,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",
@@ -275,9 +276,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) {
@@ -342,7 +346,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);
@@ -482,6 +486,155 @@ void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) }EXPORT_SYMBOL (mmc_wait_for_req_done); +/* +* mmc_cqe_start_req - Start a CQE request. +* @host: MMC host to start the request +* @mrq: request to start +* +* Start the request, re-tuning if needed and it is possible. Returns an error +* code if the request fails to start or -EBUSY if CQE is busy. +*/ +int mmc_cqe_start_req (struct mmc_host *host,struct mmc_request *mrq) +{ +int err; + +/* +* CQE cannot process re-tuning commands. Caller must hold retuning +* while CQE is in use. Re-tuning can happen here only when CQE has no +* active requests i.e. this is the first. Note, re-tuning will call +* ->cqe_off(). +*/ + 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); + +/** +* 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_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); + } + + 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 + +/* +* mmc_cqe_recovery - Recover from CQE errors. +* @host: MMC host to recover +* +* Recovery consists of stopping CQE, stopping eMMC, discarding the queue in +* in eMMC, and discarding the queue in CQE. CQE must call +* mmc_cqe_request_done() on all requests. An error is returned if the eMMC +* fails to discard its queue. +*/ +int mmc_cqe_recovery (struct mmc_host *host) +{ +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); + +mmc_retune_release (host); + +return err; +} +EXPORT_SYMBOL (mmc_cqe_recovery); +/** * mmc_is_req_done - Determine if a 'cap_cmd_during_tfr' request is done * @host: MMC host
drivers/mmc/core/core.h +4 -0
@@ -152,4 +152,8 @@ static inline void mmc_claim_host(struct mmc_host *host)void mmc_ctx_get_card (struct mmc_card *card,struct mmc_ctx *ctx);void mmc_ctx_put_card (struct mmc_card *card,struct mmc_ctx *ctx); +int mmc_cqe_start_req (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); +#endif
include/linux/mmc/host.h +2 -0
@@ -474,6 +474,8 @@ static inline void *mmc_priv(struct mmc_host *host)void mmc_request_done (struct mmc_host *,struct mmc_request *);void mmc_command_done (struct mmc_host *host,struct mmc_request *mrq); +void mmc_cqe_request_done (struct mmc_host *host,struct mmc_request *mrq); +static inline void mmc_signal_sdio_irq (struct mmc_host *host) { host->ops->enable_sdio_irq (host,0 );
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v7 3/10 mmc: mmc: Enable Command Queuing
In reply to Adrian HunterEnable the Command Queue if the host controller supports a command queue engine. It is not compatible with Packed Commands, so make a note of that in the comment.
--- drivers/mmc/core/mmc.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
drivers/mmc/core/mmc.c +17 -0
@@ -1784,6 +1784,23 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr, }/* +* Enable Command Queue if supported. Note that Packed Commands cannot +* be used with Command Queue. +*/ + 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 * Command Queue.
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v7 4/10 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 | 12 ++++++++++++ 2 files changed, 19 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 +12 -0
@@ -1807,6 +1807,18 @@ 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->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)); + } + } +if (!oldcard) host->card = card;
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v7 5/10 mmc: block: Use local variables in mmc_blk_data_prep()
In reply to Adrian HunterUse local variables in mmc_blk_data_prep() in preparation for adding CQE support which doesn't use the output variables.
--- drivers/mmc/core/block.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-)
drivers/mmc/core/block.c +18 -11
@@ -1534,21 +1534,22 @@ 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 =mmc_queue_req_to_req (mqrq); +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 ));
@@ -1596,18 +1597,18 @@ 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);/* * 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);mmc_set_data_timeout (&brq->data, card);
@@ -1636,6 +1637,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 v7 6/10 mmc: block: Prepare CQE data
In reply to Adrian HunterEnhance mmc_blk_data_prep() to support CQE requests. That means adding some things that for non-CQE requests would be encoded into the command arguments - such as the block address, reliable-write flag, and data tag flag. Also the request tag is needed to provide the command queue task id, and a comment is added to explain the future possibility of defining a priority.
--- drivers/mmc/core/block.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-)
drivers/mmc/core/block.c +15 -1
@@ -1554,6 +1554,7 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq,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 ;
@@ -1568,6 +1569,14 @@ 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 always set "simple" priority by not setting +* MMC_DATA_PRIO. +*/ /* * The block layer doesn't support all sector count
@@ -1597,8 +1606,10 @@ 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
@@ -1610,6 +1621,9 @@ static void mmc_blk_data_prep(struct mmc_queue *mq, struct mmc_queue_req *mqrq, ((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); brq->data.sg = mqrq->sg;
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v7 7/10 mmc: block: Factor out mmc_setup_queue()
In reply to Adrian HunterFactor out some common code that will also be used with blk-mq.
--- drivers/mmc/core/queue.c | 53 ++++++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 22 deletions(-)
drivers/mmc/core/queue.c +31 -22
@@ -223,6 +223,36 @@ static void mmc_exit_request(struct request_queue *q, struct request *req) mq_rq->sg =NULL ; } +static void mmc_setup_queue (struct mmc_queue *mq,struct mmc_card *card) +{ +struct mmc_host *host = card->host; +u64 limit =BLK_BOUNCE_HIGH ; + +if (mmc_dev (host)->dma_mask && *mmc_dev (host)->dma_mask) + limit = (u64 )dma_max_pfn (mmc_dev (host)) <<PAGE_SHIFT ; + +queue_flag_set_unlocked (QUEUE_FLAG_NONROT , mq->queue); +queue_flag_clear_unlocked (QUEUE_FLAG_ADD_RANDOM , mq->queue); +if (mmc_can_erase (card)) +mmc_queue_setup_discard (mq->queue, card); + + card->bouncesz =mmc_queue_calc_bouncesz (host); +if (card->bouncesz) { +blk_queue_max_hw_sectors (mq->queue, card->bouncesz /512 ); +blk_queue_max_segments (mq->queue, card->bouncesz /512 ); +blk_queue_max_segment_size (mq->queue, card->bouncesz); + }else { +blk_queue_bounce_limit (mq->queue, limit); +blk_queue_max_hw_sectors (mq->queue, +min (host->max_blk_count, host->max_req_size /512 )); +blk_queue_max_segments (mq->queue, host->max_segs); +blk_queue_max_segment_size (mq->queue, host->max_seg_size); + } + +/* Initialize thread_sem even if it is not used */ +sema_init (&mq->thread_sem,1 ); +} +/** * mmc_init_queue - initialise a queue structure. * @mq: mmc queue
@@ -236,12 +266,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, spinlock_t *lock, const char *subname) { struct mmc_host *host = card->host; -u64 limit =BLK_BOUNCE_HIGH ;int ret = -ENOMEM ; -if (mmc_dev (host)->dma_mask && *mmc_dev (host)->dma_mask) - limit = (u64 )dma_max_pfn (mmc_dev (host)) <<PAGE_SHIFT ; - mq->card = card; mq->queue =blk_alloc_queue (GFP_KERNEL );if (!mq->queue)
@@ -260,25 +286,8 @@ int mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card, }blk_queue_prep_rq (mq->queue, mmc_prep_request); -queue_flag_set_unlocked (QUEUE_FLAG_NONROT , mq->queue); -queue_flag_clear_unlocked (QUEUE_FLAG_ADD_RANDOM , mq->queue); -if (mmc_can_erase (card)) -mmc_queue_setup_discard (mq->queue, card); - card->bouncesz =mmc_queue_calc_bouncesz (host); -if (card->bouncesz) { -blk_queue_max_hw_sectors (mq->queue, card->bouncesz /512 ); -blk_queue_max_segments (mq->queue, card->bouncesz /512 ); -blk_queue_max_segment_size (mq->queue, card->bouncesz); - }else { -blk_queue_bounce_limit (mq->queue, limit); -blk_queue_max_hw_sectors (mq->queue, -min (host->max_blk_count, host->max_req_size /512 )); -blk_queue_max_segments (mq->queue, host->max_segs); -blk_queue_max_segment_size (mq->queue, host->max_seg_size); - } - -sema_init (&mq->thread_sem,1 ); +mmc_setup_queue (mq, card); mq->thread =kthread_run (mmc_queue_thread, mq,"mmcqd/%d%s" , host->index, subname ? subname :"" );
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v7 8/10 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
CQE offers 25% - 50% better random multi-threaded I/O. There is a slight (e.g. 2%) drop in sequential read speed but no observable change to sequential write.
CQE automatically sends the commands to complete requests. However it only supports reads / writes and so-called "direct commands" (DCMD). Furthermore DCMD is limited to one command at a time, but discards require 3 commands. That makes issuing discards through CQE very awkward, but some CQE's don't support DCMD anyway. So for discards, the existing non-CQE approach is taken, where the mmc core code issues the 3 commands one at a time i.e. mmc_erase(). Where DCMD is used, is for issuing flushes.
--- drivers/mmc/core/block.c | 217 +++++++++++++++++++++++++- drivers/mmc/core/block.h | 7 + drivers/mmc/core/queue.c | 385 ++++++++++++++++++++++++++++++++++++++++++++--- drivers/mmc/core/queue.h | 46 +++++- 4 files changed, 626 insertions(+), 29 deletions(-)
drivers/mmc/core/block.c +213 -4
@@ -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
@@ -1266,7 +1267,10 @@ static void mmc_blk_issue_discard_rq(struct mmc_queue *mq, struct request *req)else mmc_blk_reset_success (md, type); fail: -blk_end_request (req, status,blk_rq_bytes (req)); +if (req->mq_ctx) +blk_mq_end_request (req, status); +else +blk_end_request (req, status,blk_rq_bytes (req)); } static void mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,
@@ -1336,7 +1340,10 @@ static void mmc_blk_issue_secdiscard_rq(struct mmc_queue *mq,if (!err)mmc_blk_reset_success (md, type); out: -blk_end_request (req, status,blk_rq_bytes (req)); +if (req->mq_ctx) +blk_mq_end_request (req, status); +else +blk_end_request (req, status,blk_rq_bytes (req)); }static void mmc_blk_issue_flush (struct mmc_queue *mq,struct request *req)
@@ -1346,7 +1353,10 @@ static void mmc_blk_issue_flush(struct mmc_queue *mq, struct request *req)int ret =0 ; ret =mmc_flush_cache (card); -blk_end_request_all (req, ret ?BLK_STS_IOERR :BLK_STS_OK ); +if (req->mq_ctx) +blk_mq_end_request (req, ret ?BLK_STS_IOERR :BLK_STS_OK ); +else +blk_end_request_all (req, ret ?BLK_STS_IOERR :BLK_STS_OK ); }/*
@@ -1659,6 +1669,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_to_mmc_queue_req (req); +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); + +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) { +if (mqrq->retries++ <MMC_CQE_RETRIES ) +blk_mq_requeue_request (req, true); +else +blk_mq_end_request (req,BLK_STS_IOERR ); + }else if (mrq->data) { +if (blk_update_request (req,BLK_STS_OK , mrq->data->bytes_xfered)) +blk_mq_requeue_request (req, true); +else +__blk_mq_end_request (req,BLK_STS_OK ); + }else { +blk_mq_end_request (req,BLK_STS_OK ); + } + +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_cqe_check_busy (mq); + +spin_unlock_irqrestore (q->queue_lock, flags); + +if (!mq->cqe_busy) +blk_mq_run_hw_queues (q, true); + +if (put_card) +mmc_ctx_put_card (mq->card, &mq->ctx); +} + +void mmc_blk_cqe_recovery (struct mmc_queue *mq) +{ +struct mmc_card *card = mq->card; +struct mmc_host *host = card->host; +int err; + +mmc_get_card (card); + +pr_debug ("%s: CQE recovery start\n" ,mmc_hostname (host)); + + mq->cqe_in_recovery = true; + + err =mmc_cqe_recovery (host); +if (err) +mmc_blk_reset (mq->blkdata, host,MMC_BLK_CQE_RECOVERY ); +else +mmc_blk_reset_success (mq->blkdata,MMC_BLK_CQE_RECOVERY ); + + mq->cqe_in_recovery = false; + +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); +struct request *req =mmc_queue_req_to_req (mqrq); +struct request_queue *q = req->q; +struct mmc_queue *mq = q->queuedata; + +/* +* Block layer timeouts race with completions which means the normal +* completion path cannot be used during recovery. +*/ +if (mq->cqe_in_recovery) +mmc_blk_cqe_complete_rq (req); +else +blk_mq_complete_request (req); +} + +static int mmc_blk_cqe_start_req (struct mmc_host *host,struct mmc_request *mrq) +{ + mrq->done = mmc_blk_cqe_req_done; + mrq->recovery_notifier = mmc_cqe_recovery_notifier; + +return mmc_cqe_start_req (host, mrq); +} + +static struct mmc_request *mmc_blk_cqe_prep_dcmd (struct mmc_queue_req *mqrq, +struct request *req) +{ +struct mmc_blk_request *brq = &mqrq->brq; + +memset (brq,0 ,sizeof (*brq)); + + brq->mrq.cmd = &brq->cmd; + brq->mrq.tag = 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_to_mmc_queue_req (req); +struct mmc_request *mrq =mmc_blk_cqe_prep_dcmd (mqrq, req); + + 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_to_mmc_queue_req (req); + +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->part_type); +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_DRV_IN : +case REQ_OP_DRV_OUT : +mmc_blk_issue_drv_op (mq, req); +break ; +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 : +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 ; +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,
@@ -2094,7 +2303,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 +361 -24
463 lines not on this page · raw message
drivers/mmc/core/queue.h +45 -1
77 lines not on this page · raw message
Signature · 1 line
1.9.1
Adrian Hunter
maintainerPATCH v7 9/10 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 | 1154 +++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/host/cqhci.h | 240 ++++++++++ 4 files changed, 1408 insertions(+) create mode 100644 drivers/mmc/host/cqhci.c create mode 100644 drivers/mmc/host/cqhci.h
drivers/mmc/host/Kconfig +13 -0
@@ -843,6 +843,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
@@ -89,6 +89,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 +1154 -0
1,154 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
Adrian Hunter
maintainerPATCH v7 10/10 mmc: sdhci-pci: Add CQHCI support for Intel GLK
In reply to Adrian HunterAdd CQHCI initialization and implement CQHCI operations for Intel GLK.
--- drivers/mmc/host/Kconfig | 1 + drivers/mmc/host/sdhci-pci-core.c | 154 +++++++++++++++++++++++++++++++++++++- 2 files changed, 154 insertions(+), 1 deletion(-)
drivers/mmc/host/Kconfig +1 -0
@@ -81,6 +81,7 @@ config MMC_SDHCI_BIG_ENDIAN_32BIT_BYTE_SWAPPER config MMC_SDHCI_PCI tristate "SDHCI support on PCI bus" depends on MMC_SDHCI && PCI + select MMC_CQHCI help This selects the PCI Secure Digital Host Controller Interface. Most controllers found today are PCI devices.
drivers/mmc/host/sdhci-pci-core.c +153 -1
205 lines not on this page · raw message
Signature · 1 line
1.9.1
Adrian Hunter
maintainerQuoted 5 lines · Adrian Hunter
Here is V7 of the hardware command queue patches without the software command queue patches, now using blk-mq.
HW CMDQ offers 25% - 50% better random multi-threaded I/O. I see a slight 2% drop in sequential read speed but no change to sequential write.
Any comments?
+ Christoph
Quoted 8 lines · Adrian Hunter
Quoted 5 lines · Adrian Hunter
Here is V7 of the hardware command queue patches without the software command queue patches, now using blk-mq.
HW CMDQ offers 25% - 50% better random multi-threaded I/O. I see a slight 2% drop in sequential read speed but no change to sequential write.
Any comments?
A couple of overall comments, for now.
To make sure we don't overlook something when converting to mq, I would prefer that we first convert the existing mmc block code to mq, then we add CMDQ on top.
Regarding patch1. in the long-term solution, we should really strive towards getting rid of the big mmc host lock, as it causes us to lose some of the benefits on which principles mq is designed upon.
However, it may be feasible to use patch1 as an intermediate step, to be able to convert to mq short term. Then we can continue doing the re-factoring, to get rid of the big mmc host lock and solve other relates issues/optimize things. What remains to be seen in this approach, is how well mq performs, as we would still be using the big mmc host lock. We may tolerate some minor regressions, but if too much, there is no other way that first removing the big mmc lock.
Of course, if Linus/Christoph don't think this intermediate approach is good enough, we will have to respect that as well.
Kind regards
Uffe
Adrian Hunter
maintainerQuoted 10 lines · Ulf Hansson
+ Christoph
Quoted 7 lines · Adrian Hunter
Quoted 5 lines · Adrian Hunter
Here is V7 of the hardware command queue patches without the software command queue patches, now using blk-mq.
HW CMDQ offers 25% - 50% better random multi-threaded I/O. I see a slight 2% drop in sequential read speed but no change to sequential write.
Quoted 7 lines
Quoted 1 line
Any comments?
A couple of overall comments, for now.
To make sure we don't overlook something when converting to mq, I would prefer that we first convert the existing mmc block code to mq, then we add CMDQ on top.
That doesn't make sense. This patch set is not converting the legacy driver to mq therefore it cannot overlook anything for converting to mq.
Quoted 4 lines
Regarding patch1. in the long-term solution, we should really strive towards getting rid of the big mmc host lock, as it causes us to lose some of the benefits on which principles mq is designed upon.
Lose what benefits?
Quoted 7 lines
However, it may be feasible to use patch1 as an intermediate step, to be able to convert to mq short term. Then we can continue doing the re-factoring, to get rid of the big mmc host lock and solve other relates issues/optimize things. What remains to be seen in this approach, is how well mq performs, as we would still be using the big mmc host lock. We may tolerate some minor regressions, but if too much, there is no other way that first removing the big mmc lock.
Unlike HDDs, eMMC must switch between internal partitions (LUNs) so there must a way to arbitrate between them.
Quoted 2 lines
Of course, if Linus/Christoph don't think this intermediate approach is good enough, we will have to respect that as well.
Adrian Hunter
maintainerQuoted 13 lines · Adrian Hunter
Quoted 12 lines · Ulf Hansson
+ Christoph
Quoted 8 lines · Adrian Hunter
Quoted 5 lines · Adrian Hunter
Here is V7 of the hardware command queue patches without the software command queue patches, now using blk-mq.
HW CMDQ offers 25% - 50% better random multi-threaded I/O. I see a slight 2% drop in sequential read speed but no change to sequential write.
Any comments?
Quoted 8 lines
Quoted 5 lines
A couple of overall comments, for now.
To make sure we don't overlook something when converting to mq, I would prefer that we first convert the existing mmc block code to mq, then we add CMDQ on top.
That doesn't make sense. This patch set is not converting the legacy driver to mq therefore it cannot overlook anything for converting to mq.
And then you go silent again.
I can send blk-mq support for legacy requests in a few days if you like, but I want to hear a better explanation of why you are delaying CQE support.
Quoted 16 lines · Adrian Hunter
Quoted 15 lines · Adrian Hunter
Quoted 14 lines · Ulf Hansson
+ Christoph
Quoted 8 lines · Adrian Hunter
Quoted 5 lines · Adrian Hunter
Here is V7 of the hardware command queue patches without the software command queue patches, now using blk-mq.
HW CMDQ offers 25% - 50% better random multi-threaded I/O. I see a slight 2% drop in sequential read speed but no change to sequential write.
Any comments?
A couple of overall comments, for now.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
To make sure we don't overlook something when converting to mq, I would prefer that we first convert the existing mmc block code to mq, then we add CMDQ on top.
That doesn't make sense. This patch set is not converting the legacy driver to mq therefore it cannot overlook anything for converting to mq.
And then you go silent again.
We have weekends in Sweden - and I also work on other things than mmc :-).
I do however admit, that I could have been reviewing a bit faster throughout the re-spins. Apologize for that, but I am only doing my best.
Quoted 3 lines
I can send blk-mq support for legacy requests in a few days if you like, but I want to hear a better explanation of why you are delaying CQE support.
That would be very nice, however be aware of that we are in the merge window, so I am not picking new material for 4.14 from this point. I assume you understand why.
Still, big changes is always nice to queue up early for a release cycle. Let's aim for that!
Moreover, I am not delaying CQE, but really want it to be merged asap! However, I am also having the role as a maintainer and the things that comes with it. For example, I would like the community to reach consensus around how to move forward with CQE, before I decide to pick it up.
Kind regards
Uffe
Adrian Hunter
maintainerQuoted 33 lines · Ulf Hansson
Quoted 16 lines · Adrian Hunter
Quoted 15 lines · Adrian Hunter
Quoted 14 lines · Ulf Hansson
+ Christoph
Quoted 8 lines · Adrian Hunter
Quoted 5 lines · Adrian Hunter
Here is V7 of the hardware command queue patches without the software command queue patches, now using blk-mq.
HW CMDQ offers 25% - 50% better random multi-threaded I/O. I see a slight 2% drop in sequential read speed but no change to sequential write.
Any comments?
A couple of overall comments, for now.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
To make sure we don't overlook something when converting to mq, I would prefer that we first convert the existing mmc block code to mq, then we add CMDQ on top.
That doesn't make sense. This patch set is not converting the legacy driver to mq therefore it cannot overlook anything for converting to mq.
And then you go silent again.
We have weekends in Sweden - and I also work on other things than mmc :-).
I do however admit, that I could have been reviewing a bit faster throughout the re-spins. Apologize for that, but I am only doing my best.
Quoted 1 line
Quoted 6 lines
Quoted 2 lines
I can send blk-mq support for legacy requests in a few days if you like, but I want to hear a better explanation of why you are delaying CQE support.
That would be very nice, however be aware of that we are in the merge window, so I am not picking new material for 4.14 from this point. I assume you understand why.
Nope. This is new functionality - doesn't affect anyone who doesn't have a command queue engine. Next to no chance of regressions. Tested by several in the community. Substantially unchanged since February. It is not even very much code in the block driver.
Quoted 3 lines
Still, big changes is always nice to queue up early for a release cycle. Let's aim for that!
You said that in February. Never happened. You said you wanted blk-mq, so I waited to re-base on top, but it never appeared.
Quoted 5 lines
Moreover, I am not delaying CQE, but really want it to be merged asap! However, I am also having the role as a maintainer and the things that comes with it. For example, I would like the community to reach consensus around how to move forward with CQE, before I decide to pick it up.
It has been more than 6 months. That is enough time to wait for "consensus".
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
I can send blk-mq support for legacy requests in a few days if you like, but I want to hear a better explanation of why you are delaying CQE support.
Quoted 8 lines
Quoted 3 lines
That would be very nice, however be aware of that we are in the merge window, so I am not picking new material for 4.14 from this point. I assume you understand why.
Nope. This is new functionality - doesn't affect anyone who doesn't have a command queue engine. Next to no chance of regressions. Tested by several in the community. Substantially unchanged since February. It is not even very much code in the block driver.
Let me make it clear, once more - I don't want to maintain more hacks in mmc block layer code.
This series add blkmq support, using a method (which may be considered as intermediate) via a new change in patch1 - but only for the new CQE path. That means the old legacy mmc block path is still there. So, for the reason stated above - no thanks!
Quoted 7 lines
Quoted 4 lines
Still, big changes is always nice to queue up early for a release cycle. Let's aim for that!
You said that in February. Never happened. You said you wanted blk-mq, so I waited to re-base on top, but it never appeared.
Yes, I want blkmq - and I believe I have explained why several times by now.
Unfortunate, blkmq just doesn't appear, we have to work on it - together.
Quoted 8 lines
Quoted 6 lines
Moreover, I am not delaying CQE, but really want it to be merged asap! However, I am also having the role as a maintainer and the things that comes with it. For example, I would like the community to reach consensus around how to move forward with CQE, before I decide to pick it up.
It has been more than 6 months. That is enough time to wait for "consensus".
Normally it should be more than enough, on the other hand, it has turned out this was more complex than we first thought.
Kind regards
Uffe
Adrian Hunter
maintainerQuoted 15 lines · Ulf Hansson
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
I can send blk-mq support for legacy requests in a few days if you like, but I want to hear a better explanation of why you are delaying CQE support.
Quoted 8 lines
Quoted 3 lines
That would be very nice, however be aware of that we are in the merge window, so I am not picking new material for 4.14 from this point. I assume you understand why.
Nope. This is new functionality - doesn't affect anyone who doesn't have a command queue engine. Next to no chance of regressions. Tested by several in the community. Substantially unchanged since February. It is not even very much code in the block driver.
Quoted 7 lines
Let me make it clear, once more - I don't want to maintain more hacks in mmc block layer code.
This series add blkmq support, using a method (which may be considered as intermediate) via a new change in patch1 - but only for the new CQE path. That means the old legacy mmc block path is still there. So, for the reason stated above - no thanks!
And where is your alternative. When I pointed out you need a way to arbitrate between internal partitions, you went silent again.
Can't have CQE without blk-mq but can't have blk-mq because you don't understand it, is hardly acceptable.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Still, big changes is always nice to queue up early for a release cycle. Let's aim for that!
Quoted 6 lines
Quoted 2 lines
You said that in February. Never happened. You said you wanted blk-mq, so I waited to re-base on top, but it never appeared.
Yes, I want blkmq - and I believe I have explained why several times by now.
Unfortunate, blkmq just doesn't appear, we have to work on it - together.
If we are working on it together, how come you have never taken the time to find out how blk-mq works?
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Moreover, I am not delaying CQE, but really want it to be merged asap! However, I am also having the role as a maintainer and the things that comes with it. For example, I would like the community to reach consensus around how to move forward with CQE, before I decide to pick it up.
Quoted 4 lines
Quoted 1 line
It has been more than 6 months. That is enough time to wait for "consensus".
Normally it should be more than enough, on the other hand, it has turned out this was more complex than we first thought.
Nonsense. I have raised the issues time and again but there have never been any replies.
Quoted 24 lines · Adrian Hunter
Quoted 15 lines · Ulf Hansson
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
I can send blk-mq support for legacy requests in a few days if you like, but I want to hear a better explanation of why you are delaying CQE support.
Quoted 8 lines
Quoted 3 lines
That would be very nice, however be aware of that we are in the merge window, so I am not picking new material for 4.14 from this point. I assume you understand why.
Nope. This is new functionality - doesn't affect anyone who doesn't have a command queue engine. Next to no chance of regressions. Tested by several in the community. Substantially unchanged since February. It is not even very much code in the block driver.
Quoted 7 lines
Let me make it clear, once more - I don't want to maintain more hacks in mmc block layer code.
This series add blkmq support, using a method (which may be considered as intermediate) via a new change in patch1 - but only for the new CQE path. That means the old legacy mmc block path is still there. So, for the reason stated above - no thanks!
Quoted 5 lines
And where is your alternative. When I pointed out you need a way to arbitrate between internal partitions, you went silent again.
Can't have CQE without blk-mq but can't have blk-mq because you don't understand it, is hardly acceptable.
Adrian, this discussion seems to lead nowhere. Can we please stop and be constructive instead!
Regarding the arbitration issue. We have been moving forward, re-factoring the mmc block driver code, soon also solving the problem for the rpmb internal partition [1]. Maybe the background to why Linus is working on mmc block re-factoring, hasn't been entirely clear. Anyway, it's exactly because of moving closer to address these issues.
Even if the problems certainly becomes a step harder to resolve for the boot and the general purpose partitions, it's still a path we should try to find a solution for. Yeah, that may mean we need to suggest changes for the generic block layer, to teach it to better deal with these kind of devices.
Finally, I have never said the arbitration issue *must* be solved before converting to blkmq. Only that we should avoid performance regressions, but that of course applies to whatever changes we do.
[...]
Kind regards
Uffe
Adrian Hunter
maintainerQuoted 25 lines · Ulf Hansson
Quoted 24 lines · Adrian Hunter
Quoted 22 lines · Ulf Hansson
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
I can send blk-mq support for legacy requests in a few days if you like, but I want to hear a better explanation of why you are delaying CQE support.
Quoted 8 lines
Quoted 3 lines
That would be very nice, however be aware of that we are in the merge window, so I am not picking new material for 4.14 from this point. I assume you understand why.
Nope. This is new functionality - doesn't affect anyone who doesn't have a command queue engine. Next to no chance of regressions. Tested by several in the community. Substantially unchanged since February. It is not even very much code in the block driver.
Let me make it clear, once more - I don't want to maintain more hacks in mmc block layer code.
This series add blkmq support, using a method (which may be considered as intermediate) via a new change in patch1 - but only for the new CQE path. That means the old legacy mmc block path is still there. So, for the reason stated above - no thanks!
Quoted 8 lines
Quoted 5 lines
And where is your alternative. When I pointed out you need a way to arbitrate between internal partitions, you went silent again.
Can't have CQE without blk-mq but can't have blk-mq because you don't understand it, is hardly acceptable.
Adrian, this discussion seems to lead nowhere. Can we please stop and be constructive instead!
If you want to be constructive you will queue CQE support for v4.15 now!
Quoted 6 lines
Regarding the arbitration issue. We have been moving forward, re-factoring the mmc block driver code, soon also solving the problem for the rpmb internal partition [1]. Maybe the background to why Linus is working on mmc block re-factoring, hasn't been entirely clear. Anyway, it's exactly because of moving closer to address these issues.
Nope, wrt blk-mq you are moving sideways with no clear idea where you're going.
Quoted 5 lines
Even if the problems certainly becomes a step harder to resolve for the boot and the general purpose partitions, it's still a path we should try to find a solution for. Yeah, that may mean we need to suggest changes for the generic block layer, to teach it to better deal with these kind of devices.
You mean you have no idea how to do it but we are still expected to wait. How is that acceptable!
Quoted 3 lines
Finally, I have never said the arbitration issue *must* be solved before converting to blkmq. Only that we should avoid performance regressions, but that of course applies to whatever changes we do.
Then there is no problem in queuing up the CQE patches now!
Quoted 52 lines · Adrian Hunter
Quoted 25 lines · Ulf Hansson
Quoted 24 lines · Adrian Hunter
Quoted 22 lines · Ulf Hansson
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
I can send blk-mq support for legacy requests in a few days if you like, but I want to hear a better explanation of why you are delaying CQE support.
Quoted 8 lines
Quoted 3 lines
That would be very nice, however be aware of that we are in the merge window, so I am not picking new material for 4.14 from this point. I assume you understand why.
Nope. This is new functionality - doesn't affect anyone who doesn't have a command queue engine. Next to no chance of regressions. Tested by several in the community. Substantially unchanged since February. It is not even very much code in the block driver.
Let me make it clear, once more - I don't want to maintain more hacks in mmc block layer code.
This series add blkmq support, using a method (which may be considered as intermediate) via a new change in patch1 - but only for the new CQE path. That means the old legacy mmc block path is still there. So, for the reason stated above - no thanks!
Quoted 8 lines
Quoted 5 lines
And where is your alternative. When I pointed out you need a way to arbitrate between internal partitions, you went silent again.
Can't have CQE without blk-mq but can't have blk-mq because you don't understand it, is hardly acceptable.
Adrian, this discussion seems to lead nowhere. Can we please stop and be constructive instead!
If you want to be constructive you will queue CQE support for v4.15 now!
Quoted 6 lines
Regarding the arbitration issue. We have been moving forward, re-factoring the mmc block driver code, soon also solving the problem for the rpmb internal partition [1]. Maybe the background to why Linus is working on mmc block re-factoring, hasn't been entirely clear. Anyway, it's exactly because of moving closer to address these issues.
Nope, wrt blk-mq you are moving sideways with no clear idea where you're going.
Quoted 5 lines
Even if the problems certainly becomes a step harder to resolve for the boot and the general purpose partitions, it's still a path we should try to find a solution for. Yeah, that may mean we need to suggest changes for the generic block layer, to teach it to better deal with these kind of devices.
Quoted 8 lines
You mean you have no idea how to do it but we are still expected to wait. How is that acceptable!
Quoted 3 lines
Finally, I have never said the arbitration issue *must* be solved before converting to blkmq. Only that we should avoid performance regressions, but that of course applies to whatever changes we do.
Then there is no problem in queuing up the CQE patches now!
Either you are not paying attention or just being grumpy.
So for the last time, I don't want to pick CQE, prior the existing mmc block code has converted to blkmq.
End of discussion!
Kind regards
Uffe
Adrian Hunter
maintainerQuoted 60 lines · Ulf Hansson
Quoted 59 lines · Adrian Hunter
Quoted 25 lines · Ulf Hansson
Quoted 24 lines · Adrian Hunter
Quoted 22 lines · Ulf Hansson
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
I can send blk-mq support for legacy requests in a few days if you like, but I want to hear a better explanation of why you are delaying CQE support.
Quoted 8 lines
Quoted 3 lines
That would be very nice, however be aware of that we are in the merge window, so I am not picking new material for 4.14 from this point. I assume you understand why.
Nope. This is new functionality - doesn't affect anyone who doesn't have a command queue engine. Next to no chance of regressions. Tested by several in the community. Substantially unchanged since February. It is not even very much code in the block driver.
Let me make it clear, once more - I don't want to maintain more hacks in mmc block layer code.
This series add blkmq support, using a method (which may be considered as intermediate) via a new change in patch1 - but only for the new CQE path. That means the old legacy mmc block path is still there. So, for the reason stated above - no thanks!
Quoted 8 lines
Quoted 5 lines
And where is your alternative. When I pointed out you need a way to arbitrate between internal partitions, you went silent again.
Can't have CQE without blk-mq but can't have blk-mq because you don't understand it, is hardly acceptable.
Adrian, this discussion seems to lead nowhere. Can we please stop and be constructive instead!
If you want to be constructive you will queue CQE support for v4.15 now!
Quoted 6 lines
Regarding the arbitration issue. We have been moving forward, re-factoring the mmc block driver code, soon also solving the problem for the rpmb internal partition [1]. Maybe the background to why Linus is working on mmc block re-factoring, hasn't been entirely clear. Anyway, it's exactly because of moving closer to address these issues.
Nope, wrt blk-mq you are moving sideways with no clear idea where you're going.
Quoted 5 lines
Even if the problems certainly becomes a step harder to resolve for the boot and the general purpose partitions, it's still a path we should try to find a solution for. Yeah, that may mean we need to suggest changes for the generic block layer, to teach it to better deal with these kind of devices.
You mean you have no idea how to do it but we are still expected to wait. How is that acceptable!
Quoted 3 lines
Finally, I have never said the arbitration issue *must* be solved before converting to blkmq. Only that we should avoid performance regressions, but that of course applies to whatever changes we do.
Quoted 6 lines
Quoted 1 line
Then there is no problem in queuing up the CQE patches now!
Either you are not paying attention or just being grumpy.
So for the last time, I don't want to pick CQE, prior the existing mmc block code has converted to blkmq.
Which is unreasonable and unacceptable.
Quoted 1 line
End of discussion!
Hardly. I plan to submit blk-mq patches in a few days and I expect a proper response. Not silence. Not "consensus". And especially not "we want to do it a different way but we don't know what that is".