Commit ff0699e0 authored by Huazhong Tan's avatar Huazhong Tan Committed by David S. Miller

net: hns3: stop napi polling when HNS3_NIC_STATE_DOWN is set

When calling napi_disable during reset down process, if NAPIF_STATE_MISSED
is set, napi_complete will call __napi_schedule to do the polling again.
So this patch uses HNS3_NIC_STATE_DOWN to ensure the polling is not
scheduled again.

Also, when napi_complete returns true, it means polling is scheduled
again, it is not neccssary to enable the interrupt.
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6a5f6fa3
...@@ -415,9 +415,6 @@ static void hns3_nic_net_down(struct net_device *netdev) ...@@ -415,9 +415,6 @@ static void hns3_nic_net_down(struct net_device *netdev)
const struct hnae3_ae_ops *ops; const struct hnae3_ae_ops *ops;
int i; int i;
if (test_and_set_bit(HNS3_NIC_STATE_DOWN, &priv->state))
return;
/* disable vectors */ /* disable vectors */
for (i = 0; i < priv->vector_num; i++) for (i = 0; i < priv->vector_num; i++)
hns3_vector_disable(&priv->tqp_vector[i]); hns3_vector_disable(&priv->tqp_vector[i]);
...@@ -439,6 +436,11 @@ static void hns3_nic_net_down(struct net_device *netdev) ...@@ -439,6 +436,11 @@ static void hns3_nic_net_down(struct net_device *netdev)
static int hns3_nic_net_stop(struct net_device *netdev) static int hns3_nic_net_stop(struct net_device *netdev)
{ {
struct hns3_nic_priv *priv = netdev_priv(netdev);
if (test_and_set_bit(HNS3_NIC_STATE_DOWN, &priv->state))
return 0;
netif_tx_stop_all_queues(netdev); netif_tx_stop_all_queues(netdev);
netif_carrier_off(netdev); netif_carrier_off(netdev);
...@@ -2699,6 +2701,7 @@ static void hns3_update_new_int_gl(struct hns3_enet_tqp_vector *tqp_vector) ...@@ -2699,6 +2701,7 @@ static void hns3_update_new_int_gl(struct hns3_enet_tqp_vector *tqp_vector)
static int hns3_nic_common_poll(struct napi_struct *napi, int budget) static int hns3_nic_common_poll(struct napi_struct *napi, int budget)
{ {
struct hns3_nic_priv *priv = netdev_priv(napi->dev);
struct hns3_enet_ring *ring; struct hns3_enet_ring *ring;
int rx_pkt_total = 0; int rx_pkt_total = 0;
...@@ -2707,6 +2710,11 @@ static int hns3_nic_common_poll(struct napi_struct *napi, int budget) ...@@ -2707,6 +2710,11 @@ static int hns3_nic_common_poll(struct napi_struct *napi, int budget)
bool clean_complete = true; bool clean_complete = true;
int rx_budget; int rx_budget;
if (unlikely(test_bit(HNS3_NIC_STATE_DOWN, &priv->state))) {
napi_complete(napi);
return 0;
}
/* Since the actual Tx work is minimal, we can give the Tx a larger /* Since the actual Tx work is minimal, we can give the Tx a larger
* budget and be more aggressive about cleaning up the Tx descriptors. * budget and be more aggressive about cleaning up the Tx descriptors.
*/ */
...@@ -2731,9 +2739,11 @@ static int hns3_nic_common_poll(struct napi_struct *napi, int budget) ...@@ -2731,9 +2739,11 @@ static int hns3_nic_common_poll(struct napi_struct *napi, int budget)
if (!clean_complete) if (!clean_complete)
return budget; return budget;
napi_complete(napi); if (likely(!test_bit(HNS3_NIC_STATE_DOWN, &priv->state)) &&
hns3_update_new_int_gl(tqp_vector); napi_complete(napi)) {
hns3_mask_vector_irq(tqp_vector, 1); hns3_update_new_int_gl(tqp_vector);
hns3_mask_vector_irq(tqp_vector, 1);
}
return rx_pkt_total; return rx_pkt_total;
} }
......
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