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

powerpc/pseries/hv-24x7: convert to papr_sysparm API

The new papr_sysparm API handles the details of system parameter
retrieval. Use that instead of open-coding the RTAS call, work area
management, and retries.

Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20230125-b4-powerpc-rtas-queue-v3-17-26929c8cce78@linux.ibm.com

authored by

Nathan Lynch and committed by
Michael Ellerman
69b9f5a5 fff9846b

+15 -22
+15 -22
arch/powerpc/perf/hv-24x7.c
··· 18 18 #include <asm/firmware.h> 19 19 #include <asm/hvcall.h> 20 20 #include <asm/io.h> 21 + #include <asm/papr-sysparm.h> 21 22 #include <linux/byteorder/generic.h> 22 23 23 24 #include <asm/rtas.h> ··· 67 66 * Refer PAPR+ document to get parameter token value as '43'. 68 67 */ 69 68 70 - #define PROCESSOR_MODULE_INFO 43 71 - 72 69 static u32 phys_sockets; /* Physical sockets */ 73 70 static u32 phys_chipspersocket; /* Physical chips per socket*/ 74 71 static u32 phys_coresperchip; /* Physical cores per chip */ ··· 78 79 */ 79 80 void read_24x7_sys_info(void) 80 81 { 81 - const s32 token = rtas_token("ibm,get-system-parameter"); 82 - int call_status; 82 + struct papr_sysparm_buf *buf; 83 83 84 84 /* 85 85 * Making system parameter: chips and sockets and cores per chip ··· 88 90 phys_chipspersocket = 1; 89 91 phys_coresperchip = 1; 90 92 91 - do { 92 - spin_lock(&rtas_data_buf_lock); 93 - call_status = rtas_call(token, 3, 1, NULL, PROCESSOR_MODULE_INFO, 94 - __pa(rtas_data_buf), RTAS_DATA_BUF_SIZE); 95 - if (call_status == 0) { 96 - int ntypes = be16_to_cpup((__be16 *)&rtas_data_buf[2]); 97 - int len = be16_to_cpup((__be16 *)&rtas_data_buf[0]); 93 + buf = papr_sysparm_buf_alloc(); 94 + if (!buf) 95 + return; 98 96 99 - if (len >= 8 && ntypes != 0) { 100 - phys_sockets = be16_to_cpup((__be16 *)&rtas_data_buf[4]); 101 - phys_chipspersocket = be16_to_cpup((__be16 *)&rtas_data_buf[6]); 102 - phys_coresperchip = be16_to_cpup((__be16 *)&rtas_data_buf[8]); 103 - } 97 + if (!papr_sysparm_get(PAPR_SYSPARM_PROC_MODULE_INFO, buf)) { 98 + int ntypes = be16_to_cpup((__be16 *)&buf->val[0]); 99 + int len = be16_to_cpu(buf->len); 100 + 101 + if (len >= 8 && ntypes != 0) { 102 + phys_sockets = be16_to_cpup((__be16 *)&buf->val[2]); 103 + phys_chipspersocket = be16_to_cpup((__be16 *)&buf->val[4]); 104 + phys_coresperchip = be16_to_cpup((__be16 *)&buf->val[6]); 104 105 } 105 - spin_unlock(&rtas_data_buf_lock); 106 - } while (rtas_busy_delay(call_status)); 107 - 108 - if (call_status != 0) { 109 - pr_err("Error calling get-system-parameter %d\n", 110 - call_status); 111 106 } 107 + 108 + papr_sysparm_buf_free(buf); 112 109 } 113 110 114 111 /* Domains for which more than one result element are returned for each event. */