ionic: fix double use of queue-lock
[linux-2.6-microblaze.git] / drivers / net / ethernet / pensando / ionic / ionic_ethtool.c
index 6583be5..3de1a03 100644 (file)
@@ -32,6 +32,9 @@ static void ionic_get_stats(struct net_device *netdev,
        struct ionic_lif *lif = netdev_priv(netdev);
        u32 i;
 
+       if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
+               return;
+
        memset(buf, 0, stats->n_stats * sizeof(*buf));
        for (i = 0; i < ionic_num_stats_grps; i++)
                ionic_stats_groups[i].get_values(lif, &buf);
@@ -274,6 +277,9 @@ static int ionic_set_link_ksettings(struct net_device *netdev,
        struct ionic *ionic = lif->ionic;
        int err = 0;
 
+       if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
+               return -EBUSY;
+
        /* set autoneg */
        if (ks->base.autoneg != idev->port_info->config.an_enable) {
                mutex_lock(&ionic->dev_cmd_lock);
@@ -320,6 +326,9 @@ static int ionic_set_pauseparam(struct net_device *netdev,
        u32 requested_pause;
        int err;
 
+       if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
+               return -EBUSY;
+
        if (pause->autoneg)
                return -EOPNOTSUPP;
 
@@ -372,6 +381,9 @@ static int ionic_set_fecparam(struct net_device *netdev,
        u8 fec_type;
        int ret = 0;
 
+       if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
+               return -EBUSY;
+
        if (lif->ionic->idev.port_info->config.an_enable) {
                netdev_err(netdev, "FEC request not allowed while autoneg is enabled\n");
                return -EINVAL;
@@ -408,7 +420,9 @@ static int ionic_set_fecparam(struct net_device *netdev,
 }
 
 static int ionic_get_coalesce(struct net_device *netdev,
-                             struct ethtool_coalesce *coalesce)
+                             struct ethtool_coalesce *coalesce,
+                             struct kernel_ethtool_coalesce *kernel_coal,
+                             struct netlink_ext_ack *extack)
 {
        struct ionic_lif *lif = netdev_priv(netdev);
 
@@ -426,7 +440,9 @@ static int ionic_get_coalesce(struct net_device *netdev,
 }
 
 static int ionic_set_coalesce(struct net_device *netdev,
-                             struct ethtool_coalesce *coalesce)
+                             struct ethtool_coalesce *coalesce,
+                             struct kernel_ethtool_coalesce *kernel_coal,
+                             struct netlink_ext_ack *extack)
 {
        struct ionic_lif *lif = netdev_priv(netdev);
        struct ionic_identity *ident;
@@ -528,6 +544,9 @@ static int ionic_set_ringparam(struct net_device *netdev,
        struct ionic_queue_params qparam;
        int err;
 
+       if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
+               return -EBUSY;
+
        ionic_init_queue_params(lif, &qparam);
 
        if (ring->rx_mini_pending || ring->rx_jumbo_pending) {
@@ -563,7 +582,10 @@ static int ionic_set_ringparam(struct net_device *netdev,
 
        qparam.ntxq_descs = ring->tx_pending;
        qparam.nrxq_descs = ring->rx_pending;
+
+       mutex_lock(&lif->queue_lock);
        err = ionic_reconfigure_queues(lif, &qparam);
+       mutex_unlock(&lif->queue_lock);
        if (err)
                netdev_info(netdev, "Ring reconfiguration failed, changes canceled: %d\n", err);
 
@@ -597,6 +619,9 @@ static int ionic_set_channels(struct net_device *netdev,
        int max_cnt;
        int err;
 
+       if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
+               return -EBUSY;
+
        ionic_init_queue_params(lif, &qparam);
 
        if (ch->rx_count != ch->tx_count) {
@@ -657,7 +682,9 @@ static int ionic_set_channels(struct net_device *netdev,
                return 0;
        }
 
+       mutex_lock(&lif->queue_lock);
        err = ionic_reconfigure_queues(lif, &qparam);
+       mutex_unlock(&lif->queue_lock);
        if (err)
                netdev_info(netdev, "Queue reconfiguration failed, changes canceled: %d\n", err);
 
@@ -947,6 +974,9 @@ static int ionic_nway_reset(struct net_device *netdev)
        struct ionic *ionic = lif->ionic;
        int err = 0;
 
+       if (test_bit(IONIC_LIF_F_FW_RESET, lif->state))
+               return -EBUSY;
+
        /* flap the link to force auto-negotiation */
 
        mutex_lock(&ionic->dev_cmd_lock);