netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Chan <mchan@broadcom.com>
To: <davem@davemloft.net>
Cc: <netdev@vger.kernel.org>, <nhorman@tuxdriver.com>,
	Michael Chan <mchan@broadcom.com>
Subject: [PATCH 1/3] cnic: Don't take rcu_read_lock in cnic_rcv_netevent()
Date: Fri, 30 May 2014 16:18:41 -0700	[thread overview]
Message-ID: <1401491923-5480-2-git-send-email-mchan@broadcom.com> (raw)
In-Reply-To: <1401491923-5480-1-git-send-email-mchan@broadcom.com>

Because the called function, such as bnx2fc_indicate_netevent(), can sleep,
we cannot take rcu_lock().  To prevent the rcu protected ulp_ops from going
away, we use the cnic_lock mutex and set the ULP_F_CALL_PENDING flag.
The code already waits for ULP_F_CALL_PENDING flag to clear in
cnic_unregister_device().

Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/ethernet/broadcom/cnic.c |   15 +++++++++++----
 1 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c
index 09f3fef..7f40a2c 100644
--- a/drivers/net/ethernet/broadcom/cnic.c
+++ b/drivers/net/ethernet/broadcom/cnic.c
@@ -5624,20 +5624,27 @@ static void cnic_rcv_netevent(struct cnic_local *cp, unsigned long event,
 {
 	int if_type;
 
-	rcu_read_lock();
 	for (if_type = 0; if_type < MAX_CNIC_ULP_TYPE; if_type++) {
 		struct cnic_ulp_ops *ulp_ops;
 		void *ctx;
 
-		ulp_ops = rcu_dereference(cp->ulp_ops[if_type]);
-		if (!ulp_ops || !ulp_ops->indicate_netevent)
+		mutex_lock(&cnic_lock);
+		ulp_ops = rcu_dereference_protected(cp->ulp_ops[if_type],
+						lockdep_is held(&cnic_lock));
+		if (!ulp_ops || !ulp_ops->indicate_netevent) {
+			mutex_unlock(&cnic_lock);
 			continue;
+		}
 
 		ctx = cp->ulp_handle[if_type];
 
+		set_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]);
+		mutex_unlock(&cnic_lock);
+
 		ulp_ops->indicate_netevent(ctx, event, vlan_id);
+
+		clear_bit(ULP_F_CALL_PENDING, &cp->ulp_flags[if_type]);
 	}
-	rcu_read_unlock();
 }
 
 /* netdev event handler */
-- 
1.7.1

  reply	other threads:[~2014-05-30 21:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-30 23:18 [PATCH 0/3] cnic fixes Michael Chan
2014-05-30 23:18 ` Michael Chan [this message]
2014-05-30 23:18   ` [PATCH 2/3] cnic: Don't take cnic_dev_lock in cnic_alloc_uio_rings() Michael Chan
2014-05-30 22:33     ` Benjamin Poirier
2014-06-02 20:31       ` Michael Chan
2014-06-02 21:24         ` Benjamin Poirier
2014-05-30 22:50     ` Benjamin Poirier
2014-05-31  5:40       ` Michael Chan
2014-05-30 23:18     ` [PATCH 3/3] cnic: Fix missing ISCSI_KEVENT_IF_DOWN message Michael Chan
2014-05-31 13:07     ` [PATCH 2/3] cnic: Don't take cnic_dev_lock in cnic_alloc_uio_rings() Neil Horman
2014-06-01  0:07       ` Michael Chan
2014-06-02 23:53 ` [PATCH 0/3] cnic fixes David Miller
2014-06-02 23:57   ` David Miller
2014-06-03  0:08     ` Michael Chan

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=1401491923-5480-2-git-send-email-mchan@broadcom.com \
    --to=mchan@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=nhorman@tuxdriver.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;
as well as URLs for NNTP newsgroup(s).