RE: [PATCH V2 1/2] SD/MMC: add an interface to re-initialize bounce buffer
Hi Chris, Do you have any concerns about this patch? Or another advice? Thanks. -Original Message- From: Liu Qiang-B32616 Sent: Wednesday, December 21, 2011 3:10 PM To: c...@laptop.org; linux-mmc@vger.kernel.org Cc: Li Yang-R58472; Liu Qiang-B32616; Liu Qiang-B32616 Subject: [PATCH V2 1/2] SD/MMC: add an interface to re-initialize bounce buffer Add bounce_size under /sys/block/mmcblk0/bouncesz. Support dynamic adjustment of bounce buffer in run-time (include mounted or unmounted filesystem). /sys/block/mmcblk0/bouncesz should be integer multiple of 512, the value should be range from 4096 to 4194304. 1. use variable instead of MMC_QUEUE_BOUNCESZ; 2. Re-initialize bounce buffer accorinding to new bounce size at run-time; Signed-off-by: Qiang Liu qiang@freescale.com --- changes for V2 merge former 2 patches to 1 Here is the test results with different mmc bounce size, IOzone is used to test performance of mass data transmission. Environment: PowerPC P1022DS platform, Sandisk Class 10, 4G memory card, EXT4 filesystem [root@p2020ds root]# cat /sys/fs/ block/mmcblk0/bouncesz 65536 [root@p2020ds root]# mount /dev/mmcblk0p1 /mnt/ EXT4-fs (mmcblk0p1): mounted filesystem without journal. Opts: [root@p2020ds root]# iozone -Rab result -i0 -i1 -r64 =- -n1g -g4g -f /mnt/ff KB reclen write rewritereadreread 1048576 64 14229 13286 662028 663372 2097152 64 13758 126054954947443 4194304 64 13435 122152197422096 [root@p2020ds root]# echo 262144 /sys/block/mmcblk0/bouncesz [root@p2020ds root]# cat /sys/block/mmcblk0/bouncesz 262144 [root@p2020ds root]# iozone -Rab result -i0 -i1 -r64 -n1g -g4g -f /mnt/ff KB reclen write rewritereadreread 1048576 64 19228 19416 676659 677785 2097152 64 18512 184992697827055 4194304 64 17932 181852194521805 [root@p2020ds root]# echo 8192 /sys/block/mmcblk0/bouncesz [root@p2020ds root]# cat /sys/block/mmcblk0/bouncesz 8192 [root@p2020ds root]# iozone -Rab result -i0 -i1 -r64 -n1g -g1g -f /mnt/ff KB reclen write rewritereadreread 1048576 6450683324 640266 641609 --- drivers/mmc/card/block.c | 43 +++ drivers/mmc/card/queue.c | 102 +- drivers/mmc/card/queue.h |6 +++ 3 files changed, 149 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 0c959c9..790abe2 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -59,6 +59,9 @@ MODULE_ALIAS(mmc:block); #define INAND_CMD38_ARG_SECTRIM1 0x81 #define INAND_CMD38_ARG_SECTRIM2 0x88 +#define MMC_MIN_QUEUE_BOUNCESZ 4096 +#define MMC_MAX_QUEUE_BOUNCESZ 4194304 + static DEFINE_MUTEX(block_mutex); /* @@ -108,6 +111,7 @@ struct mmc_blk_data { unsigned intpart_curr; struct device_attribute force_ro; struct device_attribute power_ro_lock; + struct device_attribute bouncesz; int area_type; }; @@ -1633,6 +1637,7 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md) del_gendisk(md-disk); } + device_remove_file(disk_to_dev(md-disk), md-bouncesz); /* Then flush out any already in there */ mmc_cleanup_queue(md-queue); mmc_blk_put(md); @@ -1739,6 +1744,33 @@ static const struct mmc_fixup blk_fixups[] = END_FIXUP }; +#ifdef CONFIG_MMC_BLOCK_BOUNCE +static ssize_t mmc_bouncesz_show(struct device *dev, + struct device_attribute *attr, char *buf) { +return sprintf(buf, %u\n, mmc_queue_bouncesz); } + +static ssize_t mmc_bouncesz_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned int bouncesz; + struct mmc_blk_data *md; + + if ((sscanf(buf, %d, bouncesz) != 1) || + (bouncesz MMC_MIN_QUEUE_BOUNCESZ) || + (bouncesz MMC_MAX_QUEUE_BOUNCESZ) || + (bouncesz % 512 != 0)) + return -EINVAL; + + md = mmc_blk_get(dev_to_disk(dev)); + mmc_reinit_bounce_queue(md-queue, md-queue.card, bouncesz); + mmc_blk_put(md); + return mmc_queue_bouncesz; +} +#endif + static int mmc_blk_probe(struct mmc_card *card) { struct mmc_blk_data *md, *part_md; @@ -1771,6 +1803,17 @@ static int mmc_blk_probe(struct mmc_card *card) mmc_set_drvdata(card, md); mmc_fixup_device(card, blk_fixups); +#ifdef CONFIG_MMC_BLOCK_BOUNCE + md-bouncesz.show = mmc_bouncesz_show; + md-bouncesz.store = mmc_bouncesz_store; + sysfs_attr_init(md-bouncesz.attr
RE: [PATCH V2 1/2] SD/MMC: add an interface to re-initialize bounce buffer
Hi Chris, Happy holidays! How about this patch? And [PATCH V2 2/2] mmc/doc: feature description of runtime bounce buffer size adjustment? I add the description in Documents/mmc/mmc-dev-attrs.txt according to your suggestion. Thanks for your reply. -Original Message- From: Liu Qiang-B32616 Sent: Wednesday, December 21, 2011 3:10 PM To: c...@laptop.org; linux-mmc@vger.kernel.org Cc: Li Yang-R58472; Liu Qiang-B32616; Liu Qiang-B32616 Subject: [PATCH V2 1/2] SD/MMC: add an interface to re-initialize bounce buffer Add bounce_size under /sys/block/mmcblk0/bouncesz. Support dynamic adjustment of bounce buffer in run-time (include mounted or unmounted filesystem). /sys/block/mmcblk0/bouncesz should be integer multiple of 512, the value should be range from 4096 to 4194304. 1. use variable instead of MMC_QUEUE_BOUNCESZ; 2. Re-initialize bounce buffer accorinding to new bounce size at run-time; Signed-off-by: Qiang Liu qiang@freescale.com --- changes for V2 merge former 2 patches to 1 Here is the test results with different mmc bounce size, IOzone is used to test performance of mass data transmission. Environment: PowerPC P1022DS platform, Sandisk Class 10, 4G memory card, EXT4 filesystem [root@p2020ds root]# cat /sys/fs/ block/mmcblk0/bouncesz 65536 [root@p2020ds root]# mount /dev/mmcblk0p1 /mnt/ EXT4-fs (mmcblk0p1): mounted filesystem without journal. Opts: [root@p2020ds root]# iozone -Rab result -i0 -i1 -r64 =- -n1g -g4g -f /mnt/ff KB reclen write rewritereadreread 1048576 64 14229 13286 662028 663372 2097152 64 13758 126054954947443 4194304 64 13435 122152197422096 [root@p2020ds root]# echo 262144 /sys/block/mmcblk0/bouncesz [root@p2020ds root]# cat /sys/block/mmcblk0/bouncesz 262144 [root@p2020ds root]# iozone -Rab result -i0 -i1 -r64 -n1g -g4g -f /mnt/ff KB reclen write rewritereadreread 1048576 64 19228 19416 676659 677785 2097152 64 18512 184992697827055 4194304 64 17932 181852194521805 [root@p2020ds root]# echo 8192 /sys/block/mmcblk0/bouncesz [root@p2020ds root]# cat /sys/block/mmcblk0/bouncesz 8192 [root@p2020ds root]# iozone -Rab result -i0 -i1 -r64 -n1g -g1g -f /mnt/ff KB reclen write rewritereadreread 1048576 6450683324 640266 641609 --- drivers/mmc/card/block.c | 43 +++ drivers/mmc/card/queue.c | 102 +- drivers/mmc/card/queue.h |6 +++ 3 files changed, 149 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 0c959c9..790abe2 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -59,6 +59,9 @@ MODULE_ALIAS(mmc:block); #define INAND_CMD38_ARG_SECTRIM1 0x81 #define INAND_CMD38_ARG_SECTRIM2 0x88 +#define MMC_MIN_QUEUE_BOUNCESZ 4096 +#define MMC_MAX_QUEUE_BOUNCESZ 4194304 + static DEFINE_MUTEX(block_mutex); /* @@ -108,6 +111,7 @@ struct mmc_blk_data { unsigned intpart_curr; struct device_attribute force_ro; struct device_attribute power_ro_lock; + struct device_attribute bouncesz; int area_type; }; @@ -1633,6 +1637,7 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md) del_gendisk(md-disk); } + device_remove_file(disk_to_dev(md-disk), md-bouncesz); /* Then flush out any already in there */ mmc_cleanup_queue(md-queue); mmc_blk_put(md); @@ -1739,6 +1744,33 @@ static const struct mmc_fixup blk_fixups[] = END_FIXUP }; +#ifdef CONFIG_MMC_BLOCK_BOUNCE +static ssize_t mmc_bouncesz_show(struct device *dev, + struct device_attribute *attr, char *buf) { +return sprintf(buf, %u\n, mmc_queue_bouncesz); } + +static ssize_t mmc_bouncesz_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned int bouncesz; + struct mmc_blk_data *md; + + if ((sscanf(buf, %d, bouncesz) != 1) || + (bouncesz MMC_MIN_QUEUE_BOUNCESZ) || + (bouncesz MMC_MAX_QUEUE_BOUNCESZ) || + (bouncesz % 512 != 0)) + return -EINVAL; + + md = mmc_blk_get(dev_to_disk(dev)); + mmc_reinit_bounce_queue(md-queue, md-queue.card, bouncesz); + mmc_blk_put(md); + return mmc_queue_bouncesz; +} +#endif + static int mmc_blk_probe(struct mmc_card *card) { struct mmc_blk_data *md, *part_md; @@ -1771,6 +1803,17 @@ static int mmc_blk_probe(struct mmc_card *card) mmc_set_drvdata(card, md); mmc_fixup_device(card, blk_fixups
[PATCH V2 1/2] SD/MMC: add an interface to re-initialize bounce buffer
Add bounce_size under /sys/block/mmcblk0/bouncesz. Support dynamic adjustment of bounce buffer in run-time (include mounted or unmounted filesystem). /sys/block/mmcblk0/bouncesz should be integer multiple of 512, the value should be range from 4096 to 4194304. 1. use variable instead of MMC_QUEUE_BOUNCESZ; 2. Re-initialize bounce buffer accorinding to new bounce size at run-time; Signed-off-by: Qiang Liu qiang@freescale.com --- changes for V2 merge former 2 patches to 1 Here is the test results with different mmc bounce size, IOzone is used to test performance of mass data transmission. Environment: PowerPC P1022DS platform, Sandisk Class 10, 4G memory card, EXT4 filesystem [root@p2020ds root]# cat /sys/fs/ block/mmcblk0/bouncesz 65536 [root@p2020ds root]# mount /dev/mmcblk0p1 /mnt/ EXT4-fs (mmcblk0p1): mounted filesystem without journal. Opts: [root@p2020ds root]# iozone -Rab result -i0 -i1 -r64 =- -n1g -g4g -f /mnt/ff KB reclen write rewritereadreread 1048576 64 14229 13286 662028 663372 2097152 64 13758 126054954947443 4194304 64 13435 122152197422096 [root@p2020ds root]# echo 262144 /sys/block/mmcblk0/bouncesz [root@p2020ds root]# cat /sys/block/mmcblk0/bouncesz 262144 [root@p2020ds root]# iozone -Rab result -i0 -i1 -r64 -n1g -g4g -f /mnt/ff KB reclen write rewritereadreread 1048576 64 19228 19416 676659 677785 2097152 64 18512 184992697827055 4194304 64 17932 181852194521805 [root@p2020ds root]# echo 8192 /sys/block/mmcblk0/bouncesz [root@p2020ds root]# cat /sys/block/mmcblk0/bouncesz 8192 [root@p2020ds root]# iozone -Rab result -i0 -i1 -r64 -n1g -g1g -f /mnt/ff KB reclen write rewritereadreread 1048576 6450683324 640266 641609 --- drivers/mmc/card/block.c | 43 +++ drivers/mmc/card/queue.c | 102 +- drivers/mmc/card/queue.h |6 +++ 3 files changed, 149 insertions(+), 2 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 0c959c9..790abe2 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -59,6 +59,9 @@ MODULE_ALIAS(mmc:block); #define INAND_CMD38_ARG_SECTRIM1 0x81 #define INAND_CMD38_ARG_SECTRIM2 0x88 +#define MMC_MIN_QUEUE_BOUNCESZ 4096 +#define MMC_MAX_QUEUE_BOUNCESZ 4194304 + static DEFINE_MUTEX(block_mutex); /* @@ -108,6 +111,7 @@ struct mmc_blk_data { unsigned intpart_curr; struct device_attribute force_ro; struct device_attribute power_ro_lock; + struct device_attribute bouncesz; int area_type; }; @@ -1633,6 +1637,7 @@ static void mmc_blk_remove_req(struct mmc_blk_data *md) del_gendisk(md-disk); } + device_remove_file(disk_to_dev(md-disk), md-bouncesz); /* Then flush out any already in there */ mmc_cleanup_queue(md-queue); mmc_blk_put(md); @@ -1739,6 +1744,33 @@ static const struct mmc_fixup blk_fixups[] = END_FIXUP }; +#ifdef CONFIG_MMC_BLOCK_BOUNCE +static ssize_t mmc_bouncesz_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ +return sprintf(buf, %u\n, mmc_queue_bouncesz); +} + +static ssize_t mmc_bouncesz_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned int bouncesz; + struct mmc_blk_data *md; + + if ((sscanf(buf, %d, bouncesz) != 1) || + (bouncesz MMC_MIN_QUEUE_BOUNCESZ) || + (bouncesz MMC_MAX_QUEUE_BOUNCESZ) || + (bouncesz % 512 != 0)) + return -EINVAL; + + md = mmc_blk_get(dev_to_disk(dev)); + mmc_reinit_bounce_queue(md-queue, md-queue.card, bouncesz); + mmc_blk_put(md); + return mmc_queue_bouncesz; +} +#endif + static int mmc_blk_probe(struct mmc_card *card) { struct mmc_blk_data *md, *part_md; @@ -1771,6 +1803,17 @@ static int mmc_blk_probe(struct mmc_card *card) mmc_set_drvdata(card, md); mmc_fixup_device(card, blk_fixups); +#ifdef CONFIG_MMC_BLOCK_BOUNCE + md-bouncesz.show = mmc_bouncesz_show; + md-bouncesz.store = mmc_bouncesz_store; + sysfs_attr_init(md-bouncesz.attr); + md-bouncesz.attr.name = bouncesz; + md-bouncesz.attr.mode = S_IRUGO | S_IWUSR; + err = device_create_file(disk_to_dev(md-disk), md-bouncesz); + if (err) + goto out; +#endif + if (mmc_add_disk(md)) goto out; diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index dcad59c..c563e33 100644 ---