diff options
Diffstat (limited to 'arch/ia64/kernel/smpboot.c')
| -rw-r--r-- | arch/ia64/kernel/smpboot.c | 206 |
1 files changed, 206 insertions, 0 deletions
diff --git a/arch/ia64/kernel/smpboot.c b/arch/ia64/kernel/smpboot.c index dbc6b610cc64..0d5ee57c9865 100644 --- a/arch/ia64/kernel/smpboot.c +++ b/arch/ia64/kernel/smpboot.c | |||
| @@ -3,6 +3,11 @@ | |||
| 3 | * | 3 | * |
| 4 | * Copyright (C) 1998-2003, 2005 Hewlett-Packard Co | 4 | * Copyright (C) 1998-2003, 2005 Hewlett-Packard Co |
| 5 | * David Mosberger-Tang <davidm@hpl.hp.com> | 5 | * David Mosberger-Tang <davidm@hpl.hp.com> |
| 6 | * Copyright (C) 2001, 2004-2005 Intel Corp | ||
| 7 | * Rohit Seth <rohit.seth@intel.com> | ||
| 8 | * Suresh Siddha <suresh.b.siddha@intel.com> | ||
| 9 | * Gordon Jin <gordon.jin@intel.com> | ||
| 10 | * Ashok Raj <ashok.raj@intel.com> | ||
| 6 | * | 11 | * |
| 7 | * 01/05/16 Rohit Seth <rohit.seth@intel.com> Moved SMP booting functions from smp.c to here. | 12 | * 01/05/16 Rohit Seth <rohit.seth@intel.com> Moved SMP booting functions from smp.c to here. |
| 8 | * 01/04/27 David Mosberger <davidm@hpl.hp.com> Added ITC synching code. | 13 | * 01/04/27 David Mosberger <davidm@hpl.hp.com> Added ITC synching code. |
| @@ -10,6 +15,11 @@ | |||
| 10 | * smp_boot_cpus()/smp_commence() is replaced by | 15 | * smp_boot_cpus()/smp_commence() is replaced by |
| 11 | * smp_prepare_cpus()/__cpu_up()/smp_cpus_done(). | 16 | * smp_prepare_cpus()/__cpu_up()/smp_cpus_done(). |
| 12 | * 04/06/21 Ashok Raj <ashok.raj@intel.com> Added CPU Hotplug Support | 17 | * 04/06/21 Ashok Raj <ashok.raj@intel.com> Added CPU Hotplug Support |
| 18 | * 04/12/26 Jin Gordon <gordon.jin@intel.com> | ||
| 19 | * 04/12/26 Rohit Seth <rohit.seth@intel.com> | ||
| 20 | * Add multi-threading and multi-core detection | ||
| 21 | * 05/01/30 Suresh Siddha <suresh.b.siddha@intel.com> | ||
| 22 | * Setup cpu_sibling_map and cpu_core_map | ||
| 13 | */ | 23 | */ |
| 14 | #include <linux/config.h> | 24 | #include <linux/config.h> |
| 15 | 25 | ||
| @@ -122,6 +132,11 @@ EXPORT_SYMBOL(cpu_online_map); | |||
| 122 | cpumask_t cpu_possible_map; | 132 | cpumask_t cpu_possible_map; |
| 123 | EXPORT_SYMBOL(cpu_possible_map); | 133 | EXPORT_SYMBOL(cpu_possible_map); |
| 124 | 134 | ||
| 135 | cpumask_t cpu_core_map[NR_CPUS] __cacheline_aligned; | ||
| 136 | cpumask_t cpu_sibling_map[NR_CPUS] __cacheline_aligned; | ||
| 137 | int smp_num_siblings = 1; | ||
| 138 | int smp_num_cpucores = 1; | ||
| 139 | |||
| 125 | /* which logical CPU number maps to which CPU (physical APIC ID) */ | 140 | /* which logical CPU number maps to which CPU (physical APIC ID) */ |
| 126 | volatile int ia64_cpu_to_sapicid[NR_CPUS]; | 141 | volatile int ia64_cpu_to_sapicid[NR_CPUS]; |
| 127 | EXPORT_SYMBOL(ia64_cpu_to_sapicid); | 142 | EXPORT_SYMBOL(ia64_cpu_to_sapicid); |
| @@ -598,7 +613,68 @@ void __devinit smp_prepare_boot_cpu(void) | |||
| 598 | cpu_set(smp_processor_id(), cpu_callin_map); | 613 | cpu_set(smp_processor_id(), cpu_callin_map); |
| 599 | } | 614 | } |
| 600 | 615 | ||
| 616 | /* | ||
| 617 | * mt_info[] is a temporary store for all info returned by | ||
| 618 | * PAL_LOGICAL_TO_PHYSICAL, to be copied into cpuinfo_ia64 when the | ||
| 619 | * specific cpu comes. | ||
| 620 | */ | ||
| 621 | static struct { | ||
| 622 | __u32 socket_id; | ||
| 623 | __u16 core_id; | ||
| 624 | __u16 thread_id; | ||
| 625 | __u16 proc_fixed_addr; | ||
| 626 | __u8 valid; | ||
| 627 | }mt_info[NR_CPUS] __devinit; | ||
| 628 | |||
| 601 | #ifdef CONFIG_HOTPLUG_CPU | 629 | #ifdef CONFIG_HOTPLUG_CPU |
| 630 | static inline void | ||
| 631 | remove_from_mtinfo(int cpu) | ||
| 632 | { | ||
| 633 | int i; | ||
| 634 | |||
| 635 | for_each_cpu(i) | ||
| 636 | if (mt_info[i].valid && mt_info[i].socket_id == | ||
| 637 | cpu_data(cpu)->socket_id) | ||
| 638 | mt_info[i].valid = 0; | ||
| 639 | } | ||
| 640 | |||
| 641 | static inline void | ||
| 642 | clear_cpu_sibling_map(int cpu) | ||
| 643 | { | ||
| 644 | int i; | ||
| 645 | |||
| 646 | for_each_cpu_mask(i, cpu_sibling_map[cpu]) | ||
| 647 | cpu_clear(cpu, cpu_sibling_map[i]); | ||
| 648 | for_each_cpu_mask(i, cpu_core_map[cpu]) | ||
| 649 | cpu_clear(cpu, cpu_core_map[i]); | ||
| 650 | |||
| 651 | cpu_sibling_map[cpu] = cpu_core_map[cpu] = CPU_MASK_NONE; | ||
| 652 | } | ||
| 653 | |||
| 654 | static void | ||
| 655 | remove_siblinginfo(int cpu) | ||
| 656 | { | ||
| 657 | int last = 0; | ||
| 658 | |||
| 659 | if (cpu_data(cpu)->threads_per_core == 1 && | ||
| 660 | cpu_data(cpu)->cores_per_socket == 1) { | ||
| 661 | cpu_clear(cpu, cpu_core_map[cpu]); | ||
| 662 | cpu_clear(cpu, cpu_sibling_map[cpu]); | ||
| 663 | return; | ||
| 664 | } | ||
| 665 | |||
| 666 | last = (cpus_weight(cpu_core_map[cpu]) == 1 ? 1 : 0); | ||
| 667 | |||
| 668 | /* remove it from all sibling map's */ | ||
| 669 | clear_cpu_sibling_map(cpu); | ||
| 670 | |||
| 671 | /* if this cpu is the last in the core group, remove all its info | ||
| 672 | * from mt_info structure | ||
| 673 | */ | ||
| 674 | if (last) | ||
| 675 | remove_from_mtinfo(cpu); | ||
| 676 | } | ||
| 677 | |||
| 602 | extern void fixup_irqs(void); | 678 | extern void fixup_irqs(void); |
| 603 | /* must be called with cpucontrol mutex held */ | 679 | /* must be called with cpucontrol mutex held */ |
| 604 | int __cpu_disable(void) | 680 | int __cpu_disable(void) |
| @@ -611,6 +687,7 @@ int __cpu_disable(void) | |||
| 611 | if (cpu == 0) | 687 | if (cpu == 0) |
| 612 | return -EBUSY; | 688 | return -EBUSY; |
| 613 | 689 | ||
| 690 | remove_siblinginfo(cpu); | ||
| 614 | fixup_irqs(); | 691 | fixup_irqs(); |
| 615 | local_flush_tlb_all(); | 692 | local_flush_tlb_all(); |
| 616 | cpu_clear(cpu, cpu_callin_map); | 693 | cpu_clear(cpu, cpu_callin_map); |
| @@ -663,6 +740,23 @@ smp_cpus_done (unsigned int dummy) | |||
| 663 | (int)num_online_cpus(), bogosum/(500000/HZ), (bogosum/(5000/HZ))%100); | 740 | (int)num_online_cpus(), bogosum/(500000/HZ), (bogosum/(5000/HZ))%100); |
| 664 | } | 741 | } |
| 665 | 742 | ||
| 743 | static inline void __devinit | ||
| 744 | set_cpu_sibling_map(int cpu) | ||
| 745 | { | ||
| 746 | int i; | ||
| 747 | |||
| 748 | for_each_online_cpu(i) { | ||
| 749 | if ((cpu_data(cpu)->socket_id == cpu_data(i)->socket_id)) { | ||
| 750 | cpu_set(i, cpu_core_map[cpu]); | ||
| 751 | cpu_set(cpu, cpu_core_map[i]); | ||
| 752 | if (cpu_data(cpu)->core_id == cpu_data(i)->core_id) { | ||
| 753 | cpu_set(i, cpu_sibling_map[cpu]); | ||
| 754 | cpu_set(cpu, cpu_sibling_map[i]); | ||
| 755 | } | ||
| 756 | } | ||
| 757 | } | ||
| 758 | } | ||
| 759 | |||
| 666 | int __devinit | 760 | int __devinit |
| 667 | __cpu_up (unsigned int cpu) | 761 | __cpu_up (unsigned int cpu) |
| 668 | { | 762 | { |
| @@ -685,6 +779,15 @@ __cpu_up (unsigned int cpu) | |||
| 685 | if (ret < 0) | 779 | if (ret < 0) |
| 686 | return ret; | 780 | return ret; |
| 687 | 781 | ||
| 782 | if (cpu_data(cpu)->threads_per_core == 1 && | ||
| 783 | cpu_data(cpu)->cores_per_socket == 1) { | ||
| 784 | cpu_set(cpu, cpu_sibling_map[cpu]); | ||
| 785 | cpu_set(cpu, cpu_core_map[cpu]); | ||
| 786 | return 0; | ||
| 787 | } | ||
| 788 | |||
| 789 | set_cpu_sibling_map(cpu); | ||
| 790 | |||
| 688 | return 0; | 791 | return 0; |
| 689 | } | 792 | } |
| 690 | 793 | ||
| @@ -712,3 +815,106 @@ init_smp_config(void) | |||
| 712 | ia64_sal_strerror(sal_ret)); | 815 | ia64_sal_strerror(sal_ret)); |
| 713 | } | 816 | } |
| 714 | 817 | ||
| 818 | static inline int __devinit | ||
| 819 | check_for_mtinfo_index(void) | ||
| 820 | { | ||
| 821 | int i; | ||
| 822 | |||
| 823 | for_each_cpu(i) | ||
| 824 | if (!mt_info[i].valid) | ||
| 825 | return i; | ||
| 826 | |||
| 827 | return -1; | ||
| 828 | } | ||
| 829 | |||
| 830 | /* | ||
| 831 | * Search the mt_info to find out if this socket's cid/tid information is | ||
| 832 | * cached or not. If the socket exists, fill in the core_id and thread_id | ||
| 833 | * in cpuinfo | ||
| 834 | */ | ||
| 835 | static int __devinit | ||
| 836 | check_for_new_socket(__u16 logical_address, struct cpuinfo_ia64 *c) | ||
| 837 | { | ||
| 838 | int i; | ||
| 839 | __u32 sid = c->socket_id; | ||
| 840 | |||
| 841 | for_each_cpu(i) { | ||
| 842 | if (mt_info[i].valid && mt_info[i].proc_fixed_addr == logical_address | ||
| 843 | && mt_info[i].socket_id == sid) { | ||
| 844 | c->core_id = mt_info[i].core_id; | ||
| 845 | c->thread_id = mt_info[i].thread_id; | ||
| 846 | return 1; /* not a new socket */ | ||
| 847 | } | ||
| 848 | } | ||
| 849 | return 0; | ||
| 850 | } | ||
| 851 | |||
| 852 | /* | ||
| 853 | * identify_siblings(cpu) gets called from identify_cpu. This populates the | ||
| 854 | * information related to logical execution units in per_cpu_data structure. | ||
| 855 | */ | ||
| 856 | void __devinit | ||
| 857 | identify_siblings(struct cpuinfo_ia64 *c) | ||
| 858 | { | ||
| 859 | s64 status; | ||
| 860 | u16 pltid; | ||
| 861 | u64 proc_fixed_addr; | ||
| 862 | int count, i; | ||
| 863 | pal_logical_to_physical_t info; | ||
| 864 | |||
| 865 | if (smp_num_cpucores == 1 && smp_num_siblings == 1) | ||
| 866 | return; | ||
| 867 | |||
| 868 | if ((status = ia64_pal_logical_to_phys(0, &info)) != PAL_STATUS_SUCCESS) { | ||
| 869 | printk(KERN_ERR "ia64_pal_logical_to_phys failed with %ld\n", | ||
| 870 | status); | ||
| 871 | return; | ||
| 872 | } | ||
| 873 | if ((status = ia64_sal_physical_id_info(&pltid)) != PAL_STATUS_SUCCESS) { | ||
| 874 | printk(KERN_ERR "ia64_sal_pltid failed with %ld\n", status); | ||
| 875 | return; | ||
| 876 | } | ||
| 877 | if ((status = ia64_pal_fixed_addr(&proc_fixed_addr)) != PAL_STATUS_SUCCESS) { | ||
| 878 | printk(KERN_ERR "ia64_pal_fixed_addr failed with %ld\n", status); | ||
| 879 | return; | ||
| 880 | } | ||
| 881 | |||
| 882 | c->socket_id = (pltid << 8) | info.overview_ppid; | ||
| 883 | c->cores_per_socket = info.overview_cpp; | ||
| 884 | c->threads_per_core = info.overview_tpc; | ||
| 885 | count = c->num_log = info.overview_num_log; | ||
| 886 | |||
| 887 | /* If the thread and core id information is already cached, then | ||
| 888 | * we will simply update cpu_info and return. Otherwise, we will | ||
| 889 | * do the PAL calls and cache core and thread id's of all the siblings. | ||
| 890 | */ | ||
| 891 | if (check_for_new_socket(proc_fixed_addr, c)) | ||
| 892 | return; | ||
| 893 | |||
| 894 | for (i = 0; i < count; i++) { | ||
| 895 | int index; | ||
| 896 | |||
| 897 | if (i && (status = ia64_pal_logical_to_phys(i, &info)) | ||
| 898 | != PAL_STATUS_SUCCESS) { | ||
| 899 | printk(KERN_ERR "ia64_pal_logical_to_phys failed" | ||
| 900 | " with %ld\n", status); | ||
| 901 | return; | ||
| 902 | } | ||
| 903 | if (info.log2_la == proc_fixed_addr) { | ||
| 904 | c->core_id = info.log1_cid; | ||
| 905 | c->thread_id = info.log1_tid; | ||
| 906 | } | ||
| 907 | |||
| 908 | index = check_for_mtinfo_index(); | ||
| 909 | /* We will not do the mt_info caching optimization in this case. | ||
| 910 | */ | ||
| 911 | if (index < 0) | ||
| 912 | continue; | ||
| 913 | |||
| 914 | mt_info[index].valid = 1; | ||
| 915 | mt_info[index].socket_id = c->socket_id; | ||
| 916 | mt_info[index].core_id = info.log1_cid; | ||
| 917 | mt_info[index].thread_id = info.log1_tid; | ||
| 918 | mt_info[index].proc_fixed_addr = info.log2_la; | ||
| 919 | } | ||
| 920 | } | ||
