[v7,1/7] bus/fslmc: fix the conflicting dmb function

Message ID 1569562904-43950-2-git-send-email-gavin.hu@arm.com (mailing list archive)
State Superseded, archived
Delegated to: David Marchand
Headers
Series use WFE for aarch64 |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK
ci/iol-dpdk_compile_ovs success Compile Testing PASS
ci/iol-dpdk_compile success Compile Testing PASS
ci/iol-dpdk_compile_spdk success Compile Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS

Commit Message

Gavin Hu Sept. 27, 2019, 5:41 a.m. UTC
  There are two definitions conflicting each other, for more
details, refer to [1].

include/rte_atomic_64.h:19: error: "dmb" redefined [-Werror]
drivers/bus/fslmc/mc/fsl_mc_sys.h:36: note: this is the location of the
previous definition
 #define dmb() {__asm__ __volatile__("" : : : "memory"); }

The fix is to include the spinlock.h file before the other header files,
this is inline with the coding style[2] about the "header includes".
The fix changes the function to take the argument for arm to be
meaningful.

[1] http://inbox.dpdk.org/users/VI1PR08MB537631AB25F41B8880DCCA988FDF0@i
VI1PR08MB5376.eurprd08.prod.outlook.com/T/#u
[2] https://doc.dpdk.org/guides/contributing/coding_style.html

Fixes: 3af733ba8da8 ("bus/fslmc: introduce MC object functions")
Cc: stable@dpdk.org

Signed-off-by: Gavin Hu <gavin.hu@arm.com>
Reviewed-by: Phil Yang <phi.yang@arm.com>
---
 drivers/bus/fslmc/mc/fsl_mc_sys.h | 10 +++++++---
 drivers/bus/fslmc/mc/mc_sys.c     |  3 +--
 2 files changed, 8 insertions(+), 5 deletions(-)
  

Comments

Hemant Agrawal Sept. 27, 2019, 8:24 a.m. UTC | #1
Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>
  
David Marchand Oct. 17, 2019, 3:06 p.m. UTC | #2
On Fri, Sep 27, 2019 at 7:42 AM Gavin Hu <gavin.hu@arm.com> wrote:
>
> There are two definitions conflicting each other, for more
> details, refer to [1].
>
> include/rte_atomic_64.h:19: error: "dmb" redefined [-Werror]
> drivers/bus/fslmc/mc/fsl_mc_sys.h:36: note: this is the location of the
> previous definition
>  #define dmb() {__asm__ __volatile__("" : : : "memory"); }

Interesting, this means that we have a leftover macro from the arm
header that can pollute the namespace.

Anyway, this driver is not using the memory barrier api from the EAL.

How about simply fixing with?
#define __iormb()      rte_io_rmb()
#define __iowmb()      rte_io_wmb()

>
> The fix is to include the spinlock.h file before the other header files,
> this is inline with the coding style[2] about the "header includes".
> The fix changes the function to take the argument for arm to be
> meaningful.
>
> [1] http://inbox.dpdk.org/users/VI1PR08MB537631AB25F41B8880DCCA988FDF0@i
> VI1PR08MB5376.eurprd08.prod.outlook.com/T/#u

This url is broken, there is a trailing i on the first line.

> [2] https://doc.dpdk.org/guides/contributing/coding_style.html
>
> Fixes: 3af733ba8da8 ("bus/fslmc: introduce MC object functions")
> Cc: stable@dpdk.org
>
> Signed-off-by: Gavin Hu <gavin.hu@arm.com>
> Reviewed-by: Phil Yang <phi.yang@arm.com>
  

Patch

diff --git a/drivers/bus/fslmc/mc/fsl_mc_sys.h b/drivers/bus/fslmc/mc/fsl_mc_sys.h
index d0c7b39..fe9dc95 100644
--- a/drivers/bus/fslmc/mc/fsl_mc_sys.h
+++ b/drivers/bus/fslmc/mc/fsl_mc_sys.h
@@ -33,10 +33,14 @@  struct fsl_mc_io {
 #include <linux/byteorder/little_endian.h>
 
 #ifndef dmb
-#define dmb() {__asm__ __volatile__("" : : : "memory"); }
+#ifdef RTE_ARCH_ARM64
+#define dmb(opt) {asm volatile("dmb " #opt : : : "memory"); }
+#else
+#define dmb(opt)
 #endif
-#define __iormb()	dmb()
-#define __iowmb()	dmb()
+#endif
+#define __iormb()	dmb(ld)
+#define __iowmb()	dmb(st)
 #define __arch_getq(a)		(*(volatile uint64_t *)(a))
 #define __arch_putq(v, a)	(*(volatile uint64_t *)(a) = (v))
 #define __arch_putq32(v, a)	(*(volatile uint32_t *)(a) = (v))
diff --git a/drivers/bus/fslmc/mc/mc_sys.c b/drivers/bus/fslmc/mc/mc_sys.c
index efafdc3..22143ef 100644
--- a/drivers/bus/fslmc/mc/mc_sys.c
+++ b/drivers/bus/fslmc/mc/mc_sys.c
@@ -4,11 +4,10 @@ 
  * Copyright 2017 NXP
  *
  */
+#include <rte_spinlock.h>
 #include <fsl_mc_sys.h>
 #include <fsl_mc_cmd.h>
 
-#include <rte_spinlock.h>
-
 /** User space framework uses MC Portal in shared mode. Following change
  * introduces lock in MC FLIB
  */