Commit 2be1d5d1 authored by Vasant Hegde's avatar Vasant Hegde Committed by Michael Ellerman

powerpc/powernv: Enhance opal message read interface

Use "opal-msg-size" device tree property to allocate memory for
"opal_msg".
Signed-off-by: default avatarVasant Hegde <hegdevasant@linux.vnet.ibm.com>
[mpe: s/uint32_t/u32/ and mark opal_msg_size as __ro_after_init]
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190826065701.8853-1-hegdevasant@linux.vnet.ibm.com
parent b4d37a7b
...@@ -58,6 +58,8 @@ static DEFINE_SPINLOCK(opal_write_lock); ...@@ -58,6 +58,8 @@ static DEFINE_SPINLOCK(opal_write_lock);
static struct atomic_notifier_head opal_msg_notifier_head[OPAL_MSG_TYPE_MAX]; static struct atomic_notifier_head opal_msg_notifier_head[OPAL_MSG_TYPE_MAX];
static uint32_t opal_heartbeat; static uint32_t opal_heartbeat;
static struct task_struct *kopald_tsk; static struct task_struct *kopald_tsk;
static struct opal_msg *opal_msg;
static u32 opal_msg_size __ro_after_init;
void opal_configure_cores(void) void opal_configure_cores(void)
{ {
...@@ -271,14 +273,9 @@ static void opal_message_do_notify(uint32_t msg_type, void *msg) ...@@ -271,14 +273,9 @@ static void opal_message_do_notify(uint32_t msg_type, void *msg)
static void opal_handle_message(void) static void opal_handle_message(void)
{ {
s64 ret; s64 ret;
/*
* TODO: pre-allocate a message buffer depending on opal-msg-size
* value in /proc/device-tree.
*/
static struct opal_msg msg;
u32 type; u32 type;
ret = opal_get_msg(__pa(&msg), sizeof(msg)); ret = opal_get_msg(__pa(opal_msg), opal_msg_size);
/* No opal message pending. */ /* No opal message pending. */
if (ret == OPAL_RESOURCE) if (ret == OPAL_RESOURCE)
return; return;
...@@ -290,14 +287,14 @@ static void opal_handle_message(void) ...@@ -290,14 +287,14 @@ static void opal_handle_message(void)
return; return;
} }
type = be32_to_cpu(msg.msg_type); type = be32_to_cpu(opal_msg->msg_type);
/* Sanity check */ /* Sanity check */
if (type >= OPAL_MSG_TYPE_MAX) { if (type >= OPAL_MSG_TYPE_MAX) {
pr_warn_once("%s: Unknown message type: %u\n", __func__, type); pr_warn_once("%s: Unknown message type: %u\n", __func__, type);
return; return;
} }
opal_message_do_notify(type, (void *)&msg); opal_message_do_notify(type, (void *)opal_msg);
} }
static irqreturn_t opal_message_notify(int irq, void *data) static irqreturn_t opal_message_notify(int irq, void *data)
...@@ -306,10 +303,24 @@ static irqreturn_t opal_message_notify(int irq, void *data) ...@@ -306,10 +303,24 @@ static irqreturn_t opal_message_notify(int irq, void *data)
return IRQ_HANDLED; return IRQ_HANDLED;
} }
static int __init opal_message_init(void) static int __init opal_message_init(struct device_node *opal_node)
{ {
int ret, i, irq; int ret, i, irq;
ret = of_property_read_u32(opal_node, "opal-msg-size", &opal_msg_size);
if (ret) {
pr_notice("Failed to read opal-msg-size property\n");
opal_msg_size = sizeof(struct opal_msg);
}
opal_msg = kmalloc(opal_msg_size, GFP_KERNEL);
if (!opal_msg) {
opal_msg_size = sizeof(struct opal_msg);
/* Try to allocate fixed message size */
opal_msg = kmalloc(opal_msg_size, GFP_KERNEL);
BUG_ON(opal_msg == NULL);
}
for (i = 0; i < OPAL_MSG_TYPE_MAX; i++) for (i = 0; i < OPAL_MSG_TYPE_MAX; i++)
ATOMIC_INIT_NOTIFIER_HEAD(&opal_msg_notifier_head[i]); ATOMIC_INIT_NOTIFIER_HEAD(&opal_msg_notifier_head[i]);
...@@ -913,7 +924,7 @@ static int __init opal_init(void) ...@@ -913,7 +924,7 @@ static int __init opal_init(void)
} }
/* Initialise OPAL messaging system */ /* Initialise OPAL messaging system */
opal_message_init(); opal_message_init(opal_node);
/* Initialise OPAL asynchronous completion interface */ /* Initialise OPAL asynchronous completion interface */
opal_async_comp_init(); opal_async_comp_init();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment