diff options
author | Alistair Popple <alistair@popple.id.au> | 2014-09-09 15:57:26 +1000 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-10-01 14:23:06 +1000 |
commit | 69a833b6e2fc1636e25539ce58bde6e72f1c3bec (patch) | |
tree | b658b3a433f1ade3494fd8de85709691f9f60997 /core/ipmi.c | |
parent | befc5fdb30604a24cdcd7c3c1d0f2b4e60af453e (diff) | |
download | skiboot-69a833b6e2fc1636e25539ce58bde6e72f1c3bec.zip skiboot-69a833b6e2fc1636e25539ce58bde6e72f1c3bec.tar.gz skiboot-69a833b6e2fc1636e25539ce58bde6e72f1c3bec.tar.bz2 |
bt/ipmi: Fixup allocation of bt/ipmi messages
The original implementation of the bt and ipmi layers required the bt,
ipmi and message data to be allocated separately. This is sub-optimal
as it could cause excessive memory fragmentation. This patch fixes the
problem by adding a function to the bt layer to allocate space for
both the required data and bt/ipmi message.
Signed-off-by: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'core/ipmi.c')
-rw-r--r-- | core/ipmi.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/core/ipmi.c b/core/ipmi.c index 30ea78a..1f9dd5f 100644 --- a/core/ipmi.c +++ b/core/ipmi.c @@ -35,7 +35,7 @@ static void ipmi_process_storage_resp(struct ipmi_msg *msg) * I couldn't find any mention of endianess in the IPMI spec, * but ipmitool seemed to assume little endian? */ - memcpy(&new_time, msg->resp_data, 4); + memcpy(&new_time, msg->data, 4); time = le32_to_cpu(new_time); break; @@ -48,39 +48,37 @@ static void ipmi_process_storage_resp(struct ipmi_msg *msg) } } -static uint32_t time_result; static int64_t ipmi_get_sel_time(void) { - struct ipmi_msg *msg = malloc(sizeof(struct ipmi_msg)); + struct ipmi_msg *msg; + static uint32_t time_result; + msg = bt_alloc_ipmi_msg(0, 4); if (!msg) return OPAL_HARDWARE; msg->cmd = IPMI_GET_SEL_TIME_CMD; msg->netfn = IPMI_NETFN_STORAGE_REQUEST; - msg->req_data = NULL; - msg->req_data_len = 0; - msg->resp_data = (uint8_t *) &time_result; - msg->resp_data_len = 4; + if (bt_add_ipmi_msg_wait(msg)) return -1; + memcpy(&time_result, msg->data, sizeof(time_result)); + return time_result; } static int64_t ipmi_set_sel_time(uint32_t tv) { - struct ipmi_msg *msg = malloc(sizeof(struct ipmi_msg)); + struct ipmi_msg *msg; + msg = bt_alloc_ipmi_msg(sizeof(tv), 0); if (!msg) return OPAL_HARDWARE; msg->cmd = IPMI_SET_SEL_TIME_CMD; msg->netfn = IPMI_NETFN_STORAGE_REQUEST; - msg->req_data = (uint8_t *) &tv; - msg->req_data_len = 4; - msg->resp_data = NULL; - msg->resp_data_len = 0; + memcpy(msg->data, &tv, sizeof(tv)); return bt_add_ipmi_msg_wait(msg); } @@ -141,28 +139,24 @@ static void ipmi_cmd_done(struct ipmi_msg *msg) } out: - free(msg); + bt_free_ipmi_msg(msg); } -static uint8_t chassis_control; int64_t ipmi_opal_chassis_control(uint64_t request) { - struct ipmi_msg *msg = zalloc(sizeof(struct ipmi_msg)); + struct ipmi_msg *msg; + uint8_t chassis_control = request; + msg = bt_alloc_ipmi_msg(sizeof(chassis_control), 0); if (!msg) return OPAL_HARDWARE; if (request > IPMI_CHASSIS_SOFT_SHUTDOWN) return OPAL_PARAMETER; - chassis_control = request; - msg->cmd = IPMI_CHASSIS_CONTROL_CMD; msg->netfn = IPMI_NETFN_CHASSIS_REQUEST; - msg->req_data = (uint8_t *)&chassis_control; - msg->req_data_len = sizeof(chassis_control); - msg->resp_data = NULL; - msg->resp_data_len = 0; + msg->data[0] = chassis_control; prlog(PR_INFO, "IPMI: sending chassis control request %llu\n", request); |