Skip to content

RFC mmc: mmc: Add Software Command Queuing

Adrian Hunter linux-mmc 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest46 patches 0 repliesNew

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/46mmc: core: Add support for sending commands during data transferdrivers/mmc/core/core.c include/linux/mmc/core.h include/linux/mmc/host.h+101 -60 replies
2/46mmc: mmc_test: Add tests for sending commands during transferdrivers/mmc/card/mmc_test.c+308 -00 replies
3/46mmc: sdhci: Move busy signal handling into sdhci_finish_cmd()drivers/mmc/host/sdhci.c+26 -280 replies
4/46mmc: sdhci: Get rid of redundant BUG_ONsdrivers/mmc/host/sdhci.c+0 -90 replies
5/46mmc: sdhci: Simplify sdhci_finish_command() by clearing host->cmd at the startdrivers/mmc/host/sdhci.c+12 -130 replies
6/46mmc: sdhci: Record what command is using the data linesdrivers/mmc/host/sdhci.c drivers/mmc/host/sdhci.h+15 -30 replies
7/46mmc: sdhci: Get rid of host->busy_handledrivers/mmc/host/sdhci.c drivers/mmc/host/sdhci.h+6 -90 replies
8/46mmc: sdhci: Reduce the use of host->mrqdrivers/mmc/host/sdhci.c+8 -80 replies
9/46mmc: sdhci: Move host->data warningdrivers/mmc/host/sdhci.c+2 -20 replies
10/46mmc: sdhci: Factor out sdhci_finish_mrq()drivers/mmc/host/sdhci.c+18 -120 replies
11/46mmc: sdhci: Factor out sdhci_needs_reset()drivers/mmc/host/sdhci.c+11 -70 replies
12/46mmc: sdhci: Track whether a reset is pendingdrivers/mmc/host/sdhci.c drivers/mmc/host/sdhci.h+21 -00 replies
13/46mmc: sdhci: Clear pointers when a request finishesdrivers/mmc/host/sdhci.c+9 -30 replies
14/46mmc: sdhci: Ensure all requests get errored outdrivers/mmc/host/sdhci.c+23 -80 replies
15/46mmc: sdhci: Factor out sdhci_data_line_cmd()drivers/mmc/host/sdhci.c+8 -30 replies
16/46mmc: sdhci: Separate timer timeout for command and data requestsdrivers/mmc/host/sdhci.c drivers/mmc/host/sdhci.h+53 -100 replies
17/46mmc: sdhci: Allow for finishing multiple requestsdrivers/mmc/host/sdhci.c drivers/mmc/host/sdhci.h+53 -230 replies
18/46mmc: sdhci: Factor out sdhci_auto_cmd12()drivers/mmc/host/sdhci.c+8 -20 replies
19/46mmc: sdhci: Do not reset cmd or data circuits that are in usedrivers/mmc/host/sdhci.c+6 -30 replies
20/46mmc: sdhci: Support cap_cmd_during_tfr requestsdrivers/mmc/host/sdhci.c+14 -20 replies
21/46mmc: sdhci-pci: Set MMC_CAP_CMD_DURING_TFR for Intel eMMC controllersdrivers/mmc/host/sdhci-pci-core.c+1 -00 replies
22/46mmc: sdhci-acpi: Set MMC_CAP_CMD_DURING_TFR for Intel eMMC controllersdrivers/mmc/host/sdhci-acpi.c+1 -10 replies
23/46mmc: queue: Fix queue thread wake-updrivers/mmc/card/block.c drivers/mmc/card/queue.c drivers/mmc/card/queue.h +2 more+22 -290 replies
24/46mmc: queue: Factor out mmc_queue_alloc_bounce_bufs()drivers/mmc/card/queue.c+27 -180 replies
25/46mmc: queue: Factor out mmc_queue_alloc_bounce_sgs()drivers/mmc/card/queue.c+28 -160 replies
26/46mmc: queue: Factor out mmc_queue_alloc_sgs()drivers/mmc/card/queue.c+16 -60 replies
27/46mmc: queue: Factor out mmc_queue_reqs_free_bufs()drivers/mmc/card/queue.c+26 -390 replies
28/46mmc: queue: Introduce queue depthdrivers/mmc/card/queue.c drivers/mmc/card/queue.h+5 -00 replies
29/46mmc: queue: Use queue depth to allocate and freedrivers/mmc/card/queue.c+46 -570 replies
30/46mmc: queue: Allocate queue of size qdepthdrivers/mmc/card/queue.c drivers/mmc/card/queue.h+6 -20 replies
31/46mmc: mmc: Add Command Queue definitionsdrivers/mmc/core/mmc.c include/linux/mmc/card.h include/linux/mmc/mmc.h+39 -00 replies
32/46mmc: mmc: Add functions to enable / disable the Command Queuedrivers/mmc/core/mmc_ops.c include/linux/mmc/core.h+29 -00 replies
33/46mmc: mmc_test: Disable Command Queue while mmc_test is useddrivers/mmc/card/mmc_test.c drivers/mmc/core/mmc.c include/linux/mmc/card.h+16 -04 replies
34/46mmc: block: Disable Command Queue while RPMB is useddrivers/mmc/card/block.c+38 -80 replies
35/46mmc: core: Do not prepare a new request twicedrivers/mmc/core/core.c include/linux/mmc/host.h+10 -30 replies
36/46mmc: core: Export mmc_retune_hold() and mmc_retune_release()drivers/mmc/core/host.c drivers/mmc/core/host.h include/linux/mmc/core.h+5 -20 replies
37/46mmc: block: Factor out mmc_blk_requeue()drivers/mmc/card/block.c+10 -80 replies
38/46mmc: block: Fix 4K native sector checkdrivers/mmc/card/block.c+5 -30 replies
39/46mmc: block: Use local var for mqrq_curdrivers/mmc/card/block.c+9 -80 replies
40/46mmc: block: Pass mqrq to mmc_blk_prep_packed_list()drivers/mmc/card/block.c+5 -40 replies
41/46mmc: block: Introduce queue semanticsdrivers/mmc/card/block.c drivers/mmc/card/queue.c drivers/mmc/card/queue.h+77 -490 replies
42/46mmc: queue: Add a function to control wake-up on new requestsdrivers/mmc/card/queue.c drivers/mmc/card/queue.h+18 -00 replies
43/46mmc: block: Add Software Command Queuingdrivers/mmc/card/block.c drivers/mmc/card/queue.c drivers/mmc/card/queue.h +1 more+610 -30 replies
44/46mmc: mmc: Enable Software Command Queuingdrivers/mmc/core/mmc.c include/linux/mmc/host.h+17 -10 replies
45/46mmc: sdhci-pci: Enable Software Command Queuing for some Intel controllersdrivers/mmc/host/sdhci-pci-core.c+1 -10 replies
46/46mmc: sdhci-acpi: Enable Software Command Queuing for some Intel controllersdrivers/mmc/host/sdhci-acpi.c+1 -10 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH RFC 00/46] mmc: mmc: Add Software Command Queuing

