From: Noam Camus <noamca@mellanox.com>
To: <davem@davemloft.net>
Cc: <noamca@mellanox.com>, <linux-kernel@vger.kernel.org>,
<abrodkin@synopsys.com>, <eladkan@mellanox.com>,
<talz@mellanox.com>
Subject: [PATCH 2/3] net: nps_enet: Sync access to packet sent flag
Date: Tue, 26 Apr 2016 10:35:25 +0300 [thread overview]
Message-ID: <1461656126-22226-3-git-send-email-noamca@mellanox.com> (raw)
In-Reply-To: <1461656126-22226-1-git-send-email-noamca@mellanox.com>
From: Elad Kanfi <eladkan@mellanox.com>
Below is a description of a possible problematic
sequence. CPU-A is sending a frame and CPU-B handles
the interrupt that indicates the frame was sent. CPU-B
reads an invalid value of tx_packet_sent.
CPU-A CPU-B
----- -----
nps_enet_send_frame
.
.
tx_packet_sent = true
order HW to start tx
.
.
HW complete tx
------> get tx complete interrupt
.
.
if(tx_packet_sent == true)
end memory transaction
(tx_packet_sent actually
written)
Problem solution:
Add a memory barrier after setting tx_packet_sent,
in order to make sure that it is written before
the packet is sent.
Signed-off-by: Elad Kanfi <eladkan@mellanox.com>
Acked-by: Noam Camus <noamca@mellanox.com>
---
drivers/net/ethernet/ezchip/nps_enet.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/ezchip/nps_enet.c b/drivers/net/ethernet/ezchip/nps_enet.c
index 5ed06a6..8cf3cde 100644
--- a/drivers/net/ethernet/ezchip/nps_enet.c
+++ b/drivers/net/ethernet/ezchip/nps_enet.c
@@ -394,6 +394,13 @@ static void nps_enet_send_frame(struct net_device *ndev,
/* Indicate SW is done */
priv->tx_packet_sent = true;
+
+ /* before the frame is sent we have to make
+ * sure that priv->tx_packet_sent will be valid
+ * for the CPU'S that handles the ISR and NAPI poll
+ */
+ smp_wmb();
+
tx_ctrl_value |= NPS_ENET_ENABLE << TX_CTL_CT_SHIFT;
/* Send Frame */
nps_enet_reg_set(priv, NPS_ENET_REG_TX_CTL, tx_ctrl_value);
--
1.7.1
next prev parent reply other threads:[~2016-04-26 7:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-26 7:35 [PATCH 0/3] Net driver bugs fix and code style Noam Camus
2016-04-26 7:35 ` [PATCH 1/3] net: nps_enet: " Noam Camus
2016-04-26 7:35 ` Noam Camus [this message]
2016-04-26 7:35 ` [PATCH 3/3] net: nps_enet: bug fix - handle lost tx interrupts Noam Camus
2016-04-26 15:57 ` [PATCH 0/3] Net driver bugs fix and code style David Miller
2016-04-26 17:23 ` Noam Camus
2016-04-26 17:57 ` David Miller
2016-04-26 17:58 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1461656126-22226-3-git-send-email-noamca@mellanox.com \
--to=noamca@mellanox.com \
--cc=abrodkin@synopsys.com \
--cc=davem@davemloft.net \
--cc=eladkan@mellanox.com \
--cc=linux-kernel@vger.kernel.org \
--cc=talz@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®