All of lore.kernel.org
 help / color / mirror / Atom feed
From: Shannon Nelson <snelson@pensando.io>
To: netdev@vger.kernel.org, davem@davemloft.net, kuba@kernel.org,
	richardcochran@gmail.com
Cc: drivers@pensando.io, Shannon Nelson <snelson@pensando.io>
Subject: [PATCH net-next 8/8] ionic: extend ts_config set locking
Date: Wed,  7 Apr 2021 16:20:01 -0700	[thread overview]
Message-ID: <20210407232001.16670-9-snelson@pensando.io> (raw)
In-Reply-To: <20210407232001.16670-1-snelson@pensando.io>

Make sure the configuration is locked before
operating on it for the replay.

Signed-off-by: Shannon Nelson <snelson@pensando.io>
---
 drivers/net/ethernet/pensando/ionic/ionic_phc.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_phc.c b/drivers/net/ethernet/pensando/ionic/ionic_phc.c
index 2bb749097d9e..177dbf89affd 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_phc.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_phc.c
@@ -79,6 +79,8 @@ static int ionic_lif_hwstamp_set_ts_config(struct ionic_lif *lif,
 	if (!lif->phc || !lif->phc->ptp)
 		return -EOPNOTSUPP;
 
+	mutex_lock(&lif->phc->config_lock);
+
 	if (new_ts) {
 		config = new_ts;
 	} else {
@@ -96,12 +98,16 @@ static int ionic_lif_hwstamp_set_ts_config(struct ionic_lif *lif,
 	}
 
 	tx_mode = ionic_hwstamp_tx_mode(config->tx_type);
-	if (tx_mode < 0)
-		return tx_mode;
+	if (tx_mode < 0) {
+		err = tx_mode;
+		goto err_queues;
+	}
 
 	mask = cpu_to_le64(BIT_ULL(tx_mode));
-	if ((ionic->ident.lif.eth.hwstamp_tx_modes & mask) != mask)
-		return -ERANGE;
+	if ((ionic->ident.lif.eth.hwstamp_tx_modes & mask) != mask) {
+		err = -ERANGE;
+		goto err_queues;
+	}
 
 	rx_filt = ionic_hwstamp_rx_filt(config->rx_filter);
 	rx_all = config->rx_filter != HWTSTAMP_FILTER_NONE && !rx_filt;
@@ -116,8 +122,6 @@ static int ionic_lif_hwstamp_set_ts_config(struct ionic_lif *lif,
 	dev_dbg(ionic->dev, "config_rx_filter %d rx_filt %#llx rx_all %d\n",
 		config->rx_filter, rx_filt, rx_all);
 
-	mutex_lock(&lif->phc->config_lock);
-
 	if (tx_mode) {
 		err = ionic_lif_create_hwstamp_txq(lif);
 		if (err)
-- 
2.17.1


  parent reply	other threads:[~2021-04-07 23:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07 23:19 [PATCH net-next 0/8] ionic: hwstamp tweaks Shannon Nelson
2021-04-07 23:19 ` [PATCH net-next 1/8] ionic: fix up a couple of code style nits Shannon Nelson
2021-04-07 23:19 ` [PATCH net-next 2/8] ionic: remove unnecessary compat ifdef Shannon Nelson
2021-04-07 23:19 ` [PATCH net-next 3/8] ionic: check for valid tx_mode on SKBTX_HW_TSTAMP xmit Shannon Nelson
2021-04-07 23:19 ` [PATCH net-next 4/8] ionic: add SKBTX_IN_PROGRESS Shannon Nelson
2021-04-07 23:19 ` [PATCH net-next 5/8] ionic: re-start ptp after queues up Shannon Nelson
2021-04-07 23:19 ` [PATCH net-next 6/8] ionic: ignore EBUSY on queue start Shannon Nelson
2021-04-07 23:20 ` [PATCH net-next 7/8] ionic: add ts_config replay Shannon Nelson
2021-04-07 23:20 ` Shannon Nelson [this message]
2021-04-08 20:30 ` [PATCH net-next 0/8] ionic: hwstamp tweaks patchwork-bot+netdevbpf
2021-04-11 15:38 ` Richard Cochran
2021-04-12 16:33   ` Shannon Nelson
2021-04-13  1:25     ` Richard Cochran

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=20210407232001.16670-9-snelson@pensando.io \
    --to=snelson@pensando.io \
    --cc=davem@davemloft.net \
    --cc=drivers@pensando.io \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.