diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2012-01-06 07:06:51 -0500 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-02-13 20:39:03 -0500 |
commit | e3de2be7368d2983bd7f7ddb6e9cf5ea32363128 (patch) | |
tree | 810c6a3d5fe404ebbe98f98561b1b9b49ac6e4fb /drivers/mmc | |
parent | dd13b4ed4650bb3a7d6c86b549ab66a6aa0c00d8 (diff) |
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>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/tmio_mmc.h | 7 | ||||
-rw-r--r-- | drivers/mmc/host/tmio_mmc_dma.c | 12 | ||||
-rw-r--r-- | 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 a95e6d901726..f96c536d130a 100644 --- a/drivers/mmc/host/tmio_mmc.h +++ b/drivers/mmc/host/tmio_mmc.h | |||
@@ -20,8 +20,8 @@ | |||
20 | #include <linux/mmc/tmio.h> | 20 | #include <linux/mmc/tmio.h> |
21 | #include <linux/mutex.h> | 21 | #include <linux/mutex.h> |
22 | #include <linux/pagemap.h> | 22 | #include <linux/pagemap.h> |
23 | #include <linux/spinlock.h> | ||
24 | #include <linux/scatterlist.h> | 23 | #include <linux/scatterlist.h> |
24 | #include <linux/spinlock.h> | ||
25 | 25 | ||
26 | /* Definitions for values the CTRL_SDIO_STATUS register can take. */ | 26 | /* Definitions for values the CTRL_SDIO_STATUS register can take. */ |
27 | #define TMIO_SDIO_STAT_IOIRQ 0x0001 | 27 | #define TMIO_SDIO_STAT_IOIRQ 0x0001 |
@@ -120,6 +120,7 @@ void tmio_mmc_start_dma(struct tmio_mmc_host *host, struct mmc_data *data); | |||
120 | void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable); | 120 | void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable); |
121 | void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata); | 121 | void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata); |
122 | void tmio_mmc_release_dma(struct tmio_mmc_host *host); | 122 | void tmio_mmc_release_dma(struct tmio_mmc_host *host); |
123 | void tmio_mmc_abort_dma(struct tmio_mmc_host *host); | ||
123 | #else | 124 | #else |
124 | static inline void tmio_mmc_start_dma(struct tmio_mmc_host *host, | 125 | static inline void tmio_mmc_start_dma(struct tmio_mmc_host *host, |
125 | struct mmc_data *data) | 126 | struct mmc_data *data) |
@@ -140,6 +141,10 @@ static inline void tmio_mmc_request_dma(struct tmio_mmc_host *host, | |||
140 | static inline void tmio_mmc_release_dma(struct tmio_mmc_host *host) | 141 | static inline void tmio_mmc_release_dma(struct tmio_mmc_host *host) |
141 | { | 142 | { |
142 | } | 143 | } |
144 | |||
145 | static inline void tmio_mmc_abort_dma(struct tmio_mmc_host *host) | ||
146 | { | ||
147 | } | ||
143 | #endif | 148 | #endif |
144 | 149 | ||
145 | #ifdef CONFIG_PM | 150 | #ifdef CONFIG_PM |
diff --git a/drivers/mmc/host/tmio_mmc_dma.c b/drivers/mmc/host/tmio_mmc_dma.c index 7a6e6cc8f8b8..8253ec12003e 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) | |||
34 | #endif | 34 | #endif |
35 | } | 35 | } |
36 | 36 | ||
37 | void tmio_mmc_abort_dma(struct tmio_mmc_host *host) | ||
38 | { | ||
39 | tmio_mmc_enable_dma(host, false); | ||
40 | |||
41 | if (host->chan_rx) | ||
42 | dmaengine_terminate_all(host->chan_rx); | ||
43 | if (host->chan_tx) | ||
44 | dmaengine_terminate_all(host->chan_tx); | ||
45 | |||
46 | tmio_mmc_enable_dma(host, true); | ||
47 | } | ||
48 | |||
37 | static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host) | 49 | static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host) |
38 | { | 50 | { |
39 | struct scatterlist *sg = host->sg_ptr, *sg_tmp; | 51 | 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 abad01b37cfb..5f9ad74fbf80 100644 --- a/drivers/mmc/host/tmio_mmc_pio.c +++ b/drivers/mmc/host/tmio_mmc_pio.c | |||
@@ -41,8 +41,8 @@ | |||
41 | #include <linux/platform_device.h> | 41 | #include <linux/platform_device.h> |
42 | #include <linux/pm_runtime.h> | 42 | #include <linux/pm_runtime.h> |
43 | #include <linux/scatterlist.h> | 43 | #include <linux/scatterlist.h> |
44 | #include <linux/workqueue.h> | ||
45 | #include <linux/spinlock.h> | 44 | #include <linux/spinlock.h> |
45 | #include <linux/workqueue.h> | ||
46 | 46 | ||
47 | #include "tmio_mmc.h" | 47 | #include "tmio_mmc.h" |
48 | 48 | ||
@@ -246,6 +246,7 @@ static void tmio_mmc_reset_work(struct work_struct *work) | |||
246 | /* Ready for new calls */ | 246 | /* Ready for new calls */ |
247 | host->mrq = NULL; | 247 | host->mrq = NULL; |
248 | 248 | ||
249 | tmio_mmc_abort_dma(host); | ||
249 | mmc_request_done(host->mmc, mrq); | 250 | mmc_request_done(host->mmc, mrq); |
250 | } | 251 | } |
251 | 252 | ||
@@ -272,6 +273,9 @@ static void tmio_mmc_finish_request(struct tmio_mmc_host *host) | |||
272 | host->mrq = NULL; | 273 | host->mrq = NULL; |
273 | spin_unlock_irqrestore(&host->lock, flags); | 274 | spin_unlock_irqrestore(&host->lock, flags); |
274 | 275 | ||
276 | if (mrq->cmd->error || (mrq->data && mrq->data->error)) | ||
277 | tmio_mmc_abort_dma(host); | ||
278 | |||
275 | mmc_request_done(host->mmc, mrq); | 279 | mmc_request_done(host->mmc, mrq); |
276 | } | 280 | } |
277 | 281 | ||