Skip to content

Commit 54680fe

Browse files
hormscjb
authored andcommitted
mmc: tmio: Cache interrupt masks
This avoids the need to look up the masks each time an interrupt is handled. As suggested by Guennadi. Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Acked-by: Magnus Damm <magnus.damm@gmail.com> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Chris Ball <cjb@laptop.org>
1 parent ad5fd97 commit 54680fe

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

drivers/mmc/host/tmio_mmc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ struct tmio_mmc_host {
7979
struct delayed_work delayed_reset_work;
8080
struct work_struct done;
8181

82+
/* Cache IRQ mask */
83+
u32 sdcard_irq_mask;
84+
u32 sdio_irq_mask;
85+
8286
spinlock_t lock; /* protect host private data */
8387
unsigned long last_req_ts;
8488
struct mutex ios_lock; /* protect set_ios() context */

drivers/mmc/host/tmio_mmc_pio.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@
4848

4949
void tmio_mmc_enable_mmc_irqs(struct tmio_mmc_host *host, u32 i)
5050
{
51-
u32 mask = sd_ctrl_read32(host, CTL_IRQ_MASK) & ~(i & TMIO_MASK_IRQ);
52-
sd_ctrl_write32(host, CTL_IRQ_MASK, mask);
51+
host->sdcard_irq_mask &= ~(i & TMIO_MASK_IRQ);
52+
sd_ctrl_write32(host, CTL_IRQ_MASK, host->sdcard_irq_mask);
5353
}
5454

5555
void tmio_mmc_disable_mmc_irqs(struct tmio_mmc_host *host, u32 i)
5656
{
57-
u32 mask = sd_ctrl_read32(host, CTL_IRQ_MASK) | (i & TMIO_MASK_IRQ);
58-
sd_ctrl_write32(host, CTL_IRQ_MASK, mask);
57+
host->sdcard_irq_mask |= (i & TMIO_MASK_IRQ);
58+
sd_ctrl_write32(host, CTL_IRQ_MASK, host->sdcard_irq_mask);
5959
}
6060

6161
static void tmio_mmc_ack_mmc_irqs(struct tmio_mmc_host *host, u32 i)
@@ -127,11 +127,13 @@ static void tmio_mmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
127127

128128
if (enable) {
129129
host->sdio_irq_enabled = 1;
130+
host->sdio_irq_mask = TMIO_SDIO_MASK_ALL &
131+
~TMIO_SDIO_STAT_IOIRQ;
130132
sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0001);
131-
sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK,
132-
(TMIO_SDIO_MASK_ALL & ~TMIO_SDIO_STAT_IOIRQ));
133+
sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
133134
} else {
134-
sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, TMIO_SDIO_MASK_ALL);
135+
host->sdio_irq_mask = TMIO_SDIO_MASK_ALL;
136+
sd_ctrl_write16(host, CTL_SDIO_IRQ_MASK, host->sdio_irq_mask);
135137
sd_ctrl_write16(host, CTL_TRANSACTION_CTL, 0x0000);
136138
host->sdio_irq_enabled = 0;
137139
}
@@ -548,26 +550,25 @@ irqreturn_t tmio_mmc_irq(int irq, void *devid)
548550
struct tmio_mmc_host *host = devid;
549551
struct mmc_host *mmc = host->mmc;
550552
struct tmio_mmc_data *pdata = host->pdata;
551-
unsigned int ireg, irq_mask, status;
552-
unsigned int sdio_ireg, sdio_irq_mask, sdio_status;
553+
unsigned int ireg, status;
554+
unsigned int sdio_ireg, sdio_status;
553555

554556
pr_debug("MMC IRQ begin\n");
555557

556558
status = sd_ctrl_read32(host, CTL_STATUS);
557-
irq_mask = sd_ctrl_read32(host, CTL_IRQ_MASK);
558-
ireg = status & TMIO_MASK_IRQ & ~irq_mask;
559+
ireg = status & TMIO_MASK_IRQ & ~host->sdcard_irq_mask;
559560

560561
sdio_ireg = 0;
561562
if (!ireg && pdata->flags & TMIO_MMC_SDIO_IRQ) {
562563
sdio_status = sd_ctrl_read16(host, CTL_SDIO_STATUS);
563-
sdio_irq_mask = sd_ctrl_read16(host, CTL_SDIO_IRQ_MASK);
564-
sdio_ireg = sdio_status & TMIO_SDIO_MASK_ALL & ~sdio_irq_mask;
564+
sdio_ireg = sdio_status & TMIO_SDIO_MASK_ALL &
565+
~host->sdio_irq_mask;
565566

566567
sd_ctrl_write16(host, CTL_SDIO_STATUS, sdio_status & ~TMIO_SDIO_MASK_ALL);
567568

568569
if (sdio_ireg && !host->sdio_irq_enabled) {
569570
pr_warning("tmio_mmc: Spurious SDIO IRQ, disabling! 0x%04x 0x%04x 0x%04x\n",
570-
sdio_status, sdio_irq_mask, sdio_ireg);
571+
sdio_status, host->sdio_irq_mask, sdio_ireg);
571572
tmio_mmc_enable_sdio_irq(mmc, 0);
572573
goto out;
573574
}
@@ -623,9 +624,9 @@ irqreturn_t tmio_mmc_irq(int irq, void *devid)
623624
}
624625

625626
pr_warning("tmio_mmc: Spurious irq, disabling! "
626-
"0x%08x 0x%08x 0x%08x\n", status, irq_mask, ireg);
627+
"0x%08x 0x%08x 0x%08x\n", status, host->sdcard_irq_mask, ireg);
627628
pr_debug_status(status);
628-
tmio_mmc_disable_mmc_irqs(host, status & ~irq_mask);
629+
tmio_mmc_disable_mmc_irqs(host, status & ~host->sdcard_irq_mask);
629630

630631
out:
631632
return IRQ_HANDLED;
@@ -882,6 +883,7 @@ int __devinit tmio_mmc_host_probe(struct tmio_mmc_host **host,
882883
tmio_mmc_clk_stop(_host);
883884
tmio_mmc_reset(_host);
884885

886+
_host->sdcard_irq_mask = sd_ctrl_read32(_host, CTL_IRQ_MASK);
885887
tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL);
886888
if (pdata->flags & TMIO_MMC_SDIO_IRQ)
887889
tmio_mmc_enable_sdio_irq(mmc, 0);

0 commit comments

Comments
 (0)