From: Manish Chopra <manish.chopra@qlogic.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <Yuval.Mintz@qlogic.com>,
Manish Chopra <manish.chopra@caviumnetworks.com>
Subject: [PATCH v3 net-next 7/7] qed: Fix possible race when reading firmware return code.
Date: Fri, 14 Oct 2016 05:19:23 -0400 [thread overview]
Message-ID: <1476436763-5274-8-git-send-email-manish.chopra@qlogic.com> (raw)
In-Reply-To: <1476436763-5274-1-git-send-email-manish.chopra@qlogic.com>
From: Manish Chopra <manish.chopra@caviumnetworks.com>
While handling SPQ ramrod completion, there is a possible race
where driver might not read updated fw return code based on
ramrod completion done. This patch ensures that fw return code
is written first and then completion done flag is updated
using appropriate memory barriers.
Signed-off-by: Manish Chopra <manish.chopra@caviumnetworks.com>
Signed-off-by: Yuval Mintz <Yuval.Mintz@caviumnetworks.com>
---
drivers/net/ethernet/qlogic/qed/qed_sp.h | 4 ++--
drivers/net/ethernet/qlogic/qed/qed_spq.c | 12 ++++++------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/qlogic/qed/qed_sp.h b/drivers/net/ethernet/qlogic/qed/qed_sp.h
index 652c908..27c450f 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_sp.h
+++ b/drivers/net/ethernet/qlogic/qed/qed_sp.h
@@ -111,8 +111,8 @@ union qed_spq_req_comp {
};
struct qed_spq_comp_done {
- u64 done;
- u8 fw_return_code;
+ unsigned int done;
+ u8 fw_return_code;
};
struct qed_spq_entry {
diff --git a/drivers/net/ethernet/qlogic/qed/qed_spq.c b/drivers/net/ethernet/qlogic/qed/qed_spq.c
index 259a615..6c05402 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_spq.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_spq.c
@@ -54,11 +54,10 @@ static void qed_spq_blocking_cb(struct qed_hwfn *p_hwfn,
comp_done = (struct qed_spq_comp_done *)cookie;
- comp_done->done = 0x1;
- comp_done->fw_return_code = fw_return_code;
+ comp_done->fw_return_code = fw_return_code;
- /* make update visible to waiting thread */
- smp_wmb();
+ /* Make sure completion done is visible on waiting thread */
+ smp_store_release(&comp_done->done, 0x1);
}
static int __qed_spq_block(struct qed_hwfn *p_hwfn,
@@ -74,8 +73,9 @@ static int __qed_spq_block(struct qed_hwfn *p_hwfn,
while (iter_cnt--) {
/* Validate we receive completion update */
- smp_rmb();
- if (comp_done->done == 1) {
+ if (READ_ONCE(comp_done->done) == 1) {
+ /* Read updated FW return value */
+ smp_read_barrier_depends();
if (p_fw_ret)
*p_fw_ret = comp_done->fw_return_code;
return 0;
--
2.7.2
next prev parent reply other threads:[~2016-10-14 10:04 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-14 9:19 [PATCH v3 net-next 0/7] qed*: driver updates Manish Chopra
2016-10-14 9:19 ` [PATCH v3 net-next 1/7] qed: Pass MAC hints to VFs Manish Chopra
2016-10-14 9:19 ` [PATCH v3 net-next 2/7] qede: GSO support for tunnels with outer csum Manish Chopra
2016-10-14 9:19 ` [PATCH v3 net-next 3/7] qede: Prevent GSO on long Geneve headers Manish Chopra
2016-10-14 9:19 ` [PATCH v3 net-next 4/7] qed*: Allow unicast filtering Manish Chopra
2016-10-14 9:19 ` [PATCH v3 net-next 5/7] qed: Allow chance for fast ramrod completions Manish Chopra
2016-10-14 9:19 ` [PATCH v3 net-next 6/7] qed: Handle malicious VFs events Manish Chopra
2016-10-14 9:19 ` Manish Chopra [this message]
2016-10-14 16:00 ` [PATCH v3 net-next 0/7] qed*: driver updates 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=1476436763-5274-8-git-send-email-manish.chopra@qlogic.com \
--to=manish.chopra@qlogic.com \
--cc=Yuval.Mintz@qlogic.com \
--cc=davem@davemloft.net \
--cc=manish.chopra@caviumnetworks.com \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).