From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yongseok Koh Subject: [PATCH v3 1/8] eal: introduce DMA memory barriers Date: Thu, 18 Jan 2018 16:44:23 -0800 Message-ID: <20180119004430.15305-2-yskoh@mellanox.com> References: <20180116011050.18866-1-yskoh@mellanox.com> <20180119004430.15305-1-yskoh@mellanox.com> Mime-Version: 1.0 Content-Type: text/plain Cc: dev@dpdk.org, Yongseok Koh To: adrien.mazarguil@6wind.com, nelio.laranjeiro@6wind.com, bruce.richardson@intel.com, konstantin.ananyev@intel.com, chaozhu@linux.vnet.ibm.com, jerin.jacob@caviumnetworks.com, jianbo.liu@arm.com Return-path: Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-eopbgr60068.outbound.protection.outlook.com [40.107.6.68]) by dpdk.org (Postfix) with ESMTP id 3693E1B2CC for ; Fri, 19 Jan 2018 01:44:53 +0100 (CET) In-Reply-To: <20180119004430.15305-1-yskoh@mellanox.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This commit introduces rte_dma_wmb() and rte_dma_rmb(), in order to guarantee the ordering of coherent shared memory between the CPU and a DMA capable device. Signed-off-by: Yongseok Koh --- lib/librte_eal/common/include/generic/rte_atomic.h | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/lib/librte_eal/common/include/generic/rte_atomic.h b/lib/librte_eal/common/include/generic/rte_atomic.h index 3ba7245a3..1ffa51e31 100644 --- a/lib/librte_eal/common/include/generic/rte_atomic.h +++ b/lib/librte_eal/common/include/generic/rte_atomic.h @@ -98,6 +98,58 @@ static inline void rte_io_wmb(void); */ static inline void rte_io_rmb(void); +/** + * Write memory barrier for coherent memory between lcore and IO device + * + * Guarantees that the STORE operations on coherent memory that + * precede the rte_dma_wmb() call are visible to I/O device before the + * STORE operations that follow it. + * + * DMA memory barrier is a lightweight version of I/O device barriers + * which are system-wide data synchronization barriers. This is for + * only coherent memory domain between lcore and IO device but it is + * same as the I/O device barriers in most of architectures. However, + * some architecture provides even lighter barriers which are + * somewhere in between I/O device barriers and SMP barriers. For + * example, in case of ARMv8, data memory barrier can have different + * shareability domains - inner-shareable and outer-shareable. And + * inner-shareable data memory barrier fits for SMP barriers and + * outer-shareable one for DMA barriers, which acts on coherent + * memory. + * + * In most cases, I/O device barriers are safer but if operations are + * on coherent memory instead of incoherent MMIO region of a device, + * then DMA barriers can be used and this could bring performance gain + * depending on architectures. + */ +static inline void rte_dma_wmb(void); + +/** + * Read memory barrier for coherent memory between lcore and IO device + * + * Guarantees that the LOAD operations on coherent memory updated by + * IO device that precede the rte_dma_rmb() call are visible to CPU + * before the LOAD operations that follow it. + * + * DMA memory barrier is a lightweight version of I/O device barriers + * which are system-wide data synchronization barriers. This is for + * only coherent memory domain between lcore and IO device but it is + * same as the I/O device barriers in most of architectures. However, + * some architecture provides even lighter barriers which are + * somewhere in between I/O device barriers and SMP barriers. For + * example, in case of ARMv8, data memory barrier can have different + * shareability domains - inner-shareable and outer-shareable. And + * inner-shareable data memory barrier fits for SMP barriers and + * outer-shareable one for DMA barriers, which acts on coherent + * memory. + * + * In most cases, I/O device barriers are safer but if operations are + * on coherent memory instead of incoherent MMIO region of a device, + * then DMA barriers can be used and this could bring performance gain + * depending on architectures. + */ +static inline void rte_dma_rmb(void); + #endif /* __DOXYGEN__ */ /** -- 2.11.0