| From 471b39df4319e8f35fe4ab3d91c859c391385bdd Mon Sep 17 00:00:00 2001 |
| From: Guennadi Liakhovetski <g.liakhovetski@gmx.de> |
| Date: Fri, 6 Jan 2012 13:06:51 +0100 |
| Subject: mmc: tmio_mmc: fix card eject during IO with DMA |
| |
| When DMA is in use and the card is ejected during IO, DMA transfers have to |
| be terminated, otherwise the dmaengine driver fails to operate properly, |
| when the card is re-inserted. |
| |
| Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> |
| Signed-off-by: Chris Ball <cjb@laptop.org> |
| (cherry picked from commit e3de2be7368d2983bd7f7ddb6e9cf5ea32363128) |
| |
| Signed-off-by: Simon Horman <horms@verge.net.au> |
| --- |
| drivers/mmc/host/tmio_mmc.h | 7 ++++++- |
| drivers/mmc/host/tmio_mmc_dma.c | 12 ++++++++++++ |
| drivers/mmc/host/tmio_mmc_pio.c | 6 +++++- |
| 3 files changed, 23 insertions(+), 2 deletions(-) |
| |
| diff --git a/drivers/mmc/host/tmio_mmc.h b/drivers/mmc/host/tmio_mmc.h |
| index a95e6d9..f96c536 100644 |
| --- a/drivers/mmc/host/tmio_mmc.h |
| +++ b/drivers/mmc/host/tmio_mmc.h |
| @@ -20,8 +20,8 @@ |
| #include <linux/mmc/tmio.h> |
| #include <linux/mutex.h> |
| #include <linux/pagemap.h> |
| -#include <linux/spinlock.h> |
| #include <linux/scatterlist.h> |
| +#include <linux/spinlock.h> |
| |
| /* Definitions for values the CTRL_SDIO_STATUS register can take. */ |
| #define TMIO_SDIO_STAT_IOIRQ 0x0001 |
| @@ -120,6 +120,7 @@ void tmio_mmc_start_dma(struct tmio_mmc_host *host, struct mmc_data *data); |
| void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable); |
| void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata); |
| void tmio_mmc_release_dma(struct tmio_mmc_host *host); |
| +void tmio_mmc_abort_dma(struct tmio_mmc_host *host); |
| #else |
| static inline void tmio_mmc_start_dma(struct tmio_mmc_host *host, |
| struct mmc_data *data) |
| @@ -140,6 +141,10 @@ static inline void tmio_mmc_request_dma(struct tmio_mmc_host *host, |
| static inline void tmio_mmc_release_dma(struct tmio_mmc_host *host) |
| { |
| } |
| + |
| +static inline void tmio_mmc_abort_dma(struct tmio_mmc_host *host) |
| +{ |
| +} |
| #endif |
| |
| #ifdef CONFIG_PM |
| diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c |
| index 7a6e6cc..8253ec1 100644 |
| --- a/drivers/mmc/host/tmio_mmc_dma.c |
| +++ b/drivers/mmc/host/tmio_mmc_dma.c |
| @@ -34,6 +34,18 @@ void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable) |
| #endif |
| } |
| |
| +void tmio_mmc_abort_dma(struct tmio_mmc_host *host) |
| +{ |
| + tmio_mmc_enable_dma(host, false); |
| + |
| + if (host->chan_rx) |
| + dmaengine_terminate_all(host->chan_rx); |
| + if (host->chan_tx) |
| + dmaengine_terminate_all(host->chan_tx); |
| + |
| + tmio_mmc_enable_dma(host, true); |
| +} |
| + |
| static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host) |
| { |
| struct scatterlist *sg = host->sg_ptr, *sg_tmp; |
| diff --git a/drivers/mmc/host/tmio_mmc_pio.c b/drivers/mmc/host/tmio_mmc_pio.c |
| index abad01b..5f9ad74 100644 |
| --- a/drivers/mmc/host/tmio_mmc_pio.c |
| +++ b/drivers/mmc/host/tmio_mmc_pio.c |
| @@ -41,8 +41,8 @@ |
| #include <linux/platform_device.h> |
| #include <linux/pm_runtime.h> |
| #include <linux/scatterlist.h> |
| -#include <linux/workqueue.h> |
| #include <linux/spinlock.h> |
| +#include <linux/workqueue.h> |
| |
| #include "tmio_mmc.h" |
| |
| @@ -246,6 +246,7 @@ static void tmio_mmc_reset_work(struct work_struct *work) |
| /* Ready for new calls */ |
| host->mrq = NULL; |
| |
| + tmio_mmc_abort_dma(host); |
| mmc_request_done(host->mmc, mrq); |
| } |
| |
| @@ -272,6 +273,9 @@ static void tmio_mmc_finish_request(struct tmio_mmc_host *host) |
| host->mrq = NULL; |
| spin_unlock_irqrestore(&host->lock, flags); |
| |
| + if (mrq->cmd->error || (mrq->data && mrq->data->error)) |
| + tmio_mmc_abort_dma(host); |
| + |
| mmc_request_done(host->mmc, mrq); |
| } |
| |
| -- |
| 1.7.10.2.565.gbd578b5 |
| |