From: Per Forlin <per.forlin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> To: linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org, Nicolas Pitre <nicolas.pitre-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>, linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org, Venkatraman S <svenkatr-l0cyMroinI0@public.gmane.org> Subject: [PATCH v6 02/11] omap_hsmmc: add support for pre_req and post_req Date: Sun, 19 Jun 2011 23:17:28 +0200 [thread overview] Message-ID: <1308518257-9783-3-git-send-email-per.forlin@linaro.org> (raw) In-Reply-To: <1308518257-9783-1-git-send-email-per.forlin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 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-QSEj5FYQhm4dnm+yROfE0A@public.gmane.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 cd317af..b29ca90 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; }; @@ -1343,8 +1349,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; @@ -1362,6 +1369,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) +{ + int dma_len; + + if (!next && data->host_cookie && + data->host_cookie != host->next_data.cookie) { + 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)) { + dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, + data->sg_len, + omap_hsmmc_get_dma_dir(host, data)); + + } else { + 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; +} + /* * Routine to configure and start DMA for the MMC card */ @@ -1395,9 +1441,10 @@ static int omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host, mmc_hostname(host->mmc), ret); return ret; } + ret = omap_hsmmc_pre_dma_transfer(host, data, NULL); + if (ret) + return ret; - host->dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, - data->sg_len, omap_hsmmc_get_dma_dir(host, data)); host->dma_ch = dma_ch; host->dma_sg_idx = 0; @@ -1477,6 +1524,35 @@ omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req) return 0; } +static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, + int err) +{ + struct omap_hsmmc_host *host = mmc_priv(mmc); + struct mmc_data *data = mrq->data; + + if (host->use_dma) { + dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, + omap_hsmmc_get_dma_dir(host, data)); + data->host_cookie = 0; + } +} + +static void omap_hsmmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq, + bool is_first_req) +{ + struct omap_hsmmc_host *host = mmc_priv(mmc); + + if (mrq->data->host_cookie) { + mrq->data->host_cookie = 0; + return ; + } + + if (host->use_dma) + if (omap_hsmmc_pre_dma_transfer(host, mrq->data, + &host->next_data)) + mrq->data->host_cookie = 0; +} + /* * Request function. for read/write operation */ @@ -1925,6 +2001,8 @@ static int omap_hsmmc_disable_fclk(struct mmc_host *mmc, int lazy) static const struct mmc_host_ops omap_hsmmc_ops = { .enable = omap_hsmmc_enable_fclk, .disable = omap_hsmmc_disable_fclk, + .post_req = omap_hsmmc_post_req, + .pre_req = omap_hsmmc_pre_req, .request = omap_hsmmc_request, .set_ios = omap_hsmmc_set_ios, .get_cd = omap_hsmmc_get_cd, @@ -2074,6 +2152,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) host->mapbase = res->start; host->base = ioremap(host->mapbase, SZ_4K); host->power_mode = MMC_POWER_OFF; + host->next_data.cookie = 1; platform_set_drvdata(pdev, host); INIT_WORK(&host->mmc_carddetect_work, omap_hsmmc_detect); -- 1.7.4.1
WARNING: multiple messages have this Message-ID (diff)
From: per.forlin@linaro.org (Per Forlin) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v6 02/11] omap_hsmmc: add support for pre_req and post_req Date: Sun, 19 Jun 2011 23:17:28 +0200 [thread overview] Message-ID: <1308518257-9783-3-git-send-email-per.forlin@linaro.org> (raw) In-Reply-To: <1308518257-9783-1-git-send-email-per.forlin@linaro.org> 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 cd317af..b29ca90 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; }; @@ -1343,8 +1349,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; @@ -1362,6 +1369,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) +{ + int dma_len; + + if (!next && data->host_cookie && + data->host_cookie != host->next_data.cookie) { + 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)) { + dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, + data->sg_len, + omap_hsmmc_get_dma_dir(host, data)); + + } else { + 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; +} + /* * Routine to configure and start DMA for the MMC card */ @@ -1395,9 +1441,10 @@ static int omap_hsmmc_start_dma_transfer(struct omap_hsmmc_host *host, mmc_hostname(host->mmc), ret); return ret; } + ret = omap_hsmmc_pre_dma_transfer(host, data, NULL); + if (ret) + return ret; - host->dma_len = dma_map_sg(mmc_dev(host->mmc), data->sg, - data->sg_len, omap_hsmmc_get_dma_dir(host, data)); host->dma_ch = dma_ch; host->dma_sg_idx = 0; @@ -1477,6 +1524,35 @@ omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req) return 0; } +static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, + int err) +{ + struct omap_hsmmc_host *host = mmc_priv(mmc); + struct mmc_data *data = mrq->data; + + if (host->use_dma) { + dma_unmap_sg(mmc_dev(host->mmc), data->sg, data->sg_len, + omap_hsmmc_get_dma_dir(host, data)); + data->host_cookie = 0; + } +} + +static void omap_hsmmc_pre_req(struct mmc_host *mmc, struct mmc_request *mrq, + bool is_first_req) +{ + struct omap_hsmmc_host *host = mmc_priv(mmc); + + if (mrq->data->host_cookie) { + mrq->data->host_cookie = 0; + return ; + } + + if (host->use_dma) + if (omap_hsmmc_pre_dma_transfer(host, mrq->data, + &host->next_data)) + mrq->data->host_cookie = 0; +} + /* * Request function. for read/write operation */ @@ -1925,6 +2001,8 @@ static int omap_hsmmc_disable_fclk(struct mmc_host *mmc, int lazy) static const struct mmc_host_ops omap_hsmmc_ops = { .enable = omap_hsmmc_enable_fclk, .disable = omap_hsmmc_disable_fclk, + .post_req = omap_hsmmc_post_req, + .pre_req = omap_hsmmc_pre_req, .request = omap_hsmmc_request, .set_ios = omap_hsmmc_set_ios, .get_cd = omap_hsmmc_get_cd, @@ -2074,6 +2152,7 @@ static int __init omap_hsmmc_probe(struct platform_device *pdev) host->mapbase = res->start; host->base = ioremap(host->mapbase, SZ_4K); host->power_mode = MMC_POWER_OFF; + host->next_data.cookie = 1; platform_set_drvdata(pdev, host); INIT_WORK(&host->mmc_carddetect_work, omap_hsmmc_detect); -- 1.7.4.1
next prev parent reply other threads:[~2011-06-19 21:17 UTC|newest] Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top 2011-06-19 21:17 [PATCH v6 00/11] mmc: use nonblock mmc requests to minimize latency Per Forlin 2011-06-19 21:17 ` Per Forlin [not found] ` <1308518257-9783-1-git-send-email-per.forlin-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org> 2011-06-19 21:17 ` [PATCH v6 01/11] mmc: add non-blocking mmc request function Per Forlin 2011-06-19 21:17 ` Per Forlin 2011-06-19 21:17 ` Per Forlin [this message] 2011-06-19 21:17 ` [PATCH v6 02/11] omap_hsmmc: add support for pre_req and post_req Per Forlin 2011-06-21 5:41 ` Kishore Kadiyala 2011-06-21 5:41 ` Kishore Kadiyala 2011-06-21 6:51 ` Per Forlin 2011-06-21 6:51 ` Per Forlin 2011-06-21 13:56 ` Kishore Kadiyala 2011-06-21 13:56 ` Kishore Kadiyala 2011-06-21 19:18 ` Nicolas Pitre 2011-06-21 19:18 ` Nicolas Pitre 2011-06-21 20:18 ` Per Forlin 2011-06-21 20:18 ` Per Forlin 2011-06-21 20:29 ` Nicolas Pitre 2011-06-21 20:29 ` Nicolas Pitre 2011-06-19 21:17 ` [PATCH v6 03/11] mmci: implement pre_req() and post_req() Per Forlin 2011-06-19 21:17 ` Per Forlin 2011-06-19 21:17 ` [PATCH v6 04/11] mmc: mmc_test: add debugfs file to list all tests Per Forlin 2011-06-19 21:17 ` Per Forlin 2011-06-19 21:17 ` [PATCH v6 05/11] mmc: mmc_test: add test for non-blocking transfers Per Forlin 2011-06-19 21:17 ` Per Forlin 2011-06-19 21:17 ` [PATCH v6 06/11] mmc: add member in mmc queue struct to hold request data Per Forlin 2011-06-19 21:17 ` Per Forlin 2011-06-19 21:17 ` [PATCH v6 07/11] mmc: add a block request prepare function Per Forlin 2011-06-19 21:17 ` Per Forlin 2011-06-19 21:17 ` [PATCH v6 08/11] mmc: move error code in mmc_block_issue_rw_rq to a separate function Per Forlin 2011-06-19 21:17 ` Per Forlin 2011-06-19 21:17 ` [PATCH v6 09/11] mmc: add a second mmc queue request member Per Forlin 2011-06-19 21:17 ` Per Forlin 2011-06-19 21:17 ` [PATCH v6 10/11] mmc: test: add random fault injection in core.c Per Forlin 2011-06-19 21:17 ` Per Forlin 2011-06-19 21:17 ` [PATCH v6 11/11] mmc: add handling for two parallel block requests in issue_rw_rq Per Forlin 2011-06-19 21:17 ` Per Forlin 2011-06-20 15:17 ` Kishore Kadiyala 2011-06-20 15:17 ` Kishore Kadiyala 2011-06-21 6:40 ` Per Forlin 2011-06-21 6:40 ` Per Forlin 2011-06-21 7:05 ` Per Forlin 2011-06-21 7:05 ` Per Forlin 2011-06-21 13:52 ` Kishore Kadiyala 2011-06-21 13:52 ` Kishore Kadiyala 2011-06-21 21:01 ` Per Forlin 2011-06-21 21:01 ` Per Forlin 2011-06-21 7:14 ` Per Forlin 2011-06-21 7:14 ` Per Forlin 2011-06-21 7:53 ` [PATCH v6 00/11] mmc: use nonblock mmc requests to minimize latency Russell King - ARM Linux 2011-06-21 7:53 ` Russell King - ARM Linux 2011-06-21 8:09 ` Per Forlin 2011-06-21 8:09 ` Per Forlin 2011-06-21 9:26 ` Per Forlin 2011-06-21 9:26 ` Per Forlin 2011-06-23 13:37 ` Russell King - ARM Linux 2011-06-23 13:37 ` Russell King - ARM Linux 2011-06-24 8:58 ` Per Forlin 2011-06-24 8:58 ` Per Forlin 2011-06-27 9:42 ` Per Forlin 2011-06-27 9:42 ` Per Forlin 2011-06-27 10:02 ` Russell King - ARM Linux 2011-06-27 10:02 ` Russell King - ARM Linux [not found] ` <20110627100212.GA16103-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org> 2011-06-27 10:21 ` Per Forlin 2011-06-27 10:21 ` Per Forlin 2011-06-27 15:29 ` Linus Walleij 2011-06-27 15:29 ` Linus Walleij 2011-06-27 16:34 ` Vijaya Kumar K-1 2011-06-27 16:34 ` Vijaya Kumar K-1 [not found] ` <20110621075319.GN26089-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org> 2011-06-27 10:34 ` saeed bishara 2011-06-27 10:34 ` saeed bishara [not found] ` <BANLkTimnuEK_9RedmD1OgcunX3rPvd-O0Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2011-06-27 11:02 ` Russell King - ARM Linux 2011-06-27 11:02 ` Russell King - ARM Linux [not found] ` <20110627110234.GC16103-l+eeeJia6m9vn6HldHNs0ANdhmdF6hFW@public.gmane.org> 2011-06-28 6:22 ` saeed bishara 2011-06-28 6:22 ` saeed bishara 2011-07-03 14:47 ` Russell King - ARM Linux 2011-07-03 14:47 ` Russell King - ARM Linux
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=1308518257-9783-3-git-send-email-per.forlin@linaro.org \ --to=per.forlin-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \ --cc=linaro-dev-cunTk1MwBs8s++Sfvej+rw@public.gmane.org \ --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \ --cc=linux-mmc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \ --cc=nicolas.pitre-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \ --cc=svenkatr-l0cyMroinI0@public.gmane.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.