diff mbox series

[v3] mmc: limit the number of retries when analyse tuples failed

Message ID 20210123033230.36442-1-fengnanchang@gmail.com
State New
Headers show
Series [v3] mmc: limit the number of retries when analyse tuples failed | expand

Commit Message

fengnan chang Jan. 23, 2021, 3:32 a.m. UTC
when analyse tuples failed, may enter an endless loop,so limit the time of retries.

Signed-off-by: Fengnan Chang <fengnanchang@gmail.com>
---
 drivers/mmc/core/sdio_cis.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Ulf Hansson Jan. 26, 2021, 9:57 a.m. UTC | #1
On Sat, 23 Jan 2021 at 04:32, Fengnan Chang <fengnanchang@gmail.com> wrote:
>

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

>

> Signed-off-by: Fengnan Chang <fengnanchang@gmail.com>


Applied for fixes and by adding a stable tag, thanks!

Kind regards
Uffe


> ---

>  drivers/mmc/core/sdio_cis.c | 6 ++++++

>  1 file changed, 6 insertions(+)

>

> diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c

> index dcb3dee59fa5..b8d8b6df9961 100644

> --- a/drivers/mmc/core/sdio_cis.c

> +++ b/drivers/mmc/core/sdio_cis.c

> @@ -24,6 +24,8 @@

>  #include "sdio_cis.h"

>  #include "sdio_ops.h"

>

> +#define SDIO_READ_CIS_TIMEOUT_MS  (10 * 1000) /* 10s */

> +

>  static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func,

>                          const unsigned char *buf, unsigned size)

>  {

> @@ -266,6 +268,8 @@ static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)

>

>         do {

>                 unsigned char tpl_code, tpl_link;

> +               unsigned long timeout = jiffies +

> +                       msecs_to_jiffies(SDIO_READ_CIS_TIMEOUT_MS);

>

>                 ret = mmc_io_rw_direct(card, 0, 0, ptr++, 0, &tpl_code);

>                 if (ret)

> @@ -318,6 +322,8 @@ static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)

>                         prev = &this->next;

>

>                         if (ret == -ENOENT) {

> +                               if (time_after(jiffies, timeout))

> +                                       break;

>                                 /* warn about unknown tuples */

>                                 pr_warn_ratelimited("%s: queuing unknown"

>                                        " CIS tuple 0x%02x (%u bytes)\n",

> --

> 2.25.1

>
diff mbox series

Patch

diff --git a/drivers/mmc/core/sdio_cis.c b/drivers/mmc/core/sdio_cis.c
index dcb3dee59fa5..b8d8b6df9961 100644
--- a/drivers/mmc/core/sdio_cis.c
+++ b/drivers/mmc/core/sdio_cis.c
@@ -24,6 +24,8 @@ 
 #include "sdio_cis.h"
 #include "sdio_ops.h"

+#define SDIO_READ_CIS_TIMEOUT_MS  (10 * 1000) /* 10s */
+
 static int cistpl_vers_1(struct mmc_card *card, struct sdio_func *func,
 			 const unsigned char *buf, unsigned size)
 {
@@ -266,6 +268,8 @@  static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)

 	do {
 		unsigned char tpl_code, tpl_link;
+		unsigned long timeout = jiffies +
+			msecs_to_jiffies(SDIO_READ_CIS_TIMEOUT_MS);

 		ret = mmc_io_rw_direct(card, 0, 0, ptr++, 0, &tpl_code);
 		if (ret)
@@ -318,6 +322,8 @@  static int sdio_read_cis(struct mmc_card *card, struct sdio_func *func)
 			prev = &this->next;

 			if (ret == -ENOENT) {
+				if (time_after(jiffies, timeout))
+					break;
 				/* warn about unknown tuples */
 				pr_warn_ratelimited("%s: queuing unknown"
 				       " CIS tuple 0x%02x (%u bytes)\n",