Re: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled

2024-04-29 Thread Marek Vasut

On 4/30/24 12:36 AM, Jaehoon Chung wrote:




-Original Message-
From: Marek Vasut 
Sent: Friday, April 26, 2024 8:41 PM
To: Jaehoon Chung ; u-boot@lists.denx.de
Cc: 'Peng Fan' ; 'Simon Glass' 
Subject: Re: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled

On 4/26/24 8:27 AM, Jaehoon Chung wrote:

Dear Marek,


-Original Message-
From: Marek Vasut 
Sent: Wednesday, April 24, 2024 8:18 AM
To: u-boot@lists.denx.de; Jaehoon Chung 
Cc: Peng Fan ; Simon Glass 
Subject: Re: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled

On 3/16/24 9:13 PM, Marek Vasut wrote:

In case the cyclic framework is enabled, poll the card detect of already
initialized cards and deinitialize them in case they are removed. Since
the card initialization is a longer process and card initialization is
done on first access to an uninitialized card anyway, avoid initializing
newly detected uninitialized cards in the cyclic callback.


Any input on this ?


When I have applied your patch from patchwork, it didn't apply directly.
If you're ok, I will apply after touch your patch. Is it ok?


Sure.


After touching your patch, I will inform again to you.


btw. what is the problem with the patch ?


RE: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled

2024-04-29 Thread Jaehoon Chung



> -Original Message-
> From: Marek Vasut 
> Sent: Friday, April 26, 2024 8:41 PM
> To: Jaehoon Chung ; u-boot@lists.denx.de
> Cc: 'Peng Fan' ; 'Simon Glass' 
> Subject: Re: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled
>
> On 4/26/24 8:27 AM, Jaehoon Chung wrote:
> > Dear Marek,
> >
> >> -Original Message-
> >> From: Marek Vasut 
> >> Sent: Wednesday, April 24, 2024 8:18 AM
> >> To: u-boot@lists.denx.de; Jaehoon Chung 
> >> Cc: Peng Fan ; Simon Glass 
> >> Subject: Re: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled
> >>
> >> On 3/16/24 9:13 PM, Marek Vasut wrote:
> >>> In case the cyclic framework is enabled, poll the card detect of already
> >>> initialized cards and deinitialize them in case they are removed. Since
> >>> the card initialization is a longer process and card initialization is
> >>> done on first access to an uninitialized card anyway, avoid initializing
> >>> newly detected uninitialized cards in the cyclic callback.
> >>
> >> Any input on this ?
> >
> > When I have applied your patch from patchwork, it didn't apply directly.
> > If you're ok, I will apply after touch your patch. Is it ok?
>
> Sure.

After touching your patch, I will inform again to you.

Best Regards,
Jaehoon Chung




Re: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled

2024-04-26 Thread Marek Vasut

On 4/26/24 8:27 AM, Jaehoon Chung wrote:

Dear Marek,


-Original Message-
From: Marek Vasut 
Sent: Wednesday, April 24, 2024 8:18 AM
To: u-boot@lists.denx.de; Jaehoon Chung 
Cc: Peng Fan ; Simon Glass 
Subject: Re: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled

On 3/16/24 9:13 PM, Marek Vasut wrote:

In case the cyclic framework is enabled, poll the card detect of already
initialized cards and deinitialize them in case they are removed. Since
the card initialization is a longer process and card initialization is
done on first access to an uninitialized card anyway, avoid initializing
newly detected uninitialized cards in the cyclic callback.


Any input on this ?


When I have applied your patch from patchwork, it didn't apply directly.
If you're ok, I will apply after touch your patch. Is it ok?


Sure.


RE: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled

2024-04-26 Thread Jaehoon Chung
Dear Marek,

> -Original Message-
> From: Marek Vasut 
> Sent: Wednesday, April 24, 2024 8:18 AM
> To: u-boot@lists.denx.de; Jaehoon Chung 
> Cc: Peng Fan ; Simon Glass 
> Subject: Re: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled
>
> On 3/16/24 9:13 PM, Marek Vasut wrote:
> > In case the cyclic framework is enabled, poll the card detect of already
> > initialized cards and deinitialize them in case they are removed. Since
> > the card initialization is a longer process and card initialization is
> > done on first access to an uninitialized card anyway, avoid initializing
> > newly detected uninitialized cards in the cyclic callback.
>
> Any input on this ?

