Skip to contentSkip to conversation

mmc: limit the number of retries when analyse tuples failed

PATCH Superseded Fengnan Chang 2 participants 2 messages Jan 12, 2021 – Jan 19, 2021 MMC, SD and SDIO

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mmc: limit the number of retries when analyse tuples failed

when analyse tuples failed, may enter an endless loop,so limit the number of retries.

---
 drivers/mmc/core/sdio_cis.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mmc/core/sdio_cis.c +4 -0
index dcb3dee59fa5..a3f0c3cc0c2c 100644
@@ -266,6 +266,7 @@ static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)
 
 	do {
 		unsigned char tpl_code, tpl_link;
+		int  tries = 100;
 
 		ret = mmc_io_rw_direct(card, 0, 0, ptr++, 0, &tpl_code);
 		if (ret)
@@ -318,6 +319,9 @@ static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)
 			prev = &this->next;
 
 			if (ret == -ENOENT) {
+				tries--;
+				if (!tries)
+					break;
 				/* warn about unknown tuples */
 				pr_warn_ratelimited("%s: queuing unknown"
 				       " CIS tuple 0x%02x (%u bytes)\n",
Signature · 1 line
2.25.1
#1 lore raw
Quoted 13 lines · Fengnan Chang

when analyse tuples failed, may enter an endless loop,so limit the number of retries.

---
 drivers/mmc/core/sdio_cis.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/mmc/core/sdio_cis.c +0 -0
index dcb3dee59fa5..a3f0c3cc0c2c 100644

drivers/mmc/core/sdio_cis.c static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func) · line 270

Quoted 5 lines
drivers/mmc/core/sdio_cis.c +1 -0
@@ -266,6 +266,7 @@ static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)
 
        do {
                unsigned char tpl_code, tpl_link;
+               int  tries = 100;
 

From a general point of view I agree, we should set a limit to avoid looping forever. Although, I am wondering why exactly is 100 a good value for retries?

Did you encounter this problem and tried to limit the loop to 100 to fix the problem - or is the fix done based on pure code analysis?

An option to limit the loop with retries is to bail out when a timer elapses. Perhaps that is better suited for this case or what do you think?

Quoted 13 lines
drivers/mmc/core/sdio_cis.c +3 -1
                ret = mmc_io_rw_direct(card, 0, 0, ptr++, 0, &tpl_code);
                if (ret)
@@ -318,6 +319,9 @@ static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)
                        prev = &this->next;
 
                        if (ret == -ENOENT) {
+                               tries--;
+                               if (!tries)
+                                       break;
                                /* warn about unknown tuples */
                                pr_warn_ratelimited("%s: queuing unknown"
                                       " CIS tuple 0x%02x (%u bytes)\n",
--
Quoted 2 lines

2.25.1

Kind regards
Uffe