[rtems commit] bsps/xnandpsu: Don't rely on usleep for polling

Joel Sherrill joel at rtems.org
Tue Sep 26 13:37:54 UTC 2023


Module:    rtems
Branch:    master
Commit:    2b5526aa5eed47703e8cd525e7348207bf24e2fb
Changeset: http://git.rtems.org/rtems/commit/?id=2b5526aa5eed47703e8cd525e7348207bf24e2fb

Author:    Kinsey Moore <kinsey.moore at oarcorp.com>
Date:      Tue Sep 19 14:23:06 2023 -0500

bsps/xnandpsu: Don't rely on usleep for polling

When polling hardware registers in high performance situations, don't
rely on usleep or other standard sleep functions since they will
necessarily rely on kernel ticks to be woken up. This can easily cause
an immense reduction in throughput.

---

 bsps/shared/dev/nand/xnandpsu.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/bsps/shared/dev/nand/xnandpsu.c b/bsps/shared/dev/nand/xnandpsu.c
index 85e6ba8532..9e9f8959cf 100644
--- a/bsps/shared/dev/nand/xnandpsu.c
+++ b/bsps/shared/dev/nand/xnandpsu.c
@@ -814,6 +814,21 @@ void XNandPsu_DisableEccMode(XNandPsu *InstancePtr)
 	InstancePtr->EccMode = XNANDPSU_NONE;
 }
 
+#ifdef __rtems__
+#include <rtems/rtems/clock.h>
+static void udelay( void )
+{
+	uint64_t time = rtems_clock_get_uptime_nanoseconds() + 1000;
+	while (1) {
+		uint64_t newtime = rtems_clock_get_uptime_nanoseconds();
+		if (newtime > time) {
+			break;
+		}
+	}
+}
+#define usleep(x) udelay()
+#endif
+
 /*****************************************************************************/
 /**
 *



More information about the vc mailing list