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

s390/sysinfo,stsi: change return code handling

Change return code handling of the stsi() function:

In case function code 0 was specified the return value is the
current configuration level (already shifted). That way all
the code that actually copied the stsi_0() function can go
away.

Otherwise the return value is 0 (success) or negative to
indicate an error (currently only -EOPNOTSUPP).

Also stsi() is no longer an inline function. The function is
not performance critical, but every caller would generate an
exception table entry for this function.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Heiko Carstens and committed by
Martin Schwidefsky
caf757c6 94f2b9e2

+51 -60
+1 -15
arch/s390/include/asm/sysinfo.h
··· 153 153 union topology_entry tle[0]; 154 154 }; 155 155 156 - static inline int stsi(void *sysinfo, int fc, int sel1, int sel2) 157 - { 158 - register int r0 asm("0") = (fc << 28) | sel1; 159 - register int r1 asm("1") = sel2; 160 - 161 - asm volatile( 162 - " stsi 0(%2)\n" 163 - "0: jz 2f\n" 164 - "1: lhi %0,%3\n" 165 - "2:\n" 166 - EX_TABLE(0b, 1b) 167 - : "+d" (r0) : "d" (r1), "a" (sysinfo), "K" (-ENOSYS) 168 - : "cc", "memory"); 169 - return r0; 170 - } 156 + int stsi(void *sysinfo, int fc, int sel1, int sel2); 171 157 172 158 /* 173 159 * Service level reporting interface.
+3 -3
arch/s390/kernel/early.c
··· 222 222 struct sysinfo_3_2_2 *vmms = (struct sysinfo_3_2_2 *)&sysinfo_page; 223 223 224 224 /* Check current-configuration-level */ 225 - if ((stsi(NULL, 0, 0, 0) >> 28) <= 2) { 225 + if (stsi(NULL, 0, 0, 0) <= 2) { 226 226 S390_lowcore.machine_flags |= MACHINE_FLAG_LPAR; 227 227 return; 228 228 } 229 229 /* Get virtual-machine cpu information. */ 230 - if (stsi(vmms, 3, 2, 2) == -ENOSYS || !vmms->count) 230 + if (stsi(vmms, 3, 2, 2) || !vmms->count) 231 231 return; 232 232 233 233 /* Running under KVM? If not we assume z/VM */ ··· 246 246 return; 247 247 S390_lowcore.machine_flags |= MACHINE_FLAG_TOPOLOGY; 248 248 for (max_mnest = 6; max_mnest > 1; max_mnest--) { 249 - if (stsi(&sysinfo_page, 15, 1, max_mnest) != -ENOSYS) 249 + if (stsi(&sysinfo_page, 15, 1, max_mnest) == 0) 250 250 break; 251 251 } 252 252 topology_max_mnest = max_mnest;
+10 -19
arch/s390/kernel/lgr.c
··· 51 51 static struct debug_info *lgr_dbf; 52 52 53 53 /* 54 - * Return number of valid stsi levels 55 - */ 56 - static inline int stsi_0(void) 57 - { 58 - int rc = stsi(NULL, 0, 0, 0); 59 - 60 - return rc == -ENOSYS ? rc : (((unsigned int) rc) >> 28); 61 - } 62 - 63 - /* 64 54 * Copy buffer and then convert it to ASCII 65 55 */ 66 56 static void cpascii(char *dst, char *src, int size) ··· 66 76 { 67 77 struct sysinfo_1_1_1 *si = (void *) lgr_page; 68 78 69 - if (stsi(si, 1, 1, 1) == -ENOSYS) 79 + if (stsi(si, 1, 1, 1)) 70 80 return; 71 81 cpascii(lgr_info->manufacturer, si->manufacturer, 72 82 sizeof(si->manufacturer)); ··· 83 93 { 84 94 struct sysinfo_2_2_2 *si = (void *) lgr_page; 85 95 86 - if (stsi(si, 2, 2, 2) == -ENOSYS) 96 + if (stsi(si, 2, 2, 2)) 87 97 return; 88 98 cpascii(lgr_info->name, si->name, sizeof(si->name)); 89 99 memcpy(&lgr_info->lpar_number, &si->lpar_number, ··· 98 108 struct sysinfo_3_2_2 *si = (void *) lgr_page; 99 109 int i; 100 110 101 - if (stsi(si, 3, 2, 2) == -ENOSYS) 111 + if (stsi(si, 3, 2, 2)) 102 112 return; 103 113 for (i = 0; i < min_t(u8, si->count, VM_LEVEL_MAX); i++) { 104 114 cpascii(lgr_info->vm[i].name, si->vm[i].name, ··· 114 124 */ 115 125 static void lgr_info_get(struct lgr_info *lgr_info) 116 126 { 127 + int level; 128 + 117 129 memset(lgr_info, 0, sizeof(*lgr_info)); 118 130 stfle(lgr_info->stfle_fac_list, ARRAY_SIZE(lgr_info->stfle_fac_list)); 119 - lgr_info->level = stsi_0(); 120 - if (lgr_info->level == -ENOSYS) 121 - return; 122 - if (lgr_info->level >= 1) 131 + level = stsi(NULL, 0, 0, 0); 132 + lgr_info->level = level; 133 + if (level >= 1) 123 134 lgr_stsi_1_1_1(lgr_info); 124 - if (lgr_info->level >= 2) 135 + if (level >= 2) 125 136 lgr_stsi_2_2_2(lgr_info); 126 - if (lgr_info->level >= 3) 137 + if (level >= 3) 127 138 lgr_stsi_3_2_2(lgr_info); 128 139 } 129 140
+31 -10
arch/s390/kernel/sysinfo.c
··· 24 24 25 25 int topology_max_mnest; 26 26 27 - static inline int stsi_0(void) 27 + /* 28 + * stsi - store system information 29 + * 30 + * Returns the current configuration level if function code 0 was specified. 31 + * Otherwise returns 0 on success or a negative value on error. 32 + */ 33 + int stsi(void *sysinfo, int fc, int sel1, int sel2) 28 34 { 29 - int rc = stsi(NULL, 0, 0, 0); 35 + register int r0 asm("0") = (fc << 28) | sel1; 36 + register int r1 asm("1") = sel2; 37 + int rc = 0; 30 38 31 - return rc == -ENOSYS ? rc : (((unsigned int) rc) >> 28); 39 + asm volatile( 40 + " stsi 0(%3)\n" 41 + "0: jz 2f\n" 42 + "1: lhi %1,%4\n" 43 + "2:\n" 44 + EX_TABLE(0b, 1b) 45 + : "+d" (r0), "+d" (rc) 46 + : "d" (r1), "a" (sysinfo), "K" (-EOPNOTSUPP) 47 + : "cc", "memory"); 48 + if (rc) 49 + return rc; 50 + return fc ? 0 : ((unsigned int) r0) >> 28; 32 51 } 52 + EXPORT_SYMBOL(stsi); 33 53 34 54 static void stsi_1_1_1(struct seq_file *m, struct sysinfo_1_1_1 *info) 35 55 { 36 56 int i; 37 57 38 - if (stsi(info, 1, 1, 1) == -ENOSYS) 58 + if (stsi(info, 1, 1, 1)) 39 59 return; 40 60 EBCASC(info->manufacturer, sizeof(info->manufacturer)); 41 61 EBCASC(info->type, sizeof(info->type)); ··· 117 97 seq_putc(m, '\n'); 118 98 if (!MACHINE_HAS_TOPOLOGY) 119 99 return; 120 - stsi(info, 15, 1, topology_max_mnest); 100 + if (stsi(info, 15, 1, topology_max_mnest)) 101 + return; 121 102 seq_printf(m, "CPU Topology HW: "); 122 103 for (i = 0; i < TOPOLOGY_NR_MAG; i++) 123 104 seq_printf(m, " %d", info->mag[i]); ··· 137 116 struct sysinfo_1_2_2_extension *ext; 138 117 int i; 139 118 140 - if (stsi(info, 1, 2, 2) == -ENOSYS) 119 + if (stsi(info, 1, 2, 2)) 141 120 return; 142 121 ext = (struct sysinfo_1_2_2_extension *) 143 122 ((unsigned long) info + info->acc_offset); ··· 173 152 174 153 static void stsi_2_2_2(struct seq_file *m, struct sysinfo_2_2_2 *info) 175 154 { 176 - if (stsi(info, 2, 2, 2) == -ENOSYS) 155 + if (stsi(info, 2, 2, 2)) 177 156 return; 178 157 EBCASC(info->name, sizeof(info->name)); 179 158 seq_putc(m, '\n'); ··· 200 179 { 201 180 int i; 202 181 203 - if (stsi(info, 3, 2, 2) == -ENOSYS) 182 + if (stsi(info, 3, 2, 2)) 204 183 return; 205 184 for (i = 0; i < info->count; i++) { 206 185 EBCASC(info->vm[i].name, sizeof(info->vm[i].name)); ··· 223 202 224 203 if (!info) 225 204 return 0; 226 - level = stsi_0(); 205 + level = stsi(NULL, 0, 0, 0); 227 206 if (level >= 1) 228 207 stsi_1_1_1(m, info); 229 208 if (level >= 1) ··· 386 365 if (!info) 387 366 return; 388 367 389 - if (stsi(info, 1, 2, 2) != -ENOSYS) { 368 + if (stsi(info, 1, 2, 2) == 0) { 390 369 /* 391 370 * Major sigh. The cpu capability encoding is "special". 392 371 * If the first 9 bits of info->capability are 0 then it
+2 -2
arch/s390/kvm/priv.c
··· 211 211 spin_unlock(&fi->lock); 212 212 213 213 /* deal with other level 3 hypervisors */ 214 - if (stsi(mem, 3, 2, 2) == -ENOSYS) 214 + if (stsi(mem, 3, 2, 2)) 215 215 mem->count = 0; 216 216 if (mem->count < 8) 217 217 mem->count++; ··· 259 259 mem = get_zeroed_page(GFP_KERNEL); 260 260 if (!mem) 261 261 goto out_fail; 262 - if (stsi((void *) mem, fc, sel1, sel2) == -ENOSYS) 262 + if (stsi((void *) mem, fc, sel1, sel2)) 263 263 goto out_mem; 264 264 break; 265 265 case 3:
+4 -11
drivers/s390/net/qeth_core_main.c
··· 2993 2993 struct sysinfo_2_2_2 *info222 = (struct sysinfo_2_2_2 *)info; 2994 2994 struct sysinfo_3_2_2 *info322 = (struct sysinfo_3_2_2 *)info; 2995 2995 struct ccw_dev_id ccwid; 2996 - int level, rc; 2996 + int level; 2997 2997 2998 2998 tid->chpid = card->info.chpid; 2999 2999 ccw_device_get_id(CARD_RDEV(card), &ccwid); ··· 3001 3001 tid->devno = ccwid.devno; 3002 3002 if (!info) 3003 3003 return; 3004 - 3005 - rc = stsi(NULL, 0, 0, 0); 3006 - if (rc == -ENOSYS) 3007 - level = rc; 3008 - else 3009 - level = (((unsigned int) rc) >> 28); 3010 - 3011 - if ((level >= 2) && (stsi(info222, 2, 2, 2) != -ENOSYS)) 3004 + level = stsi(NULL, 0, 0, 0); 3005 + if ((level >= 2) && (stsi(info222, 2, 2, 2) == 0)) 3012 3006 tid->lparnr = info222->lpar_number; 3013 - 3014 - if ((level >= 3) && (stsi(info322, 3, 2, 2) != -ENOSYS)) { 3007 + if ((level >= 3) && (stsi(info322, 3, 2, 2) == 0)) { 3015 3008 EBCASC(info322->vm[0].name, sizeof(info322->vm[0].name)); 3016 3009 memcpy(tid->vmname, info322->vm[0].name, sizeof(tid->vmname)); 3017 3010 }