Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 65648
b: refs/heads/master
c: 6f4285d
h: refs/heads/master
v: v3
  • Loading branch information
Pierre Ossman committed Sep 27, 2007
1 parent 8952f13 commit 0cb3a76
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 5d3ad4e8a12e538eead0a37d22b1ba6aec0f2127
refs/heads/master: 6f4285d13300f1c8cd675a41ab390cea06173cd1
28 changes: 23 additions & 5 deletions trunk/drivers/mmc/core/sdio_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

static int process_sdio_pending_irqs(struct mmc_card *card)
{
int i, ret;
int i, ret, count;
unsigned char pending;

ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending);
Expand All @@ -37,6 +37,7 @@ static int process_sdio_pending_irqs(struct mmc_card *card)
return ret;
}

count = 0;
for (i = 1; i <= 7; i++) {
if (pending & (1 << i)) {
struct sdio_func *func = card->sdio_func[i - 1];
Expand All @@ -46,20 +47,21 @@ static int process_sdio_pending_irqs(struct mmc_card *card)
sdio_func_id(func));
} else if (func->irq_handler) {
func->irq_handler(func);
count++;
} else
printk(KERN_WARNING "%s: pending IRQ with no handler\n",
sdio_func_id(func));
}
}

return 0;
return count;
}

static int sdio_irq_thread(void *_host)
{
struct mmc_host *host = _host;
struct sched_param param = { .sched_priority = 1 };
unsigned long period;
unsigned long period, idle_period;
int ret;

sched_setscheduler(current, SCHED_FIFO, &param);
Expand All @@ -70,8 +72,9 @@ static int sdio_irq_thread(void *_host)
* asynchronous notification of pending SDIO card interrupts
* hence we poll for them in that case.
*/
idle_period = msecs_to_jiffies(10);
period = (host->caps & MMC_CAP_SDIO_IRQ) ?
MAX_SCHEDULE_TIMEOUT : msecs_to_jiffies(10);
MAX_SCHEDULE_TIMEOUT : idle_period;

pr_debug("%s: IRQ thread started (poll period = %lu jiffies)\n",
mmc_hostname(host), period);
Expand Down Expand Up @@ -101,9 +104,24 @@ static int sdio_irq_thread(void *_host)
* errors. FIXME: determine if due to card removal and
* possibly exit this thread if so.
*/
if (ret)
if (ret < 0)
ssleep(1);

/*
* Adaptive polling frequency based on the assumption
* that an interrupt will be closely followed by more.
* This has a substantial benefit for network devices.
*/
if (!(host->caps & MMC_CAP_SDIO_IRQ)) {
if (ret > 0)
period /= 2;
else {
period++;
if (period > idle_period)
period = idle_period;
}
}

set_task_state(current, TASK_INTERRUPTIBLE);
if (host->caps & MMC_CAP_SDIO_IRQ)
host->ops->enable_sdio_irq(host, 1);
Expand Down

0 comments on commit 0cb3a76

Please sign in to comment.