Re: [PATCH v2] bus: mhi: Ensure correct ring update ordering with memory barrier

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/26/2020 8:06 AM, Loic Poulain wrote:
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@xxxxxxxxxx>
---
  v2: fix comment style

  drivers/bus/mhi/core/main.c | 7 +++++++
  1 file changed, 7 insertions(+)

diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c
index 67188ea..ea39df0 100644
--- a/drivers/bus/mhi/core/main.c
+++ b/drivers/bus/mhi/core/main.c
@@ -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);
  }


Do we care about the ordering between updating ctxt_wp and the doorbell? As far as I am aware common device implementations only use the value from the doorbell, but I wonder if that changes, could we run into issues?

--
Jeffrey Hugo
Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [Linux for Sparc]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux