| .. | .. |
|---|
| 79 | 79 | */ |
|---|
| 80 | 80 | void read_24x7_sys_info(void) |
|---|
| 81 | 81 | { |
|---|
| 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; |
|---|
| 85 | 84 | |
|---|
| 86 | 85 | /* |
|---|
| 87 | 86 | * Making system parameter: chips and sockets and cores per chip |
|---|
| .. | .. |
|---|
| 91 | 90 | phys_chipspersocket = 1; |
|---|
| 92 | 91 | phys_coresperchip = 1; |
|---|
| 93 | 92 | |
|---|
| 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)); |
|---|
| 99 | 109 | |
|---|
| 100 | 110 | if (call_status != 0) { |
|---|
| 101 | 111 | pr_err("Error calling get-system-parameter %d\n", |
|---|
| 102 | 112 | 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]); |
|---|
| 116 | 113 | } |
|---|
| 117 | | - |
|---|
| 118 | | -out: |
|---|
| 119 | | - spin_unlock(&rtas_data_buf_lock); |
|---|
| 120 | 114 | } |
|---|
| 121 | 115 | |
|---|
| 122 | 116 | /* Domains for which more than one result element are returned for each event. */ |
|---|
| .. | .. |
|---|
| 1416 | 1410 | } |
|---|
| 1417 | 1411 | |
|---|
| 1418 | 1412 | domain = event_get_domain(event); |
|---|
| 1419 | | - if (domain >= HV_PERF_DOMAIN_MAX) { |
|---|
| 1413 | + if (domain == 0 || domain >= HV_PERF_DOMAIN_MAX) { |
|---|
| 1420 | 1414 | pr_devel("invalid domain %d\n", domain); |
|---|
| 1421 | 1415 | return -EINVAL; |
|---|
| 1422 | 1416 | } |
|---|