From patchwork Fri May 26 02:54:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Kerr X-Patchwork-Id: 767217 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wYrPc3pXgz9s7h for ; Fri, 26 May 2017 12:56:36 +1000 (AEST) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3wYrPc2tT6zDqx5 for ; Fri, 26 May 2017 12:56:36 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3wYrMj5vxFzDqkL for ; Fri, 26 May 2017 12:54:57 +1000 (AEST) Received: by ozlabs.org (Postfix, from userid 1023) id 3wYrMj3T1lz9sN1; Fri, 26 May 2017 12:54:57 +1000 (AEST) From: Jeremy Kerr To: skiboot@lists.ozlabs.org Date: Fri, 26 May 2017 12:54:28 +1000 Message-Id: <1495767271-8216-10-git-send-email-jk@ozlabs.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495767271-8216-1-git-send-email-jk@ozlabs.org> References: <1495767271-8216-1-git-send-email-jk@ozlabs.org> Subject: [Skiboot] [PATCH RFC v2 09/12] opal-prd: split prd message reading from handling X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Dan Crowell MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Signed-off-by: Jeremy Kerr Reviewed-by: Vasant Hegde --- external/opal-prd/opal-prd.c | 47 ++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c index 349363d..e6cd353 100644 --- a/external/opal-prd/opal-prd.c +++ b/external/opal-prd/opal-prd.c @@ -1228,7 +1228,29 @@ static int handle_msg_occ_reset(struct opal_prd_ctx *ctx, return 0; } -static int handle_prd_msg(struct opal_prd_ctx *ctx) +static int handle_prd_msg(struct opal_prd_ctx *ctx, struct opal_prd_msg *msg) +{ + int rc = -1; + + switch (msg->hdr.type) { + case OPAL_PRD_MSG_TYPE_ATTN: + rc = handle_msg_attn(ctx, msg); + break; + case OPAL_PRD_MSG_TYPE_OCC_RESET: + rc = handle_msg_occ_reset(ctx, msg); + break; + case OPAL_PRD_MSG_TYPE_OCC_ERROR: + rc = handle_msg_occ_error(ctx, msg); + break; + default: + pr_log(LOG_WARNING, "Invalid incoming message type 0x%x", + msg->hdr.type); + } + + return rc; +} + +static int read_prd_msg(struct opal_prd_ctx *ctx) { struct opal_prd_msg *msg; int size; @@ -1293,22 +1315,6 @@ static int handle_prd_msg(struct opal_prd_ctx *ctx) } } - switch (msg->hdr.type) { - case OPAL_PRD_MSG_TYPE_ATTN: - rc = handle_msg_attn(ctx, msg); - break; - case OPAL_PRD_MSG_TYPE_OCC_RESET: - rc = handle_msg_occ_reset(ctx, msg); - break; - case OPAL_PRD_MSG_TYPE_OCC_ERROR: - rc = handle_msg_occ_error(ctx, msg); - break; - default: - pr_log(LOG_WARNING, "Invalid incoming message type 0x%x", - msg->hdr.type); - return -1; - } - return 0; } @@ -1603,8 +1609,11 @@ static int run_attn_loop(struct opal_prd_ctx *ctx) if (!rc) continue; - if (pollfds[0].revents & POLLIN) - handle_prd_msg(ctx); + if (pollfds[0].revents & POLLIN) { + rc = read_prd_msg(ctx); + if (!rc) + handle_prd_msg(ctx, ctx->msg); + } if (pollfds[1].revents & POLLIN) { fd = accept(ctx->socket, NULL, NULL);