summaryrefslogtreecommitdiffstats
path: root/bsps/shared
diff options
context:
space:
mode:
authorKinsey Moore <kinsey.moore@oarcorp.com>2023-06-21 10:47:33 -0500
committerJoel Sherrill <joel@rtems.org>2023-06-22 10:46:33 -0500
commit333fd02631196f5d0034903f8634bcced32684d0 (patch)
tree72ff573db85e9f98336f1bb091d1f1abecae394e /bsps/shared
parentbsps/sparc: Deprecate BSP-specific interrupt API (diff)
downloadrtems-333fd02631196f5d0034903f8634bcced32684d0.tar.bz2
bsps/xqspipsu: Handle SMP systems properly
The NOR driver was not written with SMP systems and caching in mind. This makes the IsBusy flag volatile for updates across cores and introduces cache flushing and invalidation where necessary for data manipulated by the DMA engine in the QSPI peripheral.
Diffstat (limited to 'bsps/shared')
-rw-r--r--bsps/shared/dev/spi/xqspipsu-flash-helper.c3
-rw-r--r--bsps/shared/dev/spi/xqspipsu.c23
2 files changed, 26 insertions, 0 deletions
diff --git a/bsps/shared/dev/spi/xqspipsu-flash-helper.c b/bsps/shared/dev/spi/xqspipsu-flash-helper.c
index 4e018bf2fa..c9d8273b87 100644
--- a/bsps/shared/dev/spi/xqspipsu-flash-helper.c
+++ b/bsps/shared/dev/spi/xqspipsu-flash-helper.c
@@ -314,6 +314,7 @@ static int FlashReadID(XQspiPsu *QspiPsuPtr)
}
while (TransferInProgress);
+ rtems_cache_invalidate_multiple_data_lines(ReadBfrPtr, 3);
/* In case of dual, read both and ensure they are same make/size */
/*
@@ -860,6 +861,7 @@ int QspiPsu_NOR_Read(
while (TransferInProgress);
}
+ rtems_cache_invalidate_multiple_data_lines(ReadBuffer, ByteCount);
return 0;
}
@@ -1047,6 +1049,7 @@ static int MultiDieRead(
Address += data_len;
remain_len -= data_len;
}
+ rtems_cache_invalidate_multiple_data_lines(ReadBfrPtr, ByteCount);
return 0;
}
diff --git a/bsps/shared/dev/spi/xqspipsu.c b/bsps/shared/dev/spi/xqspipsu.c
index 1286efd359..c77407bdf4 100644
--- a/bsps/shared/dev/spi/xqspipsu.c
+++ b/bsps/shared/dev/spi/xqspipsu.c
@@ -84,6 +84,9 @@
#include "xqspipsu.h"
#include "xqspipsu_control.h"
#include "sleep.h"
+#ifdef __rtems__
+#include <rtems/rtems/cache.h>
+#endif
/************************** Constant Definitions *****************************/
#define MAX_DELAY_CNT 10000000U /**< Max delay count */
@@ -442,7 +445,16 @@ s32 XQspiPsu_PolledTransfer(XQspiPsu *InstancePtr, XQspiPsu_Msg *Msg,
for (Index = 0; Index < (s32)NumMsg; Index++) {
Xil_AssertNonvoid(Msg[Index].ByteCount > 0U);
+#ifdef __rtems__
+ if (Msg[Index].TxBfrPtr != NULL) {
+ rtems_cache_flush_multiple_data_lines(Msg[Index].TxBfrPtr, Msg[Index].ByteCount);
+ }
+#endif
}
+#ifdef __rtems__
+ rtems_cache_flush_multiple_data_lines(Msg, NumMsg * sizeof(*Msg));
+#endif
+
/*
* Check whether there is another transfer in progress.
* Not thread-safe
@@ -582,7 +594,18 @@ s32 XQspiPsu_InterruptTransfer(XQspiPsu *InstancePtr, XQspiPsu_Msg *Msg,
Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
for (Index = 0; Index < (s32)NumMsg; Index++)
+#ifdef __rtems__
+ {
+#endif
Xil_AssertNonvoid(Msg[Index].ByteCount > 0U);
+#ifdef __rtems__
+ if (Msg[Index].TxBfrPtr != NULL) {
+ rtems_cache_flush_multiple_data_lines(Msg[Index].TxBfrPtr, Msg[Index].ByteCount);
+ }
+ }
+ rtems_cache_flush_multiple_data_lines(Msg, NumMsg * sizeof(*Msg));
+#endif
+
/*
* Check whether there is another transfer in progress.
* Not thread-safe