Re: [PATCH 1/2] omap: hsmmc: Normalize dma cleanup operations
On Tue, Sep 13, 2011 at 1:26 AM, Per Forlin per.for...@linaro.org wrote: On 1 September 2011 21:05, Venkatraman S svenk...@ti.com wrote: Reuse omap_hsmmc_dma_cleanup even for normal dma teardown in omap_hsmmc_dma_cb. Consolidate multiple points of dma unmap into a single location in post_req function, to prevent double unmapping. It's optional to use pre_req() and post_req(). The SDIO framework doesn't utilise these hooks. For instance this wont work together with SDIO-wlan on the pandaboard. If pre_req() has been issued it's fine to defer dma_unmap() until post_req(). If pre_req() is not called the driver should call dma_unmap() directly. In that case, can the actual 'request' function just call pre_req and post_req (at the beginning and at the end), if host_cookie is not set ? -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] omap: hsmmc: Normalize dma cleanup operations
On 14 September 2011 15:40, S, Venkatraman svenk...@ti.com wrote: On Tue, Sep 13, 2011 at 1:26 AM, Per Forlin per.for...@linaro.org wrote: On 1 September 2011 21:05, Venkatraman S svenk...@ti.com wrote: Reuse omap_hsmmc_dma_cleanup even for normal dma teardown in omap_hsmmc_dma_cb. Consolidate multiple points of dma unmap into a single location in post_req function, to prevent double unmapping. It's optional to use pre_req() and post_req(). The SDIO framework doesn't utilise these hooks. For instance this wont work together with SDIO-wlan on the pandaboard. If pre_req() has been issued it's fine to defer dma_unmap() until post_req(). If pre_req() is not called the driver should call dma_unmap() directly. In that case, can the actual 'request' function just call pre_req and post_req (at the beginning and at the end), if host_cookie is not set ? Which request() function do your refer to? The mmc_host_ops.request() returns before the transfer is finished. Apart from that, I would say yes. It's nice to have the same code path for valid cookie and invalid cookie scenario. Note that the host_cookie could be set but with an invalid value. host driver: 1. validate cookie 2. if invalid cookie call pre_req() 3. run request 4. done - if (has called pre_req() #2) - call post_req(). A general fix would be to put this logic in mmc_wait_for_req() in core.c, but at this level it's not possible to validate the cookie. In the current implementation the host driver controls the cookie value. /Per -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] omap: hsmmc: Normalize dma cleanup operations
On Tue, Sep 13, 2011 at 1:26 AM, Per Forlin per.for...@linaro.org wrote: On 1 September 2011 21:05, Venkatraman S svenk...@ti.com wrote: Reuse omap_hsmmc_dma_cleanup even for normal dma teardown in omap_hsmmc_dma_cb. Consolidate multiple points of dma unmap into a single location in post_req function, to prevent double unmapping. It's optional to use pre_req() and post_req(). The SDIO framework doesn't utilise these hooks. For instance this wont work together with SDIO-wlan on the pandaboard. If pre_req() has been issued it's fine to defer dma_unmap() until post_req(). If pre_req() is not called the driver should call dma_unmap() directly. Thanks for the clarification. I'll redo the fix. -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] omap: hsmmc: Normalize dma cleanup operations
On 1 September 2011 21:05, Venkatraman S svenk...@ti.com wrote: Reuse omap_hsmmc_dma_cleanup even for normal dma teardown in omap_hsmmc_dma_cb. Consolidate multiple points of dma unmap into a single location in post_req function, to prevent double unmapping. It's optional to use pre_req() and post_req(). The SDIO framework doesn't utilise these hooks. For instance this wont work together with SDIO-wlan on the pandaboard. If pre_req() has been issued it's fine to defer dma_unmap() until post_req(). If pre_req() is not called the driver should call dma_unmap() directly. Regards, Per -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/2] omap: hsmmc: Normalize dma cleanup operations
On Fri, Sep 2, 2011 at 12:35 AM, Venkatraman S svenk...@ti.com wrote: Reuse omap_hsmmc_dma_cleanup even for normal dma teardown in omap_hsmmc_dma_cb. Consolidate multiple points of dma unmap into a single location in post_req function, to prevent double unmapping. Signed-off-by: Venkatraman S svenk...@ti.com --- drivers/mmc/host/omap_hsmmc.c | 20 +--- 1 files changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 21e4a79..5b7776c 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -999,7 +999,8 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) { int dma_ch; - host-data-error = errno; + if (host-data) The condition check above becomes redundant since dma_cleanup is called during errors in omap_hsmmc_do_irq. Better have this check in the dma_cb where dma_cleanup is newly added. + host-data-error = errno; spin_lock(host-irq_lock); dma_ch = host-dma_ch; @@ -1007,12 +1008,8 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) spin_unlock(host-irq_lock); if (host-use_dma dma_ch != -1) { - dma_unmap_sg(mmc_dev(host-mmc), host-data-sg, - host-data-sg_len, - omap_hsmmc_get_dma_dir(host, host-data)); omap_free_dma(dma_ch); } - host-data = NULL; No need to remove the above one. } /* @@ -1370,7 +1367,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) { struct omap_hsmmc_host *host = cb_data; struct mmc_data *data; - int dma_ch, req_in_progress; + int req_in_progress; if (!(ch_status OMAP_DMA_BLOCK_IRQ)) { dev_warn(mmc_dev(host-mmc), unexpected dma status %x\n, @@ -1394,16 +1391,9 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) return; } - 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; - host-dma_ch = -1; spin_unlock(host-irq_lock); - - omap_free_dma(dma_ch); + omap_hsmmc_dma_cleanup(host, 0); /* If DMA has finished after TC, complete the request */ if (!req_in_progress) { @@ -1575,7 +1565,7 @@ static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, struct omap_hsmmc_host *host = mmc_priv(mmc); struct mmc_data *data = mrq-data; - if (host-use_dma) { Here also , the above conditional check is required. + if (data-host_cookie) { dma_unmap_sg(mmc_dev(host-mmc), data-sg, data-sg_len, omap_hsmmc_get_dma_dir(host, data)); data-host_cookie = 0; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/2] omap: hsmmc: Normalize dma cleanup operations
Reuse omap_hsmmc_dma_cleanup even for normal dma teardown in omap_hsmmc_dma_cb. Consolidate multiple points of dma unmap into a single location in post_req function, to prevent double unmapping. Signed-off-by: Venkatraman S svenk...@ti.com --- drivers/mmc/host/omap_hsmmc.c | 20 +--- 1 files changed, 5 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/host/omap_hsmmc.c b/drivers/mmc/host/omap_hsmmc.c index 21e4a79..5b7776c 100644 --- a/drivers/mmc/host/omap_hsmmc.c +++ b/drivers/mmc/host/omap_hsmmc.c @@ -999,7 +999,8 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) { int dma_ch; - host-data-error = errno; + if (host-data) + host-data-error = errno; spin_lock(host-irq_lock); dma_ch = host-dma_ch; @@ -1007,12 +1008,8 @@ static void omap_hsmmc_dma_cleanup(struct omap_hsmmc_host *host, int errno) spin_unlock(host-irq_lock); if (host-use_dma dma_ch != -1) { - dma_unmap_sg(mmc_dev(host-mmc), host-data-sg, - host-data-sg_len, - omap_hsmmc_get_dma_dir(host, host-data)); omap_free_dma(dma_ch); } - host-data = NULL; } /* @@ -1370,7 +1367,7 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) { struct omap_hsmmc_host *host = cb_data; struct mmc_data *data; - int dma_ch, req_in_progress; + int req_in_progress; if (!(ch_status OMAP_DMA_BLOCK_IRQ)) { dev_warn(mmc_dev(host-mmc), unexpected dma status %x\n, @@ -1394,16 +1391,9 @@ static void omap_hsmmc_dma_cb(int lch, u16 ch_status, void *cb_data) return; } - 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; - host-dma_ch = -1; spin_unlock(host-irq_lock); - - omap_free_dma(dma_ch); + omap_hsmmc_dma_cleanup(host, 0); /* If DMA has finished after TC, complete the request */ if (!req_in_progress) { @@ -1575,7 +1565,7 @@ static void omap_hsmmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, struct omap_hsmmc_host *host = mmc_priv(mmc); struct mmc_data *data = mrq-data; - if (host-use_dma) { + if (data-host_cookie) { dma_unmap_sg(mmc_dev(host-mmc), data-sg, data-sg_len, omap_hsmmc_get_dma_dir(host, data)); data-host_cookie = 0; -- 1.7.1 -- To unsubscribe from this list: send the line unsubscribe linux-mmc in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html