Add MMC packed function
Subsystems (4)
cover Add MMC packed function
Hi All,
Now some SD/MMC controllers can support packed command or packed request, that means it can package multiple requests to host controller to be handled at one time, which can improve the I/O performence. Thus this patchset is used to add the MMC packed function to support packed request or packed command.
In this patch set, I implemented the SD host ADMA3 transfer mode to support packed request. The ADMA3 transfer mode can process a multi-block data transfer by using a pair of command descriptor and ADMA2 descriptor. In future we can easily expand the MMC packed function to support packed command.
Below are some comparison data between packed request and non-packed request with fio tool. The fio command I used is like below with changing the '--rw' parameter and enabling the direct IO flag to measure the actual hardware transfer speed.
./fio --filename=/dev/mmcblk0p30 --direct=1 --iodepth=20 --rw=read --bs=4K --size=512M --group_reporting --numjobs=20 --name=test_read
My eMMC card working at HS400 Enhanced strobe mode:
[ 2.229856] mmc0: new HS400 Enhanced strobe MMC card at address 0001 [ 2.237566] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB [ 2.242621] mmcblk0boot0: mmc0:0001 HBG4a2 partition 1 4.00 MiB [ 2.249110] mmcblk0boot1: mmc0:0001 HBG4a2 partition 2 4.00 MiB [ 2.255307] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB, chardev (248:0)
1. Non-packed request
I tested 3 times for each case and output a average speed.
1) Sequential read:
Speed: 28.9MiB/s, 26.4MiB/s, 30.9MiB/s
Average speed: 28.7MiB/s
2) Random read:
Speed: 18.2MiB/s, 8.9MiB/s, 15.8MiB/s
Average speed: 14.3MiB/s
3) Sequential write:
Speed: 21.1MiB/s, 27.9MiB/s, 25MiB/s
Average speed: 24.7MiB/s
4) Random write:
Speed: 21.5MiB/s, 18.1MiB/s, 18.1MiB/s
Average speed: 19.2MiB/s
2. Packed request
In packed request mode, I set the host controller can package maximum 10 requests at one time (Actually I can increase the package number), and I enabled read/write packed request mode. Also I tested 3 times for each case and output a average speed.
1) Sequential read:
Speed: 165MiB/s, 167MiB/s, 164MiB/s
Average speed: 165.3MiB/s
2) Random read:
Speed: 147MiB/s, 141MiB/s, 144MiB/s
Average speed: 144MiB/s
3) Sequential write:
Speed: 87.8MiB/s, 89.1MiB/s, 90.0MiB/s
Average speed: 89MiB/s
4) Random write:
Speed: 90.9MiB/s, 89.8MiB/s, 90.4MiB/s
Average speed: 90.4MiB/s
Form above data, we can see the packed request can improve the performance greatly. Any comments are welcome. Thanks a lot.
Baolin Wang (7):
blk-mq: Export blk_mq_hctx_has_pending() function
mmc: core: Add MMC packed request function
mmc: host: sdhci: Introduce ADMA3 transfer mode
mmc: host: sdhci: Factor out the command configuration
mmc: host: sdhci: Remove redundant sg_count member of struct
sdhci_host
mmc: host: sdhci: Add MMC packed request support
mmc: host: sdhci-sprd: Add MMC packed request support
block/blk-mq.c | 3 +- drivers/mmc/core/Kconfig | 2 + drivers/mmc/core/Makefile | 1 + drivers/mmc/core/block.c | 71 +++++- drivers/mmc/core/block.h | 3 +- drivers/mmc/core/core.c | 51 ++++ drivers/mmc/core/core.h | 3 + drivers/mmc/core/packed.c | 478 ++++++++++++++++++++++++++++++++++++++ drivers/mmc/core/queue.c | 28 ++- drivers/mmc/host/Kconfig | 1 + drivers/mmc/host/sdhci-sprd.c | 22 +- drivers/mmc/host/sdhci.c | 513 +++++++++++++++++++++++++++++++++++------ drivers/mmc/host/sdhci.h | 59 ++++- include/linux/blk-mq.h | 1 + include/linux/mmc/core.h | 1 + include/linux/mmc/host.h | 3 + include/linux/mmc/packed.h | 123 ++++++++++ 17 files changed, 1286 insertions(+), 77 deletions(-) create mode 100644 drivers/mmc/core/packed.c create mode 100644 include/linux/mmc/packed.h
Signature · 1 line
1.7.9.5
RFC PATCH 1/7 blk-mq: Export blk_mq_hctx_has_pending() function
Some SD/MMC host controllers can support packed command or packed request, that means we can package several requests to host controller at one time to improve performence. And this patch set will introduce MMC packed function to support this feature by following patches.
To support MMC packed function, the MMC layer need to know if there are requests are pending now in hardware queue to help to combine requests as much as possible. If we know there are requests pending in hardware queue, then we should not package requests to host controller immediately, instead we should collect more requests into MMC packed queue to be packed to host controller with packed condition.
Thus export this function for MMC packed function.
--- block/blk-mq.c | 3 ++- include/linux/blk-mq.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
block/blk-mq.c +2 -1
@@ -63,12 +63,13 @@ static int blk_mq_poll_stats_bkt(const struct request *rq)* Check if any of the ctx, dispatch list or elevator * have pending work in this hardware queue. */ -static bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx) +bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx) {return !list_empty_careful (&hctx->dispatch) ||sbitmap_any_bit_set (&hctx->ctx_map) ||blk_mq_sched_has_work (hctx); } +EXPORT_SYMBOL_GPL (blk_mq_hctx_has_pending);/* * Mark this ctx as having pending work in this hardware queue
include/linux/blk-mq.h +1 -0
@@ -334,6 +334,7 @@ int blk_mq_freeze_queue_wait_timeout(struct request_queue *q,void blk_mq_quiesce_queue_nowait (struct request_queue *q);unsigned int blk_mq_rq_cpu (struct request *rq); +bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx);/* * Driver command data is immediately after the request. So subtract request
Signature · 1 line
1.7.9.5
Re: [RFC PATCH 1/7] blk-mq: Export blk_mq_hctx_has_pending() function
Quoted 26 lines · Baolin Wang
Some SD/MMC host controllers can support packed command or packed request, that means we can package several requests to host controller at one time to improve performence. And this patch set will introduce MMC packed function to support this feature by following patches.
To support MMC packed function, the MMC layer need to know if there are requests are pending now in hardware queue to help to combine requests as much as possible. If we know there are requests pending in hardware queue, then we should not package requests to host controller immediately, instead we should collect more requests into MMC packed queue to be packed to host controller with packed condition.
Thus export this function for MMC packed function.
Signed-off-by Baolin Wang <[email protected]>--- block/blk-mq.c | 3 ++- include/linux/blk-mq.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)block/blk-mq.c +0
-0@@ -63,12 +63,13 @@ static int blk_mq_poll_stats_bkt(const struct request *rq)* Check if any of the ctx, dispatch list or elevator
block/blk-mq.c static int blk_mq_poll_stats_bkt(const struct request *rq) · line 72
Quoted 10 lines
block/blk-mq.c +2
-1* have pending work in this hardware queue. */ -static bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx) +bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx) {return !list_empty_careful (&hctx->dispatch) ||sbitmap_any_bit_set (&hctx->ctx_map) ||blk_mq_sched_has_work (hctx); } +EXPORT_SYMBOL_GPL (blk_mq_hctx_has_pending);
Just wondering why you don't use the 'last' field of 'struct blk_mq_queue_data', which is passed to .queue_rq(), and supposed for implementing batch submission.
Thanks,
Ming
Re: [RFC PATCH 1/7] blk-mq: Export blk_mq_hctx_has_pending() function
Hi Ming,
Quoted 33 lines · Ming Lei
Quoted 31 lines · Baolin Wang
Some SD/MMC host controllers can support packed command or packed request, that means we can package several requests to host controller at one time to improve performence. And this patch set will introduce MMC packed function to support this feature by following patches.
To support MMC packed function, the MMC layer need to know if there are requests are pending now in hardware queue to help to combine requests as much as possible. If we know there are requests pending in hardware queue, then we should not package requests to host controller immediately, instead we should collect more requests into MMC packed queue to be packed to host controller with packed condition.
Thus export this function for MMC packed function.
Signed-off-by Baolin Wang <[email protected]>--- block/blk-mq.c | 3 ++- include/linux/blk-mq.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)block/blk-mq.c +1
-1@@ -63,12 +63,13 @@ static int blk_mq_poll_stats_bkt(const struct request *rq)* Check if any of the ctx, dispatch list or elevator * have pending work in this hardware queue. */ -static bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx) +bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx) {
Quoted 8 lines
block/blk-mq.c static int blk_mq_poll_stats_bkt(const struct request *rq) · line 72
Quoted 5 lines
block/blk-mq.c +1
-0return !list_empty_careful (&hctx->dispatch) ||sbitmap_any_bit_set (&hctx->ctx_map) ||blk_mq_sched_has_work (hctx); } +EXPORT_SYMBOL_GPL (blk_mq_hctx_has_pending);Just wondering why you don't use the 'last' field of 'struct
blk_mq_queue_data', which is passed to .queue_rq(), and supposed for implementing batch submission.
The 'last' field of 'struct blk_mq_queue_data' does not indicate the last request in the hardware queue, since we want to collect more requests from block layer as much as possible to be packed later.
And from blk_mq_do_dispatch_sched()--->blk_mq_dispatch_rq_list()---> queue_rq(), I always get 'bd.last = true', which is not useful to combine requests for MMC packed queue. Maybe I missed anything?
Thanks for your comments.
Signature · 2 lines
Baolin Wang Best Regards
Re: [RFC PATCH 1/7] blk-mq: Export blk_mq_hctx_has_pending() function
Quoted 45 lines · Baolin Wang
Hi Ming,
Quoted 33 lines · Ming Lei
Quoted 31 lines · Baolin Wang
Some SD/MMC host controllers can support packed command or packed request, that means we can package several requests to host controller at one time to improve performence. And this patch set will introduce MMC packed function to support this feature by following patches.
To support MMC packed function, the MMC layer need to know if there are requests are pending now in hardware queue to help to combine requests as much as possible. If we know there are requests pending in hardware queue, then we should not package requests to host controller immediately, instead we should collect more requests into MMC packed queue to be packed to host controller with packed condition.
Thus export this function for MMC packed function.
Signed-off-by Baolin Wang <[email protected]>--- block/blk-mq.c | 3 ++- include/linux/blk-mq.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)block/blk-mq.c +1
-1@@ -63,12 +63,13 @@ static int blk_mq_poll_stats_bkt(const struct request *rq)* Check if any of the ctx, dispatch list or elevator * have pending work in this hardware queue. */ -static bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx) +bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx) {Quoted 8 lines
block/blk-mq.c static int blk_mq_poll_stats_bkt(const struct request *rq) · line 72
Quoted 5 lines
block/blk-mq.c +1
-0return !list_empty_careful (&hctx->dispatch) ||sbitmap_any_bit_set (&hctx->ctx_map) ||blk_mq_sched_has_work (hctx); } +EXPORT_SYMBOL_GPL (blk_mq_hctx_has_pending);Just wondering why you don't use the 'last' field of 'struct
blk_mq_queue_data', which is passed to .queue_rq(), and supposed for implementing batch submission.
Quoted 7 lines
The 'last' field of 'struct
blk_mq_queue_data' does not indicate the last request in the hardware queue, since we want to collect more requests from block layer as much as possible to be packed later.And from blk_mq_do_dispatch_sched()--->blk_mq_dispatch_rq_list()--->
queue_rq(), I always get 'bd.last = true', which is not useful to combine requests for MMC packed queue. Maybe I missed anything?
That is one flaw of current implementation, and we may improve it, so other drivers(virtio-io, ...) can benefit from it too.
Thanks,
Ming
Re: [RFC PATCH 1/7] blk-mq: Export blk_mq_hctx_has_pending() function
Quoted 61 lines · Ming Lei
Quoted 60 lines · Baolin Wang
Hi Ming,
Quoted 44 lines · Ming Lei
Quoted 42 lines · Baolin Wang
Some SD/MMC host controllers can support packed command or packed request,
that means we can package several requests to host controller at one time
to improve performence. And this patch set will introduce MMC packed function
to support this feature by following patches.To support MMC packed function, the MMC layer need to know if there are
requests are pending now in hardware queue to help to combine requests
as much as possible. If we know there are requests pending in hardware
queue, then we should not package requests to host controller immediately,
instead we should collect more requests into MMC packed queue to be packed
to host controller with packed condition.Thus export this function for MMC packed function.
Signed-off-by Baolin Wang <[email protected]>--- block/blk-mq.c | 3 ++- include/linux/blk-mq.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)block/blk-mq.c +1
-1@@ -63,12 +63,13 @@ static int blk_mq_poll_stats_bkt(const structrequest *rq) * Check if any of the ctx, dispatch list or elevator * have pending work in this hardware queue. */ -static bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx) +bool blk_mq_hctx_has_pending (struct blk_mq_hw_ctx *hctx) {return !list_empty_careful (&hctx->dispatch) || sbitmap_any_bit_set(&hctx->ctx_map) ||Quoted 8 lines
block/blk-mq.c static int blk_mq_poll_stats_bkt(const struct · line 73
Quoted 3 lines
block/blk-mq.c +1
-0blk_mq_sched_has_work (hctx); } +EXPORT_SYMBOL_GPL (blk_mq_hctx_has_pending);Just wondering why you don't use the 'last' field of 'struct
blk_mq_queue_data',
which is passed to .queue_rq(), and supposed for implementing batch submission.The 'last' field of 'struct
blk_mq_queue_data' does not indicate the last request in the hardware queue, since we want to collect more requests from block layer as much as possible to be packed later.
Quoted 7 lines
Quoted 3 lines
And from blk_mq_do_dispatch_sched()--->blk_mq_dispatch_rq_list()--->
queue_rq(), I always get 'bd.last = true', which is not useful to combine requests for MMC packed queue. Maybe I missed anything?That is one flaw of current implementation, and we may improve it, so other
drivers(virtio-io, ...)can benefit from it too.
OK. I am not sure can I add a new flag to indicate if there are requests are pending in the hardware queue? That will help MMC driver to combine more requests.
Or do you have any other good suggestion? Thanks.
block/blk-mq.c +0 -0
@@ -1257,6 +1257,8 @@ bool blk_mq_dispatch_rq_list(struct
request_queue *q, struct list_head *list,
bd.last = !blk_mq_get_driver_tag(nxt);
}+ bd.rq_pending = blk_mq_hctx_has_pending(hctx);
+
ret = q->mq_ops->queue_rq(hctx, &bd);
if (ret == BLK_STS_RESOURCE || ret == BLK_STS_DEV_RESOURCE) {
/*include/linux/blk-mq.h +1 -1
@@ -118,6 +118,7 @@ struct blk_mq_tag_set {struct blk_mq_queue_data {struct request *rq;bool last; +bool rq_pending; }; --
Baolin Wang
Best Regards
RFC PATCH 2/7 mmc: core: Add MMC packed request function
In reply to Baolin WangSome SD controllers can support packed command or packed request, that means it can package several requests to host controller to be handled at one time, which can reduce interrutps and improve the DMA transfer. As a result, the I/O performence can be improved.
Thus this patch adds MMC packed function to support packed requests or packe command.
The basic concept of this function is that, we try to collect more requests from block layer as much as possible to be linked into MMC packed queue by mmc_blk_packed_issue_rw_rq(). When the last request of the hardware queue comes, or the collected request numbers are larger than 16, or a larger request comes, then we can start to pakage a packed request to host controller. The MMC packed function also supplies packed algorithm operations to help to package qualified requests. After finishing the packed request, the MMC packed function will help to complete each request, at the same time, the MMC packed queue will allow to collect more requests from block layer. After completing each request, the MMC packed function can try to package another packed request to host controller directly in the complete path, if there are enough requests in MMC packed queue or the request pending flag is not set. If the pending flag was set, we should let the mmc_blk_packed_issue_rw_rq() collect more request as much as possible.
--- drivers/mmc/core/Kconfig | 2 + drivers/mmc/core/Makefile | 1 + drivers/mmc/core/block.c | 71 ++++++- drivers/mmc/core/block.h | 3 +- drivers/mmc/core/core.c | 51 +++++ drivers/mmc/core/core.h | 3 + drivers/mmc/core/packed.c | 478 ++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/core/queue.c | 28 ++- include/linux/mmc/core.h | 1 + include/linux/mmc/host.h | 3 + include/linux/mmc/packed.h | 123 ++++++++++++ 11 files changed, 760 insertions(+), 4 deletions(-) create mode 100644 drivers/mmc/core/packed.c create mode 100644 include/linux/mmc/packed.h
drivers/mmc/core/Kconfig +2 -0
@@ -81,3 +81,5 @@ config MMC_TEST This driver is only of interest to those developing or testing a host driver. Most people should say N here. +config MMC_PACKED + bool
drivers/mmc/core/Makefile +1 -0
@@ -18,3 +18,4 @@ obj-$(CONFIG_MMC_BLOCK) += mmc_block.o mmc_block-objs := block.o queue.o obj-$(CONFIG_MMC_TEST) += mmc_test.o obj-$(CONFIG_SDIO_UART) += sdio_uart.o +obj-$(CONFIG_MMC_PACKED) += packed.o
drivers/mmc/core/block.c +70 -1
93 lines not on this page · raw message
drivers/mmc/core/block.h +2 -1
@@ -9,7 +9,8 @@enum mmc_issued ; -enum mmc_issued mmc_blk_mq_issue_rq (struct mmc_queue *mq,struct request *req); +enum mmc_issued mmc_blk_mq_issue_rq (struct mmc_queue *mq,struct request *req, +bool last);void mmc_blk_mq_complete (struct request *req);void mmc_blk_mq_recovery (struct mmc_queue *mq);
drivers/mmc/core/core.c +51 -0
69 lines not on this page · raw message
drivers/mmc/core/core.h +3 -0
@@ -138,6 +138,9 @@ static inline void mmc_claim_host(struct mmc_host *host)void mmc_cqe_post_req (struct mmc_host *host,struct mmc_request *mrq);int mmc_cqe_recovery (struct mmc_host *host); +int mmc_packed_start_req (struct mmc_host *host,struct mmc_request *mrq); +void mmc_packed_request_done (struct mmc_host *host,struct mmc_request *mrq); +/** * mmc_pre_req - Prepare for a new request * @host: MMC host to prepare command
drivers/mmc/core/packed.c new file +478 -0
478 lines not on this page · raw message
drivers/mmc/core/queue.c +26 -2
@@ -244,7 +244,7 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,struct mmc_host *host = card->host;enum mmc_issue_type issue_type;enum mmc_issued issued; -bool get_card, cqe_retune_ok; +bool get_card, cqe_retune_ok, last = false;int ret;if (mmc_card_removed (mq->card)) {
@@ -270,6 +270,15 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx, }break ;case MMC_ISSUE_ASYNC : +/* +* If packed request is busy now, we can return BLK_STS_RESOURCE +* to tell block layer to queue them later and MMC packed layer +* will try to combine requests as much as possible. +*/ +if (host->packed &&mmc_packed_queue_is_busy (host->packed)) { +spin_unlock_irq (&mq->lock); +return BLK_STS_RESOURCE ; + }break ;default :/*
@@ -305,9 +314,12 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx, !host->hold_retune; } +if (host->packed) + last = bd->last && !blk_mq_hctx_has_pending (hctx); +blk_mq_start_request (req); - issued =mmc_blk_mq_issue_rq (mq, req); + issued =mmc_blk_mq_issue_rq (mq, req, last);switch (issued) {case MMC_REQ_BUSY :
@@ -339,8 +351,20 @@ static blk_status_t mmc_mq_queue_rq(struct blk_mq_hw_ctx *hctx,return ret; } +static void mmc_mq_commit_rqs (struct blk_mq_hw_ctx *hctx) +{ +struct mmc_queue *mq = hctx->queue->queuedata; +struct mmc_card *card = mq->card; +struct mmc_host *host = card->host; + +/* Tell MMC packed more requests will be coming */ +if (host->packed) +mmc_packed_queue_commit_rqs (host->packed); +} +static const struct blk_mq_ops mmc_mq_ops = { .queue_rq = mmc_mq_queue_rq, + .commit_rqs = mmc_mq_commit_rqs, .init_request = mmc_mq_init_request, .exit_request = mmc_mq_exit_request, .complete = mmc_blk_mq_complete,
include/linux/mmc/core.h +1 -0
@@ -165,6 +165,7 @@ struct mmc_request {bool cap_cmd_during_tfr;int tag; +struct list_head packed_list; };struct mmc_card ;
include/linux/mmc/host.h +3 -0
@@ -13,6 +13,7 @@#include <linux/mmc/core.h> #include <linux/mmc/card.h> +#include <linux/mmc/packed.h> #include <linux/mmc/pm.h> #include <linux/dma-direction.h>
@@ -441,6 +442,8 @@ struct mmc_host {/* Ongoing data transfer that allows commands during transfer */ struct mmc_request *ongoing_mrq; +struct mmc_packed *packed; +#ifdef CONFIG_FAIL_MMC_REQUEST struct fault_attr fail_mmc_request;#endif
include/linux/mmc/packed.h new file +123 -0
123 lines not on this page · raw message
Signature · 1 line
1.7.9.5
RFC PATCH 3/7 mmc: host: sdhci: Introduce ADMA3 transfer mode
In reply to Baolin WangThe standard SD host controller can support ADMA3 transfer mode optionally. The ADMA3 uses command descriptor to issue an SD command, and a multi-block data transfer is programmed by using a pair of command descriptor and ADMA2 descriptor. ADMA3 performs multiple of multi-block data transfer by using integrated descriptor.
This is a preparation patch to add ADMA3 structures and help to expand the ADMA buffer for support ADMA3 transfer mode.
--- drivers/mmc/host/sdhci.c | 105 ++++++++++++++++++++++++++++++++++++++-------- drivers/mmc/host/sdhci.h | 48 +++++++++++++++++++++ 2 files changed, 136 insertions(+), 17 deletions(-)
drivers/mmc/host/sdhci.c +88 -17
@@ -240,7 +240,7 @@ static void sdhci_do_reset(struct sdhci_host *host, u8 mask) host->ops->reset (host, mask);if (mask &SDHCI_RESET_ALL ) { -if (host->flags & (SDHCI_USE_SDMA |SDHCI_USE_ADMA )) { +if (host->flags & (SDHCI_USE_SDMA |SDHCI_USE_ADMA |SDHCI_USE_ADMA3 )) {if (host->ops->enable_dma) host->ops->enable_dma (host); }
@@ -3750,10 +3750,17 @@ int sdhci_setup_host(struct sdhci_host *host) (host->caps & SDHCI_CAN_DO_ADMA2)) host->flags |=SDHCI_USE_ADMA ; +if ((host->quirks2 &SDHCI_QUIRK2_USE_ADMA3_SUPPORT ) && + (host->flags &SDHCI_USE_ADMA ) && + (host->caps1 &SDHCI_CAN_DO_ADMA3 )) { +DBG ("Enable ADMA3 mode for data transfer\n" ); + host->flags |=SDHCI_USE_ADMA3 ; + } +if ((host->quirks &SDHCI_QUIRK_BROKEN_ADMA ) && (host->flags &SDHCI_USE_ADMA )) {DBG ("Disabling ADMA as it is marked broken\n" ); - host->flags &= ~SDHCI_USE_ADMA ; + host->flags &= ~(SDHCI_USE_ADMA |SDHCI_USE_ADMA3 ); }/*
@@ -3775,7 +3782,7 @@ int sdhci_setup_host(struct sdhci_host *host)if (ret) {pr_warn ("%s: No suitable DMA available - falling back to PIO\n" ,mmc_hostname (mmc)); - host->flags &= ~(SDHCI_USE_SDMA |SDHCI_USE_ADMA ); + host->flags &= ~(SDHCI_USE_SDMA |SDHCI_USE_ADMA |SDHCI_USE_ADMA3 ); ret =0 ; }
@@ -3799,31 +3806,68 @@ int sdhci_setup_host(struct sdhci_host *host) host->desc_sz =SDHCI_ADMA2_32_DESC_SZ ; } + host->adma3_table_cnt =1 ; + +if (host->flags &SDHCI_USE_ADMA3 ) { +/* We can pack maximum 16 requests once */ + host->adma3_table_cnt =SDHCI_MAX_ADMA3_ENTRIES ; + +if (host->flags &SDHCI_USE_64_BIT_DMA ) + host->integr_desc_sz =SDHCI_INTEGR_64_DESC_SZ ; +else + host->integr_desc_sz =SDHCI_INTEGR_32_DESC_SZ ; + + host->cmd_desc_sz =SDHCI_ADMA3_CMD_DESC_SZ ; + host->cmd_table_sz = host->adma3_table_cnt * +SDHCI_ADMA3_CMD_DESC_SZ *SDHCI_ADMA3_CMD_DESC_ENTRIES ; + + buf =dma_alloc_coherent (mmc_dev (mmc), + host->adma3_table_cnt * + host->integr_desc_sz, + &dma,GFP_KERNEL ); +if (!buf) { +pr_warn ("%s: Unable to allocate ADMA3 integrated buffers - falling back to ADMA\n" , +mmc_hostname (mmc)); + host->flags &= ~SDHCI_USE_ADMA3 ; + host->adma3_table_cnt =1 ; + }else { + host->integr_table = buf; + host->integr_addr = dma; + } + } + host->align_buffer_sz =SDHCI_MAX_SEGS *SDHCI_ADMA2_ALIGN ;/* * Use zalloc to zero the reserved high 32-bits of 128-bit * descriptors so that they never need to be written. */ buf =dma_alloc_coherent (mmc_dev (mmc), - host->align_buffer_sz + host->adma_table_sz, + host->align_buffer_sz * + host->adma3_table_cnt + + host->cmd_table_sz + + host->adma_table_sz * + host->adma3_table_cnt, &dma,GFP_KERNEL );if (!buf) {pr_warn ("%s: Unable to allocate ADMA buffers - falling back to standard DMA\n" ,mmc_hostname (mmc)); - host->flags &= ~SDHCI_USE_ADMA ; - }else if ((dma + host->align_buffer_sz) & + host->flags &= ~(SDHCI_USE_ADMA |SDHCI_USE_ADMA3 ); + }else if ((dma + host->align_buffer_sz * host->adma3_table_cnt) & (SDHCI_ADMA2_DESC_ALIGN -1 )) {pr_warn ("%s: unable to allocate aligned ADMA descriptor\n" ,mmc_hostname (mmc)); - host->flags &= ~SDHCI_USE_ADMA ; -dma_free_coherent (mmc_dev (mmc), host->align_buffer_sz + - host->adma_table_sz, buf, dma); + host->flags &= ~(SDHCI_USE_ADMA |SDHCI_USE_ADMA3 ); +dma_free_coherent (mmc_dev (mmc), host->align_buffer_sz * + host->adma3_table_cnt + + host->cmd_table_sz + + host->adma_table_sz * + host->adma3_table_cnt, buf, dma); }else { host->align_buffer = buf; host->align_addr = dma; - host->adma_table = buf + host->align_buffer_sz; - host->adma_addr = dma + host->align_buffer_sz; + host->adma_table = buf + host->align_buffer_sz * host->adma3_table_cnt; + host->adma_addr = dma + host->align_buffer_sz * host->adma3_table_cnt; } }
@@ -4222,12 +4266,21 @@ int sdhci_setup_host(struct sdhci_host *host)regulator_disable (mmc->supply.vqmmc); undma:if (host->align_buffer) -dma_free_coherent (mmc_dev (mmc), host->align_buffer_sz + - host->adma_table_sz, host->align_buffer, +dma_free_coherent (mmc_dev (mmc), + host->align_buffer_sz * host->adma3_table_cnt + + host->cmd_table_sz + + host->adma_table_sz * host->adma3_table_cnt, + host->align_buffer, host->align_addr); host->adma_table =NULL ; host->align_buffer =NULL ; +if (host->integr_table) +dma_free_coherent (mmc_dev (mmc), + host->adma3_table_cnt * host->integr_desc_sz, + host->integr_table, host->integr_addr); + host->integr_table =NULL ; +return ret; }EXPORT_SYMBOL_GPL (sdhci_setup_host);
@@ -4240,11 +4293,20 @@ void sdhci_cleanup_host(struct sdhci_host *host)regulator_disable (mmc->supply.vqmmc);if (host->align_buffer) -dma_free_coherent (mmc_dev (mmc), host->align_buffer_sz + - host->adma_table_sz, host->align_buffer, +dma_free_coherent (mmc_dev (mmc), + host->align_buffer_sz * host->adma3_table_cnt + + host->cmd_table_sz + + host->adma_table_sz * host->adma3_table_cnt, + host->align_buffer, host->align_addr); host->adma_table =NULL ; host->align_buffer =NULL ; + +if (host->integr_table) +dma_free_coherent (mmc_dev (mmc), + host->adma3_table_cnt * host->integr_desc_sz, + host->integr_table, host->integr_addr); + host->integr_table =NULL ; }EXPORT_SYMBOL_GPL (sdhci_cleanup_host);
@@ -4372,12 +4434,21 @@ void sdhci_remove_host(struct sdhci_host *host, int dead)regulator_disable (mmc->supply.vqmmc);if (host->align_buffer) -dma_free_coherent (mmc_dev (mmc), host->align_buffer_sz + - host->adma_table_sz, host->align_buffer, +dma_free_coherent (mmc_dev (mmc), + host->align_buffer_sz * host->adma3_table_cnt + + host->cmd_table_sz + + host->adma_table_sz * host->adma3_table_cnt, + host->align_buffer, host->align_addr); host->adma_table =NULL ; host->align_buffer =NULL ; + +if (host->integr_table) +dma_free_coherent (mmc_dev (mmc), + host->adma3_table_cnt * host->integr_desc_sz, + host->integr_table, host->integr_addr); + host->integr_table =NULL ; }EXPORT_SYMBOL_GPL (sdhci_remove_host);
drivers/mmc/host/sdhci.h +48 -0
92 lines not on this page · raw message
Signature · 1 line
1.7.9.5
RFC PATCH 4/7 mmc: host: sdhci: Factor out the command configuration
In reply to Baolin WangMove the SD command configuration into one separate function to simplify the sdhci_send_command(). Moreover this function can be used to support ADMA3 transfer mode in following patches.
--- drivers/mmc/host/sdhci.c | 65 +++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 27 deletions(-)
drivers/mmc/host/sdhci.c +38 -27
@@ -1339,9 +1339,43 @@ static void sdhci_finish_data(struct sdhci_host *host) } } -void sdhci_send_command (struct sdhci_host *host,struct mmc_command *cmd) +static int sdhci_get_command (struct sdhci_host *host,struct mmc_command *cmd) {int flags; + +if ((cmd->flags &MMC_RSP_136 ) && (cmd->flags &MMC_RSP_BUSY )) { +pr_err ("%s: Unsupported response type!\n" , +mmc_hostname (host->mmc)); + cmd->error = -EINVAL ; +sdhci_finish_mrq (host, cmd->mrq); +return -EINVAL ; + } + +if (!(cmd->flags &MMC_RSP_PRESENT )) + flags =SDHCI_CMD_RESP_NONE ; +else if (cmd->flags &MMC_RSP_136 ) + flags =SDHCI_CMD_RESP_LONG ; +else if (cmd->flags &MMC_RSP_BUSY ) + flags =SDHCI_CMD_RESP_SHORT_BUSY ; +else + flags =SDHCI_CMD_RESP_SHORT ; + +if (cmd->flags &MMC_RSP_CRC ) + flags |=SDHCI_CMD_CRC ; +if (cmd->flags &MMC_RSP_OPCODE ) + flags |=SDHCI_CMD_INDEX ; + +/* CMD19 is special in that the Data Present Select should be set */ +if (cmd->data || cmd->opcode ==MMC_SEND_TUNING_BLOCK || + cmd->opcode ==MMC_SEND_TUNING_BLOCK_HS200 ) + flags |=SDHCI_CMD_DATA ; + +return SDHCI_MAKE_CMD (cmd->opcode, flags); +} + +void sdhci_send_command (struct sdhci_host *host,struct mmc_command *cmd) +{ +int command;u32 mask;unsigned long timeout;
@@ -1391,32 +1425,9 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd)sdhci_set_transfer_mode (host, cmd); -if ((cmd->flags &MMC_RSP_136 ) && (cmd->flags &MMC_RSP_BUSY )) { -pr_err ("%s: Unsupported response type!\n" , -mmc_hostname (host->mmc)); - cmd->error = -EINVAL ; -sdhci_finish_mrq (host, cmd->mrq); + command =sdhci_get_command (host, cmd); +if (command <0 )return ; - } - -if (!(cmd->flags &MMC_RSP_PRESENT )) - flags =SDHCI_CMD_RESP_NONE ; -else if (cmd->flags &MMC_RSP_136 ) - flags =SDHCI_CMD_RESP_LONG ; -else if (cmd->flags &MMC_RSP_BUSY ) - flags =SDHCI_CMD_RESP_SHORT_BUSY ; -else - flags =SDHCI_CMD_RESP_SHORT ; - -if (cmd->flags &MMC_RSP_CRC ) - flags |=SDHCI_CMD_CRC ; -if (cmd->flags &MMC_RSP_OPCODE ) - flags |=SDHCI_CMD_INDEX ; - -/* CMD19 is special in that the Data Present Select should be set */ -if (cmd->data || cmd->opcode ==MMC_SEND_TUNING_BLOCK || - cmd->opcode ==MMC_SEND_TUNING_BLOCK_HS200 ) - flags |=SDHCI_CMD_DATA ; timeout = jiffies;if (host->data_timeout)
@@ -1427,7 +1438,7 @@ void sdhci_send_command(struct sdhci_host *host, struct mmc_command *cmd) timeout +=10 *HZ ;sdhci_mod_timer (host, cmd->mrq, timeout); -sdhci_writew (host,SDHCI_MAKE_CMD (cmd->opcode, flags),SDHCI_COMMAND ); +sdhci_writew (host, command,SDHCI_COMMAND ); }EXPORT_SYMBOL_GPL (sdhci_send_command);
Signature · 1 line
1.7.9.5
RFC PATCH 5/7 mmc: host: sdhci: Remove redundant sg_count member of struct sdhci_host
In reply to Baolin WangThe mmc_data structure has a member to save the mapped sg count, so no need introduce a redundant sg_count of struct sdhci_host, remove it. This is also a preparation patch to support ADMA3 transfer mode.
--- drivers/mmc/host/sdhci.c | 12 +++++------- drivers/mmc/host/sdhci.h | 2 -- 2 files changed, 5 insertions(+), 9 deletions(-)
drivers/mmc/host/sdhci.c +5 -7
@@ -696,7 +696,7 @@ static void sdhci_adma_mark_end(void *desc) }static void sdhci_adma_table_pre (struct sdhci_host *host, -struct mmc_data *data,int sg_count) +struct mmc_data *data) {struct scatterlist *sg;unsigned long flags;
@@ -710,14 +710,12 @@ static void sdhci_adma_table_pre(struct sdhci_host *host,* We currently guess that it is LE. */ - host->sg_count = sg_count; - desc = host->adma_table; align = host->align_buffer; align_addr = host->align_addr; -for_each_sg (data->sg, sg, host->sg_count, i) { +for_each_sg (data->sg, sg, data->sg_count, i) { addr =sg_dma_address (sg); len =sg_dma_len (sg);
@@ -788,7 +786,7 @@ static void sdhci_adma_table_post(struct sdhci_host *host,bool has_unaligned = false;/* Do a quick scan of the SG list for any unaligned mappings */ -for_each_sg (data->sg, sg, host->sg_count, i) +for_each_sg (data->sg, sg, data->sg_count, i)if (sg_dma_address (sg) &SDHCI_ADMA2_MASK ) { has_unaligned = true;break ;
@@ -800,7 +798,7 @@ static void sdhci_adma_table_post(struct sdhci_host *host, align = host->align_buffer; -for_each_sg (data->sg, sg, host->sg_count, i) { +for_each_sg (data->sg, sg, data->sg_count, i) {if (sg_dma_address (sg) &SDHCI_ADMA2_MASK ) { size =SDHCI_ADMA2_ALIGN - (sg_dma_address (sg) &SDHCI_ADMA2_MASK );
@@ -1094,7 +1092,7 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)WARN_ON (1 ); host->flags &= ~SDHCI_REQ_USE_DMA ; }else if (host->flags &SDHCI_USE_ADMA ) { -sdhci_adma_table_pre (host, data, sg_cnt); +sdhci_adma_table_pre (host, data);sdhci_writel (host, host->adma_addr,SDHCI_ADMA_ADDRESS );if (host->flags &SDHCI_USE_64_BIT_DMA )
drivers/mmc/host/sdhci.h +0 -2
@@ -584,8 +584,6 @@ struct sdhci_host {struct sg_mapping_iter sg_miter;/* SG state for PIO */ unsigned int blocks;/* remaining PIO blocks */ -int sg_count;/* Mapped sg entries */ -void *adma_table;/* ADMA descriptor table */ void *align_buffer;/* Bounce buffer */ void *integr_table;/* ADMA3 intergrate descriptor table */
Signature · 1 line
1.7.9.5
RFC PATCH 6/7 mmc: host: sdhci: Add MMC packed request support
In reply to Baolin WangThis patch adds MMC packed operations to support packed requests, and enables ADMA3 transfer mode to support this feature.
Enable ADMA3 transfer mode only for read and write commands, and we will disable command interrupt and data timeout interrupt, instead we will use software data timeout for ADMA3 fransfer mode. For other non-data commands, we still use the ADMA2 transfer, since no bebefits using ADMA3 transfer.
--- drivers/mmc/host/sdhci.c | 329 +++++++++++++++++++++++++++++++++++++++++++--- drivers/mmc/host/sdhci.h | 9 ++ 2 files changed, 322 insertions(+), 16 deletions(-)
drivers/mmc/host/sdhci.c +313 -16
@@ -109,6 +109,19 @@ void sdhci_dumpregs(struct sdhci_host *host) } } +if (host->adma3_enabled) { +if (host->flags &SDHCI_USE_64_BIT_DMA ) { +SDHCI_DUMP ("ADMA3 Err: 0x%08x | ADMA3 Ptr: 0x%08x%08x\n" , +sdhci_readl (host,SDHCI_ADMA_ERROR ), +sdhci_readl (host,SDHCI_ADMA3_ADDRESS_HI ), +sdhci_readl (host,SDHCI_ADMA3_ADDRESS )); + }else { +SDHCI_DUMP ("ADMA3 Err: 0x%08x | ADMA3 Ptr: 0x%08x\n" , +sdhci_readl (host,SDHCI_ADMA_ERROR ), +sdhci_readl (host,SDHCI_ADMA3_ADDRESS )); + } + } +SDHCI_DUMP ("============================================\n" ); }EXPORT_SYMBOL_GPL (sdhci_dumpregs);
@@ -286,7 +299,9 @@ static void sdhci_config_dma(struct sdhci_host *host) goto out;/* Note if DMA Select is zero then SDMA is selected */ -if (host->flags &SDHCI_USE_ADMA ) +if (host->adma3_enabled) + ctrl |=SDHCI_CTRL_ADMA3 ; +else if (host->flags &SDHCI_USE_ADMA ) ctrl |=SDHCI_CTRL_ADMA32 ;if (host->flags &SDHCI_USE_64_BIT_DMA ) {
@@ -445,7 +460,7 @@ static inline void sdhci_led_deactivate(struct sdhci_host *host)static void sdhci_mod_timer (struct sdhci_host *host,struct mmc_request *mrq,unsigned long timeout) { -if (sdhci_data_line_cmd (mrq->cmd)) +if (host->prq ||sdhci_data_line_cmd (mrq->cmd))mod_timer (&host->data_timer, timeout);else mod_timer (&host->timer, timeout);
@@ -453,7 +468,7 @@ static void sdhci_mod_timer(struct sdhci_host *host, struct mmc_request *mrq,static void sdhci_del_timer (struct sdhci_host *host,struct mmc_request *mrq) { -if (sdhci_data_line_cmd (mrq->cmd)) +if (host->prq ||sdhci_data_line_cmd (mrq->cmd))del_timer (&host->data_timer);else del_timer (&host->timer);
@@ -710,10 +725,16 @@ static void sdhci_adma_table_pre(struct sdhci_host *host,* We currently guess that it is LE. */ - desc = host->adma_table; - align = host->align_buffer; - - align_addr = host->align_addr; +if (host->adma3_enabled) { + desc = host->adma3_pos; + align = host->adma3_align_pos; + align_addr = host->align_addr + + host->adma3_align_pos - host->align_buffer; + }else { + desc = host->adma_table; + align = host->align_buffer; + align_addr = host->align_addr; + }for_each_sg (data->sg, sg, data->sg_count, i) { addr =sg_dma_address (sg);
@@ -771,6 +792,11 @@ static void sdhci_adma_table_pre(struct sdhci_host *host,/* Add a terminating entry - nop, end, valid */ __sdhci_adma_write_desc (host, &desc,0 ,0 ,ADMA2_NOP_END_VALID ); } + +if (host->adma3_enabled) { + host->adma3_pos = desc; + host->adma3_align_pos = align; + } } static void sdhci_adma_table_post(struct sdhci_host *host,
@@ -796,7 +822,10 @@ static void sdhci_adma_table_post(struct sdhci_host *host,dma_sync_sg_for_cpu (mmc_dev (host->mmc), data->sg, data->sg_len,DMA_FROM_DEVICE ); - align = host->align_buffer; +if (host->adma3_enabled) + align = host->adma3_align_pos; +else + align = host->align_buffer;for_each_sg (data->sg, sg, data->sg_count, i) {if (sg_dma_address (sg) &SDHCI_ADMA2_MASK ) {
@@ -810,6 +839,9 @@ static void sdhci_adma_table_post(struct sdhci_host *host, align +=SDHCI_ADMA2_ALIGN ; } } + +if (host->adma3_enabled) + host->adma3_align_pos = align; } } }
@@ -1014,13 +1046,13 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) host->data_timeout =0 ; -if (sdhci_data_line_cmd (cmd)) +if (!host->prq &&sdhci_data_line_cmd (cmd))sdhci_set_timeout (host, cmd);if (!data)return ; -WARN_ON (host->data); +WARN_ON (!host->prq && host->data);/* Sanity checks */ BUG_ON (data->blksz * data->blocks >524288 );
@@ -1094,11 +1126,14 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd) }else if (host->flags &SDHCI_USE_ADMA ) {sdhci_adma_table_pre (host, data); -sdhci_writel (host, host->adma_addr,SDHCI_ADMA_ADDRESS ); -if (host->flags &SDHCI_USE_64_BIT_DMA ) -sdhci_writel (host, - (u64 )host->adma_addr >>32 , -SDHCI_ADMA_ADDRESS_HI ); +if (!host->adma3_enabled) { +sdhci_writel (host, host->adma_addr, +SDHCI_ADMA_ADDRESS ); +if (host->flags &SDHCI_USE_64_BIT_DMA ) +sdhci_writel (host, + (u64 )host->adma_addr >>32 , +SDHCI_ADMA_ADDRESS_HI ); + } }else {WARN_ON (sg_cnt !=1 );sdhci_set_sdma_addr (host,sdhci_sdma_address (host));
@@ -1121,6 +1156,9 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_command *cmd)sdhci_set_transfer_irqs (host); +if (host->adma3_enabled) +return ; +/* Set the DMA boundary value and block size */ sdhci_writew (host,SDHCI_MAKE_BLKSZ (host->sdma_boundary, data->blksz),SDHCI_BLOCK_SIZE );
@@ -1278,6 +1316,36 @@ static void sdhci_finish_mrq(struct sdhci_host *host, struct mmc_request *mrq)queue_work (host->complete_wq, &host->complete_work); } +static void sdhci_finish_packed_data (struct sdhci_host *host,int error) +{ +struct mmc_request *mrq; + + host->data =NULL ; +/* +* Reset the align buffer pointer address for unaligned mappings after +* finishing the transfer. +*/ + host->adma3_align_pos = host->align_buffer; + +if (error) +sdhci_do_reset (host,SDHCI_RESET_DATA ); + +list_for_each_entry (mrq, &host->prq->list, packed_list) { +struct mmc_data *data = mrq->data; + +sdhci_adma_table_post (host, data); + data->error = error; + +if (data->error) + data->bytes_xfered =0 ; +else + data->bytes_xfered = data->blksz * data->blocks; + } + +sdhci_del_timer (host,NULL ); +sdhci_led_deactivate (host); +} +static void sdhci_finish_data (struct sdhci_host *host) {struct mmc_command *data_cmd = host->data_cmd;
@@ -1786,6 +1854,209 @@ void sdhci_set_power(struct sdhci_host *host, unsigned char mode,* * \*****************************************************************************/ +static void sdhci_adma3_write_cmd_desc (struct sdhci_host *host, +struct mmc_command *cmd) +{ +struct mmc_data *data = cmd->data; +struct sdhci_adma3_cmd_desc *cmd_desc = host->adma3_pos; +int blksz, command; +u16 mode =0 ; + +/* Set block count */ + cmd_desc->cmd =cpu_to_le32 (ADMA3_TRAN_VALID ); + cmd_desc->reg =cpu_to_le32 (data->blocks); + cmd_desc++; + +/* Set block size */ + cmd_desc->cmd =cpu_to_le32 (ADMA3_TRAN_VALID ); + blksz =SDHCI_MAKE_BLKSZ (host->sdma_boundary, data->blksz); + cmd_desc->reg =cpu_to_le32 (blksz); + cmd_desc++; + +/* Set argument */ + cmd_desc->cmd =cpu_to_le32 (ADMA3_TRAN_VALID ); + cmd_desc->reg =cpu_to_le32 (cmd->arg); + cmd_desc++; + +/* set command and transfer mode */ +if (data->flags &MMC_DATA_READ ) + mode |=SDHCI_TRNS_READ ; + +if (!(host->quirks2 &SDHCI_QUIRK2_SUPPORT_SINGLE )) + mode |=SDHCI_TRNS_BLK_CNT_EN ; + +if (mmc_op_multi (cmd->opcode) || data->blocks >1 ) + mode |=SDHCI_TRNS_MULTI ; + +sdhci_auto_cmd_select (host, cmd, &mode); + mode |=SDHCI_TRNS_DMA ; + + command =sdhci_get_command (host, cmd); + command = (command <<16 ) | mode; + cmd_desc->cmd =cpu_to_le32 (ADMA3_TRAN_END ); + cmd_desc->reg =cpu_to_le32 (command); + + host->adma3_pos += +SDHCI_ADMA3_CMD_DESC_SZ *SDHCI_ADMA3_CMD_DESC_ENTRIES ; +} + +static void sdhci_adma3_write_integr_desc (struct sdhci_host *host, +dma_addr_t addr) +{ +struct sdhci_integr_64_desc *integr_desc = host->integr_table; + + integr_desc->cmd =cpu_to_le32 (ADMA3_INTEGR_TRAN_END ); + integr_desc->addr_lo =cpu_to_le32 ((u32 )addr); + +if (host->flags &SDHCI_USE_64_BIT_DMA ) + integr_desc->addr_hi =cpu_to_le32 ((u64 )addr >>32 ); +} + +static void sdhci_set_adma3_addr (struct sdhci_host *host,dma_addr_t addr) +{ +sdhci_writel (host, addr,SDHCI_ADMA3_ADDRESS ); +if (host->flags &SDHCI_USE_64_BIT_DMA ) +sdhci_writel (host, (u64 )addr >>32 ,SDHCI_ADMA3_ADDRESS_HI ); +} + +int sdhci_prepare_packed (struct mmc_packed *packed) +{ +struct mmc_host *mmc = packed->host; +struct sdhci_host *host =mmc_priv (mmc); +unsigned long timeout, flags; +u32 mask; + +spin_lock_irqsave (&host->lock, flags); + +if (!(host->flags &SDHCI_USE_ADMA3 ) || + !(host->flags & (SDHCI_AUTO_CMD23 |SDHCI_AUTO_CMD12 ))) { +spin_unlock_irqrestore (&host->lock, flags); +pr_err ("%s: Unsupported packed request\n" , +mmc_hostname (host->mmc)); +return -EOPNOTSUPP ; + } + +/* Wait max 10 ms */ + timeout =10 ; + mask =SDHCI_CMD_INHIBIT |SDHCI_DATA_INHIBIT ; + +while (sdhci_readl (host,SDHCI_PRESENT_STATE ) & mask) { +if (timeout ==0 ) { +sdhci_dumpregs (host); +spin_unlock_irqrestore (&host->lock, flags); + +pr_err ("%s: Controller never released inhibit bit(s).\n" , +mmc_hostname (host->mmc)); +return -EIO ; + } + + timeout--; +mdelay (1 ); + } + +/* Disable command complete event for ADMA3 mode */ + host->ier &= ~SDHCI_INT_RESPONSE ; +sdhci_writel (host, host->ier,SDHCI_INT_ENABLE ); +sdhci_writel (host, host->ier,SDHCI_SIGNAL_ENABLE ); + +/* +* Disable data timeout interrupt, and will use software timeout for +* packed request. +*/ +sdhci_set_data_timeout_irq (host, false); + +/* Enable ADMA3 mode for packed request */ + host->adma3_enabled = true; + +spin_unlock_irqrestore (&host->lock, flags); + +return 0 ; +} + +int sdhci_unprepare_packed (struct mmc_packed *packed) +{ +struct mmc_host *mmc = packed->host; +struct sdhci_host *host =mmc_priv (mmc); +unsigned long flags; + +spin_lock_irqsave (&host->lock, flags); + +/* Disable ADMA3 mode after finishing packed request */ + host->adma3_enabled = false; + +/* Re-enable command complete event after ADMA3 mode */ + host->ier |=SDHCI_INT_RESPONSE ; + +sdhci_writel (host, host->ier,SDHCI_INT_ENABLE ); +sdhci_writel (host, host->ier,SDHCI_SIGNAL_ENABLE ); +spin_unlock_irqrestore (&host->lock, flags); + +return 0 ; +} + +int sdhci_packed_request (struct mmc_packed *packed, +struct mmc_packed_request *prq) +{ +struct mmc_host *mmc = packed->host; +struct sdhci_host *host =mmc_priv (mmc); +struct mmc_request *mrq; +unsigned long timeout, flags; +u64 data_timeout =0 ; +dma_addr_t integr_addr; +int present; + +/* Firstly check card presence */ + present = mmc->ops->get_cd (mmc); + +spin_lock_irqsave (&host->lock, flags); + +sdhci_led_activate (host); + +if (!present || host->flags &SDHCI_DEVICE_DEAD ) { +spin_unlock_irqrestore (&host->lock, flags); +return -ENOMEDIUM ; + } + + host->prq = prq; + host->adma3_pos = host->adma_table; + host->adma3_align_pos = host->align_buffer; + integr_addr = host->adma_addr; + +list_for_each_entry (mrq, &prq->list, packed_list) { +struct mmc_command *cmd = mrq->cmd; + +/* Set command descriptor */ +sdhci_adma3_write_cmd_desc (host, cmd); +/* Set ADMA2 descriptors */ +sdhci_prepare_data (host, cmd); +/* Set integrated descriptor */ +sdhci_adma3_write_integr_desc (host, integr_addr); + +/* Update the integrated descriptor address */ + integr_addr = + host->adma_addr + (host->adma3_pos - host->adma_table); + +/* Calculate each command's data timeout */ +sdhci_calc_sw_timeout (host, cmd); + data_timeout += host->data_timeout; + } + + timeout = jiffies; +if (data_timeout) + timeout +=nsecs_to_jiffies (data_timeout); +else + timeout +=10 *HZ * prq->nr_reqs; +sdhci_mod_timer (host,NULL , timeout); + +/* Start ADMA3 transfer */ +sdhci_set_adma3_addr (host, host->integr_addr); + +spin_unlock_irqrestore (&host->lock, flags); + +return 0 ; +} +EXPORT_SYMBOL_GPL (sdhci_packed_request); +void sdhci_request (struct mmc_host *mmc,struct mmc_request *mrq) {struct sdhci_host *host;
@@ -2619,9 +2890,19 @@ static bool sdhci_request_done(struct sdhci_host *host) {unsigned long flags;struct mmc_request *mrq; +struct mmc_packed_request *prq;int i;spin_lock_irqsave (&host->lock, flags); + prq = host->prq; + +if (prq) { + host->prq =NULL ; +spin_unlock_irqrestore (&host->lock, flags); + +mmc_packed_finalize_requests (host->mmc, prq); +return true; + }for (i =0 ; i <SDHCI_MAX_MRQS ; i++) { mrq = host->mrqs_done[i];
@@ -2763,6 +3044,17 @@ static void sdhci_timeout_data_timer(struct timer_list *t)spin_lock_irqsave (&host->lock, flags); +if (host->prq) { +pr_err ("%s: Packed requests timeout for hardware interrupt.\n" , +mmc_hostname (host->mmc)); +sdhci_dumpregs (host); +sdhci_finish_packed_data (host, -ETIMEDOUT ); +queue_work (host->complete_wq, &host->complete_work); +spin_unlock_irqrestore (&host->lock, flags); + +return ; + } +if (host->data || host->data_cmd || (host->cmd &&sdhci_data_line_cmd (host->cmd))) { pr_err("%s: Timeout waiting for hardware interrupt.\n",
@@ -2965,7 +3257,9 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) host->ops->adma_workaround (host, intmask); } -if (host->data->error) +if (host->prq) +sdhci_finish_packed_data (host, host->data->error); +else if (host->data->error)sdhci_finish_data (host);else {if (intmask & (SDHCI_INT_DATA_AVAIL |SDHCI_INT_SPACE_AVAIL ))
@@ -3137,6 +3431,9 @@ static irqreturn_t sdhci_irq(int irq, void *dev_id) host->mrqs_done[i] =NULL ; } } + +if (host->prq) + result =IRQ_WAKE_THREAD ; out:spin_unlock (&host->lock);
drivers/mmc/host/sdhci.h +9 -0
@@ -574,6 +574,7 @@ struct sdhci_host {bool pending_reset;/* Cmd/data reset is pending */ bool irq_wake_enabled;/* IRQ wakeup is enabled */ bool v4_mode;/* Host Version 4 Enable */ +bool adma3_enabled;/* ADMA3 mode enabled */ struct mmc_request *mrqs_done[SDHCI_MAX_MRQS ];/* Requests done */ struct mmc_command *cmd;/* Current command */
@@ -581,12 +582,15 @@ struct sdhci_host {struct mmc_data *data;/* Current data request */ unsigned int data_early:1; /* Data finished before cmd */ +struct mmc_packed_request *prq;/* Current packed request */ struct sg_mapping_iter sg_miter;/* SG state for PIO */ unsigned int blocks;/* remaining PIO blocks */ void *adma_table;/* ADMA descriptor table */ void *align_buffer;/* Bounce buffer */ void *integr_table;/* ADMA3 intergrate descriptor table */ +void *adma3_pos;/* ADMA3 buffer position */ +void *adma3_align_pos;/* ADMA3 Bounce buffer position */ size_t adma_table_sz;/* ADMA descriptor table size */ size_t align_buffer_sz;/* Bounce buffer size */
@@ -843,4 +847,9 @@ bool sdhci_cqe_irq(struct sdhci_host *host, u32 intmask, int *cmd_error,void sdhci_reset_tuning (struct sdhci_host *host);void sdhci_send_tuning (struct sdhci_host *host,u32 opcode); +int sdhci_prepare_packed (struct mmc_packed *packed); +int sdhci_unprepare_packed (struct mmc_packed *packed); +int sdhci_packed_request (struct mmc_packed *packed, +struct mmc_packed_request *prq); +#endif /* __SDHCI_HW_H */
Signature · 1 line
1.7.9.5
RFC PATCH 7/7 mmc: host: sdhci-sprd: Add MMC packed request support
In reply to Baolin WangEnable the ADMA3 transfer mode as well as adding packed operations to support MMC packed requests to improve IO performance.
--- drivers/mmc/host/Kconfig | 1 + drivers/mmc/host/sdhci-sprd.c | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-)
drivers/mmc/host/Kconfig +1 -0
@@ -619,6 +619,7 @@ config MMC_SDHCI_SPRD depends on ARCH_SPRD depends on MMC_SDHCI_PLTFM select MMC_SDHCI_IO_ACCESSORS + select MMC_PACKED help This selects the SDIO Host Controller in Spreadtrum SoCs, this driver supports R11(IP version: R11P0).
drivers/mmc/host/sdhci-sprd.c +20 -2
@@ -524,10 +524,18 @@ static void sdhci_sprd_phy_param_parse(struct sdhci_sprd_host *sprd_host,static const struct sdhci_pltfm_data sdhci_sprd_pdata = { .quirks =SDHCI_QUIRK_DATA_TIMEOUT_USES_SDCLK , .quirks2 =SDHCI_QUIRK2_BROKEN_HS200 | -SDHCI_QUIRK2_USE_32BIT_BLK_CNT , +SDHCI_QUIRK2_USE_32BIT_BLK_CNT | +SDHCI_QUIRK2_USE_ADMA3_SUPPORT , .ops = &sdhci_sprd_ops, }; +static const struct mmc_packed_ops packed_ops = { + .packed_algo = mmc_packed_algo_rw, + .prepare_hardware = sdhci_prepare_packed, + .unprepare_hardware = sdhci_unprepare_packed, + .packed_request = sdhci_packed_request, +}; +static int sdhci_sprd_probe (struct platform_device *pdev) {struct sdhci_host *host;
@@ -642,10 +650,14 @@ static int sdhci_sprd_probe(struct platform_device *pdev) sprd_host->flags = host->flags; - ret =__sdhci_add_host (host); + ret =mmc_packed_init (host->mmc, &packed_ops,10 );if (ret) goto err_cleanup_host; + ret =__sdhci_add_host (host); +if (ret) + goto err_packed; +pm_runtime_mark_last_busy (&pdev->dev);pm_runtime_put_autosuspend (&pdev->dev);
@@ -653,6 +665,9 @@ static int sdhci_sprd_probe(struct platform_device *pdev) __func__, host->version);return 0 ; +err_packed: +mmc_packed_exit (host->mmc); + err_cleanup_host:sdhci_cleanup_host (host);
@@ -680,6 +695,7 @@ static int sdhci_sprd_remove(struct platform_device *pdev)struct sdhci_sprd_host *sprd_host =TO_SPRD_HOST (host);struct mmc_host *mmc = host->mmc; +mmc_packed_exit (mmc);mmc_remove_host (mmc);clk_disable_unprepare (sprd_host->clk_sdio);clk_disable_unprepare (sprd_host->clk_enable);
@@ -702,6 +718,7 @@ static int sdhci_sprd_runtime_suspend(struct device *dev)struct sdhci_host *host =dev_get_drvdata (dev);struct sdhci_sprd_host *sprd_host =TO_SPRD_HOST (host); +mmc_packed_queue_stop (host->mmc->packed);sdhci_runtime_suspend_host (host);clk_disable_unprepare (sprd_host->clk_sdio);
@@ -730,6 +747,7 @@ static int sdhci_sprd_runtime_resume(struct device *dev) goto clk_disable;sdhci_runtime_resume_host (host); +mmc_packed_queue_start (host->mmc->packed);return 0 ; clk_disable:
Signature · 1 line
1.7.9.5
Hi,
Quoted 65 lines · Baolin Wang
Hi All,
Now some SD/MMC controllers can support packed command or packed request, that means it can package multiple requests to host controller to be handled at one time, which can improve the I/O performence. Thus this patchset is used to add the MMC packed function to support packed request or packed command.
In this patch set, I implemented the SD host ADMA3 transfer mode to support packed request. The ADMA3 transfer mode can process a multi-block data transfer by using a pair of command descriptor and ADMA2 descriptor. In future we can easily expand the MMC packed function to support packed command.
Below are some comparison data between packed request and non-packed request with fio tool. The fio command I used is like below with changing the '--rw' parameter and enabling the direct IO flag to measure the actual hardware transfer speed.
./fio --filename=/dev/mmcblk0p30 --direct=1 --iodepth=20 --rw=read --bs=4K --size=512M --group_reporting --numjobs=20 --name=test_read
My eMMC card working at HS400 Enhanced strobe mode:
[ 2.229856] mmc0: new HS400 Enhanced strobe MMC card at address 0001 [ 2.237566] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB [ 2.242621] mmcblk0boot0: mmc0:0001 HBG4a2 partition 1 4.00 MiB [ 2.249110] mmcblk0boot1: mmc0:0001 HBG4a2 partition 2 4.00 MiB [ 2.255307] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB, chardev (248:0)1. Non-packed request
I tested 3 times for each case and output a average speed.1) Sequential read:
Speed: 28.9MiB/s, 26.4MiB/s, 30.9MiB/s
Average speed: 28.7MiB/s2) Random read:
Speed: 18.2MiB/s, 8.9MiB/s, 15.8MiB/s
Average speed: 14.3MiB/s3) Sequential write:
Speed: 21.1MiB/s, 27.9MiB/s, 25MiB/s
Average speed: 24.7MiB/s4) Random write:
Speed: 21.5MiB/s, 18.1MiB/s, 18.1MiB/s
Average speed: 19.2MiB/s2. Packed request
In packed request mode, I set the host controller can package maximum 10 requests at one time (Actually I can increase the package number), and I enabled read/write packed request mode. Also I tested 3 times for each case and output a average speed.1) Sequential read:
Speed: 165MiB/s, 167MiB/s, 164MiB/s
Average speed: 165.3MiB/s2) Random read:
Speed: 147MiB/s, 141MiB/s, 144MiB/s
Average speed: 144MiB/s3) Sequential write:
Speed: 87.8MiB/s, 89.1MiB/s, 90.0MiB/s
Average speed: 89MiB/s
Quoted 6 lines
4) Random write:
Speed: 90.9MiB/s, 89.8MiB/s, 90.4MiB/s
Average speed: 90.4MiB/sForm above data, we can see the packed request can improve the performance greatly. Any comments are welcome. Thanks a lot.
Any comments for this patch set? Thanks.
Quoted 35 lines
Baolin Wang (7):
blk-mq: Exportblk_mq_hctx_has_pending()function
mmc: core: Add MMC packed request function
mmc: host: sdhci: Introduce ADMA3 transfer mode
mmc: host: sdhci: Factor out the command configuration
mmc: host: sdhci: Remove redundantsg_countmember of struct
sdhci_host
mmc: host: sdhci: Add MMC packed request support
mmc: host: sdhci-sprd: Add MMC packed request supportblock/blk-mq.c | 3 +- drivers/mmc/core/Kconfig | 2 + drivers/mmc/core/Makefile | 1 + drivers/mmc/core/block.c | 71 +++++- drivers/mmc/core/block.h | 3 +- drivers/mmc/core/core.c | 51 ++++ drivers/mmc/core/core.h | 3 + drivers/mmc/core/packed.c | 478 ++++++++++++++++++++++++++++++++++++++ drivers/mmc/core/queue.c | 28 ++- drivers/mmc/host/Kconfig | 1 + drivers/mmc/host/sdhci-sprd.c | 22 +- drivers/mmc/host/sdhci.c | 513 +++++++++++++++++++++++++++++++++++------ drivers/mmc/host/sdhci.h | 59 ++++- include/linux/blk-mq.h | 1 + include/linux/mmc/core.h | 1 + include/linux/mmc/host.h | 3 + include/linux/mmc/packed.h | 123 ++++++++++ 17 files changed, 1286 insertions(+), 77 deletions(-) create mode 100644 drivers/mmc/core/packed.c create mode 100644 include/linux/mmc/packed.h--
1.7.9.5
Signature · 2 lines
Baolin Wang Best Regards
Adrian Hunter
maintainerQuoted 37 lines · Baolin Wang
Hi,
Quoted 34 lines · Baolin Wang
Hi All,
Now some SD/MMC controllers can support packed command or packed request, that means it can package multiple requests to host controller to be handled at one time, which can improve the I/O performence. Thus this patchset is used to add the MMC packed function to support packed request or packed command.
In this patch set, I implemented the SD host ADMA3 transfer mode to support packed request. The ADMA3 transfer mode can process a multi-block data transfer by using a pair of command descriptor and ADMA2 descriptor. In future we can easily expand the MMC packed function to support packed command.
Below are some comparison data between packed request and non-packed request with fio tool. The fio command I used is like below with changing the '--rw' parameter and enabling the direct IO flag to measure the actual hardware transfer speed.
./fio --filename=/dev/mmcblk0p30 --direct=1 --iodepth=20 --rw=read --bs=4K --size=512M --group_reporting --numjobs=20 --name=test_read
My eMMC card working at HS400 Enhanced strobe mode:
[ 2.229856] mmc0: new HS400 Enhanced strobe MMC card at address 0001 [ 2.237566] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB [ 2.242621] mmcblk0boot0: mmc0:0001 HBG4a2 partition 1 4.00 MiB [ 2.249110] mmcblk0boot1: mmc0:0001 HBG4a2 partition 2 4.00 MiB [ 2.255307] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB, chardev (248:0)1. Non-packed request
I tested 3 times for each case and output a average speed.1) Sequential read:
Speed: 28.9MiB/s, 26.4MiB/s, 30.9MiB/s
Average speed: 28.7MiB/s
This seems surprising low for a HS400ES card. Do you know why that is?
Quoted 31 lines
Quoted 31 lines
2) Random read:
Speed: 18.2MiB/s, 8.9MiB/s, 15.8MiB/s
Average speed: 14.3MiB/s3) Sequential write:
Speed: 21.1MiB/s, 27.9MiB/s, 25MiB/s
Average speed: 24.7MiB/s4) Random write:
Speed: 21.5MiB/s, 18.1MiB/s, 18.1MiB/s
Average speed: 19.2MiB/s2. Packed request
In packed request mode, I set the host controller can package maximum 10 requests at one time (Actually I can increase the package number), and I enabled read/write packed request mode. Also I tested 3 times for each case and output a average speed.1) Sequential read:
Speed: 165MiB/s, 167MiB/s, 164MiB/s
Average speed: 165.3MiB/s2) Random read:
Speed: 147MiB/s, 141MiB/s, 144MiB/s
Average speed: 144MiB/s3) Sequential write:
Speed: 87.8MiB/s, 89.1MiB/s, 90.0MiB/s
Average speed: 89MiB/s
Quoted 8 lines
Quoted 6 lines
4) Random write:
Speed: 90.9MiB/s, 89.8MiB/s, 90.4MiB/s
Average speed: 90.4MiB/sForm above data, we can see the packed request can improve the performance greatly. Any comments are welcome. Thanks a lot.
Any comments for this patch set? Thanks.
Did you consider adapting the CQE interface?
Hi Adrian,
Quoted 33 lines · Adrian Hunter
Quoted 31 lines · Baolin Wang
Hi,
Quoted 28 lines · Baolin Wang
Hi All,
Now some SD/MMC controllers can support packed command or packed request, that means it can package multiple requests to host controller to be handled at one time, which can improve the I/O performence. Thus this patchset is used to add the MMC packed function to support packed request or packed command.
In this patch set, I implemented the SD host ADMA3 transfer mode to support packed request. The ADMA3 transfer mode can process a multi-block data transfer by using a pair of command descriptor and ADMA2 descriptor. In future we can easily expand the MMC packed function to support packed command.
Below are some comparison data between packed request and non-packed request with fio tool. The fio command I used is like below with changing the '--rw' parameter and enabling the direct IO flag to measure the actual hardware transfer speed.
./fio --filename=/dev/mmcblk0p30 --direct=1 --iodepth=20 --rw=read --bs=4K --size=512M --group_reporting --numjobs=20 --name=test_read
My eMMC card working at HS400 Enhanced strobe mode:
[ 2.229856] mmc0: new HS400 Enhanced strobe MMC card at address 0001 [ 2.237566] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB [ 2.242621] mmcblk0boot0: mmc0:0001 HBG4a2 partition 1 4.00 MiB [ 2.249110] mmcblk0boot1: mmc0:0001 HBG4a2 partition 2 4.00 MiB [ 2.255307] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB, chardev (248:0)
Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
1. Non-packed request
I tested 3 times for each case and output a average speed.1) Sequential read:
Speed: 28.9MiB/s, 26.4MiB/s, 30.9MiB/s
Average speed: 28.7MiB/sThis seems surprising low for a HS400ES card. Do you know why that is?
I've set the clock to 400M, but it seems the hardware did not output the corresponding clock. I will check my hardware.
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
2) Random read:
Speed: 18.2MiB/s, 8.9MiB/s, 15.8MiB/s
Average speed: 14.3MiB/s3) Sequential write:
Speed: 21.1MiB/s, 27.9MiB/s, 25MiB/s
Average speed: 24.7MiB/s4) Random write:
Speed: 21.5MiB/s, 18.1MiB/s, 18.1MiB/s
Average speed: 19.2MiB/s2. Packed request
In packed request mode, I set the host controller can package maximum 10 requests at one time (Actually I can increase the package number), and I enabled read/write packed request mode. Also I tested 3 times for each case and output a average speed.1) Sequential read:
Speed: 165MiB/s, 167MiB/s, 164MiB/s
Average speed: 165.3MiB/s2) Random read:
Speed: 147MiB/s, 141MiB/s, 144MiB/s
Average speed: 144MiB/s3) Sequential write:
Speed: 87.8MiB/s, 89.1MiB/s, 90.0MiB/s
Average speed: 89MiB/s4) Random write:
Speed: 90.9MiB/s, 89.8MiB/s, 90.4MiB/s
Average speed: 90.4MiB/s
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
Form above data, we can see the packed request can improve the performance greatly. Any comments are welcome. Thanks a lot.
Any comments for this patch set? Thanks.
Did you consider adapting the CQE interface?
I am not very familiar with CQE, since my controller did not support it. But the MMC packed function had introduced some callbacks to help for different controllers to do packed request, so I think it is easy to adapt the CQE interface.
Signature · 2 lines
Baolin Wang Best Regards
Adrian Hunter
maintainerQuoted 86 lines · Baolin Wang
Hi Adrian,
Quoted 33 lines · Adrian Hunter
Quoted 31 lines · Baolin Wang
Hi,
Quoted 28 lines · Baolin Wang
Hi All,
Now some SD/MMC controllers can support packed command or packed request, that means it can package multiple requests to host controller to be handled at one time, which can improve the I/O performence. Thus this patchset is used to add the MMC packed function to support packed request or packed command.
In this patch set, I implemented the SD host ADMA3 transfer mode to support packed request. The ADMA3 transfer mode can process a multi-block data transfer by using a pair of command descriptor and ADMA2 descriptor. In future we can easily expand the MMC packed function to support packed command.
Below are some comparison data between packed request and non-packed request with fio tool. The fio command I used is like below with changing the '--rw' parameter and enabling the direct IO flag to measure the actual hardware transfer speed.
./fio --filename=/dev/mmcblk0p30 --direct=1 --iodepth=20 --rw=read --bs=4K --size=512M --group_reporting --numjobs=20 --name=test_read
My eMMC card working at HS400 Enhanced strobe mode:
[ 2.229856] mmc0: new HS400 Enhanced strobe MMC card at address 0001 [ 2.237566] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB [ 2.242621] mmcblk0boot0: mmc0:0001 HBG4a2 partition 1 4.00 MiB [ 2.249110] mmcblk0boot1: mmc0:0001 HBG4a2 partition 2 4.00 MiB [ 2.255307] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB, chardev (248:0)Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
1. Non-packed request
I tested 3 times for each case and output a average speed.1) Sequential read:
Speed: 28.9MiB/s, 26.4MiB/s, 30.9MiB/s
Average speed: 28.7MiB/sThis seems surprising low for a HS400ES card. Do you know why that is?
I've set the clock to 400M, but it seems the hardware did not output the corresponding clock. I will check my hardware.
Quoted 38 lines
Quoted 38 lines
Quoted 37 lines
2) Random read:
Speed: 18.2MiB/s, 8.9MiB/s, 15.8MiB/s
Average speed: 14.3MiB/s3) Sequential write:
Speed: 21.1MiB/s, 27.9MiB/s, 25MiB/s
Average speed: 24.7MiB/s4) Random write:
Speed: 21.5MiB/s, 18.1MiB/s, 18.1MiB/s
Average speed: 19.2MiB/s2. Packed request
In packed request mode, I set the host controller can package maximum 10 requests at one time (Actually I can increase the package number), and I enabled read/write packed request mode. Also I tested 3 times for each case and output a average speed.1) Sequential read:
Speed: 165MiB/s, 167MiB/s, 164MiB/s
Average speed: 165.3MiB/s2) Random read:
Speed: 147MiB/s, 141MiB/s, 144MiB/s
Average speed: 144MiB/s3) Sequential write:
Speed: 87.8MiB/s, 89.1MiB/s, 90.0MiB/s
Average speed: 89MiB/s4) Random write:
Speed: 90.9MiB/s, 89.8MiB/s, 90.4MiB/s
Average speed: 90.4MiB/sForm above data, we can see the packed request can improve the performance greatly. Any comments are welcome. Thanks a lot.
Quoted 9 lines
Quoted 3 lines
Quoted 1 line
Any comments for this patch set? Thanks.
Did you consider adapting the CQE interface?
I am not very familiar with CQE, since my controller did not support it. But the MMC packed function had introduced some callbacks to help for different controllers to do packed request, so I think it is easy to adapt the CQE interface.
I meant did you consider using the CQE interface instead of creating another one?
Quoted 92 lines · Adrian Hunter
Quoted 90 lines · Baolin Wang
Hi Adrian,
Quoted 33 lines · Adrian Hunter
Quoted 31 lines · Baolin Wang
Hi,
Quoted 28 lines · Baolin Wang
Hi All,
Now some SD/MMC controllers can support packed command or packed request, that means it can package multiple requests to host controller to be handled at one time, which can improve the I/O performence. Thus this patchset is used to add the MMC packed function to support packed request or packed command.
In this patch set, I implemented the SD host ADMA3 transfer mode to support packed request. The ADMA3 transfer mode can process a multi-block data transfer by using a pair of command descriptor and ADMA2 descriptor. In future we can easily expand the MMC packed function to support packed command.
Below are some comparison data between packed request and non-packed request with fio tool. The fio command I used is like below with changing the '--rw' parameter and enabling the direct IO flag to measure the actual hardware transfer speed.
./fio --filename=/dev/mmcblk0p30 --direct=1 --iodepth=20 --rw=read --bs=4K --size=512M --group_reporting --numjobs=20 --name=test_read
My eMMC card working at HS400 Enhanced strobe mode:
[ 2.229856] mmc0: new HS400 Enhanced strobe MMC card at address 0001 [ 2.237566] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB [ 2.242621] mmcblk0boot0: mmc0:0001 HBG4a2 partition 1 4.00 MiB [ 2.249110] mmcblk0boot1: mmc0:0001 HBG4a2 partition 2 4.00 MiB [ 2.255307] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB, chardev (248:0)Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
1. Non-packed request
I tested 3 times for each case and output a average speed.1) Sequential read:
Speed: 28.9MiB/s, 26.4MiB/s, 30.9MiB/s
Average speed: 28.7MiB/sThis seems surprising low for a HS400ES card. Do you know why that is?
I've set the clock to 400M, but it seems the hardware did not output the corresponding clock. I will check my hardware.
Quoted 41 lines
Quoted 31 lines
Quoted 31 lines
2) Random read:
Speed: 18.2MiB/s, 8.9MiB/s, 15.8MiB/s
Average speed: 14.3MiB/s3) Sequential write:
Speed: 21.1MiB/s, 27.9MiB/s, 25MiB/s
Average speed: 24.7MiB/s4) Random write:
Speed: 21.5MiB/s, 18.1MiB/s, 18.1MiB/s
Average speed: 19.2MiB/s2. Packed request
In packed request mode, I set the host controller can package maximum 10 requests at one time (Actually I can increase the package number), and I enabled read/write packed request mode. Also I tested 3 times for each case and output a average speed.1) Sequential read:
Speed: 165MiB/s, 167MiB/s, 164MiB/s
Average speed: 165.3MiB/s2) Random read:
Speed: 147MiB/s, 141MiB/s, 144MiB/s
Average speed: 144MiB/s3) Sequential write:
Speed: 87.8MiB/s, 89.1MiB/s, 90.0MiB/s
Average speed: 89MiB/sQuoted 8 lines
Quoted 6 lines
4) Random write:
Speed: 90.9MiB/s, 89.8MiB/s, 90.4MiB/s
Average speed: 90.4MiB/sForm above data, we can see the packed request can improve the performance greatly. Any comments are welcome. Thanks a lot.
Any comments for this patch set? Thanks.
Did you consider adapting the CQE interface?
Quoted 8 lines
Quoted 5 lines
I am not very familiar with CQE, since my controller did not support it. But the MMC packed function had introduced some callbacks to help for different controllers to do packed request, so I think it is easy to adapt the CQE interface.
I meant did you consider using the CQE interface instead of creating another one?
Sorry for misunderstanding. I think the core/core.c modification can use the CQE interface, but there are some difference in core/block.c, and I think they are different mechanisms, also I want to keep avoid affecting CQE and normal transfer, so I think adding MMC packed related interfaces will be easy to read and maintain.
Signature · 2 lines
Baolin Wang Best Regards
Hi Adrian,
Quoted 40 lines · Baolin Wang
Hi Adrian,
Quoted 36 lines · Adrian Hunter
Quoted 34 lines · Baolin Wang
Hi,
Quoted 31 lines · Baolin Wang
Hi All,
Now some SD/MMC controllers can support packed command or packed request, that means it can package multiple requests to host controller to be handled at one time, which can improve the I/O performence. Thus this patchset is used to add the MMC packed function to support packed request or packed command.
In this patch set, I implemented the SD host ADMA3 transfer mode to support packed request. The ADMA3 transfer mode can process a multi-block data transfer by using a pair of command descriptor and ADMA2 descriptor. In future we can easily expand the MMC packed function to support packed command.
Below are some comparison data between packed request and non-packed request with fio tool. The fio command I used is like below with changing the '--rw' parameter and enabling the direct IO flag to measure the actual hardware transfer speed.
./fio --filename=/dev/mmcblk0p30 --direct=1 --iodepth=20 --rw=read --bs=4K --size=512M --group_reporting --numjobs=20 --name=test_read
My eMMC card working at HS400 Enhanced strobe mode:
[ 2.229856] mmc0: new HS400 Enhanced strobe MMC card at address 0001 [ 2.237566] mmcblk0: mmc0:0001 HBG4a2 29.1 GiB [ 2.242621] mmcblk0boot0: mmc0:0001 HBG4a2 partition 1 4.00 MiB [ 2.249110] mmcblk0boot1: mmc0:0001 HBG4a2 partition 2 4.00 MiB [ 2.255307] mmcblk0rpmb: mmc0:0001 HBG4a2 partition 3 4.00 MiB, chardev (248:0)1. Non-packed request
I tested 3 times for each case and output a average speed.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
1) Sequential read:
Speed: 28.9MiB/s, 26.4MiB/s, 30.9MiB/s
Average speed: 28.7MiB/sThis seems surprising low for a HS400ES card. Do you know why that is?
I've set the clock to 400M, but it seems the hardware did not output the corresponding clock. I will check my hardware.
I've checked my hardware and did not find any problem.
The reason of low speed is that I set the bs = 4k, when I changed the bs=1M, and the speed can go up to 251MiB/s.
./fio --filename=/dev/mmcblk0p30 --direct=1 --iodepth=20 --rw=read --bs=1M --size=512M --group_reporting --numjobs=20 --name=test_read
READ: bw=251MiB/s (263MB/s), 251MiB/s-251MiB/s (263MB/s-263MB/s), io=10.0GiB (10.7GB), run=40826-40826msec
Signature · 2 lines
Baolin Wang Best Regards