hc
2023-12-09 b22da3d8526a935aa31e086e63f60ff3246cb61c
kernel/drivers/infiniband/hw/i40iw/i40iw_utils.c
....@@ -174,10 +174,14 @@
174174 rcu_read_lock();
175175 in = __in_dev_get_rcu(upper_dev);
176176
177
- if (!in->ifa_list)
178
- local_ipaddr = 0;
179
- else
180
- local_ipaddr = ntohl(in->ifa_list->ifa_address);
177
+ local_ipaddr = 0;
178
+ if (in) {
179
+ struct in_ifaddr *ifa;
180
+
181
+ ifa = rcu_dereference(in->ifa_list);
182
+ if (ifa)
183
+ local_ipaddr = ntohl(ifa->ifa_address);
184
+ }
181185
182186 rcu_read_unlock();
183187 } else {
....@@ -186,9 +190,8 @@
186190 switch (event) {
187191 case NETDEV_DOWN:
188192 action = I40IW_ARP_DELETE;
189
- /* Fall through */
193
+ fallthrough;
190194 case NETDEV_UP:
191
- /* Fall through */
192195 case NETDEV_CHANGEADDR:
193196
194197 /* Just skip if no need to handle ARP cache */
....@@ -243,9 +246,8 @@
243246 switch (event) {
244247 case NETDEV_DOWN:
245248 action = I40IW_ARP_DELETE;
246
- /* Fall through */
249
+ fallthrough;
247250 case NETDEV_UP:
248
- /* Fall through */
249251 case NETDEV_CHANGEADDR:
250252 i40iw_manage_arp_cache(iwdev,
251253 netdev->dev_addr,
....@@ -340,7 +342,7 @@
340342 switch (event) {
341343 case NETDEV_DOWN:
342344 iwdev->iw_status = 0;
343
- /* Fall through */
345
+ fallthrough;
344346 case NETDEV_UP:
345347 i40iw_port_ibevent(iwdev);
346348 break;
....@@ -476,25 +478,6 @@
476478 }
477479
478480 /**
479
- * i40iw_free_qp - callback after destroy cqp completes
480
- * @cqp_request: cqp request for destroy qp
481
- * @num: not used
482
- */
483
-static void i40iw_free_qp(struct i40iw_cqp_request *cqp_request, u32 num)
484
-{
485
- struct i40iw_sc_qp *qp = (struct i40iw_sc_qp *)cqp_request->param;
486
- struct i40iw_qp *iwqp = (struct i40iw_qp *)qp->back_qp;
487
- struct i40iw_device *iwdev;
488
- u32 qp_num = iwqp->ibqp.qp_num;
489
-
490
- iwdev = iwqp->iwdev;
491
-
492
- i40iw_rem_pdusecount(iwqp->iwpd, iwdev);
493
- i40iw_free_qp_resources(iwdev, iwqp, qp_num);
494
- i40iw_rem_devusecount(iwdev);
495
-}
496
-
497
-/**
498481 * i40iw_wait_event - wait for completion
499482 * @iwdev: iwarp device
500483 * @cqp_request: cqp request to wait
....@@ -611,30 +594,26 @@
611594 if (!atomic_dec_and_test(&iwpd->usecount))
612595 return;
613596 i40iw_free_resource(iwdev, iwdev->allocated_pds, iwpd->sc_pd.pd_id);
614
- kfree(iwpd);
615597 }
616598
617599 /**
618
- * i40iw_add_ref - add refcount for qp
600
+ * i40iw_qp_add_ref - add refcount for qp
619601 * @ibqp: iqarp qp
620602 */
621
-void i40iw_add_ref(struct ib_qp *ibqp)
603
+void i40iw_qp_add_ref(struct ib_qp *ibqp)
622604 {
623605 struct i40iw_qp *iwqp = (struct i40iw_qp *)ibqp;
624606
625
- atomic_inc(&iwqp->refcount);
607
+ refcount_inc(&iwqp->refcount);
626608 }
627609
628610 /**
629
- * i40iw_rem_ref - rem refcount for qp and free if 0
611
+ * i40iw_qp_rem_ref - rem refcount for qp and free if 0
630612 * @ibqp: iqarp qp
631613 */
632
-void i40iw_rem_ref(struct ib_qp *ibqp)
614
+void i40iw_qp_rem_ref(struct ib_qp *ibqp)
633615 {
634616 struct i40iw_qp *iwqp;
635
- enum i40iw_status_code status;
636
- struct i40iw_cqp_request *cqp_request;
637
- struct cqp_commands_info *cqp_info;
638617 struct i40iw_device *iwdev;
639618 u32 qp_num;
640619 unsigned long flags;
....@@ -642,7 +621,7 @@
642621 iwqp = to_iwqp(ibqp);
643622 iwdev = iwqp->iwdev;
644623 spin_lock_irqsave(&iwdev->qptable_lock, flags);
645
- if (!atomic_dec_and_test(&iwqp->refcount)) {
624
+ if (!refcount_dec_and_test(&iwqp->refcount)) {
646625 spin_unlock_irqrestore(&iwdev->qptable_lock, flags);
647626 return;
648627 }
....@@ -650,25 +629,8 @@
650629 qp_num = iwqp->ibqp.qp_num;
651630 iwdev->qp_table[qp_num] = NULL;
652631 spin_unlock_irqrestore(&iwdev->qptable_lock, flags);
653
- cqp_request = i40iw_get_cqp_request(&iwdev->cqp, false);
654
- if (!cqp_request)
655
- return;
632
+ complete(&iwqp->free_qp);
656633
657
- cqp_request->callback_fcn = i40iw_free_qp;
658
- cqp_request->param = (void *)&iwqp->sc_qp;
659
- cqp_info = &cqp_request->info;
660
- cqp_info->cqp_cmd = OP_QP_DESTROY;
661
- cqp_info->post_sq = 1;
662
- cqp_info->in.u.qp_destroy.qp = &iwqp->sc_qp;
663
- cqp_info->in.u.qp_destroy.scratch = (uintptr_t)cqp_request;
664
- cqp_info->in.u.qp_destroy.remove_hash_idx = true;
665
- status = i40iw_handle_cqp_op(iwdev, cqp_request);
666
- if (!status)
667
- return;
668
-
669
- i40iw_rem_pdusecount(iwqp->iwpd, iwdev);
670
- i40iw_free_qp_resources(iwdev, iwqp, qp_num);
671
- i40iw_rem_devusecount(iwdev);
672634 }
673635
674636 /**
....@@ -750,13 +712,13 @@
750712 u64 size,
751713 u32 alignment)
752714 {
753
- struct pci_dev *pcidev = (struct pci_dev *)hw->dev_context;
715
+ struct pci_dev *pcidev = hw->pcidev;
754716
755717 if (!mem)
756718 return I40IW_ERR_PARAM;
757719 mem->size = ALIGN(size, alignment);
758
- mem->va = dma_zalloc_coherent(&pcidev->dev, mem->size,
759
- (dma_addr_t *)&mem->pa, GFP_KERNEL);
720
+ mem->va = dma_alloc_coherent(&pcidev->dev, mem->size,
721
+ (dma_addr_t *)&mem->pa, GFP_KERNEL);
760722 if (!mem->va)
761723 return I40IW_ERR_NO_MEMORY;
762724 return 0;
....@@ -769,7 +731,7 @@
769731 */
770732 void i40iw_free_dma_mem(struct i40iw_hw *hw, struct i40iw_dma_mem *mem)
771733 {
772
- struct pci_dev *pcidev = (struct pci_dev *)hw->dev_context;
734
+ struct pci_dev *pcidev = hw->pcidev;
773735
774736 if (!mem || !mem->va)
775737 return;
....@@ -935,7 +897,7 @@
935897 struct i40iw_sc_qp *qp = (struct i40iw_sc_qp *)&iwqp->sc_qp;
936898
937899 i40iw_terminate_done(qp, 1);
938
- i40iw_rem_ref(&iwqp->ibqp);
900
+ i40iw_qp_rem_ref(&iwqp->ibqp);
939901 }
940902
941903 /**
....@@ -947,7 +909,7 @@
947909 struct i40iw_qp *iwqp;
948910
949911 iwqp = (struct i40iw_qp *)qp->back_qp;
950
- i40iw_add_ref(&iwqp->ibqp);
912
+ i40iw_qp_add_ref(&iwqp->ibqp);
951913 timer_setup(&iwqp->terminate_timer, i40iw_terminate_timeout, 0);
952914 iwqp->terminate_timer.expires = jiffies + HZ;
953915 add_timer(&iwqp->terminate_timer);
....@@ -963,7 +925,7 @@
963925
964926 iwqp = (struct i40iw_qp *)qp->back_qp;
965927 if (del_timer(&iwqp->terminate_timer))
966
- i40iw_rem_ref(&iwqp->ibqp);
928
+ i40iw_qp_rem_ref(&iwqp->ibqp);
967929 }
968930
969931 /**