diff options
author | Marc Pignat <marc.pignat@hevs.ch> | 2008-05-30 08:06:32 -0400 |
---|---|---|
committer | Pierre Ossman <drzeus@drzeus.cx> | 2008-07-15 08:14:41 -0400 |
commit | e181dce8acab4f7d7c4772d2a8281510d503ab21 (patch) | |
tree | f82d2d577e916802c484345dd6d1a559ea29bd9b | |
parent | 80f9254668c63ae73c1359d8de50ad94aa1aa94a (diff) |
mmc: at91_mci: show timeouts
Detect command timeout (or mci controller hangs).
Signed-off-by: Marc Pignat <marc.pignat@hevs.ch>
Signed-off-by: Hans J Koch <hjk@linutronix.de>
Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
-rw-r--r-- | drivers/mmc/host/at91_mci.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/drivers/mmc/host/at91_mci.c b/drivers/mmc/host/at91_mci.c index e40340f32e35..fce171c7c67e 100644 --- a/drivers/mmc/host/at91_mci.c +++ b/drivers/mmc/host/at91_mci.c | |||
@@ -125,8 +125,33 @@ struct at91mci_host | |||
125 | 125 | ||
126 | /* Latest in the scatterlist that has been enabled for transfer */ | 126 | /* Latest in the scatterlist that has been enabled for transfer */ |
127 | int transfer_index; | 127 | int transfer_index; |
128 | |||
129 | /* Timer for timeouts */ | ||
130 | struct timer_list timer; | ||
128 | }; | 131 | }; |
129 | 132 | ||
133 | static void at91_timeout_timer(unsigned long data) | ||
134 | { | ||
135 | struct at91mci_host *host; | ||
136 | |||
137 | host = (struct at91mci_host *)data; | ||
138 | |||
139 | if (host->request) { | ||
140 | dev_err(host->mmc->parent, "Timeout waiting end of packet\n"); | ||
141 | |||
142 | if (host->cmd && host->cmd->data) { | ||
143 | host->cmd->data->error = -ETIMEDOUT; | ||
144 | } else { | ||
145 | if (host->cmd) | ||
146 | host->cmd->error = -ETIMEDOUT; | ||
147 | else | ||
148 | host->request->cmd->error = -ETIMEDOUT; | ||
149 | } | ||
150 | |||
151 | mmc_request_done(host->mmc, host->request); | ||
152 | } | ||
153 | } | ||
154 | |||
130 | /* | 155 | /* |
131 | * Copy from sg to a dma block - used for transfers | 156 | * Copy from sg to a dma block - used for transfers |
132 | */ | 157 | */ |
@@ -557,9 +582,10 @@ static void at91_mci_process_next(struct at91mci_host *host) | |||
557 | else if ((!(host->flags & FL_SENT_STOP)) && host->request->stop) { | 582 | else if ((!(host->flags & FL_SENT_STOP)) && host->request->stop) { |
558 | host->flags |= FL_SENT_STOP; | 583 | host->flags |= FL_SENT_STOP; |
559 | at91_mci_send_command(host, host->request->stop); | 584 | at91_mci_send_command(host, host->request->stop); |
560 | } | 585 | } else { |
561 | else | 586 | del_timer(&host->timer); |
562 | mmc_request_done(host->mmc, host->request); | 587 | mmc_request_done(host->mmc, host->request); |
588 | } | ||
563 | } | 589 | } |
564 | 590 | ||
565 | /* | 591 | /* |
@@ -618,6 +644,8 @@ static void at91_mci_request(struct mmc_host *mmc, struct mmc_request *mrq) | |||
618 | host->request = mrq; | 644 | host->request = mrq; |
619 | host->flags = 0; | 645 | host->flags = 0; |
620 | 646 | ||
647 | mod_timer(&host->timer, jiffies + HZ); | ||
648 | |||
621 | at91_mci_process_next(host); | 649 | at91_mci_process_next(host); |
622 | } | 650 | } |
623 | 651 | ||
@@ -936,6 +964,8 @@ static int __init at91_mci_probe(struct platform_device *pdev) | |||
936 | 964 | ||
937 | mmc_add_host(mmc); | 965 | mmc_add_host(mmc); |
938 | 966 | ||
967 | setup_timer(&host->timer, at91_timeout_timer, (unsigned long)host); | ||
968 | |||
939 | /* | 969 | /* |
940 | * monitor card insertion/removal if we can | 970 | * monitor card insertion/removal if we can |
941 | */ | 971 | */ |
@@ -996,6 +1026,7 @@ static int __exit at91_mci_remove(struct platform_device *pdev) | |||
996 | } | 1026 | } |
997 | 1027 | ||
998 | at91_mci_disable(host); | 1028 | at91_mci_disable(host); |
1029 | del_timer_sync(&host->timer); | ||
999 | mmc_remove_host(mmc); | 1030 | mmc_remove_host(mmc); |
1000 | free_irq(host->irq, host); | 1031 | free_irq(host->irq, host); |
1001 | 1032 | ||