netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeedm@mellanox.com>
To: Saeed Mahameed <saeedm@mellanox.com>,
	Leon Romanovsky <leonro@mellanox.com>
Cc: "netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
	Parav Pandit <parav@mellanox.com>, Vu Pham <vuhuong@mellanox.com>
Subject: [PATCH mlx5-next 09/18] net/mlx5: Tide up state_lock and vport enabled flag usage
Date: Mon, 28 Oct 2019 23:35:13 +0000	[thread overview]
Message-ID: <20191028233440.5564-10-saeedm@mellanox.com> (raw)
In-Reply-To: <20191028233440.5564-1-saeedm@mellanox.com>

From: Parav Pandit <parav@mellanox.com>

When eswitch is disabled, vport event handler is unregistered.
This unregistration already synchronizes with running EQ event handler
in below code flow.

mlx5_eswitch_disable()
  mlx5_eswitch_event_handlers_unregister()
    mlx5_eq_notifier_unregister()
      atomic_notifier_chain_unregister()
        synchronize_rcu()

notifier_callchain
  eswitch_vport_event()
    queue_work()

Additionally vport->enabled flag is set under state_lock during
esw_enable_vport() but is not read under state_lock in
(a) esw_disable_vport() and (b) under atomic context
eswitch_vport_event().

It is also necessary to synchronize with already scheduled vport event.
This is already achieved using below sequence.

mlx5_eswitch_event_handlers_unregister()
  [..]
  flush_workqueue()

Hence,
(a) Remove vport->enabled check in eswitch_vport_event() which
doesn't make any sense.
(b) Remove redundant flush_workqueue() on every vport disable.
(c) Keep esw_disable_vport() symmetric with esw_enable_vport() for
state_lock.

Signed-off-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Vu Pham <vuhuong@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eswitch.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
index 0dd5e5d5ea35..f15ffb8f5cac 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1750,18 +1750,16 @@ static void esw_disable_vport(struct mlx5_eswitch *esw,
 {
 	u16 vport_num = vport->vport;
 
+	mutex_lock(&esw->state_lock);
 	if (!vport->enabled)
-		return;
+		goto done;
 
 	esw_debug(esw->dev, "Disabling vport(%d)\n", vport_num);
 	/* Mark this vport as disabled to discard new events */
 	vport->enabled = false;
 
-	/* Wait for current already scheduled events to complete */
-	flush_workqueue(esw->work_queue);
 	/* Disable events from this vport */
 	arm_vport_context_events_cmd(esw->dev, vport->vport, 0);
-	mutex_lock(&esw->state_lock);
 	/* We don't assume VFs will cleanup after themselves.
 	 * Calling vport change handler while vport is disabled will cleanup
 	 * the vport resources.
@@ -1780,6 +1778,8 @@ static void esw_disable_vport(struct mlx5_eswitch *esw,
 		esw_legacy_vport_destroy_drop_counters(vport);
 	}
 	esw->enabled_vports--;
+
+done:
 	mutex_unlock(&esw->state_lock);
 }
 
@@ -1793,12 +1793,8 @@ static int eswitch_vport_event(struct notifier_block *nb,
 
 	vport_num = be16_to_cpu(eqe->data.vport_change.vport_num);
 	vport = mlx5_eswitch_get_vport(esw, vport_num);
-	if (IS_ERR(vport))
-		return NOTIFY_OK;
-
-	if (vport->enabled)
+	if (!IS_ERR(vport))
 		queue_work(esw->work_queue, &vport->vport_change_handler);
-
 	return NOTIFY_OK;
 }
 
-- 
2.21.0


  parent reply	other threads:[~2019-10-28 23:36 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28 23:34 [PATCH mlx5-next 00/18] Mellanox, mlx5-next updates 28-10-2019 Saeed Mahameed
2019-10-28 23:34 ` [PATCH mlx5-next 01/18] net/mlx5: Fixed a typo in a comment in esw_del_uc_addr() Saeed Mahameed
2019-10-28 23:34 ` [PATCH mlx5-next 02/18] net/mlx5: E-Switch, Rename egress config to generic name Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 03/18] net/mlx5: E-Switch, Rename ingress acl config in offloads mode Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 04/18] net/mlx5: E-switch, Introduce and use vlan rule config helper Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 05/18] net/mlx5: Introduce and use mlx5_esw_is_manager_vport() Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 06/18] net/mlx5: Correct comment for legacy fields Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 07/18] net/mlx5: Move metdata fields under offloads structure Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 08/18] net/mlx5: Move legacy drop counter and rule under legacy structure Saeed Mahameed
2019-10-28 23:35 ` Saeed Mahameed [this message]
2019-10-28 23:35 ` [PATCH mlx5-next 10/18] net/mlx5: E-switch, Prepare code to handle vport enable error Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 11/18] net/mlx5: E-switch, Legacy introduce and use per vport acl tables APIs Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 12/18] net/mlx5: Move ACL drop counters life cycle close to ACL lifecycle Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 13/18] net/mlx5: E-switch, Offloads introduce and use per vport acl tables APIs Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 14/18] net/mlx5: E-switch, Offloads shift ACL programming during enable/disable vport Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 15/18] net/mlx5: Restrict metadata disablement to offloads mode Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 16/18] net/mlx5: Refactor ingress acl configuration Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 17/18] net/mlx5: E-switch, Enable metadata on own vport Saeed Mahameed
2019-10-28 23:35 ` [PATCH mlx5-next 18/18] IB/mlx5: Introduce and use mlx5_core_is_vf() Saeed Mahameed
2019-11-01 21:41 ` [PATCH mlx5-next 00/18] Mellanox, mlx5-next updates 28-10-2019 Saeed Mahameed

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=20191028233440.5564-10-saeedm@mellanox.com \
    --to=saeedm@mellanox.com \
    --cc=leonro@mellanox.com \
    --cc=linux-rdma@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=parav@mellanox.com \
    --cc=vuhuong@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;
as well as URLs for NNTP newsgroup(s).