hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/infiniband/hw/i40iw/i40iw_main.c
....@@ -188,9 +188,9 @@
188188 * i40iw_dpc - tasklet for aeq and ceq 0
189189 * @data: iwarp device
190190 */
191
-static void i40iw_dpc(unsigned long data)
191
+static void i40iw_dpc(struct tasklet_struct *t)
192192 {
193
- struct i40iw_device *iwdev = (struct i40iw_device *)data;
193
+ struct i40iw_device *iwdev = from_tasklet(iwdev, t, dpc_tasklet);
194194
195195 if (iwdev->msix_shared)
196196 i40iw_process_ceq(iwdev, iwdev->ceqlist);
....@@ -202,9 +202,9 @@
202202 * i40iw_ceq_dpc - dpc handler for CEQ
203203 * @data: data points to CEQ
204204 */
205
-static void i40iw_ceq_dpc(unsigned long data)
205
+static void i40iw_ceq_dpc(struct tasklet_struct *t)
206206 {
207
- struct i40iw_ceq *iwceq = (struct i40iw_ceq *)data;
207
+ struct i40iw_ceq *iwceq = from_tasklet(iwceq, t, dpc_tasklet);
208208 struct i40iw_device *iwdev = iwceq->iwdev;
209209
210210 i40iw_process_ceq(iwdev, iwceq);
....@@ -685,10 +685,10 @@
685685 enum i40iw_status_code status;
686686
687687 if (iwdev->msix_shared && !ceq_id) {
688
- tasklet_init(&iwdev->dpc_tasklet, i40iw_dpc, (unsigned long)iwdev);
688
+ tasklet_setup(&iwdev->dpc_tasklet, i40iw_dpc);
689689 status = request_irq(msix_vec->irq, i40iw_irq_handler, 0, "AEQCEQ", iwdev);
690690 } else {
691
- tasklet_init(&iwceq->dpc_tasklet, i40iw_ceq_dpc, (unsigned long)iwceq);
691
+ tasklet_setup(&iwceq->dpc_tasklet, i40iw_ceq_dpc);
692692 status = request_irq(msix_vec->irq, i40iw_ceq_handler, 0, "CEQ", iwceq);
693693 }
694694
....@@ -837,7 +837,7 @@
837837 u32 ret = 0;
838838
839839 if (!iwdev->msix_shared) {
840
- tasklet_init(&iwdev->dpc_tasklet, i40iw_dpc, (unsigned long)iwdev);
840
+ tasklet_setup(&iwdev->dpc_tasklet, i40iw_dpc);
841841 ret = request_irq(msix_vec->irq, i40iw_irq_handler, 0, "i40iw", iwdev);
842842 }
843843 if (ret) {
....@@ -1208,18 +1208,19 @@
12081208 {
12091209 struct net_device *dev;
12101210 struct in_device *idev;
1211
- bool got_lock = true;
12121211 u32 ip_addr;
12131212
1214
- if (!rtnl_trylock())
1215
- got_lock = false;
1216
-
1217
- for_each_netdev(&init_net, dev) {
1213
+ rcu_read_lock();
1214
+ for_each_netdev_rcu(&init_net, dev) {
12181215 if ((((rdma_vlan_dev_vlan_id(dev) < 0xFFFF) &&
12191216 (rdma_vlan_dev_real_dev(dev) == iwdev->netdev)) ||
1220
- (dev == iwdev->netdev)) && (dev->flags & IFF_UP)) {
1221
- idev = in_dev_get(dev);
1222
- for_ifa(idev) {
1217
+ (dev == iwdev->netdev)) && (READ_ONCE(dev->flags) & IFF_UP)) {
1218
+ const struct in_ifaddr *ifa;
1219
+
1220
+ idev = __in_dev_get_rcu(dev);
1221
+ if (!idev)
1222
+ continue;
1223
+ in_dev_for_each_ifa_rcu(ifa, idev) {
12231224 i40iw_debug(&iwdev->sc_dev, I40IW_DEBUG_CM,
12241225 "IP=%pI4, vlan_id=%d, MAC=%pM\n", &ifa->ifa_address,
12251226 rdma_vlan_dev_vlan_id(dev), dev->dev_addr);
....@@ -1231,12 +1232,9 @@
12311232 true,
12321233 I40IW_ARP_ADD);
12331234 }
1234
- endfor_ifa(idev);
1235
- in_dev_put(idev);
12361235 }
12371236 }
1238
- if (got_lock)
1239
- rtnl_unlock();
1237
+ rcu_read_unlock();
12401238 }
12411239
12421240 /**
....@@ -1487,36 +1485,35 @@
14871485 iwdev->iw_status = 0;
14881486 i40iw_port_ibevent(iwdev);
14891487 i40iw_destroy_rdma_device(iwdev->iwibdev);
1490
- /* fallthrough */
1488
+ fallthrough;
14911489 case IP_ADDR_REGISTERED:
14921490 if (!iwdev->reset)
14931491 i40iw_del_macip_entry(iwdev, (u8)iwdev->mac_ip_table_idx);
1494
- /* fallthrough */
1495
- /* fallthrough */
1492
+ fallthrough;
14961493 case PBLE_CHUNK_MEM:
14971494 i40iw_destroy_pble_pool(dev, iwdev->pble_rsrc);
1498
- /* fallthrough */
1495
+ fallthrough;
14991496 case CEQ_CREATED:
15001497 i40iw_dele_ceqs(iwdev);
1501
- /* fallthrough */
1498
+ fallthrough;
15021499 case AEQ_CREATED:
15031500 i40iw_destroy_aeq(iwdev);
1504
- /* fallthrough */
1501
+ fallthrough;
15051502 case IEQ_CREATED:
15061503 i40iw_puda_dele_resources(&iwdev->vsi, I40IW_PUDA_RSRC_TYPE_IEQ, iwdev->reset);
1507
- /* fallthrough */
1504
+ fallthrough;
15081505 case ILQ_CREATED:
15091506 i40iw_puda_dele_resources(&iwdev->vsi, I40IW_PUDA_RSRC_TYPE_ILQ, iwdev->reset);
1510
- /* fallthrough */
1507
+ fallthrough;
15111508 case CCQ_CREATED:
15121509 i40iw_destroy_ccq(iwdev);
1513
- /* fallthrough */
1510
+ fallthrough;
15141511 case HMC_OBJS_CREATED:
15151512 i40iw_del_hmc_objects(dev, dev->hmc_info, true, iwdev->reset);
1516
- /* fallthrough */
1513
+ fallthrough;
15171514 case CQP_CREATED:
15181515 i40iw_destroy_cqp(iwdev, true);
1519
- /* fallthrough */
1516
+ fallthrough;
15201517 case INITIAL_STATE:
15211518 i40iw_cleanup_cm_core(&iwdev->cm_core);
15221519 if (iwdev->vsi.pestat) {
....@@ -1526,7 +1523,6 @@
15261523 i40iw_del_init_mem(iwdev);
15271524 break;
15281525 case INVALID_STATE:
1529
- /* fallthrough */
15301526 default:
15311527 i40iw_pr_err("bad init_state = %d\n", iwdev->init_state);
15321528 break;
....@@ -1573,7 +1569,7 @@
15731569 status = i40iw_save_msix_info(iwdev, ldev);
15741570 if (status)
15751571 return status;
1576
- iwdev->hw.dev_context = (void *)ldev->pcidev;
1572
+ iwdev->hw.pcidev = ldev->pcidev;
15771573 iwdev->hw.hw_addr = ldev->hw_addr;
15781574 status = i40iw_allocate_dma_mem(&iwdev->hw,
15791575 &iwdev->obj_mem, 8192, 4096);
....@@ -1636,7 +1632,10 @@
16361632 iwdev = &hdl->device;
16371633 iwdev->hdl = hdl;
16381634 dev = &iwdev->sc_dev;
1639
- i40iw_setup_cm_core(iwdev);
1635
+ if (i40iw_setup_cm_core(iwdev)) {
1636
+ kfree(iwdev->hdl);
1637
+ return -ENOMEM;
1638
+ }
16401639
16411640 dev->back_dev = (void *)iwdev;
16421641 iwdev->ldev = &hdl->ldev;
....@@ -1677,6 +1676,12 @@
16771676 status = i40iw_setup_ceqs(iwdev, ldev);
16781677 if (status)
16791678 break;
1679
+
1680
+ status = i40iw_get_rdma_features(dev);
1681
+ if (status)
1682
+ dev->feature_info[I40IW_FEATURE_FW_INFO] =
1683
+ I40IW_FW_VER_DEFAULT;
1684
+
16801685 iwdev->init_state = CEQ_CREATED;
16811686 status = i40iw_initialize_hw_resources(iwdev);
16821687 if (status)