Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: netdev@vger.kernel.org
Cc: jiri@resnulli.us, oss-drivers@netronome.com,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next v2 1/6] nfp: move mutex init out of net code
Date: Fri, 26 May 2017 01:03:31 -0700	[thread overview]
Message-ID: <20170526080336.32689-2-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20170526080336.32689-1-jakub.kicinski@netronome.com>

Move mutex init to main file close to structure allocation.
This will allow mutex to be taken before net code runs (e.g.
from devlink callbacks).  While at it remember to destroy
the mutex.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_main.c     | 4 ++++
 drivers/net/ethernet/netronome/nfp/nfp_net_main.c | 1 -
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c
index bb586ce1ea06..3a131559153a 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c
@@ -41,6 +41,7 @@
 
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mutex.h>
 #include <linux/pci.h>
 #include <linux/firmware.h>
 #include <linux/vermagic.h>
@@ -342,6 +343,7 @@ static int nfp_pci_probe(struct pci_dev *pdev,
 	}
 	INIT_LIST_HEAD(&pf->vnics);
 	INIT_LIST_HEAD(&pf->ports);
+	mutex_init(&pf->lock);
 	pci_set_drvdata(pdev, pf);
 	pf->pdev = pdev;
 
@@ -380,6 +382,7 @@ static int nfp_pci_probe(struct pci_dev *pdev,
 	nfp_cpp_free(pf->cpp);
 err_disable_msix:
 	pci_set_drvdata(pdev, NULL);
+	mutex_destroy(&pf->lock);
 	kfree(pf);
 err_rel_regions:
 	pci_release_regions(pdev);
@@ -404,6 +407,7 @@ static void nfp_pci_remove(struct pci_dev *pdev)
 	nfp_cpp_free(pf->cpp);
 
 	kfree(pf->eth_tbl);
+	mutex_destroy(&pf->lock);
 	kfree(pf);
 	pci_release_regions(pdev);
 	pci_disable_device(pdev);
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
index dd1118c7e1a4..5139c13b6e53 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
@@ -641,7 +641,6 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
 	int err;
 
 	INIT_WORK(&pf->port_refresh_work, nfp_net_refresh_vnics);
-	mutex_init(&pf->lock);
 
 	/* Verify that the board has completed initialization */
 	if (!nfp_is_ready(pf->cpp)) {
-- 
2.11.0

  reply	other threads:[~2017-05-26  8:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-26  8:03 [PATCH net-next v2 0/6] nfp: devlink port implementation Jakub Kicinski
2017-05-26  8:03 ` Jakub Kicinski [this message]
2017-05-26  8:03 ` [PATCH net-next v2 2/6] nfp: add devlink support Jakub Kicinski
2017-05-26  8:03 ` [PATCH net-next v2 3/6] nfp: add helper for cleaning up vNICs Jakub Kicinski
2017-05-26  8:03 ` [PATCH net-next v2 4/6] nfp: register ports as devlink ports Jakub Kicinski
2017-05-26  8:03 ` [PATCH net-next v2 5/6] nfp: calculate total port lanes for split Jakub Kicinski
2017-05-26  8:03 ` [PATCH net-next v2 6/6] nfp: support port splitting via devlink Jakub Kicinski
2017-05-26  8:25 ` [PATCH net-next v2 0/6] nfp: devlink port implementation Jiri Pirko
2017-05-26 15:02   ` David Miller
2017-05-26 15:00 ` 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=20170526080336.32689-2-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.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