[Skiboot] [PATCH RFC 03/12] opal-prd: allow different chips for occ_reset control action
Vasant Hegde
hegdevasant at linux.vnet.ibm.com
Thu May 25 20:00:17 AEST 2017
On 05/25/2017 12:35 PM, Jeremy Kerr wrote:
> Signed-off-by: Jeremy Kerr <jk at ozlabs.org>
> ---
> external/opal-prd/opal-prd.c | 70 +++++++++++++++++++++++++++++++-------------
> 1 file changed, 50 insertions(+), 20 deletions(-)
>
> diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c
> index 5e8f798..fec9770 100644
> --- a/external/opal-prd/opal-prd.c
> +++ b/external/opal-prd/opal-prd.c
> @@ -100,6 +100,9 @@ struct control_msg {
> struct {
> unsigned int argc;
> } run_cmd;
> + struct {
> + uint64_t chip;
> + } occ_reset;
> };
> unsigned int data_len;
> unsigned char data[];
> @@ -1268,17 +1271,32 @@ static void handle_prd_control_occ_error(struct control_msg *msg)
> msg->response = 0;
> }
>
> -static void handle_prd_control_occ_reset(struct control_msg *msg)
> +static void handle_prd_control_occ_reset(struct control_msg *send_msg,
> + struct control_msg *msg)
> {
> + struct opal_prd_msg omsg;
> + uint64_t chip;
> + int rc;
> +
> + /* notify OPAL of the impending reset */
> + memset(&omsg, 0, sizeof(omsg));
> + omsg.hdr.type = OPAL_PRD_MSG_TYPE_OCC_RESET_NOTIFY;
> + omsg.hdr.size = htobe16(sizeof(omsg));
> + rc = write(ctx->fd, &omsg, sizeof(omsg));
> + if (rc != sizeof(omsg))
> + pr_log(LOG_WARNING, "FW: Failed to send OCC_RESET message: %m");
> +
> if (!hservice_runtime->process_occ_reset) {
> pr_log_nocall("process_occ_reset");
> return;
> }
>
> - pr_debug("CTRL: calling process_occ_reset(0)");
> - call_process_occ_reset(0);
> - msg->data_len = 0;
> - msg->response = 0;
> + chip = msg->occ_reset.chip;
> +
> + pr_debug("CTRL: calling process_occ_reset(%ld)", chip);
> + call_process_occ_reset(chip);
> + send_msg->data_len = 0;
> + send_msg->response = 0;
> }
>
> static void handle_prd_control_occ_actuation(struct control_msg *msg,
> @@ -1386,7 +1404,6 @@ static void handle_prd_control_run_cmd(struct control_msg *send_msg,
> static void handle_prd_control(struct opal_prd_ctx *ctx, int fd)
> {
> struct control_msg msg, *recv_msg, *send_msg;
> - struct opal_prd_msg omsg;
> bool enabled = false;
> int rc, size;
>
> @@ -1439,12 +1456,7 @@ static void handle_prd_control(struct opal_prd_ctx *ctx, int fd)
> handle_prd_control_occ_actuation(send_msg, enabled);
> break;
> case CONTROL_MSG_TEMP_OCC_RESET:
> - omsg.hdr.type = OPAL_PRD_MSG_TYPE_OCC_RESET_NOTIFY;
> - omsg.hdr.size = htobe16(sizeof(omsg));
> - rc = write(ctx->fd, &omsg, sizeof(omsg));
> - if (rc != sizeof(omsg))
> - pr_log(LOG_WARNING, "FW: Failed to send OCC_RESET message: %m");
> - handle_prd_control_occ_reset(send_msg);
> + handle_prd_control_occ_reset(send_msg, recv_msg);
> break;
> case CONTROL_MSG_TEMP_OCC_ERROR:
> handle_prd_control_occ_error(send_msg);
> @@ -1743,30 +1755,48 @@ out_close:
> return rc;
> }
>
> -static int send_occ_control(struct opal_prd_ctx *ctx, const char *str)
> +static int send_occ_control(struct opal_prd_ctx *ctx, int argc, char *argv[])
> {
> struct control_msg send_msg, *recv_msg = NULL;
> + const char *op;
> int rc;
>
> + assert(argc > 1);
assert(argc >= 1 ) ?
> + op = argv[0];
> +
> memset(&send_msg, 0, sizeof(send_msg));
>
> - if (!strcmp(str, "enable"))
> + if (!strcmp(op, "enable"))
> send_msg.type = CONTROL_MSG_ENABLE_OCCS;
> - else if (!strcmp(str, "disable"))
> + else if (!strcmp(op, "disable"))
> send_msg.type = CONTROL_MSG_DISABLE_OCCS;
> - else if (!strcmp(str, "reset"))
> + else if (!strcmp(op, "reset")) {
> + unsigned long chip = 0;
> +
> + if (argc) {
> + char *end;
> + chip = strtoul(argv[0], &end, 0);
argv[1] ?
-Vasant
More information about the Skiboot
mailing list