diff options
author | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2015-06-18 08:23:00 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2015-06-25 03:39:24 -0400 |
commit | d08d94306e9020fad18a5d079b88ba374784eef8 (patch) | |
tree | b121b154694d198ec6d240b48ffc84d44b4998e2 /arch/s390/kernel/smp.c | |
parent | e7086eb18119933753fceacfee662307b5e1d1c1 (diff) |
s390/smp: cleanup core vs. cpu in the SCLP interface
The SCLP interface to query, configure and deconfigure CPUs actually
operates on cores. For a machine without the multi-threading faciltiy
a CPU and a core are equivalent but starting with System z13 a core
can have multiple hardware threads, also referred to as logical CPUs.
To avoid confusion replace the word 'cpu' with 'core' in the SCLP
interface. Also replace MAX_CPU_ADDRESS with SCLP_MAX_CORES.
The core-id is an 8-bit field, the maximum thread id is in the range
0-31. The theoretical limit for the CPU address is therefore 8191.
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel/smp.c')
-rw-r--r-- | arch/s390/kernel/smp.c | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c index b3f1e9bb5e36..b34a1473df70 100644 --- a/arch/s390/kernel/smp.c +++ b/arch/s390/kernel/smp.c | |||
@@ -69,7 +69,7 @@ struct pcpu { | |||
69 | u16 address; /* physical cpu address */ | 69 | u16 address; /* physical cpu address */ |
70 | }; | 70 | }; |
71 | 71 | ||
72 | static u8 boot_cpu_type; | 72 | static u8 boot_core_type; |
73 | static struct pcpu pcpu_devices[NR_CPUS]; | 73 | static struct pcpu pcpu_devices[NR_CPUS]; |
74 | 74 | ||
75 | unsigned int smp_cpu_mt_shift; | 75 | unsigned int smp_cpu_mt_shift; |
@@ -589,7 +589,7 @@ static inline void __smp_store_cpu_state(int cpu, u16 address, int is_boot_cpu) | |||
589 | * old system. The ELF sections are picked up by the crash_dump code | 589 | * old system. The ELF sections are picked up by the crash_dump code |
590 | * via elfcorehdr_addr. | 590 | * via elfcorehdr_addr. |
591 | */ | 591 | */ |
592 | static void __init smp_store_cpu_states(struct sclp_cpu_info *info) | 592 | static void __init smp_store_cpu_states(struct sclp_core_info *info) |
593 | { | 593 | { |
594 | unsigned int cpu, address, i, j; | 594 | unsigned int cpu, address, i, j; |
595 | int is_boot_cpu; | 595 | int is_boot_cpu; |
@@ -606,10 +606,10 @@ static void __init smp_store_cpu_states(struct sclp_cpu_info *info) | |||
606 | cpu = 0; | 606 | cpu = 0; |
607 | for (i = 0; i < info->configured; i++) { | 607 | for (i = 0; i < info->configured; i++) { |
608 | /* Skip CPUs with different CPU type. */ | 608 | /* Skip CPUs with different CPU type. */ |
609 | if (info->has_cpu_type && info->cpu[i].type != boot_cpu_type) | 609 | if (sclp.has_core_type && info->core[i].type != boot_core_type) |
610 | continue; | 610 | continue; |
611 | for (j = 0; j <= smp_cpu_mtid; j++, cpu++) { | 611 | for (j = 0; j <= smp_cpu_mtid; j++, cpu++) { |
612 | address = (info->cpu[i].core_id << smp_cpu_mt_shift) + j; | 612 | address = (info->core[i].core_id << smp_cpu_mt_shift) + j; |
613 | is_boot_cpu = (address == pcpu_devices[0].address); | 613 | is_boot_cpu = (address == pcpu_devices[0].address); |
614 | if (is_boot_cpu && !OLDMEM_BASE) | 614 | if (is_boot_cpu && !OLDMEM_BASE) |
615 | /* Skip boot CPU for standard zfcp dump. */ | 615 | /* Skip boot CPU for standard zfcp dump. */ |
@@ -649,22 +649,22 @@ int smp_cpu_get_polarization(int cpu) | |||
649 | return pcpu_devices[cpu].polarization; | 649 | return pcpu_devices[cpu].polarization; |
650 | } | 650 | } |
651 | 651 | ||
652 | static struct sclp_cpu_info *smp_get_cpu_info(void) | 652 | static struct sclp_core_info *smp_get_core_info(void) |
653 | { | 653 | { |
654 | static int use_sigp_detection; | 654 | static int use_sigp_detection; |
655 | struct sclp_cpu_info *info; | 655 | struct sclp_core_info *info; |
656 | int address; | 656 | int address; |
657 | 657 | ||
658 | info = kzalloc(sizeof(*info), GFP_KERNEL); | 658 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
659 | if (info && (use_sigp_detection || sclp_get_cpu_info(info))) { | 659 | if (info && (use_sigp_detection || sclp_get_core_info(info))) { |
660 | use_sigp_detection = 1; | 660 | use_sigp_detection = 1; |
661 | for (address = 0; | 661 | for (address = 0; |
662 | address <= (MAX_CPU_ADDRESS << smp_cpu_mt_shift); | 662 | address < (SCLP_MAX_CORES << smp_cpu_mt_shift); |
663 | address += (1U << smp_cpu_mt_shift)) { | 663 | address += (1U << smp_cpu_mt_shift)) { |
664 | if (__pcpu_sigp_relax(address, SIGP_SENSE, 0, NULL) == | 664 | if (__pcpu_sigp_relax(address, SIGP_SENSE, 0, NULL) == |
665 | SIGP_CC_NOT_OPERATIONAL) | 665 | SIGP_CC_NOT_OPERATIONAL) |
666 | continue; | 666 | continue; |
667 | info->cpu[info->configured].core_id = | 667 | info->core[info->configured].core_id = |
668 | address >> smp_cpu_mt_shift; | 668 | address >> smp_cpu_mt_shift; |
669 | info->configured++; | 669 | info->configured++; |
670 | } | 670 | } |
@@ -675,7 +675,7 @@ static struct sclp_cpu_info *smp_get_cpu_info(void) | |||
675 | 675 | ||
676 | static int smp_add_present_cpu(int cpu); | 676 | static int smp_add_present_cpu(int cpu); |
677 | 677 | ||
678 | static int __smp_rescan_cpus(struct sclp_cpu_info *info, int sysfs_add) | 678 | static int __smp_rescan_cpus(struct sclp_core_info *info, int sysfs_add) |
679 | { | 679 | { |
680 | struct pcpu *pcpu; | 680 | struct pcpu *pcpu; |
681 | cpumask_t avail; | 681 | cpumask_t avail; |
@@ -686,9 +686,9 @@ static int __smp_rescan_cpus(struct sclp_cpu_info *info, int sysfs_add) | |||
686 | cpumask_xor(&avail, cpu_possible_mask, cpu_present_mask); | 686 | cpumask_xor(&avail, cpu_possible_mask, cpu_present_mask); |
687 | cpu = cpumask_first(&avail); | 687 | cpu = cpumask_first(&avail); |
688 | for (i = 0; (i < info->combined) && (cpu < nr_cpu_ids); i++) { | 688 | for (i = 0; (i < info->combined) && (cpu < nr_cpu_ids); i++) { |
689 | if (info->has_cpu_type && info->cpu[i].type != boot_cpu_type) | 689 | if (sclp.has_core_type && info->core[i].type != boot_core_type) |
690 | continue; | 690 | continue; |
691 | address = info->cpu[i].core_id << smp_cpu_mt_shift; | 691 | address = info->core[i].core_id << smp_cpu_mt_shift; |
692 | for (j = 0; j <= smp_cpu_mtid; j++) { | 692 | for (j = 0; j <= smp_cpu_mtid; j++) { |
693 | if (pcpu_find_address(cpu_present_mask, address + j)) | 693 | if (pcpu_find_address(cpu_present_mask, address + j)) |
694 | continue; | 694 | continue; |
@@ -714,21 +714,21 @@ static int __smp_rescan_cpus(struct sclp_cpu_info *info, int sysfs_add) | |||
714 | static void __init smp_detect_cpus(void) | 714 | static void __init smp_detect_cpus(void) |
715 | { | 715 | { |
716 | unsigned int cpu, mtid, c_cpus, s_cpus; | 716 | unsigned int cpu, mtid, c_cpus, s_cpus; |
717 | struct sclp_cpu_info *info; | 717 | struct sclp_core_info *info; |
718 | u16 address; | 718 | u16 address; |
719 | 719 | ||
720 | /* Get CPU information */ | 720 | /* Get CPU information */ |
721 | info = smp_get_cpu_info(); | 721 | info = smp_get_core_info(); |
722 | if (!info) | 722 | if (!info) |
723 | panic("smp_detect_cpus failed to allocate memory\n"); | 723 | panic("smp_detect_cpus failed to allocate memory\n"); |
724 | 724 | ||
725 | /* Find boot CPU type */ | 725 | /* Find boot CPU type */ |
726 | if (info->has_cpu_type) { | 726 | if (sclp.has_core_type) { |
727 | address = stap(); | 727 | address = stap(); |
728 | for (cpu = 0; cpu < info->combined; cpu++) | 728 | for (cpu = 0; cpu < info->combined; cpu++) |
729 | if (info->cpu[cpu].core_id == address) { | 729 | if (info->core[cpu].core_id == address) { |
730 | /* The boot cpu dictates the cpu type. */ | 730 | /* The boot cpu dictates the cpu type. */ |
731 | boot_cpu_type = info->cpu[cpu].type; | 731 | boot_core_type = info->core[cpu].type; |
732 | break; | 732 | break; |
733 | } | 733 | } |
734 | if (cpu >= info->combined) | 734 | if (cpu >= info->combined) |
@@ -741,14 +741,15 @@ static void __init smp_detect_cpus(void) | |||
741 | #endif | 741 | #endif |
742 | 742 | ||
743 | /* Set multi-threading state for the current system */ | 743 | /* Set multi-threading state for the current system */ |
744 | mtid = boot_cpu_type ? sclp.mtid : sclp.mtid_cp; | 744 | mtid = boot_core_type ? sclp.mtid : sclp.mtid_cp; |
745 | mtid = (mtid < smp_max_threads) ? mtid : smp_max_threads - 1; | 745 | mtid = (mtid < smp_max_threads) ? mtid : smp_max_threads - 1; |
746 | pcpu_set_smt(mtid); | 746 | pcpu_set_smt(mtid); |
747 | 747 | ||
748 | /* Print number of CPUs */ | 748 | /* Print number of CPUs */ |
749 | c_cpus = s_cpus = 0; | 749 | c_cpus = s_cpus = 0; |
750 | for (cpu = 0; cpu < info->combined; cpu++) { | 750 | for (cpu = 0; cpu < info->combined; cpu++) { |
751 | if (info->has_cpu_type && info->cpu[cpu].type != boot_cpu_type) | 751 | if (sclp.has_core_type && |
752 | info->core[cpu].type != boot_core_type) | ||
752 | continue; | 753 | continue; |
753 | if (cpu < info->configured) | 754 | if (cpu < info->configured) |
754 | c_cpus += smp_cpu_mtid + 1; | 755 | c_cpus += smp_cpu_mtid + 1; |
@@ -885,7 +886,7 @@ void __init smp_fill_possible_mask(void) | |||
885 | 886 | ||
886 | sclp_max = max(sclp.mtid, sclp.mtid_cp) + 1; | 887 | sclp_max = max(sclp.mtid, sclp.mtid_cp) + 1; |
887 | sclp_max = min(smp_max_threads, sclp_max); | 888 | sclp_max = min(smp_max_threads, sclp_max); |
888 | sclp_max = sclp.max_cpu * sclp_max ?: nr_cpu_ids; | 889 | sclp_max = sclp.max_cores * sclp_max ?: nr_cpu_ids; |
889 | possible = setup_possible_cpus ?: nr_cpu_ids; | 890 | possible = setup_possible_cpus ?: nr_cpu_ids; |
890 | possible = min(possible, sclp_max); | 891 | possible = min(possible, sclp_max); |
891 | for (cpu = 0; cpu < possible && cpu < nr_cpu_ids; cpu++) | 892 | for (cpu = 0; cpu < possible && cpu < nr_cpu_ids; cpu++) |
@@ -978,7 +979,7 @@ static ssize_t cpu_configure_store(struct device *dev, | |||
978 | case 0: | 979 | case 0: |
979 | if (pcpu->state != CPU_STATE_CONFIGURED) | 980 | if (pcpu->state != CPU_STATE_CONFIGURED) |
980 | break; | 981 | break; |
981 | rc = sclp_cpu_deconfigure(pcpu->address >> smp_cpu_mt_shift); | 982 | rc = sclp_core_deconfigure(pcpu->address >> smp_cpu_mt_shift); |
982 | if (rc) | 983 | if (rc) |
983 | break; | 984 | break; |
984 | for (i = 0; i <= smp_cpu_mtid; i++) { | 985 | for (i = 0; i <= smp_cpu_mtid; i++) { |
@@ -993,7 +994,7 @@ static ssize_t cpu_configure_store(struct device *dev, | |||
993 | case 1: | 994 | case 1: |
994 | if (pcpu->state != CPU_STATE_STANDBY) | 995 | if (pcpu->state != CPU_STATE_STANDBY) |
995 | break; | 996 | break; |
996 | rc = sclp_cpu_configure(pcpu->address >> smp_cpu_mt_shift); | 997 | rc = sclp_core_configure(pcpu->address >> smp_cpu_mt_shift); |
997 | if (rc) | 998 | if (rc) |
998 | break; | 999 | break; |
999 | for (i = 0; i <= smp_cpu_mtid; i++) { | 1000 | for (i = 0; i <= smp_cpu_mtid; i++) { |
@@ -1108,10 +1109,10 @@ out: | |||
1108 | 1109 | ||
1109 | int __ref smp_rescan_cpus(void) | 1110 | int __ref smp_rescan_cpus(void) |
1110 | { | 1111 | { |
1111 | struct sclp_cpu_info *info; | 1112 | struct sclp_core_info *info; |
1112 | int nr; | 1113 | int nr; |
1113 | 1114 | ||
1114 | info = smp_get_cpu_info(); | 1115 | info = smp_get_core_info(); |
1115 | if (!info) | 1116 | if (!info) |
1116 | return -ENOMEM; | 1117 | return -ENOMEM; |
1117 | get_online_cpus(); | 1118 | get_online_cpus(); |