]> git.openfabrics.org - ~shefty/libmlx4.git/commitdiff
Don't use memcpy() to write blueflame sends
authorJack Morgenstein <jackm@mellanox.co.il>
Thu, 24 Jan 2008 23:53:26 +0000 (15:53 -0800)
committerRoland Dreier <rolandd@cisco.com>
Thu, 24 Jan 2008 23:53:26 +0000 (15:53 -0800)
Some memcpy() implementations may use move-string-buffer assembly
instructions, which do not guarantee copy order into the blueflame
buffer.  This causes problems when writing into a blueflame buffer, so
use our own copy function instead.

Signed-off-by: Jack Morgenstein <jackm@mellanox.co.il>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
src/qp.c

index 8b4adaa13b9ad744129b956ba43b193c73fec1aa..5721860a3ed6fc85abd9e1017546208d56f33de3 100644 (file)
--- a/src/qp.c
+++ b/src/qp.c
@@ -168,6 +168,20 @@ static void set_data_seg(struct mlx4_wqe_data_seg *dseg, struct ibv_sge *sg)
        dseg->byte_count = htonl(sg->length);
 }
 
+/*
+ * Avoid using memcpy() to copy to BlueFlame page, since memcpy()
+ * implementations may use move-string-buffer assembler instructions,
+ * which do not guarantee order of copying.
+ */
+static void mlx4_bf_copy(unsigned long *dst, unsigned long *src, unsigned bytecnt)
+{
+       while (bytecnt > 0) {
+               *dst++ = *src++;
+               *dst++ = *src++;
+               bytecnt -= 2 * sizeof (long);
+       }
+}
+
 int mlx4_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
                          struct ibv_send_wr **bad_wr)
 {
@@ -388,7 +402,8 @@ out:
 
                pthread_spin_lock(&ctx->bf_lock);
 
-               memcpy(ctx->bf_page + ctx->bf_offset, ctrl, align(size * 16, 64));
+               mlx4_bf_copy(ctx->bf_page + ctx->bf_offset, (unsigned long *) ctrl,
+                            align(size * 16, 64));
                wc_wmb();
 
                ctx->bf_offset ^= ctx->bf_buf_size;