Commit 7ee99fc5 authored by Shannon Nelson's avatar Shannon Nelson Committed by David S. Miller

ionic: pull hwstamp queue_lock up a level

Move the hwstamp configuration use of queue_lock up
a level to simplify use and error handling.
Signed-off-by: default avatarShannon Nelson <snelson@pensando.io>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent af3d2ae1
...@@ -849,10 +849,8 @@ int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif) ...@@ -849,10 +849,8 @@ int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif)
u64 features; u64 features;
int err; int err;
mutex_lock(&lif->queue_lock);
if (lif->hwstamp_txq) if (lif->hwstamp_txq)
goto out; return 0;
features = IONIC_Q_F_2X_CQ_DESC | IONIC_TXQ_F_HWSTAMP; features = IONIC_Q_F_2X_CQ_DESC | IONIC_TXQ_F_HWSTAMP;
...@@ -894,9 +892,6 @@ int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif) ...@@ -894,9 +892,6 @@ int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif)
} }
} }
out:
mutex_unlock(&lif->queue_lock);
return 0; return 0;
err_qcq_enable: err_qcq_enable:
...@@ -907,7 +902,6 @@ int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif) ...@@ -907,7 +902,6 @@ int ionic_lif_create_hwstamp_txq(struct ionic_lif *lif)
ionic_qcq_free(lif, txq); ionic_qcq_free(lif, txq);
devm_kfree(lif->ionic->dev, txq); devm_kfree(lif->ionic->dev, txq);
err_qcq_alloc: err_qcq_alloc:
mutex_unlock(&lif->queue_lock);
return err; return err;
} }
...@@ -919,10 +913,8 @@ int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif) ...@@ -919,10 +913,8 @@ int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif)
u64 features; u64 features;
int err; int err;
mutex_lock(&lif->queue_lock);
if (lif->hwstamp_rxq) if (lif->hwstamp_rxq)
goto out; return 0;
features = IONIC_Q_F_2X_CQ_DESC | IONIC_RXQ_F_HWSTAMP; features = IONIC_Q_F_2X_CQ_DESC | IONIC_RXQ_F_HWSTAMP;
...@@ -960,9 +952,6 @@ int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif) ...@@ -960,9 +952,6 @@ int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif)
} }
} }
out:
mutex_unlock(&lif->queue_lock);
return 0; return 0;
err_qcq_enable: err_qcq_enable:
...@@ -973,7 +962,6 @@ int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif) ...@@ -973,7 +962,6 @@ int ionic_lif_create_hwstamp_rxq(struct ionic_lif *lif)
ionic_qcq_free(lif, rxq); ionic_qcq_free(lif, rxq);
devm_kfree(lif->ionic->dev, rxq); devm_kfree(lif->ionic->dev, rxq);
err_qcq_alloc: err_qcq_alloc:
mutex_unlock(&lif->queue_lock);
return err; return err;
} }
......
...@@ -194,7 +194,9 @@ int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr) ...@@ -194,7 +194,9 @@ int ionic_lif_hwstamp_set(struct ionic_lif *lif, struct ifreq *ifr)
if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) if (copy_from_user(&config, ifr->ifr_data, sizeof(config)))
return -EFAULT; return -EFAULT;
mutex_lock(&lif->queue_lock);
err = ionic_lif_hwstamp_set_ts_config(lif, &config); err = ionic_lif_hwstamp_set_ts_config(lif, &config);
mutex_unlock(&lif->queue_lock);
if (err) { if (err) {
netdev_info(lif->netdev, "hwstamp set failed: %d\n", err); netdev_info(lif->netdev, "hwstamp set failed: %d\n", err);
return err; return err;
...@@ -213,7 +215,9 @@ void ionic_lif_hwstamp_replay(struct ionic_lif *lif) ...@@ -213,7 +215,9 @@ void ionic_lif_hwstamp_replay(struct ionic_lif *lif)
if (!lif->phc || !lif->phc->ptp) if (!lif->phc || !lif->phc->ptp)
return; return;
mutex_lock(&lif->queue_lock);
err = ionic_lif_hwstamp_set_ts_config(lif, NULL); err = ionic_lif_hwstamp_set_ts_config(lif, NULL);
mutex_unlock(&lif->queue_lock);
if (err) if (err)
netdev_info(lif->netdev, "hwstamp replay failed: %d\n", err); netdev_info(lif->netdev, "hwstamp replay failed: %d\n", err);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment