diff options
| author | Chris Lew <clew@codeaurora.org> | 2017-12-05 15:23:58 -0800 |
|---|---|---|
| committer | Dhoat Harpal <hdhoat@codeaurora.org> | 2018-03-23 16:01:25 +0530 |
| commit | f497bfd257085b4f0eea388979e332df512c751d (patch) | |
| tree | 49637102c469706cd4de1b338fe55c7258fe8ee3 | |
| parent | 63d54f82b9779d0ddc8c80743dd32990ecfb4543 (diff) | |
soc: qcom: glink: smem: Add wmb between data and write index
Make sure data is flushed before updating write index by adding a wmb.
Change-Id: I3d17ed56b64ac9ca399a0ef11a638027c1ba36ae
Signed-off-by: Chris Lew <clew@codeaurora.org>
| -rw-r--r-- | drivers/soc/qcom/glink_smem_native_xprt.c | 12 |
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); |