Hi

Chuanxiao Dong sent some patches last year relating to eMMC 5.1 Software Command Queuing. He did not follow-up but I have contacted him and he says it is OK if I take over upstreaming the patches.

eMMC Command Queuing is a feature added in version 5.1. The card maintains a queue of up to 32 data transfers. Commands CMD45/CMD45 are sent to queue up transfers in advance, and then one of the transfers is selected to "execute" by CMD46/CMD47 at which point data transfer actually begins.

The advantage of command queuing is that the card can prepare for transfers in advance. That makes a big difference in the case of random reads because the card can start reading into its cache in advance.

A v5.1 host controller can manage the command queue itself, but it is also possible for software to manage the queue using an non-v5.1 host controller
- that is what Software Command Queuing is.

Refer to the JEDEC (http://www.jedec.org/) eMMC v5.1 Specification for more information about Command Queuing.

While these patches are heavily based on Dong's patches, there are some changes:

SDHCI has been amended to support commands during transfer. That is a generic change added in patches 1 - 22. In principle, that would also support SDIO's CMD52 during data transfer.

The original approach added multiple commands into the same request for sending CMD44, CMD45 and CMD13. That is not strictly necessary and has been omitted for now.

The original approach also called blk_end_request() from the mrq->done() function, which means the upper layers learnt of completed requests slightly earlier. That is not strictly related to Software Command Queuing and is something that could potentially be done for all data requests. That has been omitted for now.

The current block driver supports 2 requests on the go at a time. Patches 23 - 30 make preparations for an arbitrary sized queue. Patches 31 - 34 introduce Command Queue definitions and helpers. Patches 35 - 41 complete the job of making the block driver use a queue. Patches 42 - 44 finally add Software Command Queuing, and 45 - 46 enable it for Intel eMMC controllers. Most of the Software Command Queuing functionality is added in patch 43.

The patches can also be found here:

http://git.infradead.org/users/ahunter/linux-sdhci.git/shortlog/refs/heads/swcmdq

The patches have only had basic testing so far. Ad-hoc testing shows a degradation in sequential read performance of about 10% but an increase in throughput for mixed workload of multiple processes of about 90%. The reduction in sequential performance is due to the need to read the Queue Status register between each transfer.

These patches should not conflict with Hardware Command Queuing which handles the queue in a completely different way and thus does not need to share code with Software Command Queuing. The exceptions being the Command Queue definitions and queue allocation which should be able to be used.

Adrian Hunter (46):
mmc: core: Add support for sending commands during data transfer
mmc: mmc_test: Add tests for sending commands during transfer
mmc: sdhci: Move busy signal handling into sdhci_finish_cmd()
mmc: sdhci: Get rid of redundant BUG_ONs
mmc: sdhci: Simplify sdhci_finish_command() by clearing host->cmd at the start
mmc: sdhci: Record what command is using the data lines
mmc: sdhci: Get rid of host->busy_handle
mmc: sdhci: Reduce the use of host->mrq
mmc: sdhci: Move host->data warning
mmc: sdhci: Factor out sdhci_finish_mrq()
mmc: sdhci: Factor out sdhci_needs_reset()
mmc: sdhci: Track whether a reset is pending
mmc: sdhci: Clear pointers when a request finishes
mmc: sdhci: Ensure all requests get errored out
mmc: sdhci: Factor out sdhci_data_line_cmd()
mmc: sdhci: Separate timer timeout for command and data requests
mmc: sdhci: Allow for finishing multiple requests
mmc: sdhci: Factor out sdhci_auto_cmd12()
mmc: sdhci: Do not reset cmd or data circuits that are in use
mmc: sdhci: Support cap_cmd_during_tfr requests
mmc: sdhci-pci: Set MMC_CAP_CMD_DURING_TFR for Intel eMMC controllers
mmc: sdhci-acpi: Set MMC_CAP_CMD_DURING_TFR for Intel eMMC controllers
mmc: queue: Fix queue thread wake-up
mmc: queue: Factor out mmc_queue_alloc_bounce_bufs()
mmc: queue: Factor out mmc_queue_alloc_bounce_sgs()
mmc: queue: Factor out mmc_queue_alloc_sgs()
mmc: queue: Factor out mmc_queue_reqs_free_bufs()
mmc: queue: Introduce queue depth
mmc: queue: Use queue depth to allocate and free
mmc: queue: Allocate queue of size qdepth
mmc: mmc: Add Command Queue definitions
mmc: mmc: Add functions to enable / disable the Command Queue
mmc: mmc_test: Disable Command Queue while mmc_test is used
mmc: block: Disable Command Queue while RPMB is used
mmc: core: Do not prepare a new request twice
mmc: core: Export mmc_retune_hold() and mmc_retune_release()
mmc: block: Factor out mmc_blk_requeue()
mmc: block: Fix 4K native sector check
mmc: block: Use local var for mqrq_cur
mmc: block: Pass mqrq to mmc_blk_prep_packed_list()
mmc: block: Introduce queue semantics
mmc: queue: Add a function to control wake-up on new requests
mmc: block: Add Software Command Queuing
mmc: mmc: Enable Software Command Queuing
mmc: sdhci-pci: Enable Software Command Queuing for some Intel controllers
mmc: sdhci-acpi: Enable Software Command Queuing for some Intel controllers

 drivers/mmc/card/block.c          | 738 +++++++++++++++++++++++++++++++++++---
 drivers/mmc/card/mmc_test.c       | 316 ++++++++++++++++
 drivers/mmc/card/queue.c          | 296 +++++++++------
 drivers/mmc/card/queue.h          |  27 +-
 drivers/mmc/core/core.c           | 113 +++++-
 drivers/mmc/core/host.c           |   2 +
 drivers/mmc/core/host.h           |   2 -
 drivers/mmc/core/mmc.c            |  43 ++-
 drivers/mmc/core/mmc_ops.c        |  27 ++
 drivers/mmc/host/sdhci-acpi.c     |   4 +-
 drivers/mmc/host/sdhci-pci-core.c |   1 +
 drivers/mmc/host/sdhci.c          | 391 +++++++++++++-------
 drivers/mmc/host/sdhci.h          |   9 +-
 include/linux/mmc/card.h          |   5 +
 include/linux/mmc/core.h          |  12 +
 include/linux/mmc/host.h          |   9 +-
 include/linux/mmc/mmc.h           |  17 +
 17 files changed, 1686 insertions(+), 326 deletions(-)

Regards
Adrian