From patchwork Thu Nov 6 10:51:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 5240901 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1302DC11AC for ; Thu, 6 Nov 2014 10:51:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 32D3E20108 for ; Thu, 6 Nov 2014 10:51:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2DC0F200DC for ; Thu, 6 Nov 2014 10:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750974AbaKFKvk (ORCPT ); Thu, 6 Nov 2014 05:51:40 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:57843 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751328AbaKFKvh (ORCPT ); Thu, 6 Nov 2014 05:51:37 -0500 Received: by mail-wi0-f174.google.com with SMTP id d1so1056507wiv.13 for ; Thu, 06 Nov 2014 02:51:36 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=iukmJgYq12fuy5pTIu8/OEMgj/6DGnfVnlcGDeiak5M=; b=Ftd0CEJe9ESz/YbWvXZpm7I7rYPDSgi8IzeVaQ4sJVw13dMZit5b9Owc2PXyVG6X2J z4dWEJRZAH3N3jnMsGIfxXWZZVgoYWou8/A2vJHd5CGjAVC5XQu0iCuDdKIWW46TuEwE 4ytjay6ikxZR78/txSJmSTpiyRr2MOddagCAI5tfkndahU238jOftYS6K1/mTtyqFzfr EsgkgSq7F3J09KGiQzILwdnFP2wk3kc4GcCng2Wl5Cm8sFK8Lp/fsmclLA1n+upEA4EU y3hbQkw2k9XmQiDJIAH8gxbb7s9lo/wNNeId2/BEqvG+1LdQc/0vJAi7DBeuwrrvcbWh PjhA== X-Gm-Message-State: ALoCoQkFjqk1nNYf/pYL4Xuxvb+3U3Vgh2zICf4HDYMB+FNCjmEGXp48A32wmMlNYonUnaVyUbbz X-Received: by 10.194.61.208 with SMTP id s16mr4246838wjr.104.1415271096278; Thu, 06 Nov 2014 02:51:36 -0800 (PST) Received: from localhost ([193.47.165.251]) by mx.google.com with ESMTPSA id ny6sm19007684wic.22.2014.11.06.02.51.35 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 06 Nov 2014 02:51:35 -0800 (PST) From: Eli Cohen X-Google-Original-From: Eli Cohen To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-rdma@vger.kernel.org, ogerlitz@mellanox.com, Eli Cohen Subject: [PATCH net 2/2] net/mlx5_core: Fix race on driver load Date: Thu, 6 Nov 2014 12:51:22 +0200 Message-Id: <1415271082-7644-3-git-send-email-eli@mellanox.com> X-Mailer: git-send-email 2.1.2 In-Reply-To: <1415271082-7644-1-git-send-email-eli@mellanox.com> References: <1415271082-7644-1-git-send-email-eli@mellanox.com> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);