aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAnton Blanchard <anton@samba.org>2014-03-28 01:33:33 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2014-04-06 20:34:27 -0400
commitbb4398e1de739a13e06589fc04cbb2267ba59800 (patch)
treef2e47b907f4b5275ee708988ca7899349424f4b7 /arch
parent32b941b79394435c1b6d688abfe762c5b3c82afa (diff)
powerpc/powernv: Fix endian issues with OPAL async code
OPAL defines opal_msg as a big endian struct so we have to byte swap it on little endian builds. Signed-off-by: Anton Blanchard <anton@samba.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/include/asm/opal.h6
-rw-r--r--arch/powerpc/platforms/powernv/opal-async.c7
-rw-r--r--arch/powerpc/platforms/powernv/opal-sensor.c2
-rw-r--r--arch/powerpc/platforms/powernv/opal-sysparam.c4
-rw-r--r--arch/powerpc/platforms/powernv/opal.c10
5 files changed, 16 insertions, 13 deletions
diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h
index 6fb5f90e6464..fc73661c20fa 100644
--- a/arch/powerpc/include/asm/opal.h
+++ b/arch/powerpc/include/asm/opal.h
@@ -422,9 +422,9 @@ enum OpalSysparamPerm {
422}; 422};
423 423
424struct opal_msg { 424struct opal_msg {
425 uint32_t msg_type; 425 __be32 msg_type;
426 uint32_t reserved; 426 __be32 reserved;
427 uint64_t params[8]; 427 __be64 params[8];
428}; 428};
429 429
430struct opal_machine_check_event { 430struct opal_machine_check_event {
diff --git a/arch/powerpc/platforms/powernv/opal-async.c b/arch/powerpc/platforms/powernv/opal-async.c
index cd0c1354d404..32e2adfa5320 100644
--- a/arch/powerpc/platforms/powernv/opal-async.c
+++ b/arch/powerpc/platforms/powernv/opal-async.c
@@ -125,14 +125,15 @@ static int opal_async_comp_event(struct notifier_block *nb,
125{ 125{
126 struct opal_msg *comp_msg = msg; 126 struct opal_msg *comp_msg = msg;
127 unsigned long flags; 127 unsigned long flags;
128 uint64_t token;
128 129
129 if (msg_type != OPAL_MSG_ASYNC_COMP) 130 if (msg_type != OPAL_MSG_ASYNC_COMP)
130 return 0; 131 return 0;
131 132
132 memcpy(&opal_async_responses[comp_msg->params[0]], comp_msg, 133 token = be64_to_cpu(comp_msg->params[0]);
133 sizeof(*comp_msg)); 134 memcpy(&opal_async_responses[token], comp_msg, sizeof(*comp_msg));
134 spin_lock_irqsave(&opal_async_comp_lock, flags); 135 spin_lock_irqsave(&opal_async_comp_lock, flags);
135 __set_bit(comp_msg->params[0], opal_async_complete_map); 136 __set_bit(token, opal_async_complete_map);
136 spin_unlock_irqrestore(&opal_async_comp_lock, flags); 137 spin_unlock_irqrestore(&opal_async_comp_lock, flags);
137 138
138 wake_up(&opal_async_wait); 139 wake_up(&opal_async_wait);
diff --git a/arch/powerpc/platforms/powernv/opal-sensor.c b/arch/powerpc/platforms/powernv/opal-sensor.c
index 663cc9c65613..7503e298c4c3 100644
--- a/arch/powerpc/platforms/powernv/opal-sensor.c
+++ b/arch/powerpc/platforms/powernv/opal-sensor.c
@@ -53,7 +53,7 @@ int opal_get_sensor_data(u32 sensor_hndl, u32 *sensor_data)
53 goto out_token; 53 goto out_token;
54 } 54 }
55 55
56 ret = msg.params[1]; 56 ret = be64_to_cpu(msg.params[1]);
57 57
58out_token: 58out_token:
59 mutex_unlock(&opal_sensor_mutex); 59 mutex_unlock(&opal_sensor_mutex);
diff --git a/arch/powerpc/platforms/powernv/opal-sysparam.c b/arch/powerpc/platforms/powernv/opal-sysparam.c
index 0bd249a26f30..6b614726baf2 100644
--- a/arch/powerpc/platforms/powernv/opal-sysparam.c
+++ b/arch/powerpc/platforms/powernv/opal-sysparam.c
@@ -64,7 +64,7 @@ static int opal_get_sys_param(u32 param_id, u32 length, void *buffer)
64 goto out_token; 64 goto out_token;
65 } 65 }
66 66
67 ret = msg.params[1]; 67 ret = be64_to_cpu(msg.params[1]);
68 68
69out_token: 69out_token:
70 opal_async_release_token(token); 70 opal_async_release_token(token);
@@ -98,7 +98,7 @@ static int opal_set_sys_param(u32 param_id, u32 length, void *buffer)
98 goto out_token; 98 goto out_token;
99 } 99 }
100 100
101 ret = msg.params[1]; 101 ret = be64_to_cpu(msg.params[1]);
102 102
103out_token: 103out_token:
104 opal_async_release_token(token); 104 opal_async_release_token(token);
diff --git a/arch/powerpc/platforms/powernv/opal.c b/arch/powerpc/platforms/powernv/opal.c
index 7835d5bb973f..778a2793e75b 100644
--- a/arch/powerpc/platforms/powernv/opal.c
+++ b/arch/powerpc/platforms/powernv/opal.c
@@ -281,6 +281,7 @@ static void opal_handle_message(void)
281 * value in /proc/device-tree. 281 * value in /proc/device-tree.
282 */ 282 */
283 static struct opal_msg msg; 283 static struct opal_msg msg;
284 u32 type;
284 285
285 ret = opal_get_msg(__pa(&msg), sizeof(msg)); 286 ret = opal_get_msg(__pa(&msg), sizeof(msg));
286 /* No opal message pending. */ 287 /* No opal message pending. */
@@ -294,13 +295,14 @@ static void opal_handle_message(void)
294 return; 295 return;
295 } 296 }
296 297
298 type = be32_to_cpu(msg.msg_type);
299
297 /* Sanity check */ 300 /* Sanity check */
298 if (msg.msg_type > OPAL_MSG_TYPE_MAX) { 301 if (type > OPAL_MSG_TYPE_MAX) {
299 pr_warning("%s: Unknown message type: %u\n", 302 pr_warning("%s: Unknown message type: %u\n", __func__, type);
300 __func__, msg.msg_type);
301 return; 303 return;
302 } 304 }
303 opal_message_do_notify(msg.msg_type, (void *)&msg); 305 opal_message_do_notify(type, (void *)&msg);
304} 306}
305 307
306static int opal_message_notify(struct notifier_block *nb, 308static int opal_message_notify(struct notifier_block *nb,