hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/mmc/core/sdio_irq.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * linux/drivers/mmc/core/sdio_irq.c
34 *
....@@ -6,11 +7,6 @@
67 * Copyright: MontaVista Software Inc.
78 *
89 * Copyright 2008 Pierre Ossman
9
- *
10
- * This program is free software; you can redistribute it and/or modify
11
- * it under the terms of the GNU General Public License as published by
12
- * the Free Software Foundation; either version 2 of the License, or (at
13
- * your option) any later version.
1410 */
1511
1612 #include <linux/kernel.h>
....@@ -30,6 +26,34 @@
3026 #include "sdio_ops.h"
3127 #include "core.h"
3228 #include "card.h"
29
+
30
+static int sdio_get_pending_irqs(struct mmc_host *host, u8 *pending)
31
+{
32
+ struct mmc_card *card = host->card;
33
+ int ret;
34
+
35
+ WARN_ON(!host->claimed);
36
+
37
+ ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, pending);
38
+ if (ret) {
39
+ pr_debug("%s: error %d reading SDIO_CCCR_INTx\n",
40
+ mmc_card_id(card), ret);
41
+ return ret;
42
+ }
43
+
44
+ if (*pending && mmc_card_broken_irq_polling(card) &&
45
+ !(host->caps & MMC_CAP_SDIO_IRQ)) {
46
+ unsigned char dummy;
47
+
48
+ /* A fake interrupt could be created when we poll SDIO_CCCR_INTx
49
+ * register with a Marvell SD8797 card. A dummy CMD52 read to
50
+ * function 0 register 0xff can avoid this.
51
+ */
52
+ mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy);
53
+ }
54
+
55
+ return 0;
56
+}
3357
3458 static int process_sdio_pending_irqs(struct mmc_host *host)
3559 {
....@@ -57,23 +81,9 @@
5781 return 1;
5882 }
5983
60
- ret = mmc_io_rw_direct(card, 0, 0, SDIO_CCCR_INTx, 0, &pending);
61
- if (ret) {
62
- pr_debug("%s: error %d reading SDIO_CCCR_INTx\n",
63
- mmc_card_id(card), ret);
84
+ ret = sdio_get_pending_irqs(host, &pending);
85
+ if (ret)
6486 return ret;
65
- }
66
-
67
- if (pending && mmc_card_broken_irq_polling(card) &&
68
- !(host->caps & MMC_CAP_SDIO_IRQ)) {
69
- unsigned char dummy;
70
-
71
- /* A fake interrupt could be created when we poll SDIO_CCCR_INTx
72
- * register with a Marvell SD8797 card. A dummy CMD52 read to
73
- * function 0 register 0xff can avoid this.
74
- */
75
- mmc_io_rw_direct(card, 0, 0, 0xff, 0, &dummy);
76
- }
7787
7888 count = 0;
7989 for (i = 1; i <= 7; i++) {
....@@ -100,17 +110,16 @@
100110 return ret;
101111 }
102112
103
-void sdio_run_irqs(struct mmc_host *host)
113
+static void sdio_run_irqs(struct mmc_host *host)
104114 {
105115 mmc_claim_host(host);
106116 if (host->sdio_irqs) {
107117 process_sdio_pending_irqs(host);
108
- if (host->ops->ack_sdio_irq)
118
+ if (!host->sdio_irq_pending)
109119 host->ops->ack_sdio_irq(host);
110120 }
111121 mmc_release_host(host);
112122 }
113
-EXPORT_SYMBOL_GPL(sdio_run_irqs);
114123
115124 void sdio_irq_work(struct work_struct *work)
116125 {
....@@ -130,11 +139,10 @@
130139 static int sdio_irq_thread(void *_host)
131140 {
132141 struct mmc_host *host = _host;
133
- struct sched_param param = { .sched_priority = 1 };
134142 unsigned long period, idle_period;
135143 int ret;
136144
137
- sched_setscheduler(current, SCHED_FIFO, &param);
145
+ sched_set_fifo_low(current);
138146
139147 /*
140148 * We want to allow for SDIO cards to work even on non SDIO
....@@ -267,14 +275,15 @@
267275
268276 card->sdio_single_irq = NULL;
269277 if ((card->host->caps & MMC_CAP_SDIO_IRQ) &&
270
- card->host->sdio_irqs == 1)
278
+ card->host->sdio_irqs == 1) {
271279 for (i = 0; i < card->sdio_funcs; i++) {
272
- func = card->sdio_func[i];
273
- if (func && func->irq_handler) {
274
- card->sdio_single_irq = func;
275
- break;
276
- }
277
- }
280
+ func = card->sdio_func[i];
281
+ if (func && func->irq_handler) {
282
+ card->sdio_single_irq = func;
283
+ break;
284
+ }
285
+ }
286
+ }
278287 }
279288
280289 /**