mmc: Add Command Queue support
Subsystems (5)
Adrian Hunter
maintainerv5 cover mmc: Add Command Queue support
Hi
Here is V5 of the hardware command queue patches without the software command queue patches.
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 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 (12):
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: core: Remove unused MMC_CAP2_PACKED_CMD
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: 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 | 238 +++++++- drivers/mmc/core/block.h | 7 + drivers/mmc/core/bus.c | 7 + drivers/mmc/core/core.c | 178 +++++- drivers/mmc/core/host.c | 6 + drivers/mmc/core/host.h | 1 + drivers/mmc/core/mmc.c | 42 +- drivers/mmc/core/queue.c | 273 ++++++++- drivers/mmc/core/queue.h | 42 +- 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 | 153 ++++- include/linux/mmc/core.h | 18 +- include/linux/mmc/host.h | 63 +- include/trace/events/mmc.h | 36 +- 17 files changed, 2412 insertions(+), 61 deletions(-) create mode 100644 drivers/mmc/host/cqhci.c create mode 100644 drivers/mmc/host/cqhci.h
Regards
Adrian
Adrian Hunter
maintainerPATCH v5 1/13 mmc: core: Add mmc_retune_hold_now()
mmc_return_hold() / mmc_retune_release() are used around a group of commands to prevent re-tuning between the commands. Re-tuning can still happen before the first command. In some cases, re-tuning must be prevented entirely. Add mmc_retune_hold_now() for that purpose. It is added in preparation for CQE support where it will be used by CQE recovery.
--- drivers/mmc/core/host.c | 6 ++++++ drivers/mmc/core/host.h | 1 + 2 files changed, 7 insertions(+)
drivers/mmc/core/host.c +6 -0
@@ -111,6 +111,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
Re: [PATCH V5 01/13] mmc: core: Add mmc_retune_hold_now()
Quoted 7 lines · Adrian Hunter
mmc_return_hold()/mmc_retune_release()are used around a group of commands to prevent re-tuning between the commands. Re-tuning can still happen before the first command. In some cases, re-tuning must be prevented entirely. Addmmc_retune_hold_now()for that purpose. It is added in preparation for CQE support where it will be used by CQE recovery.Signed-off-by Adrian Hunter <[email protected]>
Quoted 2 lines
+void
mmc_retune_hold_now(struct mmc_host *host)
voidmmc_retune_release(struct mmc_host *host)
If the only hint we have about how to use these functions is through the commit log we are in trouble, but I would say in this case the function name is kind of half-obvious at least.
I think what troubles me is Rusty's API maturity guideline #6 "6. The name tells you how to use it."
Yours,
Linus Walleij
Ulf Hansson
AppliedRe: [PATCH V5 01/13] mmc: core: Add mmc_retune_hold_now()
In reply to Adrian HunterQuoted 7 lines · Adrian Hunter
mmc_return_hold()/mmc_retune_release()are used around a group of commands to prevent re-tuning between the commands. Re-tuning can still happen before the first command. In some cases, re-tuning must be prevented entirely. Addmmc_retune_hold_now()for that purpose. It is added in preparation for CQE support where it will be used by CQE recovery.Signed-off-by Adrian Hunter <[email protected]>
Thanks, applied for next!
Kind regards
Uffe
Quoted 37 lines
--- drivers/mmc/core/host.c | 6 ++++++ drivers/mmc/core/host.h | 1 + 2 files changed, 7 insertions(+)drivers/mmc/core/host.c +6
-0@@ -111,6 +111,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
-1@@ -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); --1.9.1
Adrian Hunter
maintainerPATCH v5 2/13 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), and allow for cmd being NULL which it is for CQE tasks.
--- include/linux/mmc/core.h | 13 +++++++++++-- include/trace/events/mmc.h | 36 +++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 15 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 +23 -13
@@ -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)
@@ -42,10 +44,10 @@ ),TP_fast_assign ( - __entry->cmd_opcode = mrq->cmd->opcode; - __entry->cmd_arg = mrq->cmd->arg; - __entry->cmd_flags = mrq->cmd->flags; - __entry->cmd_retries = mrq->cmd->retries; + __entry->cmd_opcode = mrq->cmd ? mrq->cmd->opcode : 0; + __entry->cmd_arg = mrq->cmd ? mrq->cmd->arg :0 ; + __entry->cmd_flags = mrq->cmd ? mrq->cmd->flags :0 ; + __entry->cmd_retries = mrq->cmd ? mrq->cmd->retries :0 ; __entry->stop_opcode = mrq->stop ? mrq->stop->opcode :0 ; __entry->stop_arg = mrq->stop ? mrq->stop->arg :0 ; __entry->stop_flags = mrq->stop ? mrq->stop->flags :0 ;
@@ -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)
@@ -119,10 +125,13 @@ ),TP_fast_assign ( - __entry->cmd_opcode = mrq->cmd->opcode; - __entry->cmd_err = mrq->cmd->error; -memcpy (__entry->cmd_resp, mrq->cmd->resp,4 ); - __entry->cmd_retries = mrq->cmd->retries; + __entry->cmd_opcode = mrq->cmd ? mrq->cmd->opcode : 0; + __entry->cmd_err = mrq->cmd ? mrq->cmd->error :0 ; + __entry->cmd_resp[0 ] = mrq->cmd ? mrq->cmd->resp[0 ] :0 ; + __entry->cmd_resp[1 ] = mrq->cmd ? mrq->cmd->resp[1 ] :0 ; + __entry->cmd_resp[2 ] = mrq->cmd ? mrq->cmd->resp[2 ] :0 ; + __entry->cmd_resp[3 ] = mrq->cmd ? mrq->cmd->resp[3 ] :0 ; + __entry->cmd_retries = mrq->cmd ? mrq->cmd->retries :0 ; __entry->stop_opcode = mrq->stop ? mrq->stop->opcode :0 ; __entry->stop_err = mrq->stop ? mrq->stop->error :0 ; __entry->stop_resp[0 ] = mrq->stop ? mrq->stop->resp[0 ] :0 ;
@@ -139,6 +148,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 +164,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 +180,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
Re: [PATCH V5 02/13] mmc: core: Add members to mmc_request and mmc_data for CQE's
Quoted 8 lines · Adrian Hunter
Most of the information needed to issue requests to a CQE is already in struct
mmc_requestand structmmc_data. Add data block address, some flags, and the task id (tag), and allow for cmd being NULL which it is for CQE tasks.Signed-off-by Adrian Hunter <[email protected]>+ int tag;
Is this consistent with the block layer idea of "tag"?
I am asking because I get confused.
I thought the block layers idea of a "tag" was some metadata associated with a request. Not that I am a block layer expert. Why can't we just name this "task_id" if that is what it is in Linux terms? Does the specification call it "tag"?
Yours,
Linus Walleij
Adrian Hunter
maintainerRe: [PATCH V5 02/13] mmc: core: Add members to mmc_request and mmc_data for CQE's
Quoted 7 lines · Linus Walleij
Quoted 5 lines · Adrian Hunter
Most of the information needed to issue requests to a CQE is already in struct
mmc_requestand structmmc_data. Add data block address, some flags, and the task id (tag), and allow for cmd being NULL which it is for CQE tasks.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Adrian Hunter <[email protected]>+ int tag;
Is this consistent with the block layer idea of "tag"?
It is named "tag" because it is the block layer tag.
Quoted 5 lines
I am asking because I get confused.
I thought the block layers idea of a "tag" was some metadata associated with a request. Not that I am a block layer expert.
The block layer tag is a unique number to identify the task to the hardware queue. It is typically a number from 0 up to queue depth - 1.
Quoted 2 lines
Why can't we just name this "
task_id" if that is what it is in Linux terms? Does the specification call it "tag"?
The eMMC specification calls it "task id" but the block layer calls it "tag". I went with "tag" to be easier for block layer people to understand.
Ulf Hansson
AppliedRe: [PATCH V5 02/13] mmc: core: Add members to mmc_request and mmc_data for CQE's
In reply to Adrian HunterQuoted 6 lines · Adrian Hunter
Most of the information needed to issue requests to a CQE is already in struct
mmc_requestand structmmc_data. Add data block address, some flags, and the task id (tag), and allow for cmd being NULL which it is for CQE tasks.Signed-off-by Adrian Hunter <[email protected]>
Thanks, applied for next!
Kind regards
Uffe
Quoted 155 lines
--- include/linux/mmc/core.h | 13 +++++++++++-- include/trace/events/mmc.h | 36 +++++++++++++++++++++++------------- 2 files changed, 34 insertions(+), 15 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 +23
-14@@ -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)@@ -42,10 +44,10 @@ ),TP_fast_assign ( - __entry->cmd_opcode = mrq->cmd->opcode; - __entry->cmd_arg = mrq->cmd->arg; - __entry->cmd_flags = mrq->cmd->flags; - __entry->cmd_retries = mrq->cmd->retries; + __entry->cmd_opcode = mrq->cmd ? mrq->cmd->opcode : 0; + __entry->cmd_arg = mrq->cmd ? mrq->cmd->arg :0 ; + __entry->cmd_flags = mrq->cmd ? mrq->cmd->flags :0 ; + __entry->cmd_retries = mrq->cmd ? mrq->cmd->retries :0 ; __entry->stop_opcode = mrq->stop ? mrq->stop->opcode :0 ; __entry->stop_arg = mrq->stop ? mrq->stop->arg :0 ; __entry->stop_flags = mrq->stop ? mrq->stop->flags :0 ;@@ -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)@@ -119,10 +125,13 @@ ),TP_fast_assign ( - __entry->cmd_opcode = mrq->cmd->opcode; - __entry->cmd_err = mrq->cmd->error; -memcpy (__entry->cmd_resp, mrq->cmd->resp,4 ); - __entry->cmd_retries = mrq->cmd->retries; + __entry->cmd_opcode = mrq->cmd ? mrq->cmd->opcode : 0; + __entry->cmd_err = mrq->cmd ? mrq->cmd->error :0 ; + __entry->cmd_resp[0 ] = mrq->cmd ? mrq->cmd->resp[0 ] :0 ; + __entry->cmd_resp[1 ] = mrq->cmd ? mrq->cmd->resp[1 ] :0 ; + __entry->cmd_resp[2 ] = mrq->cmd ? mrq->cmd->resp[2 ] :0 ; + __entry->cmd_resp[3 ] = mrq->cmd ? mrq->cmd->resp[3 ] :0 ; + __entry->cmd_retries = mrq->cmd ? mrq->cmd->retries :0 ; __entry->stop_opcode = mrq->stop ? mrq->stop->opcode :0 ; __entry->stop_err = mrq->stop ? mrq->stop->error :0 ; __entry->stop_resp[0 ] = mrq->stop ? mrq->stop->resp[0 ] :0 ;@@ -139,6 +148,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 +164,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 +180,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) --1.9.1
Adrian Hunter
maintainerPATCH v5 3/13 mmc: host: Add CQE interface
In reply to Adrian HunterAdd CQE host operations, capabilities, and host members.
--- include/linux/mmc/host.h | 59 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+)
include/linux/mmc/host.h +59 -0
@@ -162,6 +162,50 @@ struct mmc_host_ops { unsigned int direction, int blk_size); }; +struct mmc_cqe_ops { +/* Allocate resources, and make the CQE operational */ +int (*cqe_enable)(struct mmc_host *host,struct mmc_card *card); +/* Free resources, and make the CQE non-operational */ +void (*cqe_disable)(struct mmc_host *host); +/* +* Issue a read, write or DCMD request to the CQE. Also deal with the +* effect of ->cqe_off(). +*/ +int (*cqe_request)(struct mmc_host *host,struct mmc_request *mrq); +/* Free resources (e.g. DMA mapping) associated with the request */ +void (*cqe_post_req)(struct mmc_host *host,struct mmc_request *mrq); +/* +* Prepare the CQE and host controller to accept non-CQ commands. There +* is no corresponding ->cqe_on(), instead ->cqe_request() is required +* to deal with that. +*/ +void (*cqe_off)(struct mmc_host *host); +/* +* Wait for all CQE tasks to complete. Return an error if recovery +* becomes necessary. +*/ +int (*cqe_wait_for_idle)(struct mmc_host *host); +/* +* Notify CQE that a request has timed out. Return false if the request +* completed or true if a timeout happened in which case indicate if +* recovery is needed. +*/ +bool (*cqe_timeout)(struct mmc_host *host,struct mmc_request *mrq, +bool *recovery_needed); +/* +* Stop all CQE activity and prepare the CQE and host controller to +* accept recovery commands. +*/ +void (*cqe_recovery_start)(struct mmc_host *host); +/* +* Clear the queue and call mmc_cqe_request_done() on all requests. +* Requests that errored will have the error set on the mmc_request +* (data->error or cmd->error for DCMD). Requests that did not error +* will have zero data bytes transferred. +*/ +void (*cqe_recovery_finish)(struct mmc_host *host); +}; +struct mmc_async_req {/* active mmc request */ struct mmc_request *mrq;
@@ -307,6 +351,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 */
@@ -390,6 +436,19 @@ 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; +/* +* Notify uppers layers (e.g. mmc block driver) that CQE needs recovery +* due to an error associated with the mmc_request. +*/ +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
Re: [PATCH V5 03/13] mmc: host: Add CQE interface
Quoted 3 lines · Adrian Hunter
Add CQE host operations, capabilities, and host members.
Signed-off-by Adrian Hunter <[email protected]>
This looks like a clean and nice host-API to me.
Yours,
Linus Walleij
Ulf Hansson
AppliedRe: [PATCH V5 03/13] mmc: host: Add CQE interface
In reply to Adrian HunterQuoted 3 lines · Adrian Hunter
Add CQE host operations, capabilities, and host members.
Signed-off-by Adrian Hunter <[email protected]>
Thanks, applied for next! However with some minor comments, explained below.
[...]
include/linux/mmc/host.h struct mmc_host { · line 445
Quoted 8 lines
include/linux/mmc/host.h +7
-0+/* Command Queue Engine (CQE) support */ +const struct mmc_cqe_ops *cqe_ops; +void *cqe_private; +/* +* Notify uppers layers (e.g. mmc block driver) that CQE needs recovery +* due to an error associated with the mmc_request. +*/
Thanks for adding the explanation.
include/linux/mmc/host.h struct mmc_host { · line 447
Quoted 2 lines
include/linux/mmc/host.h +2
-0+void (*cqe_recovery_notifier)(struct mmc_host *, +struct mmc_request *);
Normally we don't put callbacks in the struct mmc_host that someone else than the host driver should assign - so this feels a bit upside down.
Is there any reason to why you didn't want to add a new API? Something like mmc_cqe_recover(), which the host driver could call.
Quoted 10 lines
include/linux/mmc/host.h +4
-1+int cqe_qdepth; +bool cqe_enabled; +bool cqe_on; +unsigned long private[0 ]____cacheline_aligned ; }; --1.9.1
Kind regards
Uffe
Adrian Hunter
maintainerRe: [PATCH V5 03/13] mmc: host: Add CQE interface
Quoted 10 lines · Ulf Hansson
include/linux/mmc/host.h struct mmc_host { · line 447
Quoted 2 lines · Adrian Hunter
include/linux/mmc/host.h +2
-0+void (*cqe_recovery_notifier)(struct mmc_host *, +struct mmc_request *);Normally we don't put callbacks in the struct
mmc_hostthat someone else than the host driver should assign - so this feels a bit upside down.Is there any reason to why you didn't want to add a new API? Something like
mmc_cqe_recover(), which the host driver could call.
That would make the host driver dependent on the block driver. There needs to be a function pointer, even if we wrap it in an API.
Re: [PATCH V5 03/13] mmc: host: Add CQE interface
Quoted 9 lines · Adrian Hunter
Quoted 8 lines · Ulf Hansson
include/linux/mmc/host.h struct mmc_host { · line 447
Quoted 2 lines · Adrian Hunter
include/linux/mmc/host.h +2
-0+void (*cqe_recovery_notifier)(struct mmc_host *, +struct mmc_request *);Normally we don't put callbacks in the struct
mmc_hostthat someone else than the host driver should assign - so this feels a bit upside down.
Quoted 5 lines
Quoted 2 lines
Is there any reason to why you didn't want to add a new API? Something like
mmc_cqe_recover(), which the host driver could call.That would make the host driver dependent on the block driver. There needs to be a function pointer, even if we wrap it in an API.
Okay, I see. I guess we could put such pointer somewhere closer to the mmc request queue.
Anyway, I didn't find out how this pointer was being protected from concurrent access or perhaps that is managed via mmc_claim|release_host()? Moreover, I could find it ever it being reset to NULL.
Kind regards
Uffe
Adrian Hunter
maintainerRe: [PATCH V5 03/13] mmc: host: Add CQE interface
Quoted 10 lines · Ulf Hansson
Quoted 9 lines · Adrian Hunter
Quoted 8 lines · Ulf Hansson
include/linux/mmc/host.h struct mmc_host { · line 447
Quoted 2 lines · Adrian Hunter
include/linux/mmc/host.h +2
-0+void (*cqe_recovery_notifier)(struct mmc_host *, +struct mmc_request *);Normally we don't put callbacks in the struct
mmc_hostthat someone else than the host driver should assign - so this feels a bit upside down.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Is there any reason to why you didn't want to add a new API? Something like
mmc_cqe_recover(), which the host driver could call.That would make the host driver dependent on the block driver. There needs to be a function pointer, even if we wrap it in an API.
Okay, I see. I guess we could put such pointer somewhere closer to the mmc request queue.
Another possibility is to put in into struct mmc_request like the "done" callback.
Quoted 4 lines
Anyway, I didn't find out how this pointer was being protected from concurrent access or perhaps that is managed via mmc_claim|release_host()?
It is assumed CQE is only used by the card driver so the callback can be set / reset in the card driver's probe / remove.
Quoted 2 lines
Moreover, I could find it ever it being
reset to NULL.
Yeah, doesn't look like it gets reset.
Re: [PATCH V5 03/13] mmc: host: Add CQE interface
Quoted 14 lines · Adrian Hunter
Quoted 13 lines · Ulf Hansson
Quoted 12 lines · Adrian Hunter
Quoted 10 lines · Ulf Hansson
include/linux/mmc/host.h struct mmc_host { · line 447
Quoted 2 lines · Adrian Hunter
include/linux/mmc/host.h +2
-0+void (*cqe_recovery_notifier)(struct mmc_host *, +struct mmc_request *);Normally we don't put callbacks in the struct
mmc_hostthat someone else than the host driver should assign - so this feels a bit upside down.Is there any reason to why you didn't want to add a new API? Something like
mmc_cqe_recover(), which the host driver could call.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
That would make the host driver dependent on the block driver. There needs to be a function pointer, even if we wrap it in an API.
Okay, I see. I guess we could put such pointer somewhere closer to the mmc request queue.
Another possibility is to put in into struct
mmc_requestlike the "done" callback.
Yes, I think like that.
That would also solve the problem of having to protect the pointer as the request would then have a corresponding life cycle to the block device driver.
Quoted 6 lines
Quoted 5 lines
Anyway, I didn't find out how this pointer was being protected from concurrent access or perhaps that is managed via mmc_claim|release_host()?
Quoted 7 lines
It is assumed CQE is only used by the card driver so the callback can be set / reset in the card driver's probe / remove.
Quoted 2 lines
Moreover, I could find it ever it being
reset to NULL.Yeah, doesn't look like it gets reset.
Kind regards
Uffe
Adrian Hunter
maintainerPATCH v5 4/13 mmc: core: Turn off CQE before sending commands
In reply to Adrian HunterCQE needs to be off for the host controller to accept non-CQ commands. Turn 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
@@ -260,6 +260,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); }
@@ -979,6 +982,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
@@ -1018,6 +1024,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
Re: [PATCH V5 04/13] mmc: core: Turn off CQE before sending commands
Quoted 5 lines · Adrian Hunter
CQE needs to be off for the host controller to accept non-CQ commands. Turn off the CQE before sending commands, and ensure it is off in any reset or power management paths, or re-tuning.
Signed-off-by Adrian Hunter <[email protected]>
Yours,
Linus Walleij
Ulf Hansson
AppliedRe: [PATCH V5 04/13] mmc: core: Turn off CQE before sending commands
In reply to Adrian HunterQuoted 5 lines · Adrian Hunter
CQE needs to be off for the host controller to accept non-CQ commands. Turn off the CQE before sending commands, and ensure it is off in any reset or power management paths, or re-tuning.
Signed-off-by Adrian Hunter <[email protected]>
Thanks, applied for next!
Kind regards
Uffe
Quoted 41 lines
--- drivers/mmc/core/core.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/mmc/core/core.c +9
-1@@ -260,6 +260,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); }@@ -979,6 +982,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 @@ -1018,6 +1024,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)) --1.9.1
Adrian Hunter
maintainerPATCH v5 5/13 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 | 169 +++++++++++++++++++++++++++++++++++++++++++++-- include/linux/mmc/core.h | 5 ++ 2 files changed, 169 insertions(+), 5 deletions(-)
drivers/mmc/core/core.c +164 -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,161 @@ 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); + +static 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); + } +} + +/** +* 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 + +/* +* 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
include/linux/mmc/core.h +5 -0
@@ -174,6 +174,11 @@ 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_post_req (struct mmc_host *host,struct mmc_request *mrq); +int mmc_cqe_recovery (struct mmc_host *host); +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
Re: [PATCH V5 05/13] mmc: core: Add support for handling CQE requests
drivers/mmc/core/core.c void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) · line 540
Quoted 8 lines · Adrian Hunter
Add core support for handling CQE requests, including starting, completing and recovering.
Signed-off-by Adrian Hunter <[email protected]>drivers/mmc/core/core.c +2
-0+static void __mmc_cqe_request_done (struct mmc_host *host, +struct mmc_request *mrq)
We are naming too much stuff __foo now, it gets really hard to figure out from the function name and the surrounding code what is going on.
I guess people are using this like "do parts of what mmc_cqe_request_done() is doing" but it'd be nice if we could be specific.
mmc_cqe_request_finalize() could work?
Yours,
Linus Walleij
Adrian Hunter
maintainerRe: [PATCH V5 05/13] mmc: core: Add support for handling CQE requests
Quoted 5 lines · Linus Walleij
Quoted 3 lines · Adrian Hunter
Add core support for handling CQE requests, including starting, completing and recovering.
Quoted 8 lines
drivers/mmc/core/core.c void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) · line 540
Quoted 5 lines
Signed-off-by Adrian Hunter <[email protected]>drivers/mmc/core/core.c +2
-0+static void __mmc_cqe_request_done (struct mmc_host *host, +struct mmc_request *mrq)We are naming too much stuff
__foonow, it gets really hard to figure out from the function name and the surrounding code what is going on.
You have written several times that you don't like __foo() names, however it is a normal kernel paradigm.
Quoted 4 lines
I guess people are using this like "do parts of what
mmc_cqe_request_done()is doing" but it'd be nice if we could be specific.
mmc_cqe_request_finalize()could work?
It can be rolled into mmc_cqe_request_done().
Re: [PATCH V5 05/13] mmc: core: Add support for handling CQE requests
Quoted 9 lines · Adrian Hunter
Quoted 8 lines · Linus Walleij
Quoted 4 lines · Adrian Hunter
Add core support for handling CQE requests, including starting, completing and recovering.
Signed-off-by Adrian Hunter <[email protected]>
Quoted 8 lines
Quoted 5 lines
drivers/mmc/core/core.c void mmc_wait_for_req_done(struct mmc_host *host, struct mmc_request *mrq) · line 540
Quoted 2 lines
drivers/mmc/core/core.c +2
-0+static void __mmc_cqe_request_done (struct mmc_host *host, +struct mmc_request *mrq)We are naming too much stuff
__foonow, it gets really hard to figure out from the function name and the surrounding code what is going on.You have written several times that you don't like
__foo()names, however it is a normal kernel paradigm.
Normal doesn't mean "good".
I am negative to it because it has very unclear semantics. What is the semantic meaning of prefixing a function with __* really?
I have referred to Rusty Russell's API levels:
http://sweng.the-davies.net/Home/rustys-api-design-manifesto
This is on level 3-4 and definately not at 6.
So in my opinion, I have informed, founded in theory and valid reasons to dislike it, and I don't think it is a matter of taste or opinion.
Quoted 6 lines
Quoted 4 lines
I guess people are using this like "do parts of what
mmc_cqe_request_done()is doing" but it'd be nice if we could be specific.
mmc_cqe_request_finalize()could work?It can be rolled into
mmc_cqe_request_done().
OK!
Yours,
Linus Walleij
Re: [PATCH V5 05/13] mmc: core: Add support for handling CQE requests
In reply to Adrian Hunter[...]
include/linux/mmc/core.h struct mmc_async_req *mmc_start_areq(struct mmc_host *host, · line 181
Quoted 13 lines
include/linux/mmc/core.h +5
-0@@ -174,6 +174,11 @@ 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_post_req (struct mmc_host *host,struct mmc_request *mrq); +int mmc_cqe_recovery (struct mmc_host *host); +
Please move mmc_cqe_start_req(), mmc_cqe_post_req(), mmc_cqe_recovery() to drivers/mmc/core/core.h. This makes sure they don't become abused.
Also, please move mmc_cqe_request_done() to include/linux/mmc/host.h. Then it becomes consistent with where mmc_request_done() is declared.
Feel free to also fold in a patch moving the existing mmc_start_areq() to drivers/mmc/core/core.h. Unfortunate the others closely related to these functions, are being abused by SDIO func drivers and needs more work before they can be moved.
Quoted 6 lines
include/linux/mmc/core.h +0
-1int mmc_hw_reset (struct mmc_host *host);void mmc_set_data_timeout (struct mmc_data *data,const struct mmc_card *card); --1.9.1
Sorry for not noticing this in v4.
Kind regards
Uffe
Adrian Hunter
maintainerPATCH v5 6/13 mmc: core: Remove unused MMC_CAP2_PACKED_CMD
In reply to Adrian HunterPacked commands support was removed but some bits got left behind. Remove them.
--- drivers/mmc/core/mmc.c | 23 ----------------------- include/linux/mmc/host.h | 4 ---- 2 files changed, 27 deletions(-)
drivers/mmc/core/mmc.c +0 -23
@@ -1790,29 +1790,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,*/ card->reenable_cmdq = card->ext_csd.cmdq_en; -/* -* The mandatory minimum values are defined for packed command. -* read: 5, write: 3 -*/ -if (card->ext_csd.max_packed_writes >=3 && - card->ext_csd.max_packed_reads >=5 && - host->caps2 &MMC_CAP2_PACKED_CMD ) { - err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_EXP_EVENTS_CTRL , -EXT_CSD_PACKED_EVENT_EN , - card->ext_csd.generic_cmd6_time); -if (err && err != -EBADMSG ) - goto free_card; -if (err) { -pr_warn ("%s: Enabling packed event failed\n" , -mmc_hostname (card->host)); - card->ext_csd.packed_event_en =0 ; - err =0 ; - }else { - card->ext_csd.packed_event_en =1 ; - } - } -if (!oldcard) host->card = card;
include/linux/mmc/host.h +0 -4
@@ -335,10 +335,6 @@ struct mmc_host { MMC_CAP2_HS200_1_2V_SDR)#define MMC_CAP2_CD_ACTIVE_HIGH (1 << 10)/* Card-detect signal active high */ #define MMC_CAP2_RO_ACTIVE_HIGH (1 << 11)/* Write-protect signal active high */ -#define MMC_CAP2_PACKED_RD (1 << 12)/* Allow packed read */ -#define MMC_CAP2_PACKED_WR (1 << 13)/* Allow packed write */ -#define MMC_CAP2_PACKED_CMD (MMC_CAP2_PACKED_RD | \ - MMC_CAP2_PACKED_WR)#define MMC_CAP2_NO_PRESCAN_POWERUP (1 << 14)/* Don't power up before scan */ #define MMC_CAP2_HS400_1_8V (1 << 15)/* Can support HS400 1.8V */ #define MMC_CAP2_HS400_1_2V (1 << 16)/* Can support HS400 1.2V */
Signature · 1 line
1.9.1
Re: [PATCH V5 06/13] mmc: core: Remove unused MMC_CAP2_PACKED_CMD
Quoted 4 lines · Adrian Hunter
Packed commands support was removed but some bits got left behind. Remove them.
Signed-off-by Adrian Hunter <[email protected]>
I would even apply this as patch #1 in the series (I guess that works). Sorry for leaving this cruft behind.
Yours,
Linus Walleij
Ulf Hansson
AppliedRe: [PATCH V5 06/13] mmc: core: Remove unused MMC_CAP2_PACKED_CMD
In reply to Adrian HunterQuoted 4 lines · Adrian Hunter
Packed commands support was removed but some bits got left behind. Remove them.
Signed-off-by Adrian Hunter <[email protected]>
Thanks, applied for next!
Kind regards
Uffe
Quoted 57 lines
--- drivers/mmc/core/mmc.c | 23 ----------------------- include/linux/mmc/host.h | 4 ---- 2 files changed, 27 deletions(-)drivers/mmc/core/mmc.c +0
-23@@ -1790,29 +1790,6 @@ static int mmc_init_card(struct mmc_host *host, u32 ocr,*/ card->reenable_cmdq = card->ext_csd.cmdq_en; -/* -* The mandatory minimum values are defined for packed command. -* read: 5, write: 3 -*/ -if (card->ext_csd.max_packed_writes >=3 && - card->ext_csd.max_packed_reads >=5 && - host->caps2 &MMC_CAP2_PACKED_CMD ) { - err =mmc_switch (card,EXT_CSD_CMD_SET_NORMAL , -EXT_CSD_EXP_EVENTS_CTRL , -EXT_CSD_PACKED_EVENT_EN , - card->ext_csd.generic_cmd6_time); -if (err && err != -EBADMSG ) - goto free_card; -if (err) { -pr_warn ("%s: Enabling packed event failed\n" , -mmc_hostname (card->host)); - card->ext_csd.packed_event_en =0 ; - err =0 ; - }else { - card->ext_csd.packed_event_en =1 ; - } - } -if (!oldcard) host->card = card;include/linux/mmc/host.h +0
-5@@ -335,10 +335,6 @@ struct mmc_host { MMC_CAP2_HS200_1_2V_SDR)#define MMC_CAP2_CD_ACTIVE_HIGH (1 << 10)/* Card-detect signal active high */ #define MMC_CAP2_RO_ACTIVE_HIGH (1 << 11)/* Write-protect signal active high */ -#define MMC_CAP2_PACKED_RD (1 << 12)/* Allow packed read */ -#define MMC_CAP2_PACKED_WR (1 << 13)/* Allow packed write */ -#define MMC_CAP2_PACKED_CMD (MMC_CAP2_PACKED_RD | \ - MMC_CAP2_PACKED_WR)#define MMC_CAP2_NO_PRESCAN_POWERUP (1 << 14)/* Don't power up before scan */ #define MMC_CAP2_HS400_1_8V (1 << 15)/* Can support HS400 1.8V */ #define MMC_CAP2_HS400_1_2V (1 << 16)/* Can support HS400 1.2V */ --1.9.1
Adrian Hunter
maintainerPATCH v5 7/13 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
Re: [PATCH V5 07/13] mmc: mmc: Enable Command Queuing
Quoted 6 lines · Adrian Hunter
Enable 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.
Signed-off-by Adrian Hunter <[email protected]>---
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v5 8/13 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
Re: [PATCH V5 08/13] mmc: mmc: Enable CQE's
Quoted 3 lines · Adrian Hunter
Enable or disable CQE when a card is added or removed respectively.
Signed-off-by Adrian Hunter <[email protected]>
pr_info("%s: Command Queue Engine enabled\n",
Kudos for making this pr_info() as we're introducing it to everyone so that users can see what is going on. Good!
Yours,
Linus Walleij
Adrian Hunter
maintainerPATCH v5 9/13 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
@@ -1485,21 +1485,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 ));
@@ -1547,18 +1548,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);
@@ -1587,6 +1588,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
Re: [PATCH V5 09/13] mmc: block: Use local variables in mmc_blk_data_prep()
Quoted 4 lines · Adrian Hunter
Use local variables in
mmc_blk_data_prep()in preparation for adding CQE support which doesn't use the output variables.Signed-off-by Adrian Hunter <[email protected]>
on the patch as such but:
drivers/mmc/core/block.c static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card, · line 1489
Quoted 5 lines
static void mmc_blk_data_prep(struct
mmc_queue*mq, structmmc_queue_req*mqrq,drivers/mmc/core/block.c +2
-2- int disable_multi, bool *do_rel_wr, - bool *do_data_tag) + int disable_multi, bool *do_rel_wr_p, + bool *do_data_tag_p)
We need to figure out what we mean by "tag" in eMMC.
Yours,
Linus Walleij
Adrian Hunter
maintainerRe: [PATCH V5 09/13] mmc: block: Use local variables in mmc_blk_data_prep()
Quoted 10 lines · Linus Walleij
Quoted 4 lines · Adrian Hunter
Use local variables in
mmc_blk_data_prep()in preparation for adding CQE support which doesn't use the output variables.Signed-off-by Adrian Hunter <[email protected]>Reviewed-by Linus Walleij <[email protected]>on the patch as such but:
Quoted 7 lines
drivers/mmc/core/block.c static enum mmc_blk_status mmc_blk_err_check(struct mmc_card *card, · line 1489
Quoted 5 lines
static void mmc_blk_data_prep(struct
mmc_queue*mq, structmmc_queue_req*mqrq,drivers/mmc/core/block.c +2
-2- int disable_multi, bool *do_rel_wr, - bool *do_data_tag) + int disable_multi, bool *do_rel_wr_p, + bool *do_data_tag_p)We need to figure out what we mean by "tag" in eMMC.
Data tags are an eMMC invention to categorize the type of data. They have nothing to do with block layer tags.
Adrian Hunter
maintainerPATCH v5 10/13 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
@@ -1505,6 +1505,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 ;
@@ -1519,6 +1520,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
@@ -1548,8 +1557,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
@@ -1561,6 +1572,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 v5 11/13 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.
--- drivers/mmc/core/block.c | 195 ++++++++++++++++++++++++++++++++- drivers/mmc/core/block.h | 7 ++ drivers/mmc/core/queue.c | 273 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/mmc/core/queue.h | 42 +++++++- 4 files changed, 510 insertions(+), 7 deletions(-)
drivers/mmc/core/block.c +194 -1
@@ -108,6 +108,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
@@ -1610,6 +1611,198 @@ 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); + +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 ; + +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_requeue_request (q, req); +else +__blk_end_request_all (req,BLK_STS_IOERR ); + }else if (mrq->data) { +if (__blk_end_request (req,BLK_STS_OK , mrq->data->bytes_xfered)) +blk_requeue_request (q, req); + }else { +__blk_end_request_all (req,BLK_STS_OK ); + } + +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; + +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_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; +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); +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,
@@ -2033,7 +2226,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 +268 -5
311 lines not on this page · raw message
drivers/mmc/core/queue.h +41 -1
67 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH V5 11/13] mmc: block: Add CQE support
Quoted 3 lines · Adrian Hunter
Add CQE support to the block driver, including:
- optionally using DCMD for flush requests
- manually issuing discard requests
"Manually" has no place in computer code IMO since there is no man there. But I may be especially grumpy. But I don't understand the comment anyway.
Quoted 10 lines
- issuing read / write requests to the CQE
- supporting block-layer timeouts
- handling recovery
- supporting re-tuningCQE 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.
Signed-off-by Adrian Hunter <[email protected]>
This commit message seriously needs to detail the design of the request handling thread/engine.
So adding a new (in effect) invasive block driver needs to at least be CC:ed to the block maintainers so we don't sneak anything like that in under the radar.
This duplicates the "thread that sucks out requests" from the MMC core, and doubles the problem of replacing it with something like blk-mq.
Especially these two snippets I would personally NOT merge without the explicit consent of a block layer maintainer:
Quoted 16 lines
drivers/mmc/core/queue.c +16
-0+static void mmc_cqe_request_fn (struct request_queue *q) +{ +struct mmc_queue *mq = q->queuedata; +struct request *req; + +if (!mq) { +while ((req =blk_fetch_request (q)) !=NULL ) { + req->rq_flags |=RQF_QUIET ; +__blk_end_request_all (req,BLK_STS_IOERR ); + } +return ; + } + +if (mq->asleep && !mq->cqe_busy) +wake_up_process (mq->thread); +}
(...)
Quoted 19 lines
drivers/mmc/core/queue.c +19
-0+static int mmc_cqe_thread (void *d) +{ +struct mmc_queue *mq = d; +struct request_queue *q = mq->queue; +struct mmc_card *card = mq->card; +struct mmc_host *host = card->host; +unsigned long flags; +int get_put =0 ; + + current->flags |=PF_MEMALLOC ; + +down (&mq->thread_sem); +spin_lock_irqsave (q->queue_lock, flags); +while (1 ) { +struct request *req =NULL ; +enum mmc_issue_type issue_type; +bool retune_ok = false; + +if (mq->cqe_recovery_needed) {
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 150
Quoted 10 lines
drivers/mmc/core/queue.c +10
-0+spin_unlock_irqrestore (q->queue_lock, flags); +mmc_blk_cqe_recovery (mq); +spin_lock_irqsave (q->queue_lock, flags); + mq->cqe_recovery_needed = false; + } + +set_current_state (TASK_INTERRUPTIBLE ); + +if (!kthread_should_stop ()) + req =blk_peek_request (q);
Why are you using blk_peek_request() instead of blk_fetch_request() when the other thread just goes with fetch?
Am I right in assuming that also this request queue replies on the implicit semantic that blk_peek_request(q) shall return NULL if there are no requests in the queue, and that it is pulling out a few NULLs to flush the request-handling machinery? Or did it fix this? (Put that in the commit message in that case.)
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 160
Quoted 10 lines
drivers/mmc/core/queue.c +10
-0+ +if (req) { + issue_type =mmc_cqe_issue_type (host, req); +switch (issue_type) { +case MMC_ISSUE_DCMD : +if (mmc_cqe_dcmd_busy (mq)) { + mq->cqe_busy |=MMC_CQE_DCMD_BUSY ; + req =NULL ; +break ; + }
I guess peek is used becaue you want to have the option to give it up here.
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 166
Quoted 6 lines
drivers/mmc/core/queue.c +6
-0+/* Fall through */ +case MMC_ISSUE_ASYNC : +if (blk_queue_start_tag (q, req)) { + mq->cqe_busy |=MMC_CQE_QUEUE_FULL ; + req =NULL ; + }
Then you start it with blk_queue_start_tag(), now does "tag" in this function call mean the same as the "tag" you just added to the MMC request struct?
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 174
Quoted 8 lines
drivers/mmc/core/queue.c +8
-0+break ; +default : +/* +* Timeouts are handled by mmc core, so set a +* large value to avoid races. +*/ + req->timeout =600 *HZ ; +blk_start_request (req);
And here it just starts.
Quoted 32 lines
drivers/mmc/core/queue.c +32
-0+break ; + } +if (req) { + mq->cqe_in_flight[issue_type] +=1 ; +if (mmc_cqe_tot_in_flight (mq) ==1 ) + get_put +=1 ; +if (mmc_cqe_qcnt (mq) ==1 ) + retune_ok = true; + } + } + + mq->asleep = !req; + +spin_unlock_irqrestore (q->queue_lock, flags); + +if (req) { +enum mmc_issued issued; + +set_current_state (TASK_RUNNING ); + +if (get_put) { + get_put =0 ; +mmc_get_card (card); + } + +if (host->need_retune && retune_ok && + !host->hold_retune) + host->retune_now = true; +else + host->retune_now = false; + + issued =mmc_blk_cqe_issue_rq (mq, req);
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 216
Quoted 10 lines
drivers/mmc/core/queue.c +10
-0+ +cond_resched (); + +spin_lock_irqsave (q->queue_lock, flags); + +switch (issued) { +case MMC_REQ_STARTED : +break ; +case MMC_REQ_BUSY : +blk_requeue_request (q, req);
Here it is requeued.
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 219
Quoted 3 lines
drivers/mmc/core/queue.c +3
-0+ goto finished; +case MMC_REQ_FAILED_TO_START : +__blk_end_request_all (req,BLK_STS_IOERR );
Or ended.
Quoted 15 lines
drivers/mmc/core/queue.c +15
-0+/* Fall through */ +case MMC_REQ_FINISHED : +finished: + mq->cqe_in_flight[issue_type] -=1 ; +if (mmc_cqe_tot_in_flight (mq) ==0 ) + get_put =-1 ; + } + }else { +if (get_put <0 ) { + get_put =0 ; +mmc_put_card (card); + } +/* +* Do not stop with requests in flight in case recovery +* is needed.
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 244
Quoted 10 lines
drivers/mmc/core/queue.c +10
-0+*/ +if (kthread_should_stop () && + !mmc_cqe_tot_in_flight (mq)) { +set_current_state (TASK_RUNNING ); +break ; + } +up (&mq->thread_sem); +schedule (); +down (&mq->thread_sem); +spin_lock_irqsave (q->queue_lock, flags);
And this semaphoring and threading is just as confusing as ever and now we have two of them. (Sorry, I'm grumpy.)
I think I said in the beginning maybe not in response to this series but another that I don't like the idea of making a second copy of the whole request thread. I would much rather see that ONE request thread is used for both regular requests and CQE.
Atleast I wanna see a serious rebuttal of why my claim that we should keep this code down is such a pipe dream that we just have to go ahead and make a second instance of all the core request mechanics. And that this should be part of the commit message: "I'm duplicating the queue thread because (...)" etc.
I'm sorry for being so conservative, but I am plain scared, I had serious trouble refactoring this code already, and I got the feeling that several people think the MMC stack has grown unapproachable for average developers (my Googledoc where I tried to pry it apart got very popular with developers I respect), and this is making that situation worse. Soon only you and Ulf will understand this piece of code.
I do not know if I'm especially stupid when I feel the MMC stack code is already hard to grasp, if that is the case I need to be told.
What we need is an MMC stack where it is clear where blocks come in and out and how they are processed by the block layer, but now we already have a scary Rube Goldberg-machine and it is not getting better. If people have different feelings they can tell me off right now.
I have my hopes up that we can get the code lesser and more readable with MQ, as I tried to illustrate in my attempts, which are indeed lame because they don't work because of misc and SDIO use cases, but I'm honestly doing my best. Currently with other clean-ups to get a clean surface to do that.
As it stands, the MQ migration work size is in some spots doubled or more than doubled after this commit :(
Yours,
Linus Walleij
Adrian Hunter
maintainerRe: [PATCH V5 11/13] mmc: block: Add CQE support
Quoted 9 lines · Linus Walleij
Quoted 3 lines · Adrian Hunter
Add CQE support to the block driver, including:
- optionally using DCMD for flush requests
- manually issuing discard requests"Manually" has no place in computer code IMO since there is no man there. But I may be especially grumpy. But I don't understand the comment anyway.
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().
Quoted 15 lines
Quoted 11 lines
- issuing read / write requests to the CQE
- supporting block-layer timeouts
- handling recovery
- supporting re-tuningCQE 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.
Signed-off-by Adrian Hunter <[email protected]>This commit message seriously needs to detail the design of the request handling thread/engine.
Quoted 7 lines
So adding a new (in effect) invasive block driver needs to at least be CC:ed to the block maintainers so we don't sneak anything like that in under the radar.
This duplicates the "thread that sucks out requests" from the MMC core, and doubles the problem of replacing it with something like blk-mq.
We need to start with a legacy API because people want to backport CQ to earlier kernels (we really need to get features upstream more quickly), but blk-mq has been evolving a lot (e.g. elevator support), so backporters face having either something quite different from upstream or trying to backport great chunks of the block layer.
We also don't know how blk-mq will perform so it would be prudent to start with support for both the legacy API and blk-mq (as scsi does) so that we can find out first.
A loop to remove requests from the queue is normal e.g. scsi_request_fn() and taking a consistent approach with the existing mmc thread does not double the the problem of blk-mq implementation, since the same approach can be used for both.
Quoted 45 lines
Especially these two snippets I would personally NOT merge without the explicit consent of a block layer maintainer:
Quoted 16 lines
drivers/mmc/core/queue.c +16
-0+static void mmc_cqe_request_fn (struct request_queue *q) +{ +struct mmc_queue *mq = q->queuedata; +struct request *req; + +if (!mq) { +while ((req =blk_fetch_request (q)) !=NULL ) { + req->rq_flags |=RQF_QUIET ; +__blk_end_request_all (req,BLK_STS_IOERR ); + } +return ; + } + +if (mq->asleep && !mq->cqe_busy) +wake_up_process (mq->thread); +}(...)
Quoted 24 lines
drivers/mmc/core/queue.c +24
-0+static int mmc_cqe_thread (void *d) +{ +struct mmc_queue *mq = d; +struct request_queue *q = mq->queue; +struct mmc_card *card = mq->card; +struct mmc_host *host = card->host; +unsigned long flags; +int get_put =0 ; + + current->flags |=PF_MEMALLOC ; + +down (&mq->thread_sem); +spin_lock_irqsave (q->queue_lock, flags); +while (1 ) { +struct request *req =NULL ; +enum mmc_issue_type issue_type; +bool retune_ok = false; + +if (mq->cqe_recovery_needed) { +spin_unlock_irqrestore (q->queue_lock, flags); +mmc_blk_cqe_recovery (mq); +spin_lock_irqsave (q->queue_lock, flags); + mq->cqe_recovery_needed = false; + }
Quoted 8 lines
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 150
Quoted 5 lines
drivers/mmc/core/queue.c +5
-0+ +set_current_state (TASK_INTERRUPTIBLE ); + +if (!kthread_should_stop ()) + req =blk_peek_request (q);Why are you using
blk_peek_request()instead ofblk_fetch_request()when the other thread just goes with fetch?
Because we are not always able to start the request.
Quoted 5 lines
Am I right in assuming that also this request queue replies on the implicit semantic that
blk_peek_request(q)shall return NULL if there are no requests in the queue, and that it is pulling out a few NULLs to flush the request-handling machinery? Or did it fix this? (Put that in the commit message in that case.)
CQ is different. Because read / write requests are processed asynchronously we can keep preparing and issuing more requests until the hardware queue is full. That is, we don't have to wait for the first request to complete before preparing and issuing the second request, and so on.
However, the existing thread's need to issue a "null" is not because it is a thread. It is because of the convoluted design of mmc_start_areq(). However, you still need a way to issue the prepared request when the current request completes. Either wake-up the thread to do it, or in the past I have suggested that should be done in the completion path, but that needs changes to the host controller API.
Quoted 12 lines
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 160
Quoted 11 lines
drivers/mmc/core/queue.c +10
-0+ +if (req) { + issue_type =mmc_cqe_issue_type (host, req); +switch (issue_type) { +case MMC_ISSUE_DCMD : +if (mmc_cqe_dcmd_busy (mq)) { + mq->cqe_busy |=MMC_CQE_DCMD_BUSY ; + req =NULL ; +break ; + }
Quoted 1 line
I guess peek is used becaue you want to have the option to give it up here.
Yes
Quoted 11 lines
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 166
Quoted 7 lines
drivers/mmc/core/queue.c +6
-0+/* Fall through */ +case MMC_ISSUE_ASYNC : +if (blk_queue_start_tag (q, req)) { + mq->cqe_busy |=MMC_CQE_QUEUE_FULL ; + req =NULL ; + }Then you start it with
blk_queue_start_tag(), now does "tag" in this function call mean the same as the "tag" you just added to the MMC request struct?
Yes
Quoted 11 lines
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 174
Quoted 9 lines
drivers/mmc/core/queue.c +8
-0+break ; +default : +/* +* Timeouts are handled by mmc core, so set a +* large value to avoid races. +*/ + req->timeout =600 *HZ ; +blk_start_request (req);And here it just starts.
This is the path for requests that the CQE cannot process. They don't need to be tagged because there is no command queue - no way to do more than one request at a time.
Quoted 37 lines
Quoted 37 lines
drivers/mmc/core/queue.c +36
-0+break ; + } +if (req) { + mq->cqe_in_flight[issue_type] +=1 ; +if (mmc_cqe_tot_in_flight (mq) ==1 ) + get_put +=1 ; +if (mmc_cqe_qcnt (mq) ==1 ) + retune_ok = true; + } + } + + mq->asleep = !req; + +spin_unlock_irqrestore (q->queue_lock, flags); + +if (req) { +enum mmc_issued issued; + +set_current_state (TASK_RUNNING ); + +if (get_put) { + get_put =0 ; +mmc_get_card (card); + } + +if (host->need_retune && retune_ok && + !host->hold_retune) + host->retune_now = true; +else + host->retune_now = false; + + issued =mmc_blk_cqe_issue_rq (mq, req); + +cond_resched (); + +spin_lock_irqsave (q->queue_lock, flags);
Quoted 8 lines
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 216
Quoted 6 lines
drivers/mmc/core/queue.c +6
-0+ +switch (issued) { +case MMC_REQ_STARTED : +break ; +case MMC_REQ_BUSY : +blk_requeue_request (q, req);Here it is requeued.
Any request that is started has to be either re-queued or completed.
Quoted 6 lines
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 219
Quoted 4 lines
drivers/mmc/core/queue.c +3
-0+ goto finished; +case MMC_REQ_FAILED_TO_START : +__blk_end_request_all (req,BLK_STS_IOERR );Or ended.
Any request that is started has to be either re-queued or completed.
Quoted 27 lines
Quoted 16 lines
drivers/mmc/core/queue.c +15
-0+/* Fall through */ +case MMC_REQ_FINISHED : +finished: + mq->cqe_in_flight[issue_type] -=1 ; +if (mmc_cqe_tot_in_flight (mq) ==0 ) + get_put =-1 ; + } + }else { +if (get_put <0 ) { + get_put =0 ; +mmc_put_card (card); + } +/* +* Do not stop with requests in flight in case recovery +* is needed. drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 244
Quoted 10 lines
drivers/mmc/core/queue.c +10
-0+*/ +if (kthread_should_stop () && + !mmc_cqe_tot_in_flight (mq)) { +set_current_state (TASK_RUNNING ); +break ; + } +up (&mq->thread_sem); +schedule (); +down (&mq->thread_sem); +spin_lock_irqsave (q->queue_lock, flags);
Quoted 2 lines
And this semaphoring and threading is just as confusing as ever and now we have two of them. (Sorry, I'm grumpy.)
Sure we have two, but they follow the same approach. i.e. if you can get rid of one, then you can use the same method to get rid of the other.
Quoted 5 lines
I think I said in the beginning maybe not in response to this series but another that I don't like the idea of making a second copy of the whole request thread. I would much rather see that ONE request thread is used for both regular requests and CQE.
They issue requests in completely different ways. There is essentially no common code.
Quoted 6 lines
Atleast I wanna see a serious rebuttal of why my claim that we should keep this code down is such a pipe dream that we just have to go ahead and make a second instance of all the core request mechanics. And that this should be part of the commit message: "I'm duplicating the queue thread because (...)" etc.
As I wrote above, we need to start with the legacy API, because of backporting and because we don't know how blk-mq will perform.
Quoted 7 lines
I'm sorry for being so conservative, but I am plain scared, I had serious trouble refactoring this code already, and I got the feeling that several people think the MMC stack has grown unapproachable for average developers (my Googledoc where I tried to pry it apart got very popular with developers I respect), and this is making that situation worse. Soon only you and Ulf will understand this piece of code.
The mmc block driver has problems, but the thread isn't one of them.
Quoted 3 lines
I do not know if I'm especially stupid when I feel the MMC stack code is already hard to grasp, if that is the case I need to be told.
mmc_start_areq() is very convoluted. However, getting rid of mmc_start_areq() is only the first step. Step two: have the host controller complete requests without the need of block driver polling i.e. card_busy_detect() must not be called in the normal completion path. Step
three: make it possible to issue the prepared request in the completion path of the current request. Steps two and three need host controller driver changes.
Quoted 6 lines
What we need is an MMC stack where it is clear where blocks come in and out and how they are processed by the block layer, but now we already have a scary Rube Goldberg-machine and it is not getting better. If people have different feelings they can tell me off right now.
Quoted 8 lines
I have my hopes up that we can get the code lesser and more readable with MQ, as I tried to illustrate in my attempts, which are indeed lame because they don't work because of misc and SDIO use cases, but I'm honestly doing my best. Currently with other clean-ups to get a clean surface to do that.
As it stands, the MQ migration work size is in some spots doubled or more than doubled after this commit :(
Not true. I have begun work on blk-mq for CQE and I will send an RFC in a day or two.
Re: [PATCH V5 11/13] mmc: block: Add CQE support
Quoted 11 lines · Adrian Hunter
Quoted 9 lines · Linus Walleij
Quoted 3 lines · Adrian Hunter
Add CQE support to the block driver, including:
- optionally using DCMD for flush requests
- manually issuing discard requests"Manually" has no place in computer code IMO since there is no man there. But I may be especially grumpy. But I don't understand the comment anyway.
Quoted 7 lines
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().
Ah that's a great deal of good technical detail (I think I might have even understood
what is going on) can we please make sure to get this text into the commit.
Quoted 8 lines
Quoted 7 lines
So adding a new (in effect) invasive block driver needs to at least be CC:ed to the block maintainers so we don't sneak anything like that in under the radar.
This duplicates the "thread that sucks out requests" from the MMC core, and doubles the problem of replacing it with something like blk-mq.
Quoted 5 lines
We need to start with a legacy API because people want to backport CQ to earlier kernels (we really need to get features upstream more quickly), but blk-mq has been evolving a lot (e.g. elevator support), so backporters face having either something quite different from upstream or trying to backport great chunks of the block layer.
I hope I do not come across as rude to a senior kernel developer if I just reference this:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-api-nonsense.rst
My position is that any attempts to push around the community due to internal product development falls under the "argument ti moderation" fallacy. Even for huge enterprises.
https://en.wikipedia.org/wiki/Argument_to_moderation
Quoted 3 lines
We also don't know how blk-mq will perform so it would be prudent to start with support for both the legacy API and blk-mq (as scsi does) so that we can find out first.
As far as I have understood, that is not the position of the block layer maintainers, who are quickly phasing out the old block layer in favor of the new mq scheduler.
Example: they did not accept the new BFQ scheduling policy until it was rewritten as a plugin to mq.
Quoted 4 lines
A loop to remove requests from the queue is normal e.g.
scsi_request_fn()and taking a consistent approach with the existing mmc thread does not double the the problem of blk-mq implementation, since the same approach can be used for both.
If the two threads are so similar, why do we need two threads?
My general feeling is that this part of the code is duct-taped on the side of the old request poll loop instead of refactoring and integrating the new code with the existing poll loop.
I need a clear argument as to why that is not possible if this solution should persist.
Quoted 7 lines
Quoted 5 lines
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 150
Quoted 2 lines
drivers/mmc/core/queue.c +2
-0+if (!kthread_should_stop ()) + req =blk_peek_request (q);Why are you using
blk_peek_request()instead ofblk_fetch_request()when the other thread just goes with fetch?Because we are not always able to start the request.
OK I understand this now, sorry for my ignorance.
Quoted 6 lines
Quoted 5 lines
Am I right in assuming that also this request queue replies on the implicit semantic that
blk_peek_request(q)shall return NULL if there are no requests in the queue, and that it is pulling out a few NULLs to flush the request-handling machinery? Or did it fix this? (Put that in the commit message in that case.)
Quoted 7 lines
CQ is different. Because read / write requests are processed asynchronously we can keep preparing and issuing more requests until the hardware queue is full. That is, we don't have to wait for the first request to complete before preparing and issuing the second request, and so on.
However, the existing thread's need to issue a "null" is not because it is a thread. It is because of the convoluted design of
mmc_start_areq().
Yeah that is true :(
Quoted 4 lines
However, you still need a way to issue the prepared request when the current request completes. Either wake-up the thread to do it, or in the past I have suggested that should be done in the completion path, but that needs changes to the host controller API.
We might have to do that then? It is anyways necessary for MQ which (in my implementation) sets the queue depth to 2 and get the same issue with two outstanding requests.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
drivers/mmc/core/queue.c +8
-0+break ; +default : +/* +* Timeouts are handled by mmc core, so set a +* large value to avoid races. +*/ + req->timeout =600 *HZ ; +blk_start_request (req);
Quoted 5 lines
Quoted 1 line
And here it just starts.
This is the path for requests that the CQE cannot process. They don't need to be tagged because there is no command queue - no way to do more than one request at a time.
OK I get it.
Quoted 9 lines
Quoted 7 lines
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 216
Quoted 5 lines
drivers/mmc/core/queue.c +5
-0+switch (issued) { +case MMC_REQ_STARTED : +break ; +case MMC_REQ_BUSY : +blk_requeue_request (q, req);Here it is requeued.
Any request that is started has to be either re-queued or completed.
Yup I get it.
Quoted 7 lines
Quoted 5 lines
drivers/mmc/core/queue.c static int mmc_prep_request(struct request_queue *q, struct request *req) · line 219
Quoted 3 lines
drivers/mmc/core/queue.c +3
-0+ goto finished; +case MMC_REQ_FAILED_TO_START : +__blk_end_request_all (req,BLK_STS_IOERR );Or ended.
Any request that is started has to be either re-queued or completed.
Yup.
So why can't we do all this in the existing thread instead of a new thread?
Quoted 7 lines
Quoted 4 lines
I think I said in the beginning maybe not in response to this series but another that I don't like the idea of making a second copy of the whole request thread. I would much rather see that ONE request thread is used for both regular requests and CQE.
They issue requests in completely different ways. There is essentially no common code.
That sounds a bit handwavy, sorry.
I need to know exactly why.
Will it also have to be two separate MQ paths when we migrate to that?
Quoted 8 lines
Quoted 5 lines
Atleast I wanna see a serious rebuttal of why my claim that we should keep this code down is such a pipe dream that we just have to go ahead and make a second instance of all the core request mechanics. And that this should be part of the commit message: "I'm duplicating the queue thread because (...)" etc.
As I wrote above, we need to start with the legacy API, because of backporting and because we don't know how blk-mq will perform.
Sorry I do not buy it. (See the above references.)
We need to agree to disagree and leave this to
the higher authority then.
Quoted 8 lines
Quoted 6 lines
I'm sorry for being so conservative, but I am plain scared, I had serious trouble refactoring this code already, and I got the feeling that several people think the MMC stack has grown unapproachable for average developers (my Googledoc where I tried to pry it apart got very popular with developers I respect), and this is making that situation worse. Soon only you and Ulf will understand this piece of code.
The mmc block driver has problems, but the thread isn't one of them.
The pulling out of NULLs from the end of the request queue to flush the request pipeline is definately an abuse of the API and that is a big problem.
Quoted 2 lines
mmc_start_areq()is very convoluted. However, getting rid ofmmc_start_areq()is only the first step.
We are in violent agreement, at last.
Quoted 3 lines
Step two: have the host controller
complete requests without the need of block driver polling i.e.card_busy_detect()must not be called in the normal completion path.
I agree on this too.
Quoted 3 lines
Step
three: make it possible to issue the prepared request in the completion path of the current request.
I actually did patches to do that.
OK the patches suck for several reasons. But I have a proof of concept:
https://marc.info/?l=linux-mmc&m=148665460925587&w=2
Despite the convoluted subject this is what that patch does and what the series try to build up to.
Quoted 2 lines
Steps two and three need host controller driver
changes.
I don't know about that. I think I kind of pulled off three.
Yours,
Linus Walleij
Re: [PATCH V5 11/13] mmc: block: Add CQE support
In reply to Adrian HunterQuoted 5 lines · Adrian Hunter
We need to start with a legacy API because people want to backport CQ to earlier kernels (we really need to get features upstream more quickly), but blk-mq has been evolving a lot (e.g. elevator support), so backporters face having either something quite different from upstream or trying to backport great chunks of the block layer.
Hell no - the point of Linux mainline development is to move forward. We'll need to do the right thing for long term Linux development FIRST and then worry about backporting SECOND.
Stop thinking about all kernels while you wear your mainline kernel developer hat. Yes, occasionally we can do smaller amount of reordering to keep a small fix first for stable backports, but not to this extent of using obsolete infrastructure and making an already messy driver worse just to please backports to long obsolete kernels.
Re: [PATCH V5 11/13] mmc: block: Add CQE support
In reply to Linus WalleijQuoted 3 lines · Linus Walleij
So adding a new (in effect) invasive block driver needs to at least be CC:ed to the block maintainers so we don't sneak anything like that in under the radar.
Yes.
Quoted 2 lines
And this semaphoring and threading is just as confusing as ever and now we have two of them. (Sorry, I'm grumpy.)
But your are grumpy for a good reason. The MMC driver is a pain to understand for even a seasons block layer developer.
Quoted 4 lines
What we need is an MMC stack where it is clear where blocks come in and out and how they are processed by the block layer, but now we already have a scary Rube Goldberg-machine and it is not getting better. If people have different feelings they can tell me off right now.
Agreed.
Quoted 9 lines
I have my hopes up that we can get the code lesser and more readable with MQ, as I tried to illustrate in my attempts, which are indeed lame because they don't work because of misc and SDIO use cases, but I'm honestly doing my best. Currently with other clean-ups to get a clean surface to do that.
As it stands, the MQ migration work size is in some spots doubled or more than doubled after this commit :(
I don't think we should merge this.
Adrian Hunter
maintainerRe: [PATCH V5 11/13] mmc: block: Add CQE support
Quoted 27 lines · Christoph Hellwig
Quoted 3 lines · Linus Walleij
So adding a new (in effect) invasive block driver needs to at least be CC:ed to the block maintainers so we don't sneak anything like that in under the radar.
Yes.
Quoted 2 lines
And this semaphoring and threading is just as confusing as ever and now we have two of them. (Sorry, I'm grumpy.)
But your are grumpy for a good reason. The MMC driver is a pain to understand for even a seasons block layer developer.
Quoted 4 lines
What we need is an MMC stack where it is clear where blocks come in and out and how they are processed by the block layer, but now we already have a scary Rube Goldberg-machine and it is not getting better. If people have different feelings they can tell me off right now.
Agreed.
Quoted 7 lines
I have my hopes up that we can get the code lesser and more readable with MQ, as I tried to illustrate in my attempts, which are indeed lame because they don't work because of misc and SDIO use cases, but I'm honestly doing my best. Currently with other clean-ups to get a clean surface to do that.
Quoted 5 lines
Quoted 2 lines
As it stands, the MQ migration work size is in some spots doubled or more than doubled after this commit :(
I don't think we should merge this.
OK, let's merge the blk-mq version then. Here it is in V7:
https://marc.info/?l=linux-mmc&m=150418101630159&w=2
Adrian Hunter
maintainerPATCH v5 12/13 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
@@ -88,6 +88,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 v5 13/13 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 | 153 +++++++++++++++++++++++++++++++++++++- 2 files changed, 153 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 +152 -1
201 lines not on this page · raw message
Signature · 1 line
1.9.1
Quoted 16 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Adrian Hunter
Sent: Thursday, August 10, 2017 8:08 PM
To: Ulf Hansson <[email protected]>
Cc: linux-mmc <[email protected]>; Bough Chen <[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]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Linus Walleij <[email protected]>; Shawn Lin <[email protected]>
Subject: [PATCH V5 00/13] mmc: Add Command Queue support
Quoted 9 lines
Hi
Here is V5 of the hardware command queue patches without the software command queue patches.
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.
Hi Adrian,
My work is based on 4.9 branch, I back port most mmc related patches, but not back port that much block layer related patches, so when I apply your V5 patches, I remove some code, such as "BLK_STS_IOERR" and "REQ_OP_DRV_IN" "REQ_OP_DRV_OUT", change to the old usage. No other change for your V5 patches.
This V5 patches indeed fix the 32bit DMA issue, now my i.MX8 CMDQ can pass all the stress test.
So I would like to add:
Best Regards
Haibo chen
Quoted 98 lines
Changes since V4:
mmc: core: Addmmc_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 unusedMMC_CAP2_PACKED_CMD
New patch.
mmc: mmc: Enable Command Queuing
Adjust for removal ofMMC_CAP2_PACKED_CMD.
Add a comment about Packed Commands.
mmc: mmc: Enable CQE's
Remove un-necessary check forMMC_CAP2_CQE
mmc: block: Use local variables inmmc_blk_data_prep()
New patch.
mmc: block: Prepare CQE data
Adjust due to "mmc: block: Use local variables inmmc_blk_data_prep()"
Remove priority setting.
Add explanation to commit message.
mmc: cqhci: support for command queue enabled host
Fix transfer descriptor setting incqhci_set_tran_desc()for 32-bit DMAChanges since V3:
Adjusted ...blk_end_request...() for new block status codes Fixed CQHCI transaction descriptor for "no DCMD" caseChanges 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_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 (12):
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: core: Remove unusedMMC_CAP2_PACKED_CMD
mmc: mmc: Enable Command Queuing
mmc: mmc: Enable CQE's
mmc: block: Use local variables inmmc_blk_data_prep()
mmc: block: Prepare CQE data
mmc: block: Add CQE support
mmc: sdhci-pci: Add CQHCI support for Intel GLKVenkat Gopalakrishnan (1):
mmc: cqhci: support for command queue enabled hostdrivers/mmc/core/block.c | 238 +++++++- drivers/mmc/core/block.h | 7 + drivers/mmc/core/bus.c | 7 + drivers/mmc/core/core.c | 178 +++++- drivers/mmc/core/host.c | 6 + drivers/mmc/core/host.h | 1 + drivers/mmc/core/mmc.c | 42 +- drivers/mmc/core/queue.c | 273 ++++++++- drivers/mmc/core/queue.h | 42 +- 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 | 153 ++++- include/linux/mmc/core.h | 18 +- include/linux/mmc/host.h | 63 +- include/trace/events/mmc.h | 36 +- 17 files changed, 2412 insertions(+), 61 deletions(-) create mode 100644
drivers/mmc/host/cqhci.ccreate mode 100644drivers/mmc/host/cqhci.hRegards
Adrian
--
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
Quoted 17 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Adrian Hunter
Sent: Thursday, August 10, 2017 8:08 PM
To: Ulf Hansson <[email protected]>
Cc: linux-mmc <[email protected]>; Bough Chen <[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]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Linus Walleij <[email protected]>; Shawn Lin <[email protected]>
Subject: [PATCH V5 00/13] mmc: Add Command Queue support
Quoted 9 lines
Hi
Here is V5 of the hardware command queue patches without the software command queue patches.
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.
Hi Adrian,
I test the performance on the i.MX8. Here in my side, I use 'dd' to test the sequential read/write speed, see a slight 3% drop for both read and write.
---------------------------------------------
| | read (KB/s)| write (KB/s) |
---------------------------------------------
|CMDQ in HS400ES| 257 | 94.5 |
---------------------------------------------
| HS400ES | 265 | 96.6 |
--------------------------------------------- For random multi-threaded I/O, I use 'fio' to test, the test command:
fio -filename=/mnt/test -direct=1 -iodepth 1 -thread -rw=randread - ioengine=psync -bs=4k -size=2G -numjobs=10 -runtime=60 -group_reporting - name=mytest
I test 5 times, and get the average value.
For CMDQ in HS400ES
----------------------------------------------------
| block size | 4KB | 8KB | 16KB |
----------------------------------------------------
| random read | 26340KB/s | 51844KB/s | 85738KB/s |
----------------------------------------------------
| random write | 12691KB/s | 15879KB/s | 17535KB/s |
----------------------------------------------------HS400ES without CMDQ
----------------------------------------------------
| block size | 4KB | 8KB | 16KB |
----------------------------------------------------
| random read | 18585KB/s | 35041KB/s | 63880KB/s |
----------------------------------------------------
| random write | 16465KB/s | 19210KB/s | 22672KB/s |
----------------------------------------------------For random write from the test, I find every test value differ greatly no matter enable CMDQ or not.
Quoted 1 line
From the test, I see CMDQ random read speed increase 34%~48%, but for random write, the speed
drop 17.4% ~ 33%.
When you send software cmdq V5 patch, you give some explanation for the random write. But the average random write speed also drops a lot, I think it is now a good news, which need attention!
Maybe Shawn Lin can double test this random write performance.
Best Regards
Haibo Chen
Quoted 98 lines
Changes since V4:
mmc: core: Addmmc_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 unusedMMC_CAP2_PACKED_CMD
New patch.
mmc: mmc: Enable Command Queuing
Adjust for removal ofMMC_CAP2_PACKED_CMD.
Add a comment about Packed Commands.
mmc: mmc: Enable CQE's
Remove un-necessary check forMMC_CAP2_CQE
mmc: block: Use local variables inmmc_blk_data_prep()
New patch.
mmc: block: Prepare CQE data
Adjust due to "mmc: block: Use local variables inmmc_blk_data_prep()"
Remove priority setting.
Add explanation to commit message.
mmc: cqhci: support for command queue enabled host
Fix transfer descriptor setting incqhci_set_tran_desc()for 32-bit DMAChanges since V3:
Adjusted ...blk_end_request...() for new block status codes Fixed CQHCI transaction descriptor for "no DCMD" caseChanges 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_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 (12):
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: core: Remove unusedMMC_CAP2_PACKED_CMD
mmc: mmc: Enable Command Queuing
mmc: mmc: Enable CQE's
mmc: block: Use local variables inmmc_blk_data_prep()
mmc: block: Prepare CQE data
mmc: block: Add CQE support
mmc: sdhci-pci: Add CQHCI support for Intel GLKVenkat Gopalakrishnan (1):
mmc: cqhci: support for command queue enabled hostdrivers/mmc/core/block.c | 238 +++++++- drivers/mmc/core/block.h | 7 + drivers/mmc/core/bus.c | 7 + drivers/mmc/core/core.c | 178 +++++- drivers/mmc/core/host.c | 6 + drivers/mmc/core/host.h | 1 + drivers/mmc/core/mmc.c | 42 +- drivers/mmc/core/queue.c | 273 ++++++++- drivers/mmc/core/queue.h | 42 +- 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 | 153 ++++- include/linux/mmc/core.h | 18 +- include/linux/mmc/host.h | 63 +- include/trace/events/mmc.h | 36 +- 17 files changed, 2412 insertions(+), 61 deletions(-) create mode 100644
drivers/mmc/host/cqhci.ccreate mode 100644drivers/mmc/host/cqhci.hRegards
Adrian
--
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
Hi
Quoted 63 lines · Bough Chen
Quoted 17 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Adrian Hunter
Sent: Thursday, August 10, 2017 8:08 PM
To: Ulf Hansson <[email protected]>
Cc: linux-mmc <[email protected]>; Bough Chen <[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]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Linus Walleij <[email protected]>; Shawn Lin <[email protected]>
Subject: [PATCH V5 00/13] mmc: Add Command Queue supportQuoted 9 lines
Hi
Here is V5 of the hardware command queue patches without the software command queue patches.
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.
Hi Adrian,
I test the performance on the i.MX8. Here in my side, I use 'dd' to test the sequential read/write speed, see a slight 3% drop for both read and write.
--------------------------------------------- | | read (KB/s)| write (KB/s) | --------------------------------------------- |CMDQ in HS400ES| 257 | 94.5 | --------------------------------------------- | HS400ES | 265 | 96.6 | ---------------------------------------------For random multi-threaded I/O, I use 'fio' to test, the test command:
fio -filename=/mnt/test -direct=1 -iodepth 1 -thread -rw=randread - ioengine=psync -bs=4k -size=2G -numjobs=10 -runtime=60 -group_reporting - name=mytestI test 5 times, and get the average value.
For CMDQ in HS400ES---------------------------------------------------- | block size | 4KB | 8KB | 16KB | ---------------------------------------------------- | random read | 26340KB/s | 51844KB/s | 85738KB/s | ---------------------------------------------------- | random write | 12691KB/s | 15879KB/s | 17535KB/s | ----------------------------------------------------HS400ES without CMDQ
---------------------------------------------------- | block size | 4KB | 8KB | 16KB | ---------------------------------------------------- | random read | 18585KB/s | 35041KB/s | 63880KB/s | ---------------------------------------------------- | random write | 16465KB/s | 19210KB/s | 22672KB/s | ----------------------------------------------------For random write from the test, I find every test value differ greatly no matter enable CMDQ or not.
Quoted 8 lines
Quoted 1 line
From the test, I see CMDQ random read speed increase 34%~48%, but for random write, the speed
drop 17.4% ~ 33%.
When you send software cmdq V5 patch, you give some explanation for the random write. But the average random write speed also drops a lot, I think it is now a good news, which need attention!
Maybe Shawn Lin can double test this random write performance.
Yes, I also find the performance fluctuates a lot for different eMMC chips when enabling CMDQ. I will need more data to check that. Will update it later.
Quoted 109 lines
Best Regards
Haibo ChenQuoted 92 lines
Changes since V4:
mmc: core: Addmmc_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 unusedMMC_CAP2_PACKED_CMD
New patch.
mmc: mmc: Enable Command Queuing
Adjust for removal ofMMC_CAP2_PACKED_CMD.
Add a comment about Packed Commands.
mmc: mmc: Enable CQE's
Remove un-necessary check forMMC_CAP2_CQE
mmc: block: Use local variables inmmc_blk_data_prep()
New patch.
mmc: block: Prepare CQE data
Adjust due to "mmc: block: Use local variables inmmc_blk_data_prep()"
Remove priority setting.
Add explanation to commit message.
mmc: cqhci: support for command queue enabled host
Fix transfer descriptor setting incqhci_set_tran_desc()for 32-bit DMAChanges since V3:
Adjusted ...blk_end_request...() for new block status codes Fixed CQHCI transaction descriptor for "no DCMD" caseChanges 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_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 (12):
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: core: Remove unusedMMC_CAP2_PACKED_CMD
mmc: mmc: Enable Command Queuing
mmc: mmc: Enable CQE's
mmc: block: Use local variables inmmc_blk_data_prep()
mmc: block: Prepare CQE data
mmc: block: Add CQE support
mmc: sdhci-pci: Add CQHCI support for Intel GLKVenkat Gopalakrishnan (1):
mmc: cqhci: support for command queue enabled hostdrivers/mmc/core/block.c | 238 +++++++- drivers/mmc/core/block.h | 7 + drivers/mmc/core/bus.c | 7 + drivers/mmc/core/core.c | 178 +++++- drivers/mmc/core/host.c | 6 + drivers/mmc/core/host.h | 1 + drivers/mmc/core/mmc.c | 42 +- drivers/mmc/core/queue.c | 273 ++++++++- drivers/mmc/core/queue.h | 42 +- 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 | 153 ++++- include/linux/mmc/core.h | 18 +- include/linux/mmc/host.h | 63 +- include/trace/events/mmc.h | 36 +- 17 files changed, 2412 insertions(+), 61 deletions(-) create mode 100644
drivers/mmc/host/cqhci.ccreate mode 100644drivers/mmc/host/cqhci.hQuoted 6 lines
Regards
Adrian
--
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--
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 61 lines · Bough Chen
Quoted 17 lines
-----Original Message-----
From: [email protected] [mailto:linux-mmc- [email protected]] On Behalf Of Adrian Hunter
Sent: Thursday, August 10, 2017 8:08 PM
To: Ulf Hansson <[email protected]>
Cc: linux-mmc <[email protected]>; Bough Chen <[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]>; Sahitya Tummala <[email protected]>; Harjani Ritesh <[email protected]>; Venu Byravarasu <[email protected]>; Linus Walleij <[email protected]>; Shawn Lin <[email protected]>
Subject: [PATCH V5 00/13] mmc: Add Command Queue supportQuoted 9 lines
Hi
Here is V5 of the hardware command queue patches without the software command queue patches.
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.
Hi Adrian,
I test the performance on the i.MX8. Here in my side, I use 'dd' to test the sequential read/write speed, see a slight 3% drop for both read and write.
--------------------------------------------- | | read (KB/s)| write (KB/s) | --------------------------------------------- |CMDQ in HS400ES| 257 | 94.5 | --------------------------------------------- | HS400ES | 265 | 96.6 | ---------------------------------------------For random multi-threaded I/O, I use 'fio' to test, the test command:
fio -filename=/mnt/test -direct=1 -iodepth 1 -thread -rw=randread - ioengine=psync -bs=4k -size=2G -numjobs=10 -runtime=60 -group_reporting - name=mytestI test 5 times, and get the average value.
For CMDQ in HS400ES---------------------------------------------------- | block size | 4KB | 8KB | 16KB | ---------------------------------------------------- | random read | 26340KB/s | 51844KB/s | 85738KB/s | ---------------------------------------------------- | random write | 12691KB/s | 15879KB/s | 17535KB/s | ----------------------------------------------------HS400ES without CMDQ
---------------------------------------------------- | block size | 4KB | 8KB | 16KB | ---------------------------------------------------- | random read | 18585KB/s | 35041KB/s | 63880KB/s | ---------------------------------------------------- | random write | 16465KB/s | 19210KB/s | 22672KB/s | ----------------------------------------------------
Quoted 7 lines
For random write from the test, I find every test value differ greatly no matter enable CMDQ or not.
Quoted 1 line
From the test, I see CMDQ random read speed increase 34%~48%, but for random write, the speed
drop 17.4% ~ 33%.
When you send software cmdq V5 patch, you give some explanation for the random write. But the average random write speed also drops a lot, I think it is now a good news, which need attention!
I tried your test and got quite variable results but did not see a drop:
CQ
4K 8K 16K
Random Write 10,374 KB/s 9,669 KB/s 10,712 KB/s
Non-CQ
4K 8K 16K
Random Write 9,898 KB/s 8,747 KB/s 9,098 KB/s
But given the variability of results I would not conclude CQ was faster.
I would suggest you run more tests and see if the trend continues.
Adrian Hunter
maintainerQuoted 6 lines · Adrian Hunter
Here is V5 of the hardware command queue patches without the software command queue patches.
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.
Are there any more comments? If not, shouldn't this be applied?
Quoted 4 lines · Adrian Hunter
Hi
Here is V5 of the hardware command queue patches without the software command queue patches.
I have queued up a subset of this series for next, for those changes I have replied separately.
However to also simplify for people to test and to get some build reports from 0-build, I have published a cmdq branch in my mmc tree. The branch is not intended to stay that long-term, it is just as an intermediate step to help to find any further issues.
Kind regards
Uffe
Quoted 102 lines
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 V4:
mmc: core: Addmmc_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 unusedMMC_CAP2_PACKED_CMD
New patch.
mmc: mmc: Enable Command Queuing
Adjust for removal ofMMC_CAP2_PACKED_CMD.
Add a comment about Packed Commands.
mmc: mmc: Enable CQE's
Remove un-necessary check forMMC_CAP2_CQE
mmc: block: Use local variables inmmc_blk_data_prep()
New patch.
mmc: block: Prepare CQE data
Adjust due to "mmc: block: Use local variables inmmc_blk_data_prep()" Remove priority setting.
Add explanation to commit message.
mmc: cqhci: support for command queue enabled host
Fix transfer descriptor setting incqhci_set_tran_desc()for 32-bit DMAChanges since V3:
Adjusted ...blk_end_request...() for new block status codes Fixed CQHCI transaction descriptor for "no DCMD" caseChanges 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_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 (12):
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: core: Remove unusedMMC_CAP2_PACKED_CMD
mmc: mmc: Enable Command Queuing
mmc: mmc: Enable CQE's
mmc: block: Use local variables inmmc_blk_data_prep()
mmc: block: Prepare CQE data
mmc: block: Add CQE support
mmc: sdhci-pci: Add CQHCI support for Intel GLKVenkat Gopalakrishnan (1):
mmc: cqhci: support for command queue enabled hostdrivers/mmc/core/block.c | 238 +++++++- drivers/mmc/core/block.h | 7 + drivers/mmc/core/bus.c | 7 + drivers/mmc/core/core.c | 178 +++++- drivers/mmc/core/host.c | 6 + drivers/mmc/core/host.h | 1 + drivers/mmc/core/mmc.c | 42 +- drivers/mmc/core/queue.c | 273 ++++++++- drivers/mmc/core/queue.h | 42 +- 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 | 153 ++++- include/linux/mmc/core.h | 18 +- include/linux/mmc/host.h | 63 +- include/trace/events/mmc.h | 36 +- 17 files changed, 2412 insertions(+), 61 deletions(-) create mode 100644 drivers/mmc/host/cqhci.c create mode 100644 drivers/mmc/host/cqhci.hRegards
Adrian
--
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