diff options
author | Pierre Ossman <drzeus@drzeus.cx> | 2007-08-12 10:46:32 -0400 |
---|---|---|
committer | Pierre Ossman <drzeus@drzeus.cx> | 2007-08-23 00:30:53 -0400 |
commit | e538fbe83e374a3521128c1f4642aca037661c9d (patch) | |
tree | 9a2abd920ed6767ae17747daa2e91fa9f1e5fd24 /drivers/mmc/host/sdhci.c | |
parent | 03f8590d90844f04d20488a80e75eaf4c4e0b35c (diff) |
sdhci: handle data interrupts during command
It is fully legal for a controller to start issuing data related
interrupts before it has signalled that the command has completed.
Make sure the driver actually can handle this.
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc/host/sdhci.c')
-rw-r--r-- | drivers/mmc/host/sdhci.c | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 2b327b40fa81..f8fc0a98b8c4 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c | |||
@@ -385,6 +385,9 @@ static void sdhci_prepare_data(struct sdhci_host *host, struct mmc_data *data) | |||
385 | BUG_ON(data->blksz > host->mmc->max_blk_size); | 385 | BUG_ON(data->blksz > host->mmc->max_blk_size); |
386 | BUG_ON(data->blocks > 65535); | 386 | BUG_ON(data->blocks > 65535); |
387 | 387 | ||
388 | host->data = data; | ||
389 | host->data_early = 0; | ||
390 | |||
388 | /* timeout in us */ | 391 | /* timeout in us */ |
389 | target_timeout = data->timeout_ns / 1000 + | 392 | target_timeout = data->timeout_ns / 1000 + |
390 | data->timeout_clks / host->clock; | 393 | data->timeout_clks / host->clock; |
@@ -443,11 +446,11 @@ static void sdhci_set_transfer_mode(struct sdhci_host *host, | |||
443 | { | 446 | { |
444 | u16 mode; | 447 | u16 mode; |
445 | 448 | ||
446 | WARN_ON(host->data); | ||
447 | |||
448 | if (data == NULL) | 449 | if (data == NULL) |
449 | return; | 450 | return; |
450 | 451 | ||
452 | WARN_ON(!host->data); | ||
453 | |||
451 | mode = SDHCI_TRNS_BLK_CNT_EN; | 454 | mode = SDHCI_TRNS_BLK_CNT_EN; |
452 | if (data->blocks > 1) | 455 | if (data->blocks > 1) |
453 | mode |= SDHCI_TRNS_MULTI; | 456 | mode |= SDHCI_TRNS_MULTI; |
@@ -600,9 +603,10 @@ static void sdhci_finish_command(struct sdhci_host *host) | |||
600 | 603 | ||
601 | host->cmd->error = MMC_ERR_NONE; | 604 | host->cmd->error = MMC_ERR_NONE; |
602 | 605 | ||
603 | if (host->cmd->data) | 606 | if (host->data && host->data_early) |
604 | host->data = host->cmd->data; | 607 | sdhci_finish_data(host); |
605 | else | 608 | |
609 | if (!host->cmd->data) | ||
606 | tasklet_schedule(&host->finish_tasklet); | 610 | tasklet_schedule(&host->finish_tasklet); |
607 | 611 | ||
608 | host->cmd = NULL; | 612 | host->cmd = NULL; |
@@ -991,8 +995,18 @@ static void sdhci_data_irq(struct sdhci_host *host, u32 intmask) | |||
991 | writel(readl(host->ioaddr + SDHCI_DMA_ADDRESS), | 995 | writel(readl(host->ioaddr + SDHCI_DMA_ADDRESS), |
992 | host->ioaddr + SDHCI_DMA_ADDRESS); | 996 | host->ioaddr + SDHCI_DMA_ADDRESS); |
993 | 997 | ||
994 | if (intmask & SDHCI_INT_DATA_END) | 998 | if (intmask & SDHCI_INT_DATA_END) { |
995 | sdhci_finish_data(host); | 999 | if (host->cmd) { |
1000 | /* | ||
1001 | * Data managed to finish before the | ||
1002 | * command completed. Make sure we do | ||
1003 | * things in the proper order. | ||
1004 | */ | ||
1005 | host->data_early = 1; | ||
1006 | } else { | ||
1007 | sdhci_finish_data(host); | ||
1008 | } | ||
1009 | } | ||
996 | } | 1010 | } |
997 | } | 1011 | } |
998 | 1012 | ||