Skip to content

Commit 5c8adef

Browse files
Windrow14xiaoxiang781216
authored andcommitted
drivers/mmcsd/Kconfig|mmcsd_sdio.c: check ready without sleep
If per tick is set to 10ms, it will cause nxsig_usleep(1000) in the sdio driver to sleep for 19ms, which is much longer than the expected 1ms, resulting in very low write performance. Add option to reduce CPU hogging by using sched_yield(), though it may also affect write performance when the CPU is busy. Signed-off-by: Yinzhe Wu <Yinzhe.Wu@sony.com> Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com> Reviewed-by: Jacky Cao <Jacky.Cao@sony.com> Tested-by: Yinzhe Wu <Yinzhe.Wu@sony.com>
1 parent 190c878 commit 5c8adef

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

drivers/mmcsd/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,19 @@ config MMCSD_BLOCK_WDATADELAY
177177
Some hardware needs to configure this delay to write one data block, because
178178
the hardware needs more time for wear leveling and bad block management.
179179

180+
config MMCSD_CHECK_READY_STATUS_WITHOUT_SLEEP
181+
bool "No sleep in ready-check function."
182+
default n
183+
---help---
184+
Since nxsig_usleep returns at the tick after the next tick, when
185+
CONFIG_USEC_PER_TICK is big, the real sleep time is much more than
186+
desired in mmcsd_transferready(). As a result, write speed is
187+
affected seriously.
188+
189+
When this configuration is enabled, the sleep in mmcsd_transferready
190+
will be skipped. However, CPU will be hogged by the process during
191+
this period of writing time.
192+
180193
endif
181194

182195
endif # MMCSD

drivers/mmcsd/mmcsd_sdio.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,7 +1251,13 @@ static int mmcsd_transferready(FAR struct mmcsd_state_s *priv)
12511251

12521252
/* Do not hog the CPU */
12531253

1254+
#ifdef CONFIG_MMCSD_CHECK_READY_STATUS_WITHOUT_SLEEP
1255+
/* Use sched_yield when tick is big to avoid low writing speed */
1256+
1257+
sched_yield();
1258+
#else
12541259
nxsig_usleep(1000);
1260+
#endif
12551261

12561262
/* We are still in the programming state. Calculate the elapsed
12571263
* time... we can't stay in this loop forever!

0 commit comments

Comments
 (0)