All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read
@ 2015-03-25 17:50 Cédric Le Goater
  2015-03-25 23:07 ` Stewart Smith
  0 siblings, 1 reply; 25+ messages in thread
From: Cédric Le Goater @ 2015-03-25 17:50 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Stewart Smith, Neelesh Gupta, Cédric Le Goater, skiboot

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@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 |   29 +++++++++++++++++---------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/opal-sensor.c b/arch/powerpc/platforms/powernv/opal-sensor.c
index 4ab67ef7abc9..99d6d9a371ab 100644
--- a/arch/powerpc/platforms/powernv/opal-sensor.c
+++ b/arch/powerpc/platforms/powernv/opal-sensor.c
@@ -46,18 +46,27 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data)
 
 	mutex_lock(&opal_sensor_mutex);
 	ret = opal_sensor_read(sensor_hndl, token, &data);
-	if (ret != OPAL_ASYNC_COMPLETION)
-		goto out_token;
+	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;
+		}
 
-	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;
-	}
+		ret = be64_to_cpu(msg.params[1]);
+
+		*sensor_data = be32_to_cpu(data);
+		break;
 
-	*sensor_data = be32_to_cpu(data);
-	ret = be64_to_cpu(msg.params[1]);
+	case OPAL_SUCCESS:
+		*sensor_data = be32_to_cpu(data);
+		break;
+
+	default:
+		break;
+	}
 
 out_token:
 	mutex_unlock(&opal_sensor_mutex);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2015-03-30 10:06 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-25 17:50 [PATCH] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Cédric Le Goater
2015-03-25 23:07 ` Stewart Smith
2015-03-26  9:44   ` Cedric Le Goater
2015-03-26 12:58     ` Cedric Le Goater
2015-03-26 16:04       ` [PATCH v2 1/3] powerpc/powernv: convert codes returned by OPAL calls Cédric Le Goater
2015-03-26 16:04         ` [PATCH v2 2/3] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Cédric Le Goater
2015-03-26 16:04         ` [PATCH v2 3/3] powerpc/powernv: remove opal_sensor_mutex Cédric Le Goater
2015-03-27  9:59         ` [v2,1/3] powerpc/powernv: convert codes returned by OPAL calls Michael Ellerman
2015-03-27 10:36           ` [Skiboot] [v2, 1/3] " Benjamin Herrenschmidt
2015-03-27 10:39             ` Cedric Le Goater
2015-03-27 10:45           ` [v2,1/3] " Cedric Le Goater
2015-03-27 16:39           ` [PATCH v3 1/3] " Cédric Le Goater
2015-03-30  2:05             ` Michael Ellerman
2015-03-30  6:37               ` Cedric Le Goater
2015-03-30  6:54                 ` Michael Ellerman
2015-03-30  6:56                   ` Cedric Le Goater
2015-03-30 10:06                   ` [PATCH v4 1/2] " Cédric Le Goater
2015-03-30 10:06                   ` [PATCH v4 2/2] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Cédric Le Goater
2015-03-27 16:39           ` [PATCH v3 2/3] " Cédric Le Goater
2015-03-27 16:39           ` [PATCH v3 3/3] powerpc/powernv: remove opal_sensor_mutex Cédric Le Goater
2015-03-30  2:09             ` Michael Ellerman
2015-03-30  6:51               ` Cedric Le Goater
2015-03-30  6:59                 ` Michael Ellerman
2015-03-30 10:05                   ` Cedric Le Goater
2015-03-27  6:05     ` [PATCH] powerpc/powernv: handle OPAL_SUCCESS return in opal_sensor_read Stewart Smith

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.