@@ -632,22 +632,11 @@ static void _dev_comp_vect_cpu_mask_clean_up(struct hfi1_devdata *dd,
632632 */
633633int hfi1_dev_affinity_init (struct hfi1_devdata * dd )
634634{
635- int node = pcibus_to_node (dd -> pcidev -> bus );
636635 struct hfi1_affinity_node * entry ;
637636 const struct cpumask * local_mask ;
638637 int curr_cpu , possible , i , ret ;
639638 bool new_entry = false;
640639
641- /*
642- * If the BIOS does not have the NUMA node information set, select
643- * NUMA 0 so we get consistent performance.
644- */
645- if (node < 0 ) {
646- dd_dev_err (dd , "Invalid PCI NUMA node. Performance may be affected\n" );
647- node = 0 ;
648- }
649- dd -> node = node ;
650-
651640 local_mask = cpumask_of_node (dd -> node );
652641 if (cpumask_first (local_mask ) >= nr_cpu_ids )
653642 local_mask = topology_core_cpumask (0 );
@@ -660,7 +649,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)
660649 * create an entry in the global affinity structure and initialize it.
661650 */
662651 if (!entry ) {
663- entry = node_affinity_allocate (node );
652+ entry = node_affinity_allocate (dd -> node );
664653 if (!entry ) {
665654 dd_dev_err (dd ,
666655 "Unable to allocate global affinity node\n" );
@@ -751,6 +740,7 @@ int hfi1_dev_affinity_init(struct hfi1_devdata *dd)
751740 if (new_entry )
752741 node_affinity_add_tail (entry );
753742
743+ dd -> affinity_entry = entry ;
754744 mutex_unlock (& node_affinity .lock );
755745
756746 return 0 ;
@@ -766,10 +756,9 @@ void hfi1_dev_affinity_clean_up(struct hfi1_devdata *dd)
766756{
767757 struct hfi1_affinity_node * entry ;
768758
769- if (dd -> node < 0 )
770- return ;
771-
772759 mutex_lock (& node_affinity .lock );
760+ if (!dd -> affinity_entry )
761+ goto unlock ;
773762 entry = node_affinity_lookup (dd -> node );
774763 if (!entry )
775764 goto unlock ;
@@ -780,8 +769,8 @@ void hfi1_dev_affinity_clean_up(struct hfi1_devdata *dd)
780769 */
781770 _dev_comp_vect_cpu_mask_clean_up (dd , entry );
782771unlock :
772+ dd -> affinity_entry = NULL ;
783773 mutex_unlock (& node_affinity .lock );
784- dd -> node = NUMA_NO_NODE ;
785774}
786775
787776/*
0 commit comments