Skip to content

Commit 36d57ef

Browse files
author
Ulf Hansson
committed
mmc: core: Clarify sdio_irq_pending flag for MMC_CAP2_SDIO_IRQ_NOTHREAD
The sdio_irq_pending flag is used to let host drivers indicate that it has signaled an IRQ. If that is the case and we only have a single SDIO func that have claimed an SDIO IRQ, our assumption is that we can avoid reading the SDIO_CCCR_INTx register and just call the SDIO func irq handler immediately. This makes sense, but the flag is set/cleared in a somewhat messy order, let's fix that up according to below. First, the flag is currently set in sdio_run_irqs(), which is executed as a work that was scheduled from sdio_signal_irq(). To make it more implicit that the host have signaled an IRQ, let's instead immediately set the flag in sdio_signal_irq(). This also makes the behavior consistent with host drivers that uses the legacy, mmc_signal_sdio_irq() API. This have no functional impact, because we don't expect host drivers to call sdio_signal_irq() until after the work (sdio_run_irqs()) have been executed anyways. Second, currently we never clears the flag when using the sdio_run_irqs() work, but only when using the sdio_irq_thread(). Let make the behavior consistent, by moving the flag to be cleared inside the common process_sdio_pending_irqs() function. Additionally, tweak the behavior of the flag slightly, by avoiding to clear it unless we processed the SDIO IRQ. The purpose with this at this point, is to keep the information about whether there have been an SDIO IRQ signaled by the host, so at system resume we can decide to process it without reading the SDIO_CCCR_INTx register. Tested-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent a29b5fc commit 36d57ef

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎drivers/mmc/core/sdio_irq.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,20 +59,24 @@ static int process_sdio_pending_irqs(struct mmc_host *host)
5959
{
6060
struct mmc_card *card = host->card;
6161
int i, ret, count;
62+
bool sdio_irq_pending = host->sdio_irq_pending;
6263
unsigned char pending;
6364
struct sdio_func *func;
6465

6566
/* Don't process SDIO IRQs if the card is suspended. */
6667
if (mmc_card_suspended(card))
6768
return 0;
6869

70+
/* Clear the flag to indicate that we have processed the IRQ. */
71+
host->sdio_irq_pending = false;
72+
6973
/*
7074
* Optimization, if there is only 1 function interrupt registered
7175
* and we know an IRQ was signaled then call irq handler directly.
7276
* Otherwise do the full probe.
7377
*/
7478
func = card->sdio_single_irq;
75-
if (func && host->sdio_irq_pending) {
79+
if (func && sdio_irq_pending) {
7680
func->irq_handler(func);
7781
return 1;
7882
}
@@ -110,7 +114,6 @@ static void sdio_run_irqs(struct mmc_host *host)
110114
{
111115
mmc_claim_host(host);
112116
if (host->sdio_irqs) {
113-
host->sdio_irq_pending = true;
114117
process_sdio_pending_irqs(host);
115118
if (host->ops->ack_sdio_irq)
116119
host->ops->ack_sdio_irq(host);
@@ -128,6 +131,7 @@ void sdio_irq_work(struct work_struct *work)
128131

129132
void sdio_signal_irq(struct mmc_host *host)
130133
{
134+
host->sdio_irq_pending = true;
131135
queue_delayed_work(system_wq, &host->sdio_irq_work, 0);
132136
}
133137
EXPORT_SYMBOL_GPL(sdio_signal_irq);
@@ -173,7 +177,6 @@ static int sdio_irq_thread(void *_host)
173177
if (ret)
174178
break;
175179
ret = process_sdio_pending_irqs(host);
176-
host->sdio_irq_pending = false;
177180
mmc_release_host(host);
178181

179182
/*

0 commit comments

Comments
 (0)