[Skiboot] [PATCH v2 2/3] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read
Cédric Le Goater
clg at fr.ibm.com
Fri Mar 27 03:04:46 AEDT 2015
Currently, when a sensor value is read, the kernel calls OPAL, which in
turn builds a message for the FSP, and waits for a message back.
The new device tree for OPAL sensors [1] adds new sensors that can be
read synchronously (core temperatures for instance) and that don't need
to wait for a response.
This patch modifies the opal call to accept an OPAL_SUCCESS return value
and cover the case above.
[1] https://lists.ozlabs.org/pipermail/skiboot/2015-March/000639.html
Signed-off-by: Cédric Le Goater <clg at fr.ibm.com>
---
We still uselessly reserve a token (for the response) and take a
lock, which might raise the need of a new 'opal_sensor_read_sync'
call.
arch/powerpc/platforms/powernv/opal-sensor.c | 31 ++++++++++++++++-----------
1 file changed, 19 insertions(+), 12 deletions(-)
Index: linux.git/arch/powerpc/platforms/powernv/opal-sensor.c
===================================================================
--- linux.git.orig/arch/powerpc/platforms/powernv/opal-sensor.c
+++ linux.git/arch/powerpc/platforms/powernv/opal-sensor.c
@@ -78,21 +78,28 @@ int opal_get_sensor_data(u32 sensor_hndl
mutex_lock(&opal_sensor_mutex);
ret = opal_sensor_read(sensor_hndl, token, &data);
- if (ret != OPAL_ASYNC_COMPLETION) {
+ switch (ret) {
+ case OPAL_ASYNC_COMPLETION:
+ ret = opal_async_wait_response(token, &msg);
+ if (ret) {
+ pr_err("%s: Failed to wait for the async response, %d\n",
+ __func__, ret);
+ goto out_token;
+ }
+
+ *sensor_data = be32_to_cpu(data);
+ ret = be64_to_cpu(msg.params[1]);
ret = convert_opal_code(ret);
- goto out_token;
- }
+ break;
- ret = opal_async_wait_response(token, &msg);
- if (ret) {
- pr_err("%s: Failed to wait for the async response, %d\n",
- __func__, ret);
- goto out_token;
- }
+ case OPAL_SUCCESS:
+ *sensor_data = be32_to_cpu(data);
+ break;
- *sensor_data = be32_to_cpu(data);
- ret = be64_to_cpu(msg.params[1]);
- ret = convert_opal_code(ret);
+ default:
+ ret = convert_opal_code(ret);
+ break;
+ }
out_token:
mutex_unlock(&opal_sensor_mutex);
More information about the Skiboot
mailing list