mmc: dw_mmc: Fix the max_blk_count in IDMAC
PATCH 1/1 mmc: dw_mmc: Fix the max_blk_count in IDMAC
From: Alim Akhtar <[email protected]>
max_blk_count is currently set incorrectly, and the correct value can be determined by looking at the maximum number of bytes which can be transferred and the block size. We use the maximum block size to determine the minimum number of blocks that the controller should support. It could probably do more with a smaller block size but this value should be sufficient for good performance.
This improves sequential performance by 82% on write and 6% read on one particular device.
TEST= with this patch
time dd if=/dev/zero of=/usr/local/100 bs=1M count=100 conv=fdatasync 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 2.62541 s, 39.9 MB/s real 0m2.638s user 0m0.000s sys 0m0.645s without this patch: time dd if=/dev/zero of=/usr/local/100 bs=1M count=100 conv=fdatasync 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 3.25873 s, 32.2 MB/s real 0m3.265s user 0m0.005s sys 0m0.690s
--- drivers/mmc/host/dw_mmc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
drivers/mmc/host/dw_mmc.c +16 -2
@@ -2213,10 +2213,24 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)/* Useful defaults if platform data is unset. */ #ifdef CONFIG_MMC_DW_IDMAC mmc->max_segs = host->ring_size; + +/* the BLKSIZ register is 16-bits wide */ mmc->max_blk_size =65536 ; - mmc->max_blk_count = host->ring_size; + +/* +* This value is calculated by taking the size of the +* 32-bit BYTCNT (byte count) register and dividing by the +* BLKSIZ (block size) register. This is the minimum number +* of blocks which could be handled. +*/ + mmc->max_blk_count =0xFFFF ; mmc->max_seg_size =0x1000 ; - mmc->max_req_size = mmc->max_seg_size * mmc->max_blk_count; +/* +* Maximum request size should be total number of descriptors +* times the maximum amount of data each can reference +*/ + + mmc->max_req_size = mmc->max_seg_size * mmc->max_segs;#else mmc->max_segs =64 ; mmc->max_blk_size =65536 ;/* BLKSIZ is 16 bits */
Signature · 1 line
1.7.10.4
Jaehoon Chung
maintainerPATCH 1/1 mmc: dw_mmc: Fix the max_blk_count in IDMAC
Hi,
Did you know that Seungwon has sent the patch "[PATCH 1/7] mmc: dw_mmc: fix the max_blk_count in IDMAC"? I think this patch looks like same, isn't it?
Plz check it.
Best Regards,
Jaehoon Chung
Quoted 72 lines · Yuvaraj Kumar C D
From: Alim Akhtar <[email protected]>
max_blk_countis currently set incorrectly, and the correct value can be determined by looking at the maximum number of bytes which can be transferred and the block size. We use the maximum block size to determine the minimum number of blocks that the controller should support. It could probably do more with a smaller block size but this value should be sufficient for good performance.This improves sequential performance by 82% on write and 6% read on one particular device.
TEST= with this patch
time dd if=/dev/zero of=/usr/local/100 bs=1M count=100 conv=fdatasync 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 2.62541 s, 39.9 MB/s real 0m2.638s user 0m0.000s sys 0m0.645s without this patch: time dd if=/dev/zero of=/usr/local/100 bs=1M count=100 conv=fdatasync 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 3.25873 s, 32.2 MB/s real 0m3.265s user 0m0.005s sys 0m0.690sSigned-off-by Seungwon Jeon <[email protected]>Signed-off-by Alim Akhtar <[email protected]>Signed-off-by Sonny Rao <[email protected]>Signed-off-by Yuvaraj Kumar C D <[email protected]>--- drivers/mmc/host/dw_mmc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/mmc/host/dw_mmc.c +16
-2@@ -2213,10 +2213,24 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)/* Useful defaults if platform data is unset. */ #ifdef CONFIG_MMC_DW_IDMAC mmc->max_segs = host->ring_size; + +/* the BLKSIZ register is 16-bits wide */ mmc->max_blk_size =65536 ; - mmc->max_blk_count = host->ring_size; + +/* +* This value is calculated by taking the size of the +* 32-bit BYTCNT (byte count) register and dividing by the +* BLKSIZ (block size) register. This is the minimum number +* of blocks which could be handled. +*/ + mmc->max_blk_count =0xFFFF ; mmc->max_seg_size =0x1000 ; - mmc->max_req_size = mmc->max_seg_size * mmc->max_blk_count; +/* +* Maximum request size should be total number of descriptors +* times the maximum amount of data each can reference +*/ + + mmc->max_req_size = mmc->max_seg_size * mmc->max_segs;#else mmc->max_segs =64 ; mmc->max_blk_size =65536 ;/* BLKSIZ is 16 bits */
PATCH 1/1 mmc: dw_mmc: Fix the max_blk_count in IDMAC
Quoted 4 lines · Jaehoon Chung
Hi,
Did you know that Seungwon has sent the patch "[PATCH 1/7] mmc:
dw_mmc: fix themax_blk_countin IDMAC"? I think this patch looks like same, isn't it?
Yes.Its the same one.Please discard this patch.
Quoted 79 lines
Plz check it.
Best Regards,
Jaehoon ChungQuoted 72 lines · Yuvaraj Kumar C D
From: Alim Akhtar <[email protected]>
max_blk_countis currently set incorrectly, and the correct value can be determined by looking at the maximum number of bytes which can be transferred and the block size. We use the maximum block size to determine the minimum number of blocks that the controller should support. It could probably do more with a smaller block size but this value should be sufficient for good performance.This improves sequential performance by 82% on write and 6% read on one particular device.
TEST= with this patch
time dd if=/dev/zero of=/usr/local/100 bs=1M count=100 conv=fdatasync 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 2.62541 s, 39.9 MB/s real 0m2.638s user 0m0.000s sys 0m0.645s without this patch: time dd if=/dev/zero of=/usr/local/100 bs=1M count=100 conv=fdatasync 100+0 records in 100+0 records out 104857600 bytes (105 MB) copied, 3.25873 s, 32.2 MB/s real 0m3.265s user 0m0.005s sys 0m0.690sSigned-off-by Seungwon Jeon <[email protected]>Signed-off-by Alim Akhtar <[email protected]>Signed-off-by Sonny Rao <[email protected]>Signed-off-by Yuvaraj Kumar C D <[email protected]>--- drivers/mmc/host/dw_mmc.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)drivers/mmc/host/dw_mmc.c +16
-2@@ -2213,10 +2213,24 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id)/* Useful defaults if platform data is unset. */ #ifdef CONFIG_MMC_DW_IDMAC mmc->max_segs = host->ring_size; + +/* the BLKSIZ register is 16-bits wide */ mmc->max_blk_size =65536 ; - mmc->max_blk_count = host->ring_size; + +/* +* This value is calculated by taking the size of the +* 32-bit BYTCNT (byte count) register and dividing by the +* BLKSIZ (block size) register. This is the minimum number +* of blocks which could be handled. +*/ + mmc->max_blk_count =0xFFFF ; mmc->max_seg_size =0x1000 ; - mmc->max_req_size = mmc->max_seg_size * mmc->max_blk_count; +/* +* Maximum request size should be total number of descriptors +* times the maximum amount of data each can reference +*/ + + mmc->max_req_size = mmc->max_seg_size * mmc->max_segs;#else mmc->max_segs =64 ; mmc->max_blk_size =65536 ;/* BLKSIZ is 16 bits */