[Skiboot] [PATCH v3 03/10] opal-msg: Pass parameter size to _opal_queue_msg()
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Sat May 11 21:42:16 AEST 2019
Currently _opal_queue_msg() takes number of parameters. So far this was
fine as opal_queue_msg() was supporting only fixed number of parameters
(8 * 8 bytes). Soon we are going to introduce variable size parameter.
Hence num_params -> params_size.
Cc: Jeremy Kerr <jk at ozlabs.org>
Cc: Mahesh Salgaonkar <mahesh at linux.vnet.ibm.com>
Cc: Shilpasri G Bhat <shilpa.bhat at linux.vnet.ibm.com>
Signed-off-by: Vasant Hegde <hegdevasant at linux.vnet.ibm.com>
---
core/hmi.c | 4 ++--
core/opal-msg.c | 8 ++++----
hw/occ.c | 16 +++++++++-------
hw/prd.c | 8 ++++----
include/opal-msg.h | 9 +++++++--
5 files changed, 26 insertions(+), 19 deletions(-)
diff --git a/core/hmi.c b/core/hmi.c
index e81328600..ed1da14ae 100644
--- a/core/hmi.c
+++ b/core/hmi.c
@@ -331,13 +331,13 @@ static int queue_hmi_event(struct OpalHMIEvent *hmi_evt, int recover, uint64_t *
* num_params divide the struct size by 8 bytes to get exact
* num_params value.
*/
- num_params = ALIGN_UP(sizeof(*hmi_evt), sizeof(u64)) / sizeof(u64);
+ num_params = ALIGN_UP(sizeof(*hmi_evt), sizeof(u64));
*out_flags |= OPAL_HMI_FLAGS_NEW_EVENT;
/* queue up for delivery to host. */
return _opal_queue_msg(OPAL_MSG_HMI_EVT, NULL, NULL,
- num_params, (uint64_t *)hmi_evt);
+ num_params, hmi_evt);
}
static int read_core_fir(uint32_t chip_id, uint32_t core_id, uint64_t *core_fir)
diff --git a/core/opal-msg.c b/core/opal-msg.c
index d3dd2ae3c..907a9e0af 100644
--- a/core/opal-msg.c
+++ b/core/opal-msg.c
@@ -36,7 +36,7 @@ static struct lock opal_msg_lock = LOCK_UNLOCKED;
int _opal_queue_msg(enum opal_msg_type msg_type, void *data,
void (*consumed)(void *data, int status),
- size_t num_params, const u64 *params)
+ size_t params_size, const void *params)
{
struct opal_msg_entry *entry;
@@ -57,11 +57,11 @@ int _opal_queue_msg(enum opal_msg_type msg_type, void *data,
entry->data = data;
entry->msg.msg_type = cpu_to_be32(msg_type);
- if (num_params > ARRAY_SIZE(entry->msg.params)) {
+ if (params_size > OPAL_MSG_FIXED_PARAMS_SIZE) {
prerror("Discarding extra parameters\n");
- num_params = ARRAY_SIZE(entry->msg.params);
+ params_size = OPAL_MSG_FIXED_PARAMS_SIZE;
}
- memcpy(entry->msg.params, params, num_params*sizeof(u64));
+ memcpy(entry->msg.params, params, params_size);
list_add_tail(&msg_pending_list, &entry->link);
opal_update_pending_evt(OPAL_EVENT_MSG_PENDING,
diff --git a/hw/occ.c b/hw/occ.c
index c892c905f..ec154a5ff 100644
--- a/hw/occ.c
+++ b/hw/occ.c
@@ -902,8 +902,9 @@ static void occ_throttle_poll(void *data __unused)
occ_msg.type = cpu_to_be64(OCC_THROTTLE);
occ_msg.chip = 0;
occ_msg.throttle_status = 0;
- rc = _opal_queue_msg(OPAL_MSG_OCC, NULL, NULL, 3,
- (uint64_t *)&occ_msg);
+ rc = _opal_queue_msg(OPAL_MSG_OCC, NULL, NULL,
+ sizeof(struct opal_occ_msg),
+ &occ_msg);
if (!rc)
occ_reset = false;
}
@@ -923,7 +924,8 @@ static void occ_throttle_poll(void *data __unused)
occ_msg.throttle_status = cpu_to_be64(throttle);
rc = _opal_queue_msg(OPAL_MSG_OCC, NULL,
occ_msg_consumed,
- 3, (uint64_t *)&occ_msg);
+ sizeof(struct opal_occ_msg),
+ &occ_msg);
if (!rc) {
chip->throttle = throttle;
occ_opal_msg_outstanding = true;
@@ -1932,8 +1934,8 @@ static void __occ_do_load(u8 scope, u32 dbob_id __unused, u32 seq_id)
} else if (!rc) {
struct opal_occ_msg occ_msg = { CPU_TO_BE64(OCC_LOAD), 0, 0 };
- rc = _opal_queue_msg(OPAL_MSG_OCC, NULL, NULL, 3,
- (uint64_t *)&occ_msg);
+ rc = _opal_queue_msg(OPAL_MSG_OCC, NULL, NULL,
+ sizeof(struct opal_occ_msg), &occ_msg);
if (rc)
prlog(PR_INFO, "OCC: Failed to queue message %d\n",
OCC_LOAD);
@@ -2056,8 +2058,8 @@ int occ_msg_queue_occ_reset(void)
int rc;
lock(&occ_lock);
- rc = _opal_queue_msg(OPAL_MSG_OCC, NULL, NULL, 3,
- (uint64_t *)&occ_msg);
+ rc = _opal_queue_msg(OPAL_MSG_OCC, NULL, NULL,
+ sizeof(struct opal_occ_msg), &occ_msg);
if (rc) {
prlog(PR_INFO, "OCC: Failed to queue OCC_RESET message\n");
goto out;
diff --git a/hw/prd.c b/hw/prd.c
index da2447544..9992aecf5 100644
--- a/hw/prd.c
+++ b/hw/prd.c
@@ -212,8 +212,8 @@ static void send_next_pending_event(void)
* disabled then we shouldn't propagate PRD events to the host.
*/
if (prd_enabled)
- _opal_queue_msg(OPAL_MSG_PRD, prd_msg, prd_msg_consumed, 4,
- (uint64_t *)prd_msg);
+ _opal_queue_msg(OPAL_MSG_PRD, prd_msg, prd_msg_consumed,
+ prd_msg->hdr.size, prd_msg);
}
static void __prd_event(uint32_t proc, uint8_t event)
@@ -421,8 +421,8 @@ static int prd_msg_handle_firmware_req(struct opal_prd_msg *msg)
}
if (!rc)
- rc = _opal_queue_msg(OPAL_MSG_PRD, prd_msg, prd_msg_consumed, 4,
- (uint64_t *) prd_msg);
+ rc = _opal_queue_msg(OPAL_MSG_PRD, prd_msg, prd_msg_consumed,
+ prd_msg->hdr.size, prd_msg);
else
prd_msg_inuse = false;
diff --git a/include/opal-msg.h b/include/opal-msg.h
index 9be70334d..bfe148be6 100644
--- a/include/opal-msg.h
+++ b/include/opal-msg.h
@@ -30,13 +30,18 @@
/* Max size of struct opal_msg */
#define OPAL_MSG_SIZE (64 * 1024)
+/* opal_msg fixed parameters size */
+#define OPAL_MSG_HDR_SIZE (offsetof(struct opal_msg, params))
+#define OPAL_MSG_FIXED_PARAMS_SIZE \
+ (sizeof(struct opal_msg) - OPAL_MSG_HDR_SIZE)
+
int _opal_queue_msg(enum opal_msg_type msg_type, void *data,
void (*consumed)(void *data, int status),
- size_t num_params, const u64 *params);
+ size_t params_size, const void *params);
#define opal_queue_msg(msg_type, data, cb, ...) \
_opal_queue_msg(msg_type, data, cb, \
- sizeof((u64[]) {__VA_ARGS__})/sizeof(u64), \
+ sizeof((u64[]) {__VA_ARGS__}), \
(u64[]) {__VA_ARGS__});
void opal_init_msg(void);
--
2.14.3
More information about the Skiboot
mailing list