[Skiboot] [PATCH RFC 10/12] opal-prd: Add firmware_request & firmware_notify implementations
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Thu May 25 22:31:02 AEST 2017
On 05/25/2017 12:35 PM, Jeremy Kerr wrote:
> This change adds the implementation of firmware_request() and
> firmware_notify(). To do this, we need to add a message queue, so that
> we can properly handle out-of-order messages coming from firmware.
>
> Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
> ---
> external/opal-prd/opal-prd.c | 151 ++++++++++++++++++++++++++++++++++++++++++-
> external/opal-prd/thunk.S | 2 +-
> include/opal-api.h | 16 +++++
> 3 files changed, 167 insertions(+), 2 deletions(-)
>
.../...
> + n = 0;
> + for (;;) {
> + struct prd_msgq_item *item;
> +
> + rc = read_prd_msg(ctx);
> + if (rc)
> + return -1;
> +
> + msg = ctx->msg;
> + if (msg->hdr.type == OPAL_PRD_MSG_TYPE_FIRMWARE_RESPONSE) {
> + size = be64toh(msg->fw_resp.len);
> + if (size > resp_len)
> + return -1;
> +
> + /* success! a valid response that fits into HBRT's
> + * resp buffer */
> + memcpy(resp, msg->fw_resp.data, size);
> + *resp_lenp = htobe64(size);
> + return 0;
> + }
> +
> + /* not a response? queue up for later consumption */
> + if (++n > max_msgq_len) {
> + pr_log(LOG_ERR,
> + "FW: too many messages queued (%d) while "
> + "waiting for FIRMWARE_RESPONSE", n);
> + return -1;
> + }
> + size = be16toh(msg->hdr.size);
> + item = malloc(sizeof(*item) + size);
Validate malloc return value.
> + memcpy(&item->msg, msg, size);
> + list_add_tail(&ctx->msgq, &item->list);
> + }
> +}
> +
.../...
> diff --git a/external/opal-prd/thunk.S b/external/opal-prd/thunk.S
> index b18e3cb..cca5890 100644
> --- a/external/opal-prd/thunk.S
> +++ b/external/opal-prd/thunk.S
> @@ -197,7 +197,7 @@ hinterface:
> DISABLED_THUNK(hservice_map_phys_mem)
> DISABLED_THUNK(hservice_unmap_phys_mem)
> DISABLED_THUNK(hservice_hcode_scom_update)
> - DISABLED_THUNK(hservice_firmware_request)
> + CALLBACK_THUNK(hservice_firmware_request)
> .globl __hinterface_pad
> __hinterface_pad:
> /* Reserved space for future growth */
> diff --git a/include/opal-api.h b/include/opal-api.h
> index 80033c6..e94747f 100644
> --- a/include/opal-api.h
> +++ b/include/opal-api.h
> @@ -1029,6 +1029,9 @@ enum opal_prd_msg_type {
> OPAL_PRD_MSG_TYPE_OCC_ERROR, /* HBRT <-- OPAL */
> OPAL_PRD_MSG_TYPE_OCC_RESET, /* HBRT <-- OPAL */
> OPAL_PRD_MSG_TYPE_OCC_RESET_NOTIFY, /* HBRT --> OPAL */
> + OPAL_PRD_MSG_TYPE_FIRMWARE_REQUEST, /* HBRT --> OPAL */
> + OPAL_PRD_MSG_TYPE_FIRMWARE_RESPONSE, /* HBRT <-- HBRT */
HBRT <-- OPAL
> + OPAL_PRD_MSG_TYPE_FIRMWARE_NOTIFY, /* HBRT <-- HBRT */
ditto.
-Vasant
More information about the Skiboot
mailing list