netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/2] mlx5_core fixes for 3.18
@ 2014-11-06 10:51 Eli Cohen
  2014-11-06 10:51 ` [PATCH net 1/2] net/mlx5_core: Fix race in create EQ Eli Cohen
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eli Cohen @ 2014-11-06 10:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-rdma, ogerlitz, Eli Cohen

Hi Dave,
the following two patches fix races to could lead to kernel panic in some cases.

Thanks,
Eli

Eli Cohen (2):
  net/mlx5_core: Fix race in create EQ
  net/mlx5_core: Fix race on driver load

 drivers/net/ethernet/mellanox/mlx5/core/eq.c   | 7 +++----
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 4 ++--
 2 files changed, 5 insertions(+), 6 deletions(-)

-- 
2.1.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net 1/2] net/mlx5_core: Fix race in create EQ
  2014-11-06 10:51 [PATCH net 0/2] mlx5_core fixes for 3.18 Eli Cohen
@ 2014-11-06 10:51 ` Eli Cohen
  2014-11-06 10:51 ` [PATCH net 2/2] net/mlx5_core: Fix race on driver load Eli Cohen
       [not found] ` <1415271082-7644-1-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
  2 siblings, 0 replies; 4+ messages in thread
From: Eli Cohen @ 2014-11-06 10:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-rdma, ogerlitz, Eli Cohen

After the EQ is created, it can possibly generate interrupts and the interrupt
handler is referencing eq->dev. It is therefore required to set eq->dev before
calling request_irq() so if an event is generated before request_irq() returns,
we will have a valid eq->dev field.

Signed-off-by: Eli Cohen <eli@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/eq.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
index a278238a2db6..ad2c96a02a53 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c
@@ -374,15 +374,14 @@ int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx,
 	snprintf(eq->name, MLX5_MAX_EQ_NAME, "%s@pci:%s",
 		 name, pci_name(dev->pdev));
 	eq->eqn = out.eq_number;
+	eq->irqn = vecidx;
+	eq->dev = dev;
+	eq->doorbell = uar->map + MLX5_EQ_DOORBEL_OFFSET;
 	err = request_irq(table->msix_arr[vecidx].vector, mlx5_msix_handler, 0,
 			  eq->name, eq);
 	if (err)
 		goto err_eq;
 
-	eq->irqn = vecidx;
-	eq->dev = dev;
-	eq->doorbell = uar->map + MLX5_EQ_DOORBEL_OFFSET;
-
 	err = mlx5_debug_eq_add(dev, eq);
 	if (err)
 		goto err_irq;
-- 
2.1.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH net 2/2] net/mlx5_core: Fix race on driver load
  2014-11-06 10:51 [PATCH net 0/2] mlx5_core fixes for 3.18 Eli Cohen
  2014-11-06 10:51 ` [PATCH net 1/2] net/mlx5_core: Fix race in create EQ Eli Cohen
@ 2014-11-06 10:51 ` Eli Cohen
       [not found] ` <1415271082-7644-1-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
  2 siblings, 0 replies; 4+ messages in thread
From: Eli Cohen @ 2014-11-06 10:51 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-rdma, ogerlitz, Eli Cohen

When events arrive at driver load, the event handler gets called even before
the spinlock and list are initialized. Fix this by moving the initialization
before EQs creation.

Signed-off-by: Eli Cohen <eli@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 88b2ffa0edfb..ecc6341e728a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -855,14 +855,14 @@ static int init_one(struct pci_dev *pdev,
 	dev->profile = &profile[prof_sel];
 	dev->event = mlx5_core_event;
 
+	INIT_LIST_HEAD(&priv->ctx_list);
+	spin_lock_init(&priv->ctx_lock);
 	err = mlx5_dev_init(dev, pdev);
 	if (err) {
 		dev_err(&pdev->dev, "mlx5_dev_init failed %d\n", err);
 		goto out;
 	}
 
-	INIT_LIST_HEAD(&priv->ctx_list);
-	spin_lock_init(&priv->ctx_lock);
 	err = mlx5_register_device(dev);
 	if (err) {
 		dev_err(&pdev->dev, "mlx5_register_device failed %d\n", err);
-- 
2.1.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net 0/2] mlx5_core fixes for 3.18
       [not found] ` <1415271082-7644-1-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
@ 2014-11-06 21:41   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2014-11-06 21:41 UTC (permalink / raw)
  To: eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	ogerlitz-VPRAkNaXOzVWk0Htik3J/w, eli-VPRAkNaXOzVWk0Htik3J/w

From: Eli Cohen <eli-LDSdmyG8hGV8YrgS2mwiifqBs+8SCbDb@public.gmane.org>
Date: Thu,  6 Nov 2014 12:51:20 +0200

> the following two patches fix races to could lead to kernel panic in some cases.

Series applied, thanks Eli.
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-06 21:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-06 10:51 [PATCH net 0/2] mlx5_core fixes for 3.18 Eli Cohen
2014-11-06 10:51 ` [PATCH net 1/2] net/mlx5_core: Fix race in create EQ Eli Cohen
2014-11-06 10:51 ` [PATCH net 2/2] net/mlx5_core: Fix race on driver load Eli Cohen
     [not found] ` <1415271082-7644-1-git-send-email-eli-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
2014-11-06 21:41   ` [PATCH net 0/2] mlx5_core fixes for 3.18 David Miller

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).