* [PATCH] mmc: new API for data write using scatter gather DMA @ 2014-11-26 11:07 ` Avinash Patil 0 siblings, 0 replies; 11+ messages in thread From: Avinash Patil @ 2014-11-26 11:07 UTC (permalink / raw) To: ulf.hansson Cc: linux-mmc, linux-wireless, akarwar, cluo, yangyang, huxm, patila, bin9zha0, Bing Zhao From: Bing Zhao <bzhao@marvell.com> This patch adds new API to handle scatter gather aggregation. Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: Avinash Patil <patila@marvell.com> Signed-off-by: Xinming Hu <huxm@marvell.com> Signed-off-by: Cathy Luo <cluo@marvell.com> --- drivers/mmc/core/sdio_ops.c | 65 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/sdio_func.h | 5 ++++ 2 files changed, 70 insertions(+) diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c index 62508b4..4c5e362 100644 --- a/drivers/mmc/core/sdio_ops.c +++ b/drivers/mmc/core/sdio_ops.c @@ -15,6 +15,7 @@ #include <linux/mmc/card.h> #include <linux/mmc/mmc.h> #include <linux/mmc/sdio.h> +#include <linux/export.h> #include "core.h" #include "sdio_ops.h" @@ -204,6 +205,70 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, return 0; } +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, + unsigned addr, int incr_addr, + struct sg_table *sgt, unsigned blksz) +{ + struct mmc_request mrq = {NULL}; + struct mmc_command cmd = {0}; + struct mmc_data data = {0}; + struct scatterlist *sg_ptr; + unsigned blocks = 0; + int i; + + BUG_ON(!card || !card->host); + BUG_ON(fn > 7); + BUG_ON(!blksz); + for_each_sg(sgt->sgl, sg_ptr, sgt->nents, i) { + WARN_ON(sg_ptr->length > card->host->max_seg_size); + blocks += DIV_ROUND_UP(sg_ptr->length, blksz); + } + + /* sanity check */ + if (addr & ~0x1FFFF) + return -EINVAL; + + mrq.cmd = &cmd; + mrq.data = &data; + + cmd.opcode = SD_IO_RW_EXTENDED; + cmd.arg = write ? 0x80000000 : 0x00000000; + cmd.arg |= fn << 28; + cmd.arg |= incr_addr ? 0x04000000 : 0x00000000; + cmd.arg |= addr << 9; + cmd.arg |= 0x08000000 | blocks; + cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC; + + data.blksz = blksz; + data.blocks = blocks; + data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; + + data.sg = sgt->sgl; + data.sg_len = sgt->nents; + + mmc_set_data_timeout(&data, card); + mmc_wait_for_req(card->host, &mrq); + + if (cmd.error) + return cmd.error; + if (data.error) + return data.error; + + if (mmc_host_is_spi(card->host)) { + /* host driver already reported errors */ + } else { + if (cmd.resp[0] & R5_ERROR) + return -EIO; + if (cmd.resp[0] & R5_FUNCTION_NUMBER) + return -EINVAL; + if (cmd.resp[0] & R5_OUT_OF_RANGE) + return -ERANGE; + } + + return 0; +} +EXPORT_SYMBOL_GPL(mmc_io_rw_extended_sg); + int sdio_reset(struct mmc_host *host) { int ret; diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h index 50f0bc9..927ea8f 100644 --- a/include/linux/mmc/sdio_func.h +++ b/include/linux/mmc/sdio_func.h @@ -14,6 +14,7 @@ #include <linux/device.h> #include <linux/mod_devicetable.h> +#include <linux/scatterlist.h> #include <linux/mmc/pm.h> @@ -153,6 +154,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, extern int sdio_writesb(struct sdio_func *func, unsigned int addr, void *src, int count); +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, + unsigned addr, int incr_addr, + struct sg_table *sgt, unsigned blksz); + extern unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr, int *err_ret); extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, -- 1.8.1.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH] mmc: new API for data write using scatter gather DMA @ 2014-11-26 11:07 ` Avinash Patil 0 siblings, 0 replies; 11+ messages in thread From: Avinash Patil @ 2014-11-26 11:07 UTC (permalink / raw) To: ulf.hansson Cc: linux-mmc, linux-wireless, akarwar, cluo, yangyang, huxm, patila, bin9zha0, Bing Zhao From: Bing Zhao <bzhao@marvell.com> This patch adds new API to handle scatter gather aggregation. Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: Avinash Patil <patila@marvell.com> Signed-off-by: Xinming Hu <huxm@marvell.com> Signed-off-by: Cathy Luo <cluo@marvell.com> --- drivers/mmc/core/sdio_ops.c | 65 +++++++++++++++++++++++++++++++++++++++++++ include/linux/mmc/sdio_func.h | 5 ++++ 2 files changed, 70 insertions(+) diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c index 62508b4..4c5e362 100644 --- a/drivers/mmc/core/sdio_ops.c +++ b/drivers/mmc/core/sdio_ops.c @@ -15,6 +15,7 @@ #include <linux/mmc/card.h> #include <linux/mmc/mmc.h> #include <linux/mmc/sdio.h> +#include <linux/export.h> #include "core.h" #include "sdio_ops.h" @@ -204,6 +205,70 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, return 0; } +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, + unsigned addr, int incr_addr, + struct sg_table *sgt, unsigned blksz) +{ + struct mmc_request mrq = {NULL}; + struct mmc_command cmd = {0}; + struct mmc_data data = {0}; + struct scatterlist *sg_ptr; + unsigned blocks = 0; + int i; + + BUG_ON(!card || !card->host); + BUG_ON(fn > 7); + BUG_ON(!blksz); + for_each_sg(sgt->sgl, sg_ptr, sgt->nents, i) { + WARN_ON(sg_ptr->length > card->host->max_seg_size); + blocks += DIV_ROUND_UP(sg_ptr->length, blksz); + } + + /* sanity check */ + if (addr & ~0x1FFFF) + return -EINVAL; + + mrq.cmd = &cmd; + mrq.data = &data; + + cmd.opcode = SD_IO_RW_EXTENDED; + cmd.arg = write ? 0x80000000 : 0x00000000; + cmd.arg |= fn << 28; + cmd.arg |= incr_addr ? 0x04000000 : 0x00000000; + cmd.arg |= addr << 9; + cmd.arg |= 0x08000000 | blocks; + cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC; + + data.blksz = blksz; + data.blocks = blocks; + data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; + + data.sg = sgt->sgl; + data.sg_len = sgt->nents; + + mmc_set_data_timeout(&data, card); + mmc_wait_for_req(card->host, &mrq); + + if (cmd.error) + return cmd.error; + if (data.error) + return data.error; + + if (mmc_host_is_spi(card->host)) { + /* host driver already reported errors */ + } else { + if (cmd.resp[0] & R5_ERROR) + return -EIO; + if (cmd.resp[0] & R5_FUNCTION_NUMBER) + return -EINVAL; + if (cmd.resp[0] & R5_OUT_OF_RANGE) + return -ERANGE; + } + + return 0; +} +EXPORT_SYMBOL_GPL(mmc_io_rw_extended_sg); + int sdio_reset(struct mmc_host *host) { int ret; diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h index 50f0bc9..927ea8f 100644 --- a/include/linux/mmc/sdio_func.h +++ b/include/linux/mmc/sdio_func.h @@ -14,6 +14,7 @@ #include <linux/device.h> #include <linux/mod_devicetable.h> +#include <linux/scatterlist.h> #include <linux/mmc/pm.h> @@ -153,6 +154,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, extern int sdio_writesb(struct sdio_func *func, unsigned int addr, void *src, int count); +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, + unsigned addr, int incr_addr, + struct sg_table *sgt, unsigned blksz); + extern unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr, int *err_ret); extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, -- 1.8.1.4 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] mmc: new API for data write using scatter gather DMA 2014-11-26 11:07 ` Avinash Patil (?) @ 2014-11-26 13:43 ` Ulf Hansson [not found] ` <CAPDyKFr-iaPWKWWgk-5_XcJm9sag=y=uZjfJvo-DQiJFM8BVLw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> -1 siblings, 1 reply; 11+ messages in thread From: Ulf Hansson @ 2014-11-26 13:43 UTC (permalink / raw) To: Avinash Patil Cc: linux-mmc, linux-wireless@vger.kernel.org, akarwar, cluo, yangyang, huxm, bin9zha0, Bing Zhao On 26 November 2014 at 12:07, Avinash Patil <patila@marvell.com> wrote: > From: Bing Zhao <bzhao@marvell.com> > > This patch adds new API to handle scatter gather aggregation. Why is this needed? > > Signed-off-by: Bing Zhao <bzhao@marvell.com> > Signed-off-by: Avinash Patil <patila@marvell.com> > Signed-off-by: Xinming Hu <huxm@marvell.com> > Signed-off-by: Cathy Luo <cluo@marvell.com> > --- > drivers/mmc/core/sdio_ops.c | 65 +++++++++++++++++++++++++++++++++++++++++++ > include/linux/mmc/sdio_func.h | 5 ++++ > 2 files changed, 70 insertions(+) > > diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c > index 62508b4..4c5e362 100644 > --- a/drivers/mmc/core/sdio_ops.c > +++ b/drivers/mmc/core/sdio_ops.c > @@ -15,6 +15,7 @@ > #include <linux/mmc/card.h> > #include <linux/mmc/mmc.h> > #include <linux/mmc/sdio.h> > +#include <linux/export.h> > > #include "core.h" > #include "sdio_ops.h" > @@ -204,6 +205,70 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, > return 0; > } > > +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, > + unsigned addr, int incr_addr, > + struct sg_table *sgt, unsigned blksz) > +{ > + struct mmc_request mrq = {NULL}; > + struct mmc_command cmd = {0}; > + struct mmc_data data = {0}; > + struct scatterlist *sg_ptr; > + unsigned blocks = 0; > + int i; > + > + BUG_ON(!card || !card->host); > + BUG_ON(fn > 7); > + BUG_ON(!blksz); No BUG_ON() here please. Better to return an error. > + for_each_sg(sgt->sgl, sg_ptr, sgt->nents, i) { > + WARN_ON(sg_ptr->length > card->host->max_seg_size); > + blocks += DIV_ROUND_UP(sg_ptr->length, blksz); > + } > + > + /* sanity check */ > + if (addr & ~0x1FFFF) > + return -EINVAL; > + > + mrq.cmd = &cmd; > + mrq.data = &data; > + > + cmd.opcode = SD_IO_RW_EXTENDED; > + cmd.arg = write ? 0x80000000 : 0x00000000; > + cmd.arg |= fn << 28; > + cmd.arg |= incr_addr ? 0x04000000 : 0x00000000; > + cmd.arg |= addr << 9; > + cmd.arg |= 0x08000000 | blocks; > + cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC; > + > + data.blksz = blksz; > + data.blocks = blocks; > + data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; > + > + data.sg = sgt->sgl; > + data.sg_len = sgt->nents; > + > + mmc_set_data_timeout(&data, card); > + mmc_wait_for_req(card->host, &mrq); > + > + if (cmd.error) > + return cmd.error; > + if (data.error) > + return data.error; > + > + if (mmc_host_is_spi(card->host)) { > + /* host driver already reported errors */ > + } else { > + if (cmd.resp[0] & R5_ERROR) > + return -EIO; > + if (cmd.resp[0] & R5_FUNCTION_NUMBER) > + return -EINVAL; > + if (cmd.resp[0] & R5_OUT_OF_RANGE) > + return -ERANGE; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(mmc_io_rw_extended_sg); > + > int sdio_reset(struct mmc_host *host) > { > int ret; > diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h > index 50f0bc9..927ea8f 100644 > --- a/include/linux/mmc/sdio_func.h > +++ b/include/linux/mmc/sdio_func.h > @@ -14,6 +14,7 @@ > > #include <linux/device.h> > #include <linux/mod_devicetable.h> > +#include <linux/scatterlist.h> > > #include <linux/mmc/pm.h> > > @@ -153,6 +154,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, > extern int sdio_writesb(struct sdio_func *func, unsigned int addr, > void *src, int count); > > +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, > + unsigned addr, int incr_addr, > + struct sg_table *sgt, unsigned blksz); > + > extern unsigned char sdio_f0_readb(struct sdio_func *func, > unsigned int addr, int *err_ret); > extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, > -- > 1.8.1.4 > Kind regards Uffe ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <CAPDyKFr-iaPWKWWgk-5_XcJm9sag=y=uZjfJvo-DQiJFM8BVLw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>]
* Re: [PATCH] mmc: new API for data write using scatter gather DMA 2014-11-26 13:43 ` Ulf Hansson @ 2014-11-26 18:10 ` Arend van Spriel 0 siblings, 0 replies; 11+ messages in thread From: Arend van Spriel @ 2014-11-26 18:10 UTC (permalink / raw) To: Ulf Hansson Cc: Avinash Patil, linux-mmc, linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, akarwar-eYqpPyKDWXRBDgjK7y7TUQ, cluo-eYqpPyKDWXRBDgjK7y7TUQ, yangyang-eYqpPyKDWXRBDgjK7y7TUQ, huxm-eYqpPyKDWXRBDgjK7y7TUQ, bin9zha0-Re5JQEeQqe8AvxtiuMwx3w, Bing Zhao On 11/26/14 14:43, Ulf Hansson wrote: > On 26 November 2014 at 12:07, Avinash Patil<patila-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> wrote: >> From: Bing Zhao<bzhao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> >> >> This patch adds new API to handle scatter gather aggregation. > > Why is this needed? One thing I can imagine is that the receiving device has specific scatter-gather alignment requirements that are not covered in mmc_io_rw_extended(). So the new API does not so much handle scatter-gather, but leaves that up to the caller. Question is whether mmc_io_rw_extended() could be changed to accommodate those requirements instead of duplicating big part of it. Without knowing the exact requirements that is difficult to answer. Regards, Arend > >> >> Signed-off-by: Bing Zhao<bzhao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> >> Signed-off-by: Avinash Patil<patila-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> >> Signed-off-by: Xinming Hu<huxm-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> >> Signed-off-by: Cathy Luo<cluo-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> >> --- >> drivers/mmc/core/sdio_ops.c | 65 +++++++++++++++++++++++++++++++++++++++++++ >> include/linux/mmc/sdio_func.h | 5 ++++ >> 2 files changed, 70 insertions(+) >> >> diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c >> index 62508b4..4c5e362 100644 >> --- a/drivers/mmc/core/sdio_ops.c >> +++ b/drivers/mmc/core/sdio_ops.c >> @@ -15,6 +15,7 @@ >> #include<linux/mmc/card.h> >> #include<linux/mmc/mmc.h> >> #include<linux/mmc/sdio.h> >> +#include<linux/export.h> >> >> #include "core.h" >> #include "sdio_ops.h" >> @@ -204,6 +205,70 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, >> return 0; >> } >> >> +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, >> + unsigned addr, int incr_addr, >> + struct sg_table *sgt, unsigned blksz) >> +{ >> + struct mmc_request mrq = {NULL}; >> + struct mmc_command cmd = {0}; >> + struct mmc_data data = {0}; >> + struct scatterlist *sg_ptr; >> + unsigned blocks = 0; >> + int i; >> + >> + BUG_ON(!card || !card->host); >> + BUG_ON(fn> 7); >> + BUG_ON(!blksz); > > No BUG_ON() here please. Better to return an error. > >> + for_each_sg(sgt->sgl, sg_ptr, sgt->nents, i) { >> + WARN_ON(sg_ptr->length> card->host->max_seg_size); >> + blocks += DIV_ROUND_UP(sg_ptr->length, blksz); >> + } >> + >> + /* sanity check */ >> + if (addr& ~0x1FFFF) >> + return -EINVAL; >> + >> + mrq.cmd =&cmd; >> + mrq.data =&data; >> + >> + cmd.opcode = SD_IO_RW_EXTENDED; >> + cmd.arg = write ? 0x80000000 : 0x00000000; >> + cmd.arg |= fn<< 28; >> + cmd.arg |= incr_addr ? 0x04000000 : 0x00000000; >> + cmd.arg |= addr<< 9; >> + cmd.arg |= 0x08000000 | blocks; >> + cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC; >> + >> + data.blksz = blksz; >> + data.blocks = blocks; >> + data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; >> + >> + data.sg = sgt->sgl; >> + data.sg_len = sgt->nents; >> + >> + mmc_set_data_timeout(&data, card); >> + mmc_wait_for_req(card->host,&mrq); >> + >> + if (cmd.error) >> + return cmd.error; >> + if (data.error) >> + return data.error; >> + >> + if (mmc_host_is_spi(card->host)) { >> + /* host driver already reported errors */ >> + } else { >> + if (cmd.resp[0]& R5_ERROR) >> + return -EIO; >> + if (cmd.resp[0]& R5_FUNCTION_NUMBER) >> + return -EINVAL; >> + if (cmd.resp[0]& R5_OUT_OF_RANGE) >> + return -ERANGE; >> + } >> + >> + return 0; >> +} >> +EXPORT_SYMBOL_GPL(mmc_io_rw_extended_sg); >> + >> int sdio_reset(struct mmc_host *host) >> { >> int ret; >> diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h >> index 50f0bc9..927ea8f 100644 >> --- a/include/linux/mmc/sdio_func.h >> +++ b/include/linux/mmc/sdio_func.h >> @@ -14,6 +14,7 @@ >> >> #include<linux/device.h> >> #include<linux/mod_devicetable.h> >> +#include<linux/scatterlist.h> >> >> #include<linux/mmc/pm.h> >> >> @@ -153,6 +154,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, >> extern int sdio_writesb(struct sdio_func *func, unsigned int addr, >> void *src, int count); >> >> +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, >> + unsigned addr, int incr_addr, >> + struct sg_table *sgt, unsigned blksz); >> + >> extern unsigned char sdio_f0_readb(struct sdio_func *func, >> unsigned int addr, int *err_ret); >> extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, >> -- >> 1.8.1.4 >> > > Kind regards > Uffe > -- > To unsubscribe from this list: send the line "unsubscribe linux-wireless" in > the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mmc: new API for data write using scatter gather DMA @ 2014-11-26 18:10 ` Arend van Spriel 0 siblings, 0 replies; 11+ messages in thread From: Arend van Spriel @ 2014-11-26 18:10 UTC (permalink / raw) To: Ulf Hansson Cc: Avinash Patil, linux-mmc, linux-wireless@vger.kernel.org, akarwar, cluo, yangyang, huxm, bin9zha0, Bing Zhao On 11/26/14 14:43, Ulf Hansson wrote: > On 26 November 2014 at 12:07, Avinash Patil<patila@marvell.com> wrote: >> From: Bing Zhao<bzhao@marvell.com> >> >> This patch adds new API to handle scatter gather aggregation. > > Why is this needed? One thing I can imagine is that the receiving device has specific scatter-gather alignment requirements that are not covered in mmc_io_rw_extended(). So the new API does not so much handle scatter-gather, but leaves that up to the caller. Question is whether mmc_io_rw_extended() could be changed to accommodate those requirements instead of duplicating big part of it. Without knowing the exact requirements that is difficult to answer. Regards, Arend > >> >> Signed-off-by: Bing Zhao<bzhao@marvell.com> >> Signed-off-by: Avinash Patil<patila@marvell.com> >> Signed-off-by: Xinming Hu<huxm@marvell.com> >> Signed-off-by: Cathy Luo<cluo@marvell.com> >> --- >> drivers/mmc/core/sdio_ops.c | 65 +++++++++++++++++++++++++++++++++++++++++++ >> include/linux/mmc/sdio_func.h | 5 ++++ >> 2 files changed, 70 insertions(+) >> >> diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c >> index 62508b4..4c5e362 100644 >> --- a/drivers/mmc/core/sdio_ops.c >> +++ b/drivers/mmc/core/sdio_ops.c >> @@ -15,6 +15,7 @@ >> #include<linux/mmc/card.h> >> #include<linux/mmc/mmc.h> >> #include<linux/mmc/sdio.h> >> +#include<linux/export.h> >> >> #include "core.h" >> #include "sdio_ops.h" >> @@ -204,6 +205,70 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, >> return 0; >> } >> >> +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, >> + unsigned addr, int incr_addr, >> + struct sg_table *sgt, unsigned blksz) >> +{ >> + struct mmc_request mrq = {NULL}; >> + struct mmc_command cmd = {0}; >> + struct mmc_data data = {0}; >> + struct scatterlist *sg_ptr; >> + unsigned blocks = 0; >> + int i; >> + >> + BUG_ON(!card || !card->host); >> + BUG_ON(fn> 7); >> + BUG_ON(!blksz); > > No BUG_ON() here please. Better to return an error. > >> + for_each_sg(sgt->sgl, sg_ptr, sgt->nents, i) { >> + WARN_ON(sg_ptr->length> card->host->max_seg_size); >> + blocks += DIV_ROUND_UP(sg_ptr->length, blksz); >> + } >> + >> + /* sanity check */ >> + if (addr& ~0x1FFFF) >> + return -EINVAL; >> + >> + mrq.cmd =&cmd; >> + mrq.data =&data; >> + >> + cmd.opcode = SD_IO_RW_EXTENDED; >> + cmd.arg = write ? 0x80000000 : 0x00000000; >> + cmd.arg |= fn<< 28; >> + cmd.arg |= incr_addr ? 0x04000000 : 0x00000000; >> + cmd.arg |= addr<< 9; >> + cmd.arg |= 0x08000000 | blocks; >> + cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC; >> + >> + data.blksz = blksz; >> + data.blocks = blocks; >> + data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; >> + >> + data.sg = sgt->sgl; >> + data.sg_len = sgt->nents; >> + >> + mmc_set_data_timeout(&data, card); >> + mmc_wait_for_req(card->host,&mrq); >> + >> + if (cmd.error) >> + return cmd.error; >> + if (data.error) >> + return data.error; >> + >> + if (mmc_host_is_spi(card->host)) { >> + /* host driver already reported errors */ >> + } else { >> + if (cmd.resp[0]& R5_ERROR) >> + return -EIO; >> + if (cmd.resp[0]& R5_FUNCTION_NUMBER) >> + return -EINVAL; >> + if (cmd.resp[0]& R5_OUT_OF_RANGE) >> + return -ERANGE; >> + } >> + >> + return 0; >> +} >> +EXPORT_SYMBOL_GPL(mmc_io_rw_extended_sg); >> + >> int sdio_reset(struct mmc_host *host) >> { >> int ret; >> diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h >> index 50f0bc9..927ea8f 100644 >> --- a/include/linux/mmc/sdio_func.h >> +++ b/include/linux/mmc/sdio_func.h >> @@ -14,6 +14,7 @@ >> >> #include<linux/device.h> >> #include<linux/mod_devicetable.h> >> +#include<linux/scatterlist.h> >> >> #include<linux/mmc/pm.h> >> >> @@ -153,6 +154,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, >> extern int sdio_writesb(struct sdio_func *func, unsigned int addr, >> void *src, int count); >> >> +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, >> + unsigned addr, int incr_addr, >> + struct sg_table *sgt, unsigned blksz); >> + >> extern unsigned char sdio_f0_readb(struct sdio_func *func, >> unsigned int addr, int *err_ret); >> extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, >> -- >> 1.8.1.4 >> > > Kind regards > Uffe > -- > To unsubscribe from this list: send the line "unsubscribe linux-wireless" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 11+ messages in thread
[parent not found: <CAEhWJFmxxFyh5oF33NiTQn70RhoP_z-vkRBEdVb-XcMfDDnHfg@mail.gmail.com>]
[parent not found: <e5ce420ddc0f4ceca8cac83f5350ded3@SC-EXCH04.marvell.com>]
* RE: [PATCH] mmc: new API for data write using scatter gather DMA [not found] ` <e5ce420ddc0f4ceca8cac83f5350ded3@SC-EXCH04.marvell.com> @ 2015-09-22 7:20 ` Amitkumar Karwar 0 siblings, 0 replies; 11+ messages in thread From: Amitkumar Karwar @ 2015-09-22 7:20 UTC (permalink / raw) To: ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-wireless@vger.kernel.org, Cathy Luo, Xinming Hu, bin9zha0@gmail.com Hi Ulf/Arend, > > > On Wed, Nov 26, 2014 at 11:40 PM, Arend van Spriel <arend@broadcom.com> > > wrote: > > On 11/26/14 14:43, Ulf Hansson wrote: > > > On 26 November 2014 at 12:07, Avinash Patil<patila@marvell.com> wrote: > > > From: Bing Zhao<bzhao@marvell.com> > > > > This patch adds new API to handle scatter gather aggregation. > > > Why is this needed? > > One thing I can imagine is that the receiving device has specific > scatter-gather alignment requirements that are not covered in > mmc_io_rw_extended(). So the new API does not so much handle scatter- > gather, but leaves that up to the caller. Question is whether > mmc_io_rw_extended() could be changed to accommodate those requirements > instead of duplicating big part of it. Without knowing the exact > requirements that is difficult to answer. > > Regards, > Arend My apologies for opening discussion on this topic after long time. Earlier we had dropped this patch, because we didn't see significant performance improvement with it. Now we have optimized code in our WLAN driver and are planning to have this patch. Existing mmc_io_rw_extended() API expects caller to pass single contiguous buffer. It will be split if it exceeds segment size, SG table is prepared and used it for reading/writing the data. Our intention for defining new API here is to facilitate caller to provide ready SG table(scattered buffer list). On one of our platforms maximum segments are 256 with each segment of 4k size. So this new API would be really beneficial there for performance improvement. Let me know your suggestions/thoughts. Regards, Amitkumar ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] mmc: new API for data write using scatter gather DMA @ 2015-09-22 7:20 ` Amitkumar Karwar 0 siblings, 0 replies; 11+ messages in thread From: Amitkumar Karwar @ 2015-09-22 7:20 UTC (permalink / raw) To: ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-wireless@vger.kernel.org, Cathy Luo, Xinming Hu, bin9zha0@gmail.com SGkgVWxmL0FyZW5kLA0KDQo+IA0KPiA+IE9uIFdlZCwgTm92IDI2LCAyMDE0IGF0IDExOjQwIFBN LCBBcmVuZCB2YW4gU3ByaWVsIDxhcmVuZEBicm9hZGNvbS5jb20+DQo+ID4gd3JvdGU6DQo+ID4g T24gMTEvMjYvMTQgMTQ6NDMsIFVsZiBIYW5zc29uIHdyb3RlOg0KPiA+ID4gT24gMjYgTm92ZW1i ZXIgMjAxNCBhdCAxMjowNywgQXZpbmFzaCBQYXRpbDxwYXRpbGFAbWFydmVsbC5jb20+wqAgd3Jv dGU6DQo+ID4gPiBGcm9tOiBCaW5nIFpoYW88YnpoYW9AbWFydmVsbC5jb20+DQo+IA0KPiA+ID4g VGhpcyBwYXRjaCBhZGRzIG5ldyBBUEkgdG8gaGFuZGxlIHNjYXR0ZXIgZ2F0aGVyIGFnZ3JlZ2F0 aW9uLg0KPiANCj4gPiBXaHkgaXMgdGhpcyBuZWVkZWQ/DQo+IA0KPiBPbmUgdGhpbmcgSSBjYW4g aW1hZ2luZSBpcyB0aGF0IHRoZSByZWNlaXZpbmcgZGV2aWNlIGhhcyBzcGVjaWZpYw0KPiBzY2F0 dGVyLWdhdGhlciBhbGlnbm1lbnQgcmVxdWlyZW1lbnRzIHRoYXQgYXJlIG5vdCBjb3ZlcmVkIGlu DQo+IG1tY19pb19yd19leHRlbmRlZCgpLiBTbyB0aGUgbmV3IEFQSSBkb2VzIG5vdCBzbyBtdWNo IGhhbmRsZSBzY2F0dGVyLQ0KPiBnYXRoZXIsIGJ1dCBsZWF2ZXMgdGhhdCB1cCB0byB0aGUgY2Fs bGVyLiBRdWVzdGlvbiBpcyB3aGV0aGVyDQo+IG1tY19pb19yd19leHRlbmRlZCgpIGNvdWxkIGJl IGNoYW5nZWQgdG8gYWNjb21tb2RhdGUgdGhvc2UgcmVxdWlyZW1lbnRzDQo+IGluc3RlYWQgb2Yg ZHVwbGljYXRpbmcgYmlnIHBhcnQgb2YgaXQuIFdpdGhvdXQga25vd2luZyB0aGUgZXhhY3QNCj4g cmVxdWlyZW1lbnRzIHRoYXQgaXMgZGlmZmljdWx0IHRvIGFuc3dlci4NCj4gDQo+IFJlZ2FyZHMs DQo+IEFyZW5kDQoNCk15IGFwb2xvZ2llcyBmb3Igb3BlbmluZyBkaXNjdXNzaW9uIG9uIHRoaXMg dG9waWMgYWZ0ZXIgbG9uZyB0aW1lLg0KDQpFYXJsaWVyIHdlIGhhZCBkcm9wcGVkIHRoaXMgcGF0 Y2gsIGJlY2F1c2Ugd2UgZGlkbid0IHNlZSBzaWduaWZpY2FudCBwZXJmb3JtYW5jZSBpbXByb3Zl bWVudCB3aXRoIGl0LiBOb3cgd2UgaGF2ZSBvcHRpbWl6ZWQgY29kZSBpbiBvdXIgV0xBTiBkcml2 ZXIgYW5kIGFyZSBwbGFubmluZyB0byBoYXZlIHRoaXMgcGF0Y2guDQoNCkV4aXN0aW5nIG1tY19p b19yd19leHRlbmRlZCgpIEFQSSBleHBlY3RzIGNhbGxlciB0byBwYXNzIHNpbmdsZSBjb250aWd1 b3VzIGJ1ZmZlci4gSXQgd2lsbCBiZSBzcGxpdCBpZiBpdCBleGNlZWRzIHNlZ21lbnQgc2l6ZSwg U0cgdGFibGUgaXMgcHJlcGFyZWQgYW5kIHVzZWQgaXQgZm9yIHJlYWRpbmcvd3JpdGluZyB0aGUg ZGF0YS4gT3VyIGludGVudGlvbiBmb3IgZGVmaW5pbmcgbmV3IEFQSSBoZXJlIGlzIHRvIGZhY2ls aXRhdGUgY2FsbGVyIHRvIHByb3ZpZGUgcmVhZHkgU0cgdGFibGUoc2NhdHRlcmVkIGJ1ZmZlciBs aXN0KS4gT24gb25lIG9mIG91ciBwbGF0Zm9ybXMgbWF4aW11bSBzZWdtZW50cyBhcmUgMjU2IHdp dGggZWFjaCBzZWdtZW50IG9mIDRrIHNpemUuIFNvIHRoaXMgbmV3IEFQSSB3b3VsZCBiZSByZWFs bHkgYmVuZWZpY2lhbCB0aGVyZSBmb3IgcGVyZm9ybWFuY2UgaW1wcm92ZW1lbnQuDQoNCkxldCBt ZSBrbm93IHlvdXIgc3VnZ2VzdGlvbnMvdGhvdWdodHMuDQoNClJlZ2FyZHMsDQpBbWl0a3VtYXIN Cg== ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] mmc: new API for data write using scatter gather DMA 2014-11-26 13:43 ` Ulf Hansson @ 2014-12-02 9:25 ` Avinash Patil 0 siblings, 0 replies; 11+ messages in thread From: Avinash Patil @ 2014-12-02 9:25 UTC (permalink / raw) To: Ulf Hansson Cc: linux-mmc, linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Amitkumar Karwar, Cathy Luo, Marc Yang, Xinming Hu, bin9zha0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org, Bing Zhao Hi Ulf, Purpose of patch is to offload scatter gather list population to host driver. Patch provides MMC API using which host driver can directly use to program SG DMA. Thanks, Avinash ________________________________________ From: Ulf Hansson [ulf.hansson-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org] Sent: Wednesday, November 26, 2014 7:13 PM To: Avinash Patil Cc: linux-mmc; linux-wireless-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; Amitkumar Karwar; Cathy Luo; Marc Yang; Xinming Hu; bin9zha0-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org; Bing Zhao Subject: Re: [PATCH] mmc: new API for data write using scatter gather DMA On 26 November 2014 at 12:07, Avinash Patil <patila-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> wrote: > From: Bing Zhao <bzhao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> > > This patch adds new API to handle scatter gather aggregation. Why is this needed? > > Signed-off-by: Bing Zhao <bzhao-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> > Signed-off-by: Avinash Patil <patila-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> > Signed-off-by: Xinming Hu <huxm-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> > Signed-off-by: Cathy Luo <cluo-eYqpPyKDWXRBDgjK7y7TUQ@public.gmane.org> > --- > drivers/mmc/core/sdio_ops.c | 65 +++++++++++++++++++++++++++++++++++++++++++ > include/linux/mmc/sdio_func.h | 5 ++++ > 2 files changed, 70 insertions(+) > > diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c > index 62508b4..4c5e362 100644 > --- a/drivers/mmc/core/sdio_ops.c > +++ b/drivers/mmc/core/sdio_ops.c > @@ -15,6 +15,7 @@ > #include <linux/mmc/card.h> > #include <linux/mmc/mmc.h> > #include <linux/mmc/sdio.h> > +#include <linux/export.h> > > #include "core.h" > #include "sdio_ops.h" > @@ -204,6 +205,70 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, > return 0; > } > > +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, > + unsigned addr, int incr_addr, > + struct sg_table *sgt, unsigned blksz) > +{ > + struct mmc_request mrq = {NULL}; > + struct mmc_command cmd = {0}; > + struct mmc_data data = {0}; > + struct scatterlist *sg_ptr; > + unsigned blocks = 0; > + int i; > + > + BUG_ON(!card || !card->host); > + BUG_ON(fn > 7); > + BUG_ON(!blksz); No BUG_ON() here please. Better to return an error. > + for_each_sg(sgt->sgl, sg_ptr, sgt->nents, i) { > + WARN_ON(sg_ptr->length > card->host->max_seg_size); > + blocks += DIV_ROUND_UP(sg_ptr->length, blksz); > + } > + > + /* sanity check */ > + if (addr & ~0x1FFFF) > + return -EINVAL; > + > + mrq.cmd = &cmd; > + mrq.data = &data; > + > + cmd.opcode = SD_IO_RW_EXTENDED; > + cmd.arg = write ? 0x80000000 : 0x00000000; > + cmd.arg |= fn << 28; > + cmd.arg |= incr_addr ? 0x04000000 : 0x00000000; > + cmd.arg |= addr << 9; > + cmd.arg |= 0x08000000 | blocks; > + cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC; > + > + data.blksz = blksz; > + data.blocks = blocks; > + data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; > + > + data.sg = sgt->sgl; > + data.sg_len = sgt->nents; > + > + mmc_set_data_timeout(&data, card); > + mmc_wait_for_req(card->host, &mrq); > + > + if (cmd.error) > + return cmd.error; > + if (data.error) > + return data.error; > + > + if (mmc_host_is_spi(card->host)) { > + /* host driver already reported errors */ > + } else { > + if (cmd.resp[0] & R5_ERROR) > + return -EIO; > + if (cmd.resp[0] & R5_FUNCTION_NUMBER) > + return -EINVAL; > + if (cmd.resp[0] & R5_OUT_OF_RANGE) > + return -ERANGE; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(mmc_io_rw_extended_sg); > + > int sdio_reset(struct mmc_host *host) > { > int ret; > diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h > index 50f0bc9..927ea8f 100644 > --- a/include/linux/mmc/sdio_func.h > +++ b/include/linux/mmc/sdio_func.h > @@ -14,6 +14,7 @@ > > #include <linux/device.h> > #include <linux/mod_devicetable.h> > +#include <linux/scatterlist.h> > > #include <linux/mmc/pm.h> > > @@ -153,6 +154,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, > extern int sdio_writesb(struct sdio_func *func, unsigned int addr, > void *src, int count); > > +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, > + unsigned addr, int incr_addr, > + struct sg_table *sgt, unsigned blksz); > + > extern unsigned char sdio_f0_readb(struct sdio_func *func, > unsigned int addr, int *err_ret); > extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, > -- > 1.8.1.4 > Kind regards Uffe -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] mmc: new API for data write using scatter gather DMA @ 2014-12-02 9:25 ` Avinash Patil 0 siblings, 0 replies; 11+ messages in thread From: Avinash Patil @ 2014-12-02 9:25 UTC (permalink / raw) To: Ulf Hansson Cc: linux-mmc, linux-wireless@vger.kernel.org, Amitkumar Karwar, Cathy Luo, Marc Yang, Xinming Hu, bin9zha0@gmail.com, Bing Zhao Hi Ulf, Purpose of patch is to offload scatter gather list population to host driver. Patch provides MMC API using which host driver can directly use to program SG DMA. Thanks, Avinash ________________________________________ From: Ulf Hansson [ulf.hansson@linaro.org] Sent: Wednesday, November 26, 2014 7:13 PM To: Avinash Patil Cc: linux-mmc; linux-wireless@vger.kernel.org; Amitkumar Karwar; Cathy Luo; Marc Yang; Xinming Hu; bin9zha0@gmail.com; Bing Zhao Subject: Re: [PATCH] mmc: new API for data write using scatter gather DMA On 26 November 2014 at 12:07, Avinash Patil <patila@marvell.com> wrote: > From: Bing Zhao <bzhao@marvell.com> > > This patch adds new API to handle scatter gather aggregation. Why is this needed? > > Signed-off-by: Bing Zhao <bzhao@marvell.com> > Signed-off-by: Avinash Patil <patila@marvell.com> > Signed-off-by: Xinming Hu <huxm@marvell.com> > Signed-off-by: Cathy Luo <cluo@marvell.com> > --- > drivers/mmc/core/sdio_ops.c | 65 +++++++++++++++++++++++++++++++++++++++++++ > include/linux/mmc/sdio_func.h | 5 ++++ > 2 files changed, 70 insertions(+) > > diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c > index 62508b4..4c5e362 100644 > --- a/drivers/mmc/core/sdio_ops.c > +++ b/drivers/mmc/core/sdio_ops.c > @@ -15,6 +15,7 @@ > #include <linux/mmc/card.h> > #include <linux/mmc/mmc.h> > #include <linux/mmc/sdio.h> > +#include <linux/export.h> > > #include "core.h" > #include "sdio_ops.h" > @@ -204,6 +205,70 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, > return 0; > } > > +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, > + unsigned addr, int incr_addr, > + struct sg_table *sgt, unsigned blksz) > +{ > + struct mmc_request mrq = {NULL}; > + struct mmc_command cmd = {0}; > + struct mmc_data data = {0}; > + struct scatterlist *sg_ptr; > + unsigned blocks = 0; > + int i; > + > + BUG_ON(!card || !card->host); > + BUG_ON(fn > 7); > + BUG_ON(!blksz); No BUG_ON() here please. Better to return an error. > + for_each_sg(sgt->sgl, sg_ptr, sgt->nents, i) { > + WARN_ON(sg_ptr->length > card->host->max_seg_size); > + blocks += DIV_ROUND_UP(sg_ptr->length, blksz); > + } > + > + /* sanity check */ > + if (addr & ~0x1FFFF) > + return -EINVAL; > + > + mrq.cmd = &cmd; > + mrq.data = &data; > + > + cmd.opcode = SD_IO_RW_EXTENDED; > + cmd.arg = write ? 0x80000000 : 0x00000000; > + cmd.arg |= fn << 28; > + cmd.arg |= incr_addr ? 0x04000000 : 0x00000000; > + cmd.arg |= addr << 9; > + cmd.arg |= 0x08000000 | blocks; > + cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC; > + > + data.blksz = blksz; > + data.blocks = blocks; > + data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; > + > + data.sg = sgt->sgl; > + data.sg_len = sgt->nents; > + > + mmc_set_data_timeout(&data, card); > + mmc_wait_for_req(card->host, &mrq); > + > + if (cmd.error) > + return cmd.error; > + if (data.error) > + return data.error; > + > + if (mmc_host_is_spi(card->host)) { > + /* host driver already reported errors */ > + } else { > + if (cmd.resp[0] & R5_ERROR) > + return -EIO; > + if (cmd.resp[0] & R5_FUNCTION_NUMBER) > + return -EINVAL; > + if (cmd.resp[0] & R5_OUT_OF_RANGE) > + return -ERANGE; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(mmc_io_rw_extended_sg); > + > int sdio_reset(struct mmc_host *host) > { > int ret; > diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h > index 50f0bc9..927ea8f 100644 > --- a/include/linux/mmc/sdio_func.h > +++ b/include/linux/mmc/sdio_func.h > @@ -14,6 +14,7 @@ > > #include <linux/device.h> > #include <linux/mod_devicetable.h> > +#include <linux/scatterlist.h> > > #include <linux/mmc/pm.h> > > @@ -153,6 +154,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, > extern int sdio_writesb(struct sdio_func *func, unsigned int addr, > void *src, int count); > > +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, > + unsigned addr, int incr_addr, > + struct sg_table *sgt, unsigned blksz); > + > extern unsigned char sdio_f0_readb(struct sdio_func *func, > unsigned int addr, int *err_ret); > extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, > -- > 1.8.1.4 > Kind regards Uffe ^ permalink raw reply [flat|nested] 11+ messages in thread
* RE: [PATCH] mmc: new API for data write using scatter gather DMA 2014-12-02 9:25 ` Avinash Patil (?) @ 2014-12-05 9:24 ` Avinash Patil 2014-12-05 10:16 ` Ulf Hansson -1 siblings, 1 reply; 11+ messages in thread From: Avinash Patil @ 2014-12-05 9:24 UTC (permalink / raw) To: Ulf Hansson Cc: linux-mmc, linux-wireless@vger.kernel.org, Amitkumar Karwar, Cathy Luo, Marc Yang, Xinming Hu, bin9zha0@gmail.com, Bing Zhao Hi Ulf, We have decided to drop this patch. Thanks, Avinash ________________________________________ From: Avinash Patil Sent: Tuesday, December 02, 2014 2:55 PM To: Ulf Hansson Cc: linux-mmc; linux-wireless@vger.kernel.org; Amitkumar Karwar; Cathy Luo; Marc Yang; Xinming Hu; bin9zha0@gmail.com; Bing Zhao Subject: RE: [PATCH] mmc: new API for data write using scatter gather DMA Hi Ulf, Purpose of patch is to offload scatter gather list population to host driver. Patch provides MMC API using which host driver can directly use to program SG DMA. Thanks, Avinash ________________________________________ From: Ulf Hansson [ulf.hansson@linaro.org] Sent: Wednesday, November 26, 2014 7:13 PM To: Avinash Patil Cc: linux-mmc; linux-wireless@vger.kernel.org; Amitkumar Karwar; Cathy Luo; Marc Yang; Xinming Hu; bin9zha0@gmail.com; Bing Zhao Subject: Re: [PATCH] mmc: new API for data write using scatter gather DMA On 26 November 2014 at 12:07, Avinash Patil <patila@marvell.com> wrote: > From: Bing Zhao <bzhao@marvell.com> > > This patch adds new API to handle scatter gather aggregation. Why is this needed? > > Signed-off-by: Bing Zhao <bzhao@marvell.com> > Signed-off-by: Avinash Patil <patila@marvell.com> > Signed-off-by: Xinming Hu <huxm@marvell.com> > Signed-off-by: Cathy Luo <cluo@marvell.com> > --- > drivers/mmc/core/sdio_ops.c | 65 +++++++++++++++++++++++++++++++++++++++++++ > include/linux/mmc/sdio_func.h | 5 ++++ > 2 files changed, 70 insertions(+) > > diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c > index 62508b4..4c5e362 100644 > --- a/drivers/mmc/core/sdio_ops.c > +++ b/drivers/mmc/core/sdio_ops.c > @@ -15,6 +15,7 @@ > #include <linux/mmc/card.h> > #include <linux/mmc/mmc.h> > #include <linux/mmc/sdio.h> > +#include <linux/export.h> > > #include "core.h" > #include "sdio_ops.h" > @@ -204,6 +205,70 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, > return 0; > } > > +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, > + unsigned addr, int incr_addr, > + struct sg_table *sgt, unsigned blksz) > +{ > + struct mmc_request mrq = {NULL}; > + struct mmc_command cmd = {0}; > + struct mmc_data data = {0}; > + struct scatterlist *sg_ptr; > + unsigned blocks = 0; > + int i; > + > + BUG_ON(!card || !card->host); > + BUG_ON(fn > 7); > + BUG_ON(!blksz); No BUG_ON() here please. Better to return an error. > + for_each_sg(sgt->sgl, sg_ptr, sgt->nents, i) { > + WARN_ON(sg_ptr->length > card->host->max_seg_size); > + blocks += DIV_ROUND_UP(sg_ptr->length, blksz); > + } > + > + /* sanity check */ > + if (addr & ~0x1FFFF) > + return -EINVAL; > + > + mrq.cmd = &cmd; > + mrq.data = &data; > + > + cmd.opcode = SD_IO_RW_EXTENDED; > + cmd.arg = write ? 0x80000000 : 0x00000000; > + cmd.arg |= fn << 28; > + cmd.arg |= incr_addr ? 0x04000000 : 0x00000000; > + cmd.arg |= addr << 9; > + cmd.arg |= 0x08000000 | blocks; > + cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC; > + > + data.blksz = blksz; > + data.blocks = blocks; > + data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; > + > + data.sg = sgt->sgl; > + data.sg_len = sgt->nents; > + > + mmc_set_data_timeout(&data, card); > + mmc_wait_for_req(card->host, &mrq); > + > + if (cmd.error) > + return cmd.error; > + if (data.error) > + return data.error; > + > + if (mmc_host_is_spi(card->host)) { > + /* host driver already reported errors */ > + } else { > + if (cmd.resp[0] & R5_ERROR) > + return -EIO; > + if (cmd.resp[0] & R5_FUNCTION_NUMBER) > + return -EINVAL; > + if (cmd.resp[0] & R5_OUT_OF_RANGE) > + return -ERANGE; > + } > + > + return 0; > +} > +EXPORT_SYMBOL_GPL(mmc_io_rw_extended_sg); > + > int sdio_reset(struct mmc_host *host) > { > int ret; > diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h > index 50f0bc9..927ea8f 100644 > --- a/include/linux/mmc/sdio_func.h > +++ b/include/linux/mmc/sdio_func.h > @@ -14,6 +14,7 @@ > > #include <linux/device.h> > #include <linux/mod_devicetable.h> > +#include <linux/scatterlist.h> > > #include <linux/mmc/pm.h> > > @@ -153,6 +154,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, > extern int sdio_writesb(struct sdio_func *func, unsigned int addr, > void *src, int count); > > +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, > + unsigned addr, int incr_addr, > + struct sg_table *sgt, unsigned blksz); > + > extern unsigned char sdio_f0_readb(struct sdio_func *func, > unsigned int addr, int *err_ret); > extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, > -- > 1.8.1.4 > Kind regards Uffe ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH] mmc: new API for data write using scatter gather DMA 2014-12-05 9:24 ` Avinash Patil @ 2014-12-05 10:16 ` Ulf Hansson 0 siblings, 0 replies; 11+ messages in thread From: Ulf Hansson @ 2014-12-05 10:16 UTC (permalink / raw) To: Avinash Patil Cc: linux-mmc, linux-wireless@vger.kernel.org, Amitkumar Karwar, Cathy Luo, Marc Yang, Xinming Hu, bin9zha0@gmail.com, Bing Zhao On 5 December 2014 at 10:24, Avinash Patil <patila@marvell.com> wrote: > Hi Ulf, > > We have decided to drop this patch. Why? Kind regards Uffe > > Thanks, > Avinash > ________________________________________ > From: Avinash Patil > Sent: Tuesday, December 02, 2014 2:55 PM > To: Ulf Hansson > Cc: linux-mmc; linux-wireless@vger.kernel.org; Amitkumar Karwar; Cathy Luo; Marc Yang; Xinming Hu; bin9zha0@gmail.com; Bing Zhao > Subject: RE: [PATCH] mmc: new API for data write using scatter gather DMA > > Hi Ulf, > > Purpose of patch is to offload scatter gather list population to host driver. > Patch provides MMC API using which host driver can directly use to program SG DMA. > > > Thanks, > Avinash > ________________________________________ > From: Ulf Hansson [ulf.hansson@linaro.org] > Sent: Wednesday, November 26, 2014 7:13 PM > To: Avinash Patil > Cc: linux-mmc; linux-wireless@vger.kernel.org; Amitkumar Karwar; Cathy Luo; Marc Yang; Xinming Hu; bin9zha0@gmail.com; Bing Zhao > Subject: Re: [PATCH] mmc: new API for data write using scatter gather DMA > > On 26 November 2014 at 12:07, Avinash Patil <patila@marvell.com> wrote: >> From: Bing Zhao <bzhao@marvell.com> >> >> This patch adds new API to handle scatter gather aggregation. > > Why is this needed? > >> >> Signed-off-by: Bing Zhao <bzhao@marvell.com> >> Signed-off-by: Avinash Patil <patila@marvell.com> >> Signed-off-by: Xinming Hu <huxm@marvell.com> >> Signed-off-by: Cathy Luo <cluo@marvell.com> >> --- >> drivers/mmc/core/sdio_ops.c | 65 +++++++++++++++++++++++++++++++++++++++++++ >> include/linux/mmc/sdio_func.h | 5 ++++ >> 2 files changed, 70 insertions(+) >> >> diff --git a/drivers/mmc/core/sdio_ops.c b/drivers/mmc/core/sdio_ops.c >> index 62508b4..4c5e362 100644 >> --- a/drivers/mmc/core/sdio_ops.c >> +++ b/drivers/mmc/core/sdio_ops.c >> @@ -15,6 +15,7 @@ >> #include <linux/mmc/card.h> >> #include <linux/mmc/mmc.h> >> #include <linux/mmc/sdio.h> >> +#include <linux/export.h> >> >> #include "core.h" >> #include "sdio_ops.h" >> @@ -204,6 +205,70 @@ int mmc_io_rw_extended(struct mmc_card *card, int write, unsigned fn, >> return 0; >> } >> >> +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, >> + unsigned addr, int incr_addr, >> + struct sg_table *sgt, unsigned blksz) >> +{ >> + struct mmc_request mrq = {NULL}; >> + struct mmc_command cmd = {0}; >> + struct mmc_data data = {0}; >> + struct scatterlist *sg_ptr; >> + unsigned blocks = 0; >> + int i; >> + >> + BUG_ON(!card || !card->host); >> + BUG_ON(fn > 7); >> + BUG_ON(!blksz); > > No BUG_ON() here please. Better to return an error. > >> + for_each_sg(sgt->sgl, sg_ptr, sgt->nents, i) { >> + WARN_ON(sg_ptr->length > card->host->max_seg_size); >> + blocks += DIV_ROUND_UP(sg_ptr->length, blksz); >> + } >> + >> + /* sanity check */ >> + if (addr & ~0x1FFFF) >> + return -EINVAL; >> + >> + mrq.cmd = &cmd; >> + mrq.data = &data; >> + >> + cmd.opcode = SD_IO_RW_EXTENDED; >> + cmd.arg = write ? 0x80000000 : 0x00000000; >> + cmd.arg |= fn << 28; >> + cmd.arg |= incr_addr ? 0x04000000 : 0x00000000; >> + cmd.arg |= addr << 9; >> + cmd.arg |= 0x08000000 | blocks; >> + cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC; >> + >> + data.blksz = blksz; >> + data.blocks = blocks; >> + data.flags = write ? MMC_DATA_WRITE : MMC_DATA_READ; >> + >> + data.sg = sgt->sgl; >> + data.sg_len = sgt->nents; >> + >> + mmc_set_data_timeout(&data, card); >> + mmc_wait_for_req(card->host, &mrq); >> + >> + if (cmd.error) >> + return cmd.error; >> + if (data.error) >> + return data.error; >> + >> + if (mmc_host_is_spi(card->host)) { >> + /* host driver already reported errors */ >> + } else { >> + if (cmd.resp[0] & R5_ERROR) >> + return -EIO; >> + if (cmd.resp[0] & R5_FUNCTION_NUMBER) >> + return -EINVAL; >> + if (cmd.resp[0] & R5_OUT_OF_RANGE) >> + return -ERANGE; >> + } >> + >> + return 0; >> +} >> +EXPORT_SYMBOL_GPL(mmc_io_rw_extended_sg); >> + >> int sdio_reset(struct mmc_host *host) >> { >> int ret; >> diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h >> index 50f0bc9..927ea8f 100644 >> --- a/include/linux/mmc/sdio_func.h >> +++ b/include/linux/mmc/sdio_func.h >> @@ -14,6 +14,7 @@ >> >> #include <linux/device.h> >> #include <linux/mod_devicetable.h> >> +#include <linux/scatterlist.h> >> >> #include <linux/mmc/pm.h> >> >> @@ -153,6 +154,10 @@ extern int sdio_memcpy_toio(struct sdio_func *func, unsigned int addr, >> extern int sdio_writesb(struct sdio_func *func, unsigned int addr, >> void *src, int count); >> >> +int mmc_io_rw_extended_sg(struct mmc_card *card, int write, unsigned fn, >> + unsigned addr, int incr_addr, >> + struct sg_table *sgt, unsigned blksz); >> + >> extern unsigned char sdio_f0_readb(struct sdio_func *func, >> unsigned int addr, int *err_ret); >> extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, >> -- >> 1.8.1.4 >> > > Kind regards > Uffe ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-09-22 7:20 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-26 11:07 [PATCH] mmc: new API for data write using scatter gather DMA Avinash Patil
2014-11-26 11:07 ` Avinash Patil
2014-11-26 13:43 ` Ulf Hansson
[not found] ` <CAPDyKFr-iaPWKWWgk-5_XcJm9sag=y=uZjfJvo-DQiJFM8BVLw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-11-26 18:10 ` Arend van Spriel
2014-11-26 18:10 ` Arend van Spriel
[not found] ` <CAEhWJFmxxFyh5oF33NiTQn70RhoP_z-vkRBEdVb-XcMfDDnHfg@mail.gmail.com>
[not found] ` <e5ce420ddc0f4ceca8cac83f5350ded3@SC-EXCH04.marvell.com>
2015-09-22 7:20 ` Amitkumar Karwar
2015-09-22 7:20 ` Amitkumar Karwar
2014-12-02 9:25 ` Avinash Patil
2014-12-02 9:25 ` Avinash Patil
2014-12-05 9:24 ` Avinash Patil
2014-12-05 10:16 ` Ulf Hansson
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.