2d79b9de0503ceb32d9689ec042ffef9874789d8
[openwrt.git] / target / linux / avr32 / patches / 120-fast_sd_cards_fix.patch
1 --- a/drivers/mmc/host/atmel-mci.c
2 +++ b/drivers/mmc/host/atmel-mci.c
3 @@ -77,6 +77,7 @@ struct atmel_mci {
4         struct clk              *mck;
5         struct platform_device  *pdev;
6  
7 +       int pending_stop;
8  #ifdef CONFIG_DEBUG_FS
9         struct dentry           *debugfs_root;
10         struct dentry           *debugfs_regs;
11 @@ -866,6 +867,12 @@ static void atmci_tasklet_func(unsigned long priv)
12                 data->bytes_xfered = data->blocks * data->blksz;
13                 atmci_data_complete(host, data);
14         }
15 +       /* See if there is a pending STOP which can be sent */
16 +       if (host->pending_stop && mci_cmd_is_complete(host)) {
17 +               host->pending_stop = 0;
18 +               if (mrq->stop && !mci_set_stop_sent_is_completed(host))
19 +                       send_stop_cmd(host->mmc, mrq->data, 0);
20 +       }
21  }
22  
23  static void atmci_cmd_interrupt(struct mmc_host *mmc, u32 status)
24 @@ -918,9 +925,16 @@ static void atmci_xfer_complete(struct dma_request *_req)
25          * drivers) or when interrupts are disabled for a long time.
26          */
27         mci_set_dma_complete(host);
28 -       if (data->stop && mci_cmd_is_complete(host)
29 -                       && !mci_set_stop_sent_is_completed(host))
30 -               send_stop_cmd(host->mmc, data, 0);
31 +
32 +       if (data->stop) {
33 +               if (!mci_cmd_is_complete(host)) {
34 +                       /* Just remember a STOP must be sent */
35 +                       host->pending_stop = 1;
36 +               } else if (!mci_set_stop_sent_is_completed(host)) {
37 +                       send_stop_cmd(host->mmc, data, 0);
38 +                       host->pending_stop = 0;
39 +               }
40 +       }
41  
42         /*
43          * Regardless of what the documentation says, we have to wait