Return-path: Received: from mail-qg0-f52.google.com ([209.85.192.52]:38316 "EHLO mail-qg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751544AbaLEKQJ (ORCPT ); Fri, 5 Dec 2014 05:16:09 -0500 Received: by mail-qg0-f52.google.com with SMTP id a108so211501qge.11 for ; Fri, 05 Dec 2014 02:16:08 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <1417000056-16920-1-git-send-email-patila@marvell.com> Date: Fri, 5 Dec 2014 11:16:08 +0100 Message-ID: (sfid-20141205_111614_871642_1A8CFC41) Subject: Re: [PATCH] mmc: new API for data write using scatter gather DMA From: Ulf Hansson To: Avinash Patil Cc: linux-mmc , "linux-wireless@vger.kernel.org" , Amitkumar Karwar , Cathy Luo , Marc Yang , Xinming Hu , "bin9zha0@gmail.com" , Bing Zhao Content-Type: text/plain; charset=UTF-8 Sender: linux-wireless-owner@vger.kernel.org List-ID: On 5 December 2014 at 10:24, Avinash Patil 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 wrote: >> From: Bing Zhao >> >> This patch adds new API to handle scatter gather aggregation. > > Why is this needed? > >> >> Signed-off-by: Bing Zhao >> Signed-off-by: Avinash Patil >> Signed-off-by: Xinming Hu >> Signed-off-by: Cathy Luo >> --- >> 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 >> #include >> #include >> +#include >> >> #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 >> #include >> +#include >> >> #include >> >> @@ -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