Skip to content

Commit 08a1006

Browse files
liuyonglong86davem330
authored andcommitted
net: hns3: re-organize vector handle
To prevent loss user's IRQ affinity configuration when DOWN, this patch moves out release/request operation of the vector handle from net DOWN/UP, just do it when vector resource changes. Signed-off-by: Yonglong Liu <[email protected]> Signed-off-by: Huazhong Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 698a895 commit 08a1006

File tree

1 file changed

+52
-48
lines changed

1 file changed

+52
-48
lines changed

drivers/net/ethernet/hisilicon/hns3/hns3_enet.c

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ static int hns3_nic_init_irq(struct hns3_nic_priv *priv)
161161
return ret;
162162
}
163163

164+
disable_irq(tqp_vectors->vector_irq);
165+
164166
irq_set_affinity_hint(tqp_vectors->vector_irq,
165167
&tqp_vectors->affinity_mask);
166168

@@ -179,6 +181,7 @@ static void hns3_mask_vector_irq(struct hns3_enet_tqp_vector *tqp_vector,
179181
static void hns3_vector_enable(struct hns3_enet_tqp_vector *tqp_vector)
180182
{
181183
napi_enable(&tqp_vector->napi);
184+
enable_irq(tqp_vector->vector_irq);
182185

183186
/* enable vector */
184187
hns3_mask_vector_irq(tqp_vector, 1);
@@ -378,18 +381,6 @@ static int hns3_nic_net_up(struct net_device *netdev)
378381
if (ret)
379382
return ret;
380383

381-
/* the device can work without cpu rmap, only aRFS needs it */
382-
ret = hns3_set_rx_cpu_rmap(netdev);
383-
if (ret)
384-
netdev_warn(netdev, "set rx cpu rmap fail, ret=%d!\n", ret);
385-
386-
/* get irq resource for all vectors */
387-
ret = hns3_nic_init_irq(priv);
388-
if (ret) {
389-
netdev_err(netdev, "init irq failed! ret=%d\n", ret);
390-
goto free_rmap;
391-
}
392-
393384
clear_bit(HNS3_NIC_STATE_DOWN, &priv->state);
394385

395386
/* enable the vectors */
@@ -402,22 +393,15 @@ static int hns3_nic_net_up(struct net_device *netdev)
402393

403394
/* start the ae_dev */
404395
ret = h->ae_algo->ops->start ? h->ae_algo->ops->start(h) : 0;
405-
if (ret)
406-
goto out_start_err;
407-
408-
return 0;
409-
410-
out_start_err:
411-
set_bit(HNS3_NIC_STATE_DOWN, &priv->state);
412-
while (j--)
413-
hns3_tqp_disable(h->kinfo.tqp[j]);
396+
if (ret) {
397+
set_bit(HNS3_NIC_STATE_DOWN, &priv->state);
398+
while (j--)
399+
hns3_tqp_disable(h->kinfo.tqp[j]);
414400

415-
for (j = i - 1; j >= 0; j--)
416-
hns3_vector_disable(&priv->tqp_vector[j]);
401+
for (j = i - 1; j >= 0; j--)
402+
hns3_vector_disable(&priv->tqp_vector[j]);
403+
}
417404

418-
hns3_nic_uninit_irq(priv);
419-
free_rmap:
420-
hns3_free_rx_cpu_rmap(netdev);
421405
return ret;
422406
}
423407

@@ -514,11 +498,6 @@ static void hns3_nic_net_down(struct net_device *netdev)
514498
if (ops->stop)
515499
ops->stop(priv->ae_handle);
516500

517-
hns3_free_rx_cpu_rmap(netdev);
518-
519-
/* free irq resources */
520-
hns3_nic_uninit_irq(priv);
521-
522501
/* delay ring buffer clearing to hns3_reset_notify_uninit_enet
523502
* during reset process, because driver may not be able
524503
* to disable the ring through firmware when downing the netdev.
@@ -3642,19 +3621,13 @@ static void hns3_nic_uninit_vector_data(struct hns3_nic_priv *priv)
36423621

36433622
hns3_free_vector_ring_chain(tqp_vector, &vector_ring_chain);
36443623

3645-
if (tqp_vector->irq_init_flag == HNS3_VECTOR_INITED) {
3646-
irq_set_affinity_hint(tqp_vector->vector_irq, NULL);
3647-
free_irq(tqp_vector->vector_irq, tqp_vector);
3648-
tqp_vector->irq_init_flag = HNS3_VECTOR_NOT_INITED;
3649-
}
3650-
36513624
hns3_clear_ring_group(&tqp_vector->rx_group);
36523625
hns3_clear_ring_group(&tqp_vector->tx_group);
36533626
netif_napi_del(&priv->tqp_vector[i].napi);
36543627
}
36553628
}
36563629

3657-
static int hns3_nic_dealloc_vector_data(struct hns3_nic_priv *priv)
3630+
static void hns3_nic_dealloc_vector_data(struct hns3_nic_priv *priv)
36583631
{
36593632
struct hnae3_handle *h = priv->ae_handle;
36603633
struct pci_dev *pdev = h->pdev;
@@ -3666,11 +3639,10 @@ static int hns3_nic_dealloc_vector_data(struct hns3_nic_priv *priv)
36663639
tqp_vector = &priv->tqp_vector[i];
36673640
ret = h->ae_algo->ops->put_vector(h, tqp_vector->vector_irq);
36683641
if (ret)
3669-
return ret;
3642+
return;
36703643
}
36713644

36723645
devm_kfree(&pdev->dev, priv->tqp_vector);
3673-
return 0;
36743646
}
36753647

36763648
static void hns3_ring_get_cfg(struct hnae3_queue *q, struct hns3_nic_priv *priv,
@@ -4069,6 +4041,18 @@ static int hns3_client_init(struct hnae3_handle *handle)
40694041
goto out_reg_netdev_fail;
40704042
}
40714043

4044+
/* the device can work without cpu rmap, only aRFS needs it */
4045+
ret = hns3_set_rx_cpu_rmap(netdev);
4046+
if (ret)
4047+
dev_warn(priv->dev, "set rx cpu rmap fail, ret=%d\n", ret);
4048+
4049+
ret = hns3_nic_init_irq(priv);
4050+
if (ret) {
4051+
dev_err(priv->dev, "init irq failed! ret=%d\n", ret);
4052+
hns3_free_rx_cpu_rmap(netdev);
4053+
goto out_init_irq_fail;
4054+
}
4055+
40724056
ret = hns3_client_start(handle);
40734057
if (ret) {
40744058
dev_err(priv->dev, "hns3_client_start fail! ret=%d\n", ret);
@@ -4090,6 +4074,9 @@ static int hns3_client_init(struct hnae3_handle *handle)
40904074
return ret;
40914075

40924076
out_client_start:
4077+
hns3_free_rx_cpu_rmap(netdev);
4078+
hns3_nic_uninit_irq(priv);
4079+
out_init_irq_fail:
40934080
unregister_netdev(netdev);
40944081
out_reg_netdev_fail:
40954082
hns3_uninit_phy(netdev);
@@ -4127,15 +4114,17 @@ static void hns3_client_uninit(struct hnae3_handle *handle, bool reset)
41274114
goto out_netdev_free;
41284115
}
41294116

4117+
hns3_free_rx_cpu_rmap(netdev);
4118+
4119+
hns3_nic_uninit_irq(priv);
4120+
41304121
hns3_del_all_fd_rules(netdev, true);
41314122

41324123
hns3_clear_all_ring(handle, true);
41334124

41344125
hns3_nic_uninit_vector_data(priv);
41354126

4136-
ret = hns3_nic_dealloc_vector_data(priv);
4137-
if (ret)
4138-
netdev_err(netdev, "dealloc vector error\n");
4127+
hns3_nic_dealloc_vector_data(priv);
41394128

41404129
ret = hns3_uninit_all_ring(priv);
41414130
if (ret)
@@ -4462,17 +4451,32 @@ static int hns3_reset_notify_init_enet(struct hnae3_handle *handle)
44624451
if (ret)
44634452
goto err_uninit_vector;
44644453

4454+
/* the device can work without cpu rmap, only aRFS needs it */
4455+
ret = hns3_set_rx_cpu_rmap(netdev);
4456+
if (ret)
4457+
dev_warn(priv->dev, "set rx cpu rmap fail, ret=%d\n", ret);
4458+
4459+
ret = hns3_nic_init_irq(priv);
4460+
if (ret) {
4461+
dev_err(priv->dev, "init irq failed! ret=%d\n", ret);
4462+
hns3_free_rx_cpu_rmap(netdev);
4463+
goto err_init_irq_fail;
4464+
}
4465+
44654466
ret = hns3_client_start(handle);
44664467
if (ret) {
44674468
dev_err(priv->dev, "hns3_client_start fail! ret=%d\n", ret);
4468-
goto err_uninit_ring;
4469+
goto err_client_start_fail;
44694470
}
44704471

44714472
set_bit(HNS3_NIC_STATE_INITED, &priv->state);
44724473

44734474
return ret;
44744475

4475-
err_uninit_ring:
4476+
err_client_start_fail:
4477+
hns3_free_rx_cpu_rmap(netdev);
4478+
hns3_nic_uninit_irq(priv);
4479+
err_init_irq_fail:
44764480
hns3_uninit_all_ring(priv);
44774481
err_uninit_vector:
44784482
hns3_nic_uninit_vector_data(priv);
@@ -4522,16 +4526,16 @@ static int hns3_reset_notify_uninit_enet(struct hnae3_handle *handle)
45224526
return 0;
45234527
}
45244528

4529+
hns3_free_rx_cpu_rmap(netdev);
4530+
hns3_nic_uninit_irq(priv);
45254531
hns3_clear_all_ring(handle, true);
45264532
hns3_reset_tx_queue(priv->ae_handle);
45274533

45284534
hns3_nic_uninit_vector_data(priv);
45294535

45304536
hns3_store_coal(priv);
45314537

4532-
ret = hns3_nic_dealloc_vector_data(priv);
4533-
if (ret)
4534-
netdev_err(netdev, "dealloc vector error\n");
4538+
hns3_nic_dealloc_vector_data(priv);
45354539

45364540
ret = hns3_uninit_all_ring(priv);
45374541
if (ret)

0 commit comments

Comments
 (0)