@@ -59,9 +59,8 @@ struct target_cache {
59
59
};
60
60
61
61
enum {
62
- NODE_ACCESS_CLASS_0 = 0 ,
63
- NODE_ACCESS_CLASS_1 ,
64
- NODE_ACCESS_CLASS_GENPORT_SINK ,
62
+ NODE_ACCESS_CLASS_GENPORT_SINK_LOCAL = ACCESS_COORDINATE_MAX ,
63
+ NODE_ACCESS_CLASS_GENPORT_SINK_CPU ,
65
64
NODE_ACCESS_CLASS_MAX ,
66
65
};
67
66
@@ -75,6 +74,7 @@ struct memory_target {
75
74
struct node_cache_attrs cache_attrs ;
76
75
u8 gen_port_device_handle [ACPI_SRAT_DEVICE_HANDLE_SIZE ];
77
76
bool registered ;
77
+ bool ext_updated ; /* externally updated */
78
78
};
79
79
80
80
struct memory_initiator {
@@ -127,7 +127,8 @@ static struct memory_target *acpi_find_genport_target(u32 uid)
127
127
/**
128
128
* acpi_get_genport_coordinates - Retrieve the access coordinates for a generic port
129
129
* @uid: ACPI unique id
130
- * @coord: The access coordinates written back out for the generic port
130
+ * @coord: The access coordinates written back out for the generic port.
131
+ * Expect 2 levels array.
131
132
*
132
133
* Return: 0 on success. Errno on failure.
133
134
*
@@ -143,7 +144,10 @@ int acpi_get_genport_coordinates(u32 uid,
143
144
if (!target )
144
145
return - ENOENT ;
145
146
146
- * coord = target -> coord [NODE_ACCESS_CLASS_GENPORT_SINK ];
147
+ coord [ACCESS_COORDINATE_LOCAL ] =
148
+ target -> coord [NODE_ACCESS_CLASS_GENPORT_SINK_LOCAL ];
149
+ coord [ACCESS_COORDINATE_CPU ] =
150
+ target -> coord [NODE_ACCESS_CLASS_GENPORT_SINK_CPU ];
147
151
148
152
return 0 ;
149
153
}
@@ -325,6 +329,35 @@ static void hmat_update_target_access(struct memory_target *target,
325
329
}
326
330
}
327
331
332
+ int hmat_update_target_coordinates (int nid , struct access_coordinate * coord ,
333
+ enum access_coordinate_class access )
334
+ {
335
+ struct memory_target * target ;
336
+ int pxm ;
337
+
338
+ if (nid == NUMA_NO_NODE )
339
+ return - EINVAL ;
340
+
341
+ pxm = node_to_pxm (nid );
342
+ guard (mutex )(& target_lock );
343
+ target = find_mem_target (pxm );
344
+ if (!target )
345
+ return - ENODEV ;
346
+
347
+ hmat_update_target_access (target , ACPI_HMAT_READ_LATENCY ,
348
+ coord -> read_latency , access );
349
+ hmat_update_target_access (target , ACPI_HMAT_WRITE_LATENCY ,
350
+ coord -> write_latency , access );
351
+ hmat_update_target_access (target , ACPI_HMAT_READ_BANDWIDTH ,
352
+ coord -> read_bandwidth , access );
353
+ hmat_update_target_access (target , ACPI_HMAT_WRITE_BANDWIDTH ,
354
+ coord -> write_bandwidth , access );
355
+ target -> ext_updated = true;
356
+
357
+ return 0 ;
358
+ }
359
+ EXPORT_SYMBOL_GPL (hmat_update_target_coordinates );
360
+
328
361
static __init void hmat_add_locality (struct acpi_hmat_locality * hmat_loc )
329
362
{
330
363
struct memory_locality * loc ;
@@ -374,11 +407,11 @@ static __init void hmat_update_target(unsigned int tgt_pxm, unsigned int init_px
374
407
375
408
if (target && target -> processor_pxm == init_pxm ) {
376
409
hmat_update_target_access (target , type , value ,
377
- NODE_ACCESS_CLASS_0 );
410
+ ACCESS_COORDINATE_LOCAL );
378
411
/* If the node has a CPU, update access 1 */
379
412
if (node_state (pxm_to_node (init_pxm ), N_CPU ))
380
413
hmat_update_target_access (target , type , value ,
381
- NODE_ACCESS_CLASS_1 );
414
+ ACCESS_COORDINATE_CPU );
382
415
}
383
416
}
384
417
@@ -696,8 +729,13 @@ static void hmat_update_target_attrs(struct memory_target *target,
696
729
u32 best = 0 ;
697
730
int i ;
698
731
732
+ /* Don't update if an external agent has changed the data. */
733
+ if (target -> ext_updated )
734
+ return ;
735
+
699
736
/* Don't update for generic port if there's no device handle */
700
- if (access == NODE_ACCESS_CLASS_GENPORT_SINK &&
737
+ if ((access == NODE_ACCESS_CLASS_GENPORT_SINK_LOCAL ||
738
+ access == NODE_ACCESS_CLASS_GENPORT_SINK_CPU ) &&
701
739
!(* (u16 * )target -> gen_port_device_handle ))
702
740
return ;
703
741
@@ -709,7 +747,8 @@ static void hmat_update_target_attrs(struct memory_target *target,
709
747
*/
710
748
if (target -> processor_pxm != PXM_INVAL ) {
711
749
cpu_nid = pxm_to_node (target -> processor_pxm );
712
- if (access == 0 || node_state (cpu_nid , N_CPU )) {
750
+ if (access == ACCESS_COORDINATE_LOCAL ||
751
+ node_state (cpu_nid , N_CPU )) {
713
752
set_bit (target -> processor_pxm , p_nodes );
714
753
return ;
715
754
}
@@ -737,7 +776,9 @@ static void hmat_update_target_attrs(struct memory_target *target,
737
776
list_for_each_entry (initiator , & initiators , node ) {
738
777
u32 value ;
739
778
740
- if (access == 1 && !initiator -> has_cpu ) {
779
+ if ((access == ACCESS_COORDINATE_CPU ||
780
+ access == NODE_ACCESS_CLASS_GENPORT_SINK_CPU ) &&
781
+ !initiator -> has_cpu ) {
741
782
clear_bit (initiator -> processor_pxm , p_nodes );
742
783
continue ;
743
784
}
@@ -770,20 +811,24 @@ static void __hmat_register_target_initiators(struct memory_target *target,
770
811
}
771
812
}
772
813
773
- static void hmat_register_generic_target_initiators (struct memory_target * target )
814
+ static void hmat_update_generic_target (struct memory_target * target )
774
815
{
775
816
static DECLARE_BITMAP (p_nodes , MAX_NUMNODES );
776
817
777
- __hmat_register_target_initiators (target , p_nodes ,
778
- NODE_ACCESS_CLASS_GENPORT_SINK );
818
+ hmat_update_target_attrs (target , p_nodes ,
819
+ NODE_ACCESS_CLASS_GENPORT_SINK_LOCAL );
820
+ hmat_update_target_attrs (target , p_nodes ,
821
+ NODE_ACCESS_CLASS_GENPORT_SINK_CPU );
779
822
}
780
823
781
824
static void hmat_register_target_initiators (struct memory_target * target )
782
825
{
783
826
static DECLARE_BITMAP (p_nodes , MAX_NUMNODES );
784
827
785
- __hmat_register_target_initiators (target , p_nodes , 0 );
786
- __hmat_register_target_initiators (target , p_nodes , 1 );
828
+ __hmat_register_target_initiators (target , p_nodes ,
829
+ ACCESS_COORDINATE_LOCAL );
830
+ __hmat_register_target_initiators (target , p_nodes ,
831
+ ACCESS_COORDINATE_CPU );
787
832
}
788
833
789
834
static void hmat_register_target_cache (struct memory_target * target )
@@ -835,7 +880,7 @@ static void hmat_register_target(struct memory_target *target)
835
880
*/
836
881
mutex_lock (& target_lock );
837
882
if (* (u16 * )target -> gen_port_device_handle ) {
838
- hmat_register_generic_target_initiators (target );
883
+ hmat_update_generic_target (target );
839
884
target -> registered = true;
840
885
}
841
886
mutex_unlock (& target_lock );
@@ -854,8 +899,8 @@ static void hmat_register_target(struct memory_target *target)
854
899
if (!target -> registered ) {
855
900
hmat_register_target_initiators (target );
856
901
hmat_register_target_cache (target );
857
- hmat_register_target_perf (target , NODE_ACCESS_CLASS_0 );
858
- hmat_register_target_perf (target , NODE_ACCESS_CLASS_1 );
902
+ hmat_register_target_perf (target , ACCESS_COORDINATE_LOCAL );
903
+ hmat_register_target_perf (target , ACCESS_COORDINATE_CPU );
859
904
target -> registered = true;
860
905
}
861
906
mutex_unlock (& target_lock );
@@ -927,7 +972,7 @@ static int hmat_calculate_adistance(struct notifier_block *self,
927
972
return NOTIFY_OK ;
928
973
929
974
mutex_lock (& target_lock );
930
- hmat_update_target_attrs (target , p_nodes , 1 );
975
+ hmat_update_target_attrs (target , p_nodes , ACCESS_COORDINATE_CPU );
931
976
mutex_unlock (& target_lock );
932
977
933
978
perf = & target -> coord [1 ];
0 commit comments