summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/soc/qcom/glink_smem_native_xprt.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/soc/qcom/glink_smem_native_xprt.c b/drivers/soc/qcom/glink_smem_native_xprt.c
index 4407dfbc45df..df94bbc6b696 100644
--- a/drivers/soc/qcom/glink_smem_native_xprt.c
+++ b/drivers/soc/qcom/glink_smem_native_xprt.c
@@ -539,6 +539,12 @@ static int fifo_write(struct edge_info *einfo, const void *data, int len)
uint32_t write_index = einfo->tx_ch_desc->write_index;
len = fifo_write_body(einfo, data, len, &write_index);
+
+ /* All data writes need to be flushed to memory before the write index
+ * is updated. This protects against a race condition where the remote
+ * reads stale data because the write index was written before the data.
+ */
+ wmb();
einfo->tx_ch_desc->write_index = write_index;
send_irq(einfo);
@@ -574,6 +580,12 @@ static int fifo_write_complex(struct edge_info *einfo,
len1 = fifo_write_body(einfo, data1, len1, &write_index);
len2 = fifo_write_body(einfo, data2, len2, &write_index);
len3 = fifo_write_body(einfo, data3, len3, &write_index);
+
+ /* All data writes need to be flushed to memory before the write index
+ * is updated. This protects against a race condition where the remote
+ * reads stale data because the write index was written before the data.
+ */
+ wmb();
einfo->tx_ch_desc->write_index = write_index;
send_irq(einfo);