Skip to content

Commit

Permalink
bus: mhi: Ensure correct ring update ordering with memory barrier
Browse files Browse the repository at this point in the history
The ring element data, though being part of coherent memory, still need
to be performed before updating the ring context to point to this new
element. That can be guaranteed with a memory barrier (dma_wmb).

Signed-off-by: Loic Poulain <loic.poulain@linaro.org>
Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
  • Loading branch information
Loic Poulain authored and Manivannan Sadhasivam committed Jan 21, 2021
1 parent ec75136 commit f49b6ae
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/bus/mhi/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,14 @@ void mhi_ring_chan_db(struct mhi_controller *mhi_cntrl,
dma_addr_t db;

db = ring->iommu_base + (ring->wp - ring->base);

/*
* Writes to the new ring element must be visible to the hardware
* before letting h/w know there is new element to fetch.
*/
dma_wmb();
*ring->ctxt_wp = db;

mhi_chan->db_cfg.process_db(mhi_cntrl, &mhi_chan->db_cfg,
ring->db_addr, db);
}
Expand Down

0 comments on commit f49b6ae

Please sign in to comment.