hc
2024-05-14 bedbef8ad3e75a304af6361af235302bcc61d06b
kernel/drivers/infiniband/hw/hfi1/affinity.c
....@@ -1,5 +1,5 @@
11 /*
2
- * Copyright(c) 2015 - 2018 Intel Corporation.
2
+ * Copyright(c) 2015 - 2020 Intel Corporation.
33 *
44 * This file is provided under a dual BSD/GPLv2 license. When using or
55 * redistributing this file, you may do so under either license.
....@@ -48,6 +48,7 @@
4848 #include <linux/cpumask.h>
4949 #include <linux/module.h>
5050 #include <linux/interrupt.h>
51
+#include <linux/numa.h>
5152
5253 #include "hfi.h"
5354 #include "affinity.h"
....@@ -63,6 +64,7 @@
6364 static const char * const irq_type_names[] = {
6465 "SDMA",
6566 "RCVCTXT",
67
+ "NETDEVCTXT",
6668 "GENERAL",
6769 "OTHER",
6870 };
....@@ -216,6 +218,8 @@
216218 pr_err("HFI: System BIOS may need to be upgraded\n");
217219 for (node = 0; node < node_affinity.num_possible_nodes; node++)
218220 hfi1_per_node_cntr[node] = 1;
221
+
222
+ pci_dev_put(dev);
219223
220224 return 0;
221225 }
....@@ -630,21 +634,10 @@
630634 */
631635 int hfi1_dev_affinity_init(struct hfi1_devdata *dd)
632636 {
633
- int node = pcibus_to_node(dd->pcidev->bus);
634637 struct hfi1_affinity_node *entry;
635638 const struct cpumask *local_mask;
636639 int curr_cpu, possible, i, ret;
637640 bool new_entry = false;
638
-
639
- /*
640
- * If the BIOS does not have the NUMA node information set, select
641
- * NUMA 0 so we get consistent performance.
642
- */
643
- if (node < 0) {
644
- dd_dev_err(dd, "Invalid PCI NUMA node. Performance may be affected\n");
645
- node = 0;
646
- }
647
- dd->node = node;
648641
649642 local_mask = cpumask_of_node(dd->node);
650643 if (cpumask_first(local_mask) >= nr_cpu_ids)
....@@ -658,7 +651,7 @@
658651 * create an entry in the global affinity structure and initialize it.
659652 */
660653 if (!entry) {
661
- entry = node_affinity_allocate(node);
654
+ entry = node_affinity_allocate(dd->node);
662655 if (!entry) {
663656 dd_dev_err(dd,
664657 "Unable to allocate global affinity node\n");
....@@ -749,6 +742,7 @@
749742 if (new_entry)
750743 node_affinity_add_tail(entry);
751744
745
+ dd->affinity_entry = entry;
752746 mutex_unlock(&node_affinity.lock);
753747
754748 return 0;
....@@ -764,10 +758,9 @@
764758 {
765759 struct hfi1_affinity_node *entry;
766760
767
- if (dd->node < 0)
768
- return;
769
-
770761 mutex_lock(&node_affinity.lock);
762
+ if (!dd->affinity_entry)
763
+ goto unlock;
771764 entry = node_affinity_lookup(dd->node);
772765 if (!entry)
773766 goto unlock;
....@@ -778,8 +771,8 @@
778771 */
779772 _dev_comp_vect_cpu_mask_clean_up(dd, entry);
780773 unlock:
774
+ dd->affinity_entry = NULL;
781775 mutex_unlock(&node_affinity.lock);
782
- dd->node = -1;
783776 }
784777
785778 /*
....@@ -819,10 +812,10 @@
819812 set = &entry->def_intr;
820813 cpumask_set_cpu(cpu, &set->mask);
821814 cpumask_set_cpu(cpu, &set->used);
822
- for (i = 0; i < dd->num_msix_entries; i++) {
815
+ for (i = 0; i < dd->msix_info.max_requested; i++) {
823816 struct hfi1_msix_entry *other_msix;
824817
825
- other_msix = &dd->msix_entries[i];
818
+ other_msix = &dd->msix_info.msix_entries[i];
826819 if (other_msix->type != IRQ_SDMA || other_msix == msix)
827820 continue;
828821
....@@ -914,6 +907,11 @@
914907 set = &entry->rcv_intr;
915908 scnprintf(extra, 64, "ctxt %u", rcd->ctxt);
916909 break;
910
+ case IRQ_NETDEVCTXT:
911
+ rcd = (struct hfi1_ctxtdata *)msix->arg;
912
+ set = &entry->def_intr;
913
+ scnprintf(extra, 64, "ctxt %u", rcd->ctxt);
914
+ break;
917915 default:
918916 dd_dev_err(dd, "Invalid IRQ type %d\n", msix->type);
919917 return -EINVAL;
....@@ -986,6 +984,10 @@
986984 if (rcd->ctxt != HFI1_CTRL_CTXT)
987985 set = &entry->rcv_intr;
988986 break;
987
+ case IRQ_NETDEVCTXT:
988
+ rcd = (struct hfi1_ctxtdata *)msix->arg;
989
+ set = &entry->def_intr;
990
+ break;
989991 default:
990992 mutex_unlock(&node_affinity.lock);
991993 return;