diff options
Diffstat (limited to 'arch/x86/kernel/cpu/intel_cacheinfo.c')
-rw-r--r-- | arch/x86/kernel/cpu/intel_cacheinfo.c | 63 |
1 files changed, 44 insertions, 19 deletions
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index da299eb85fc0..7293508d8f5c 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c | |||
@@ -147,7 +147,16 @@ struct _cpuid4_info { | |||
147 | union _cpuid4_leaf_ecx ecx; | 147 | union _cpuid4_leaf_ecx ecx; |
148 | unsigned long size; | 148 | unsigned long size; |
149 | unsigned long can_disable; | 149 | unsigned long can_disable; |
150 | cpumask_t shared_cpu_map; /* future?: only cpus/node is needed */ | 150 | DECLARE_BITMAP(shared_cpu_map, NR_CPUS); |
151 | }; | ||
152 | |||
153 | /* subset of above _cpuid4_info w/o shared_cpu_map */ | ||
154 | struct _cpuid4_info_regs { | ||
155 | union _cpuid4_leaf_eax eax; | ||
156 | union _cpuid4_leaf_ebx ebx; | ||
157 | union _cpuid4_leaf_ecx ecx; | ||
158 | unsigned long size; | ||
159 | unsigned long can_disable; | ||
151 | }; | 160 | }; |
152 | 161 | ||
153 | #ifdef CONFIG_PCI | 162 | #ifdef CONFIG_PCI |
@@ -278,7 +287,7 @@ amd_cpuid4(int leaf, union _cpuid4_leaf_eax *eax, | |||
278 | } | 287 | } |
279 | 288 | ||
280 | static void __cpuinit | 289 | static void __cpuinit |
281 | amd_check_l3_disable(int index, struct _cpuid4_info *this_leaf) | 290 | amd_check_l3_disable(int index, struct _cpuid4_info_regs *this_leaf) |
282 | { | 291 | { |
283 | if (index < 3) | 292 | if (index < 3) |
284 | return; | 293 | return; |
@@ -286,7 +295,8 @@ amd_check_l3_disable(int index, struct _cpuid4_info *this_leaf) | |||
286 | } | 295 | } |
287 | 296 | ||
288 | static int | 297 | static int |
289 | __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf) | 298 | __cpuinit cpuid4_cache_lookup_regs(int index, |
299 | struct _cpuid4_info_regs *this_leaf) | ||
290 | { | 300 | { |
291 | union _cpuid4_leaf_eax eax; | 301 | union _cpuid4_leaf_eax eax; |
292 | union _cpuid4_leaf_ebx ebx; | 302 | union _cpuid4_leaf_ebx ebx; |
@@ -314,6 +324,15 @@ __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf) | |||
314 | return 0; | 324 | return 0; |
315 | } | 325 | } |
316 | 326 | ||
327 | static int | ||
328 | __cpuinit cpuid4_cache_lookup(int index, struct _cpuid4_info *this_leaf) | ||
329 | { | ||
330 | struct _cpuid4_info_regs *leaf_regs = | ||
331 | (struct _cpuid4_info_regs *)this_leaf; | ||
332 | |||
333 | return cpuid4_cache_lookup_regs(index, leaf_regs); | ||
334 | } | ||
335 | |||
317 | static int __cpuinit find_num_cache_leaves(void) | 336 | static int __cpuinit find_num_cache_leaves(void) |
318 | { | 337 | { |
319 | unsigned int eax, ebx, ecx, edx; | 338 | unsigned int eax, ebx, ecx, edx; |
@@ -353,11 +372,10 @@ unsigned int __cpuinit init_intel_cacheinfo(struct cpuinfo_x86 *c) | |||
353 | * parameters cpuid leaf to find the cache details | 372 | * parameters cpuid leaf to find the cache details |
354 | */ | 373 | */ |
355 | for (i = 0; i < num_cache_leaves; i++) { | 374 | for (i = 0; i < num_cache_leaves; i++) { |
356 | struct _cpuid4_info this_leaf; | 375 | struct _cpuid4_info_regs this_leaf; |
357 | |||
358 | int retval; | 376 | int retval; |
359 | 377 | ||
360 | retval = cpuid4_cache_lookup(i, &this_leaf); | 378 | retval = cpuid4_cache_lookup_regs(i, &this_leaf); |
361 | if (retval >= 0) { | 379 | if (retval >= 0) { |
362 | switch(this_leaf.eax.split.level) { | 380 | switch(this_leaf.eax.split.level) { |
363 | case 1: | 381 | case 1: |
@@ -506,17 +524,20 @@ static void __cpuinit cache_shared_cpu_map_setup(unsigned int cpu, int index) | |||
506 | num_threads_sharing = 1 + this_leaf->eax.split.num_threads_sharing; | 524 | num_threads_sharing = 1 + this_leaf->eax.split.num_threads_sharing; |
507 | 525 | ||
508 | if (num_threads_sharing == 1) | 526 | if (num_threads_sharing == 1) |
509 | cpu_set(cpu, this_leaf->shared_cpu_map); | 527 | cpumask_set_cpu(cpu, to_cpumask(this_leaf->shared_cpu_map)); |
510 | else { | 528 | else { |
511 | index_msb = get_count_order(num_threads_sharing); | 529 | index_msb = get_count_order(num_threads_sharing); |
512 | 530 | ||
513 | for_each_online_cpu(i) { | 531 | for_each_online_cpu(i) { |
514 | if (cpu_data(i).apicid >> index_msb == | 532 | if (cpu_data(i).apicid >> index_msb == |
515 | c->apicid >> index_msb) { | 533 | c->apicid >> index_msb) { |
516 | cpu_set(i, this_leaf->shared_cpu_map); | 534 | cpumask_set_cpu(i, |
535 | to_cpumask(this_leaf->shared_cpu_map)); | ||
517 | if (i != cpu && per_cpu(cpuid4_info, i)) { | 536 | if (i != cpu && per_cpu(cpuid4_info, i)) { |
518 | sibling_leaf = CPUID4_INFO_IDX(i, index); | 537 | sibling_leaf = |
519 | cpu_set(cpu, sibling_leaf->shared_cpu_map); | 538 | CPUID4_INFO_IDX(i, index); |
539 | cpumask_set_cpu(cpu, to_cpumask( | ||
540 | sibling_leaf->shared_cpu_map)); | ||
520 | } | 541 | } |
521 | } | 542 | } |
522 | } | 543 | } |
@@ -528,9 +549,10 @@ static void __cpuinit cache_remove_shared_cpu_map(unsigned int cpu, int index) | |||
528 | int sibling; | 549 | int sibling; |
529 | 550 | ||
530 | this_leaf = CPUID4_INFO_IDX(cpu, index); | 551 | this_leaf = CPUID4_INFO_IDX(cpu, index); |
531 | for_each_cpu_mask_nr(sibling, this_leaf->shared_cpu_map) { | 552 | for_each_cpu(sibling, to_cpumask(this_leaf->shared_cpu_map)) { |
532 | sibling_leaf = CPUID4_INFO_IDX(sibling, index); | 553 | sibling_leaf = CPUID4_INFO_IDX(sibling, index); |
533 | cpu_clear(cpu, sibling_leaf->shared_cpu_map); | 554 | cpumask_clear_cpu(cpu, |
555 | to_cpumask(sibling_leaf->shared_cpu_map)); | ||
534 | } | 556 | } |
535 | } | 557 | } |
536 | #else | 558 | #else |
@@ -635,8 +657,9 @@ static ssize_t show_shared_cpu_map_func(struct _cpuid4_info *this_leaf, | |||
635 | int n = 0; | 657 | int n = 0; |
636 | 658 | ||
637 | if (len > 1) { | 659 | if (len > 1) { |
638 | cpumask_t *mask = &this_leaf->shared_cpu_map; | 660 | const struct cpumask *mask; |
639 | 661 | ||
662 | mask = to_cpumask(this_leaf->shared_cpu_map); | ||
640 | n = type? | 663 | n = type? |
641 | cpulist_scnprintf(buf, len-2, mask) : | 664 | cpulist_scnprintf(buf, len-2, mask) : |
642 | cpumask_scnprintf(buf, len-2, mask); | 665 | cpumask_scnprintf(buf, len-2, mask); |
@@ -699,7 +722,8 @@ static struct pci_dev *get_k8_northbridge(int node) | |||
699 | 722 | ||
700 | static ssize_t show_cache_disable(struct _cpuid4_info *this_leaf, char *buf) | 723 | static ssize_t show_cache_disable(struct _cpuid4_info *this_leaf, char *buf) |
701 | { | 724 | { |
702 | int node = cpu_to_node(first_cpu(this_leaf->shared_cpu_map)); | 725 | const struct cpumask *mask = to_cpumask(this_leaf->shared_cpu_map); |
726 | int node = cpu_to_node(cpumask_first(mask)); | ||
703 | struct pci_dev *dev = NULL; | 727 | struct pci_dev *dev = NULL; |
704 | ssize_t ret = 0; | 728 | ssize_t ret = 0; |
705 | int i; | 729 | int i; |
@@ -733,7 +757,8 @@ static ssize_t | |||
733 | store_cache_disable(struct _cpuid4_info *this_leaf, const char *buf, | 757 | store_cache_disable(struct _cpuid4_info *this_leaf, const char *buf, |
734 | size_t count) | 758 | size_t count) |
735 | { | 759 | { |
736 | int node = cpu_to_node(first_cpu(this_leaf->shared_cpu_map)); | 760 | const struct cpumask *mask = to_cpumask(this_leaf->shared_cpu_map); |
761 | int node = cpu_to_node(cpumask_first(mask)); | ||
737 | struct pci_dev *dev = NULL; | 762 | struct pci_dev *dev = NULL; |
738 | unsigned int ret, index, val; | 763 | unsigned int ret, index, val; |
739 | 764 | ||
@@ -878,7 +903,7 @@ err_out: | |||
878 | return -ENOMEM; | 903 | return -ENOMEM; |
879 | } | 904 | } |
880 | 905 | ||
881 | static cpumask_t cache_dev_map = CPU_MASK_NONE; | 906 | static DECLARE_BITMAP(cache_dev_map, NR_CPUS); |
882 | 907 | ||
883 | /* Add/Remove cache interface for CPU device */ | 908 | /* Add/Remove cache interface for CPU device */ |
884 | static int __cpuinit cache_add_dev(struct sys_device * sys_dev) | 909 | static int __cpuinit cache_add_dev(struct sys_device * sys_dev) |
@@ -918,7 +943,7 @@ static int __cpuinit cache_add_dev(struct sys_device * sys_dev) | |||
918 | } | 943 | } |
919 | kobject_uevent(&(this_object->kobj), KOBJ_ADD); | 944 | kobject_uevent(&(this_object->kobj), KOBJ_ADD); |
920 | } | 945 | } |
921 | cpu_set(cpu, cache_dev_map); | 946 | cpumask_set_cpu(cpu, to_cpumask(cache_dev_map)); |
922 | 947 | ||
923 | kobject_uevent(per_cpu(cache_kobject, cpu), KOBJ_ADD); | 948 | kobject_uevent(per_cpu(cache_kobject, cpu), KOBJ_ADD); |
924 | return 0; | 949 | return 0; |
@@ -931,9 +956,9 @@ static void __cpuinit cache_remove_dev(struct sys_device * sys_dev) | |||
931 | 956 | ||
932 | if (per_cpu(cpuid4_info, cpu) == NULL) | 957 | if (per_cpu(cpuid4_info, cpu) == NULL) |
933 | return; | 958 | return; |
934 | if (!cpu_isset(cpu, cache_dev_map)) | 959 | if (!cpumask_test_cpu(cpu, to_cpumask(cache_dev_map))) |
935 | return; | 960 | return; |
936 | cpu_clear(cpu, cache_dev_map); | 961 | cpumask_clear_cpu(cpu, to_cpumask(cache_dev_map)); |
937 | 962 | ||
938 | for (i = 0; i < num_cache_leaves; i++) | 963 | for (i = 0; i < num_cache_leaves; i++) |
939 | kobject_put(&(INDEX_KOBJECT_PTR(cpu,i)->kobj)); | 964 | kobject_put(&(INDEX_KOBJECT_PTR(cpu,i)->kobj)); |