aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@redhat.com>2015-04-08 21:49:36 -0400
committerDavid S. Miller <davem@davemloft.net>2015-04-09 14:25:25 -0400
commit12b3375f3963536ba3ad47d2db49f72067b4905e (patch)
tree1aa5051a9936718911a87d8cc4eed864d703132b
parent019be1cff44bdfed23163be7469419be4f38589b (diff)
mlx4/mlx5: Use dma_wmb/rmb where appropriate
This patch should help to improve the performance of the mlx4 and mlx5 on a number of architectures. For example, on x86 the dma_wmb/rmb equates out to a barrer() call as the architecture is already strong ordered, and on PowerPC the call works out to a lwsync which is significantly less expensive than the sync call that was being used for wmb. I placed the new barriers between any spots that seemed to be trying to order memory/memory reads or writes, if there are any spots that involved MMIO I left the existing wmb in place as the new barriers cannot order transactions between coherent and non-coherent memories. v2: Reduced the replacments to just the spots where I could clearly identify the usage pattern. Cc: Amir Vadai <amirv@mellanox.com> Cc: Ido Shamay <idos@mellanox.com> Cc: Eli Cohen <eli@mellanox.com> Signed-off-by: Alexander Duyck <alexander.h.duyck@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_rx.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c12
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/eq.c4
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/eq.c2
4 files changed, 10 insertions, 10 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index 79b1501e7951..4fdd3c37e47b 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -771,7 +771,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud
771 /* 771 /*
772 * make sure we read the CQE after we read the ownership bit 772 * make sure we read the CQE after we read the ownership bit
773 */ 773 */
774 rmb(); 774 dma_rmb();
775 775
776 /* Drop packet on bad receive or bad checksum */ 776 /* Drop packet on bad receive or bad checksum */
777 if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == 777 if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index 55f9f5c5344e..1783705273d8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -416,7 +416,7 @@ static bool mlx4_en_process_tx_cq(struct net_device *dev,
416 * make sure we read the CQE after we read the 416 * make sure we read the CQE after we read the
417 * ownership bit 417 * ownership bit
418 */ 418 */
419 rmb(); 419 dma_rmb();
420 420
421 if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) == 421 if (unlikely((cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) ==
422 MLX4_CQE_OPCODE_ERROR)) { 422 MLX4_CQE_OPCODE_ERROR)) {
@@ -667,7 +667,7 @@ static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc,
667 skb_frag_size(&shinfo->frags[0])); 667 skb_frag_size(&shinfo->frags[0]));
668 } 668 }
669 669
670 wmb(); 670 dma_wmb();
671 inl->byte_count = cpu_to_be32(1 << 31 | (skb->len - spc)); 671 inl->byte_count = cpu_to_be32(1 << 31 | (skb->len - spc));
672 } 672 }
673} 673}
@@ -804,7 +804,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
804 804
805 data->addr = cpu_to_be64(dma); 805 data->addr = cpu_to_be64(dma);
806 data->lkey = ring->mr_key; 806 data->lkey = ring->mr_key;
807 wmb(); 807 dma_wmb();
808 data->byte_count = cpu_to_be32(byte_count); 808 data->byte_count = cpu_to_be32(byte_count);
809 --data; 809 --data;
810 } 810 }
@@ -821,7 +821,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
821 821
822 data->addr = cpu_to_be64(dma); 822 data->addr = cpu_to_be64(dma);
823 data->lkey = ring->mr_key; 823 data->lkey = ring->mr_key;
824 wmb(); 824 dma_wmb();
825 data->byte_count = cpu_to_be32(byte_count); 825 data->byte_count = cpu_to_be32(byte_count);
826 } 826 }
827 /* tx completion can avoid cache line miss for common cases */ 827 /* tx completion can avoid cache line miss for common cases */
@@ -938,7 +938,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
938 /* Ensure new descriptor hits memory 938 /* Ensure new descriptor hits memory
939 * before setting ownership of this descriptor to HW 939 * before setting ownership of this descriptor to HW
940 */ 940 */
941 wmb(); 941 dma_wmb();
942 tx_desc->ctrl.owner_opcode = op_own; 942 tx_desc->ctrl.owner_opcode = op_own;
943 943
944 wmb(); 944 wmb();
@@ -958,7 +958,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
958 /* Ensure new descriptor hits memory 958 /* Ensure new descriptor hits memory
959 * before setting ownership of this descriptor to HW 959 * before setting ownership of this descriptor to HW
960 */ 960 */
961 wmb(); 961 dma_wmb();
962 tx_desc->ctrl.owner_opcode = op_own; 962 tx_desc->ctrl.owner_opcode = op_own;
963 if (send_doorbell) { 963 if (send_doorbell) {
964 wmb(); 964 wmb();
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c
index 6e70ffee8e87..190fd624bdfe 100644
--- a/drivers/net/ethernet/mellanox/mlx4/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx4/eq.c
@@ -188,7 +188,7 @@ static void slave_event(struct mlx4_dev *dev, u8 slave, struct mlx4_eqe *eqe)
188 memcpy(s_eqe, eqe, dev->caps.eqe_size - 1); 188 memcpy(s_eqe, eqe, dev->caps.eqe_size - 1);
189 s_eqe->slave_id = slave; 189 s_eqe->slave_id = slave;
190 /* ensure all information is written before setting the ownersip bit */ 190 /* ensure all information is written before setting the ownersip bit */
191 wmb(); 191 dma_wmb();
192 s_eqe->owner = !!(slave_eq->prod & SLAVE_EVENT_EQ_SIZE) ? 0x0 : 0x80; 192 s_eqe->owner = !!(slave_eq->prod & SLAVE_EVENT_EQ_SIZE) ? 0x0 : 0x80;
193 ++slave_eq->prod; 193 ++slave_eq->prod;
194 194
@@ -473,7 +473,7 @@ static int mlx4_eq_int(struct mlx4_dev *dev, struct mlx4_eq *eq)
473 * Make sure we read EQ entry contents after we've 473 * Make sure we read EQ entry contents after we've
474 * checked the ownership bit. 474 * checked the ownership bit.
475 */ 475 */
476 rmb(); 476 dma_rmb();
477 477
478 switch (eqe->type) { 478 switch (eqe->type) {
479 case MLX4_EVENT_TYPE_COMP: 479 case MLX4_EVENT_TYPE_COMP:
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index dbf190d9b9ad..58800e4f3958 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -208,7 +208,7 @@ static int mlx5_eq_int(struct mlx5_core_dev *dev, struct mlx5_eq *eq)
208 * Make sure we read EQ entry contents after we've 208 * Make sure we read EQ entry contents after we've
209 * checked the ownership bit. 209 * checked the ownership bit.
210 */ 210 */
211 rmb(); 211 dma_rmb();
212 212
213 mlx5_core_dbg(eq->dev, "eqn %d, eqe type %s\n", 213 mlx5_core_dbg(eq->dev, "eqn %d, eqe type %s\n",
214 eq->eqn, eqe_type_str(eqe->type)); 214 eq->eqn, eqe_type_str(eqe->type));