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
+
 /*****************************************************************************/
 /**
 *
-- 
2.39.2

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to