When I have applied your patch from patchwork, it didn't apply directly.
If you're ok, I will apply after touch your patch. Is it ok?

Best Regards,
Jaehoon Chung




Re: [PATCH v4] mmc: Poll CD in case cyclic framework is enabled

2024-04-23 Thread Marek Vasut

On 3/16/24 9:13 PM, Marek Vasut wrote:

In case the cyclic framework is enabled, poll the card detect of already
initialized cards and deinitialize them in case they are removed. Since
the card initialization is a longer process and card initialization is
done on first access to an uninitialized card anyway, avoid initializing
newly detected uninitialized cards in the cyclic callback.


Any input on this ?


[PATCH v4] mmc: Poll CD in case cyclic framework is enabled

2024-03-16 Thread Marek Vasut
In case the cyclic framework is enabled, poll the card detect of already
initialized cards and deinitialize them in case they are removed. Since
the card initialization is a longer process and card initialization is
done on first access to an uninitialized card anyway, avoid initializing
newly detected uninitialized cards in the cyclic callback.

Signed-off-by: Marek Vasut 
---
Cc: Jaehoon Chung 
Cc: Peng Fan 
Cc: Simon Glass 
---
V2: Move the cyclic registration/unregistration into mmc init/deinit
V3: Replace if (CONFIG_IS_ENABLED(CYCLIC)...) with #if as the former
does not work with structure members
V4: Stuff the code with CONFIG_IS_ENABLED() variants to avoid #ifdefs
---
 drivers/mmc/mmc.c | 32 
 include/mmc.h |  3 +++
 2 files changed, 35 insertions(+)

diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index eb5010c1465..e90ffd5dcd1 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -2985,6 +2985,20 @@ static int mmc_complete_init(struct mmc *mmc)
return err;
 }
 
+static void __maybe_unused mmc_cyclic_cd_poll(void *ctx)
+{
+   struct mmc *m = ctx;
+
+   if (!m->has_init)
+   return;
+
+   if (mmc_getcd(m))
+   return;
+
+   mmc_deinit(m);
+   m->has_init = 0;
+}
+
 int mmc_init(struct mmc *mmc)
 {
int err = 0;
@@ -3007,6 +3021,19 @@ int mmc_init(struct mmc *mmc)
if (err)
pr_info("%s: %d, time %lu\n", __func__, err, get_timer(start));
 
+   if (CONFIG_IS_ENABLED(CYCLIC, (!mmc->cyclic), (NULL))) {
+   /* Register cyclic function for card detect polling */
+   CONFIG_IS_ENABLED(CYCLIC,
+   (mmc->cyclic = cyclic_register(mmc_cyclic_cd_poll,
+  100 * 1000,
+  mmc->cfg->name, mmc)));
+   if (CONFIG_IS_ENABLED(CYCLIC, (!mmc->cyclic), (NULL))) {
+   printf("Failed to register %s CD poll function\n",
+  mmc->cfg->name);
+   err = -EINVAL;
+   }
+   }
+
return err;
 }
 
@@ -3014,6 +3041,11 @@ int mmc_deinit(struct mmc *mmc)
 {
u32 caps_filtered;
 
+   if (CONFIG_IS_ENABLED(CYCLIC, (mmc->cyclic), (NULL))) {
+   cyclic_unregister(CONFIG_IS_ENABLED(CYCLIC, (mmc->cyclic), 
NULL));
+   CONFIG_IS_ENABLED(CYCLIC, (mmc->cyclic = NULL));
+   }
+
if (!CONFIG_IS_ENABLED(MMC_UHS_SUPPORT) &&
!CONFIG_IS_ENABLED(MMC_HS200_SUPPORT) &&
!CONFIG_IS_ENABLED(MMC_HS400_SUPPORT))
diff --git a/include/mmc.h b/include/mmc.h
index 1022db3ffa7..706566fa1ad 100644
--- a/include/mmc.h
+++ b/include/mmc.h
@@ -14,6 +14,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 struct bd_info;
@@ -739,6 +740,8 @@ struct mmc {
u8 hs400_tuning;
 
enum bus_mode user_speed_mode; /* input speed mode from user */
+
+   CONFIG_IS_ENABLED(CYCLIC, (struct cyclic_info *cyclic));
 };
 
 #if CONFIG_IS_ENABLED(DM_MMC)
-- 
2.43.0