linux-mmc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "S, Venkatraman" <svenkatr@ti.com>
To: Per Forlin <per.forlin@linaro.org>
Cc: linux-mmc <linux-mmc@vger.kernel.org>,
	linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	linaro-dev <linaro-dev@lists.linaro.org>,
	David Vrabel <david.vrabel@csr.com>
Subject: Re: [PATCH v4 03/12] omap_hsmmc: add support for pre_req and post_req
Date: Thu, 16 Jun 2011 18:44:47 +0530	[thread overview]
Message-ID: <BANLkTikP8pveKPPG+_h6_hBenh91vAi4mQ@mail.gmail.com> (raw)
In-Reply-To: <1306360653-6196-4-git-send-email-per.forlin@linaro.org>

On Thu, May 26, 2011 at 3:27 AM, Per Forlin <per.forlin@linaro.org> wrote:
> pre_req() runs dma_map_sg(), post_req() runs dma_unmap_sg.
> If not calling pre_req() before omap_hsmmc_request()
> dma_map_sg will be issued before starting the transfer.
> It is optional to use pre_req(). If issuing pre_req()
> post_req() must be to be called as well.
>
> Signed-off-by: Per Forlin <per.forlin@linaro.org>
> ---
>  drivers/mmc/host/omap_hsmmc.c |   87 +++++++++++++++++++++++++++++++++++++++--
>  1 files changed, 83 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c
> index ad3731a..2116c09 100644
> --- a/drivers/mmc/host/omap_hsmmc.c
> +++ b/drivers/mmc/host/omap_hsmmc.c
> @@ -141,6 +141,11 @@
>  #define OMAP_HSMMC_WRITE(base, reg, val) \
>        __raw_writel((val), (base) + OMAP_HSMMC_##reg)
>
> +struct omap_hsmmc_next {
> +       unsigned int    dma_len;
> +       s32             cookie;
> +};
> +
>  struct omap_hsmmc_host {
>        struct  device          *dev;
>        struct  mmc_host        *mmc;
> @@ -184,6 +189,7 @@ struct omap_hsmmc_host {
>        int                     reqs_blocked;
>        int                     use_reg;
>        int                     req_in_progress;
> +       struct omap_hsmmc_next  next_data;
>
>        struct  omap_mmc_platform_data  *pdata;
>  };
> @@ -1344,8 +1350,9 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data)
>                return;
>        }
>
> -       dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
> -               omap_hsmmc_get_dma_dir(host, data));
> +       if (!data->host_cookie)
> +               dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len,
> +                            omap_hsmmc_get_dma_dir(host, data));
>
>        req_in_progress = host->req_in_progress;
>        dma_ch = host->dma_ch;
> @@ -1363,6 +1370,45 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data)
>        }
>  }
>
> +static int omap_hsmmc_pre_dma_transfer(struct omap_hsmmc_host *host,
> +                                      struct mmc_data *data,
> +                                      struct omap_hsmmc_next *next)
> +{

As you are passing &host->next_data into next, next will always be a
valid pointer. So..

> +       int dma_len;
> +
> +       if (!next && data->host_cookie &&
> +           data->host_cookie != host->next_data.cookie) {

!next will always return false and hence the rest of the check will
never be executed.
Perhaps s/&&/||/g ?


> +               printk(KERN_WARNING "[%s] invalid cookie: data->host_cookie %d"
> +                      " host->next_data.cookie %d\n",
> +                      __func__, data->host_cookie, host->next_data.cookie);
> +               data->host_cookie = 0;
> +       }
> +
> +       /* Check if next job is already prepared */
> +       if (next ||
> +           (!next && data->host_cookie != host->next_data.cookie)) {

Cookie matching will never be checked..

> +               dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg,
> +                                    data->sg_len,
> +                                    omap_hsmmc_get_dma_dir(host, data));
> +
> +       } else {

and this will never be executed as well?

> +               dma_len = host->next_data.dma_len;
> +               host->next_data.dma_len = 0;
> +       }
> +
> +
> +       if (dma_len == 0)
> +               return -EINVAL;
> +
> +       if (next) {
> +               next->dma_len = dma_len;
> +               data->host_cookie = ++next->cookie < 0 ? 1 : next->cookie;
> +       } else
> +               host->dma_len = dma_len;
> +
> +       return 0;
> +}
> +

  reply	other threads:[~2011-06-16 13:14 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-25 21:57 [PATCH v4 00/12] mmc: use nonblock mmc requests to minimize latency Per Forlin
     [not found] ` <1306360653-6196-1-git-send-email-per.forlin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2011-05-25 21:57   ` [PATCH v4 01/12] mmc: add none blocking mmc request function Per Forlin
2011-05-25 21:57   ` [PATCH v4 02/12] omap_hsmmc: use original sg_len for dma_unmap_sg Per Forlin
2011-06-16 13:16     ` S, Venkatraman
2011-06-17 10:58       ` Per Forlin
2011-05-25 21:57   ` [PATCH v4 03/12] omap_hsmmc: add support for pre_req and post_req Per Forlin
2011-06-16 13:14     ` S, Venkatraman [this message]
2011-06-17 10:15       ` Per Forlin
2011-05-25 21:57   ` [PATCH v4 05/12] mmc: mmc_test: add debugfs file to list all tests Per Forlin
2011-05-25 21:57   ` [PATCH v4 06/12] mmc: mmc_test: add test for none blocking transfers Per Forlin
2011-05-25 21:57   ` [PATCH v4 07/12] mmc: add member in mmc queue struct to hold request data Per Forlin
2011-05-25 21:57   ` [PATCH v4 08/12] mmc: add a block request prepare function Per Forlin
2011-05-25 21:57   ` [PATCH v4 09/12] mmc: move error code in mmc_block_issue_rw_rq to a separate function Per Forlin
2011-05-25 21:57   ` [PATCH v4 10/12] mmc: add a second mmc queue request member Per Forlin
2011-05-25 21:57   ` [PATCH v4 11/12] mmc: test: add random fault injection in core.c Per Forlin
2011-05-25 21:57   ` [PATCH v4 12/12] mmc: add handling for two parallel block requests in issue_rw_rq Per Forlin
2011-05-25 21:57 ` [PATCH v4 04/12] mmci: implement pre_req() and post_req() Per Forlin
2011-06-16 13:39 ` [PATCH v4 00/12] mmc: use nonblock mmc requests to minimize latency S, Venkatraman
2011-06-17 11:02   ` Per Forlin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BANLkTikP8pveKPPG+_h6_hBenh91vAi4mQ@mail.gmail.com \
    --to=svenkatr@ti.com \
    --cc=david.vrabel@csr.com \
    --cc=linaro-dev@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=per.forlin@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).