Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+50 -52
-2
arch/s390/include/asm/cpu.h
··· 8 8 #ifndef _ASM_S390_CPU_H 9 9 #define _ASM_S390_CPU_H 10 10 11 - #define MAX_CPU_ADDRESS 255 12 - 13 11 #ifndef __ASSEMBLY__ 14 12 15 13 #include <linux/types.h>
+9 -9
arch/s390/include/asm/sclp.h
··· 11 11 #include <asm/cpu.h> 12 12 13 13 #define SCLP_CHP_INFO_MASK_SIZE 32 14 + #define SCLP_MAX_CORES 256 14 15 15 16 struct sclp_chp_info { 16 17 u8 recognized[SCLP_CHP_INFO_MASK_SIZE]; ··· 27 26 char loadparm[LOADPARM_LEN]; 28 27 }; 29 28 30 - struct sclp_cpu_entry { 29 + struct sclp_core_entry { 31 30 u8 core_id; 32 31 u8 reserved0[2]; 33 32 u8 : 3; ··· 39 38 u8 reserved1; 40 39 } __attribute__((packed)); 41 40 42 - struct sclp_cpu_info { 41 + struct sclp_core_info { 43 42 unsigned int configured; 44 43 unsigned int standby; 45 44 unsigned int combined; 46 - int has_cpu_type; 47 - struct sclp_cpu_entry cpu[MAX_CPU_ADDRESS + 1]; 45 + struct sclp_core_entry core[SCLP_MAX_CORES]; 48 46 }; 49 47 50 48 struct sclp_info { ··· 51 51 unsigned char has_vt220 : 1; 52 52 unsigned char has_siif : 1; 53 53 unsigned char has_sigpif : 1; 54 - unsigned char has_cpu_type : 1; 54 + unsigned char has_core_type : 1; 55 55 unsigned char has_sprp : 1; 56 56 unsigned int ibc; 57 57 unsigned int mtid; ··· 60 60 unsigned long long rzm; 61 61 unsigned long long rnmax; 62 62 unsigned long long hamax; 63 - unsigned int max_cpu; 63 + unsigned int max_cores; 64 64 unsigned long hsa_size; 65 65 unsigned long long facilities; 66 66 }; 67 67 extern struct sclp_info sclp; 68 68 69 - int sclp_get_cpu_info(struct sclp_cpu_info *info); 70 - int sclp_cpu_configure(u8 cpu); 71 - int sclp_cpu_deconfigure(u8 cpu); 69 + int sclp_get_core_info(struct sclp_core_info *info); 70 + int sclp_core_configure(u8 core); 71 + int sclp_core_deconfigure(u8 core); 72 72 int sclp_sdias_blk_count(void); 73 73 int sclp_sdias_copy(void *dest, int blk_num, int nr_blks); 74 74 int sclp_chp_configure(struct chp_id chpid);
+25 -24
arch/s390/kernel/smp.c
··· 69 69 u16 address; /* physical cpu address */ 70 70 }; 71 71 72 - static u8 boot_cpu_type; 72 + static u8 boot_core_type; 73 73 static struct pcpu pcpu_devices[NR_CPUS]; 74 74 75 75 unsigned int smp_cpu_mt_shift; ··· 589 589 * old system. The ELF sections are picked up by the crash_dump code 590 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 594 unsigned int cpu, address, i, j; 595 595 int is_boot_cpu; ··· 606 606 cpu = 0; 607 607 for (i = 0; i < info->configured; i++) { 608 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 610 continue; 611 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 613 is_boot_cpu = (address == pcpu_devices[0].address); 614 614 if (is_boot_cpu && !OLDMEM_BASE) 615 615 /* Skip boot CPU for standard zfcp dump. */ ··· 649 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 654 static int use_sigp_detection; 655 - struct sclp_cpu_info *info; 655 + struct sclp_core_info *info; 656 656 int address; 657 657 658 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 660 use_sigp_detection = 1; 661 661 for (address = 0; 662 - address <= (MAX_CPU_ADDRESS << smp_cpu_mt_shift); 662 + address < (SCLP_MAX_CORES << smp_cpu_mt_shift); 663 663 address += (1U << smp_cpu_mt_shift)) { 664 664 if (__pcpu_sigp_relax(address, SIGP_SENSE, 0, NULL) == 665 665 SIGP_CC_NOT_OPERATIONAL) 666 666 continue; 667 - info->cpu[info->configured].core_id = 667 + info->core[info->configured].core_id = 668 668 address >> smp_cpu_mt_shift; 669 669 info->configured++; 670 670 } ··· 675 675 676 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 680 struct pcpu *pcpu; 681 681 cpumask_t avail; ··· 686 686 cpumask_xor(&avail, cpu_possible_mask, cpu_present_mask); 687 687 cpu = cpumask_first(&avail); 688 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 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 692 for (j = 0; j <= smp_cpu_mtid; j++) { 693 693 if (pcpu_find_address(cpu_present_mask, address + j)) 694 694 continue; ··· 714 714 static void __init smp_detect_cpus(void) 715 715 { 716 716 unsigned int cpu, mtid, c_cpus, s_cpus; 717 - struct sclp_cpu_info *info; 717 + struct sclp_core_info *info; 718 718 u16 address; 719 719 720 720 /* Get CPU information */ 721 - info = smp_get_cpu_info(); 721 + info = smp_get_core_info(); 722 722 if (!info) 723 723 panic("smp_detect_cpus failed to allocate memory\n"); 724 724 725 725 /* Find boot CPU type */ 726 - if (info->has_cpu_type) { 726 + if (sclp.has_core_type) { 727 727 address = stap(); 728 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 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 732 break; 733 733 } 734 734 if (cpu >= info->combined) ··· 741 741 #endif 742 742 743 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 745 mtid = (mtid < smp_max_threads) ? mtid : smp_max_threads - 1; 746 746 pcpu_set_smt(mtid); 747 747 748 748 /* Print number of CPUs */ 749 749 c_cpus = s_cpus = 0; 750 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 753 continue; 753 754 if (cpu < info->configured) 754 755 c_cpus += smp_cpu_mtid + 1; ··· 886 885 887 886 sclp_max = max(sclp.mtid, sclp.mtid_cp) + 1; 888 887 sclp_max = min(smp_max_threads, sclp_max); 889 - sclp_max = sclp.max_cpu * sclp_max ?: nr_cpu_ids; 888 + sclp_max = sclp.max_cores * sclp_max ?: nr_cpu_ids; 890 889 possible = setup_possible_cpus ?: nr_cpu_ids; 891 890 possible = min(possible, sclp_max); 892 891 for (cpu = 0; cpu < possible && cpu < nr_cpu_ids; cpu++) ··· 979 978 case 0: 980 979 if (pcpu->state != CPU_STATE_CONFIGURED) 981 980 break; 982 - rc = sclp_cpu_deconfigure(pcpu->address >> smp_cpu_mt_shift); 981 + rc = sclp_core_deconfigure(pcpu->address >> smp_cpu_mt_shift); 983 982 if (rc) 984 983 break; 985 984 for (i = 0; i <= smp_cpu_mtid; i++) { ··· 994 993 case 1: 995 994 if (pcpu->state != CPU_STATE_STANDBY) 996 995 break; 997 - rc = sclp_cpu_configure(pcpu->address >> smp_cpu_mt_shift); 996 + rc = sclp_core_configure(pcpu->address >> smp_cpu_mt_shift); 998 997 if (rc) 999 998 break; 1000 999 for (i = 0; i <= smp_cpu_mtid; i++) { ··· 1109 1108 1110 1109 int __ref smp_rescan_cpus(void) 1111 1110 { 1112 - struct sclp_cpu_info *info; 1111 + struct sclp_core_info *info; 1113 1112 int nr; 1114 1113 1115 - info = smp_get_cpu_info(); 1114 + info = smp_get_core_info(); 1116 1115 if (!info) 1117 1116 return -ENOMEM; 1118 1117 get_online_cpus();
+11 -12
drivers/s390/char/sclp_cmd.c
··· 92 92 u8 reserved[4096 - 16]; 93 93 } __attribute__((packed, aligned(PAGE_SIZE))); 94 94 95 - static void sclp_fill_cpu_info(struct sclp_cpu_info *info, 96 - struct read_cpu_info_sccb *sccb) 95 + static void sclp_fill_core_info(struct sclp_core_info *info, 96 + struct read_cpu_info_sccb *sccb) 97 97 { 98 98 char *page = (char *) sccb; 99 99 ··· 101 101 info->configured = sccb->nr_configured; 102 102 info->standby = sccb->nr_standby; 103 103 info->combined = sccb->nr_configured + sccb->nr_standby; 104 - info->has_cpu_type = sclp.has_cpu_type; 105 - memcpy(&info->cpu, page + sccb->offset_configured, 106 - info->combined * sizeof(struct sclp_cpu_entry)); 104 + memcpy(&info->core, page + sccb->offset_configured, 105 + info->combined * sizeof(struct sclp_core_entry)); 107 106 } 108 107 109 - int sclp_get_cpu_info(struct sclp_cpu_info *info) 108 + int sclp_get_core_info(struct sclp_core_info *info) 110 109 { 111 110 int rc; 112 111 struct read_cpu_info_sccb *sccb; ··· 126 127 rc = -EIO; 127 128 goto out; 128 129 } 129 - sclp_fill_cpu_info(info, sccb); 130 + sclp_fill_core_info(info, sccb); 130 131 out: 131 132 free_page((unsigned long) sccb); 132 133 return rc; ··· 136 137 struct sccb_header header; 137 138 } __attribute__((packed, aligned(8))); 138 139 139 - static int do_cpu_configure(sclp_cmdw_t cmd) 140 + static int do_core_configure(sclp_cmdw_t cmd) 140 141 { 141 142 struct cpu_configure_sccb *sccb; 142 143 int rc; ··· 170 171 return rc; 171 172 } 172 173 173 - int sclp_cpu_configure(u8 cpu) 174 + int sclp_core_configure(u8 core) 174 175 { 175 - return do_cpu_configure(SCLP_CMDW_CONFIGURE_CPU | cpu << 8); 176 + return do_core_configure(SCLP_CMDW_CONFIGURE_CPU | core << 8); 176 177 } 177 178 178 - int sclp_cpu_deconfigure(u8 cpu) 179 + int sclp_core_deconfigure(u8 core) 179 180 { 180 - return do_cpu_configure(SCLP_CMDW_DECONFIGURE_CPU | cpu << 8); 181 + return do_core_configure(SCLP_CMDW_DECONFIGURE_CPU | core << 8); 181 182 } 182 183 183 184 #ifdef CONFIG_MEMORY_HOTPLUG
+5 -5
drivers/s390/char/sclp_early.c
··· 98 98 99 99 static void __init sclp_facilities_detect(struct read_info_sccb *sccb) 100 100 { 101 - struct sclp_cpu_entry *cpue; 101 + struct sclp_core_entry *cpue; 102 102 u16 boot_cpu_address, cpu; 103 103 104 104 if (sclp_read_info_early(sccb)) ··· 106 106 107 107 sclp.facilities = sccb->facilities; 108 108 sclp.has_sprp = !!(sccb->fac84 & 0x02); 109 - sclp.has_cpu_type = !!(sccb->fac84 & 0x01); 109 + sclp.has_core_type = !!(sccb->fac84 & 0x01); 110 110 if (sccb->fac85 & 0x02) 111 111 S390_lowcore.machine_flags |= MACHINE_FLAG_ESOP; 112 112 sclp.rnmax = sccb->rnmax ? sccb->rnmax : sccb->rnmax2; ··· 116 116 117 117 if (!sccb->hcpua) { 118 118 if (MACHINE_IS_VM) 119 - sclp.max_cpu = 64; 119 + sclp.max_cores = 64; 120 120 else 121 - sclp.max_cpu = sccb->ncpurl; 121 + sclp.max_cores = sccb->ncpurl; 122 122 } else { 123 - sclp.max_cpu = sccb->hcpua + 1; 123 + sclp.max_cores = sccb->hcpua + 1; 124 124 } 125 125 126 126 boot_cpu_address = stap();