hc
2024-05-11 04dd17822334871b23ea2862f7798fb0e0007777
kernel/arch/powerpc/perf/hv-24x7.c
....@@ -79,9 +79,8 @@
7979 */
8080 void read_24x7_sys_info(void)
8181 {
82
- int call_status, len, ntypes;
83
-
84
- spin_lock(&rtas_data_buf_lock);
82
+ const s32 token = rtas_token("ibm,get-system-parameter");
83
+ int call_status;
8584
8685 /*
8786 * Making system parameter: chips and sockets and cores per chip
....@@ -91,32 +90,27 @@
9190 phys_chipspersocket = 1;
9291 phys_coresperchip = 1;
9392
94
- call_status = rtas_call(rtas_token("ibm,get-system-parameter"), 3, 1,
95
- NULL,
96
- PROCESSOR_MODULE_INFO,
97
- __pa(rtas_data_buf),
98
- RTAS_DATA_BUF_SIZE);
93
+ do {
94
+ spin_lock(&rtas_data_buf_lock);
95
+ call_status = rtas_call(token, 3, 1, NULL, PROCESSOR_MODULE_INFO,
96
+ __pa(rtas_data_buf), RTAS_DATA_BUF_SIZE);
97
+ if (call_status == 0) {
98
+ int ntypes = be16_to_cpup((__be16 *)&rtas_data_buf[2]);
99
+ int len = be16_to_cpup((__be16 *)&rtas_data_buf[0]);
100
+
101
+ if (len >= 8 && ntypes != 0) {
102
+ phys_sockets = be16_to_cpup((__be16 *)&rtas_data_buf[4]);
103
+ phys_chipspersocket = be16_to_cpup((__be16 *)&rtas_data_buf[6]);
104
+ phys_coresperchip = be16_to_cpup((__be16 *)&rtas_data_buf[8]);
105
+ }
106
+ }
107
+ spin_unlock(&rtas_data_buf_lock);
108
+ } while (rtas_busy_delay(call_status));
99109
100110 if (call_status != 0) {
101111 pr_err("Error calling get-system-parameter %d\n",
102112 call_status);
103
- } else {
104
- len = be16_to_cpup((__be16 *)&rtas_data_buf[0]);
105
- if (len < 8)
106
- goto out;
107
-
108
- ntypes = be16_to_cpup((__be16 *)&rtas_data_buf[2]);
109
-
110
- if (!ntypes)
111
- goto out;
112
-
113
- phys_sockets = be16_to_cpup((__be16 *)&rtas_data_buf[4]);
114
- phys_chipspersocket = be16_to_cpup((__be16 *)&rtas_data_buf[6]);
115
- phys_coresperchip = be16_to_cpup((__be16 *)&rtas_data_buf[8]);
116113 }
117
-
118
-out:
119
- spin_unlock(&rtas_data_buf_lock);
120114 }
121115
122116 /* Domains for which more than one result element are returned for each event. */
....@@ -1416,7 +1410,7 @@
14161410 }
14171411
14181412 domain = event_get_domain(event);
1419
- if (domain >= HV_PERF_DOMAIN_MAX) {
1413
+ if (domain == 0 || domain >= HV_PERF_DOMAIN_MAX) {
14201414 pr_devel("invalid domain %d\n", domain);
14211415 return -EINVAL;
14221416 }