From patchwork Thu May 16 17:58:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1100684 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fLF6WPHz9s7h for ; Fri, 17 May 2019 03:58:45 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454fLF0h5zzDqQ1 for ; Fri, 17 May 2019 03:58:45 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454fL22jpWzDqBG for ; Fri, 17 May 2019 03:58:33 +1000 (AEST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GHlGdO006992 for ; Thu, 16 May 2019 13:58:29 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2shajhdrjt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 13:58:29 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 18:58:27 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 18:58:24 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GHwNKQ52035704 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 17:58:23 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BCCF742047; Thu, 16 May 2019 17:58:23 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4C16542045; Thu, 16 May 2019 17:58:22 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.102.0.16]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 17:58:22 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 16 May 2019 23:28:07 +0530 X-Mailer: git-send-email 2.14.3 X-TM-AS-GCONF: 00 x-cbid: 19051617-0028-0000-0000-0000036E73A8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051617-0029-0000-0000-0000242E0F71 Message-Id: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-16_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160113 Subject: [Skiboot] [PATCH v4 01/10] core/opal: Increase opal-msg-size size X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Kernel will use `opal-msg-size` property to allocate memory for opal_msg. We want to send bigger data from OPAL to kernel. Hence increase opal-msg-size to 64K. Signed-off-by: Vasant Hegde Acked-by: Jeremy Kerr --- core/opal.c | 2 +- include/opal-msg.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/core/opal.c b/core/opal.c index 624e2a255..3a2fbb95b 100644 --- a/core/opal.c +++ b/core/opal.c @@ -416,7 +416,7 @@ void add_opal_node(void) dt_add_property_strings(opal_node, "compatible", "ibm,opal-v3"); dt_add_property_cells(opal_node, "opal-msg-async-num", OPAL_MAX_ASYNC_COMP); - dt_add_property_cells(opal_node, "opal-msg-size", sizeof(struct opal_msg)); + dt_add_property_cells(opal_node, "opal-msg-size", OPAL_MSG_SIZE); dt_add_property_u64(opal_node, "opal-base-address", base); dt_add_property_u64(opal_node, "opal-entry-address", entry); dt_add_property_u64(opal_node, "opal-runtime-size", size); diff --git a/include/opal-msg.h b/include/opal-msg.h index 74163c47d..86b6d616e 100644 --- a/include/opal-msg.h +++ b/include/opal-msg.h @@ -27,6 +27,9 @@ */ #define OPAL_MAX_ASYNC_COMP 16 +/* Max size of struct opal_msg */ +#define OPAL_MSG_SIZE (64 * 1024) + int _opal_queue_msg(enum opal_msg_type msg_type, void *data, void (*consumed)(void *data), size_t num_params, const u64 *params); From patchwork Thu May 16 17:58:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1100685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fLg1PVzz9s9y for ; Fri, 17 May 2019 03:59:07 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454fLf3RsJzDqLt for ; Fri, 17 May 2019 03:59:06 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454fL40Td8zDqBG for ; Fri, 17 May 2019 03:58:35 +1000 (AEST) Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GHlcJ0042904 for ; Thu, 16 May 2019 13:58:33 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2sha8np8bc-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 13:58:33 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 18:58:31 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 18:58:29 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GHwSjX50594008 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 17:58:28 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 257184204C; Thu, 16 May 2019 17:58:28 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 55A1842041; Thu, 16 May 2019 17:58:24 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.102.0.16]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 17:58:23 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 16 May 2019 23:28:08 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> References: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19051617-0020-0000-0000-0000033D702D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051617-0021-0000-0000-000021903913 Message-Id: <20190516175816.10558-2-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-16_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160113 Subject: [Skiboot] [PATCH v4 02/10] opal-msg: Pass return value to callback handler X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Kernel calls opal_get_msg() API to read OPAL message. In this path OPAL calls "callback" handler to inform caller that kernel read the opal message. It assumes that read is always success. This assumption was fine as message was always fixed size. Next patch introduces variable size opal message. In that situation opal_get_msg() may fail due to insufficient buffer size (ex: old kernel and new OPAL combination). So lets add `return value` parameter to "callback" handler. So that caller knows kernel didn't read the message and take appropriate action. Cc: Jeremy Kerr Cc: Mahesh Salgaonkar Cc: Oliver O'Halloran Signed-off-by: Vasant Hegde Acked-by: Jeremy Kerr --- core/opal-msg.c | 16 ++++++++-------- core/test/run-msg.c | 5 +++-- hw/fsp/fsp-mem-err.c | 6 +++--- hw/occ.c | 4 ++-- hw/prd.c | 4 ++-- include/opal-msg.h | 6 +++--- 6 files changed, 21 insertions(+), 20 deletions(-) diff --git a/core/opal-msg.c b/core/opal-msg.c index 19714670e..d3dd2ae3c 100644 --- a/core/opal-msg.c +++ b/core/opal-msg.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 IBM Corp. +/* Copyright 2013-2019 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ struct opal_msg_entry { struct list_node link; - void (*consumed)(void *data); + void (*consumed)(void *data, int status); void *data; struct opal_msg msg; }; @@ -35,8 +35,8 @@ static LIST_HEAD(msg_pending_list); static struct lock opal_msg_lock = LOCK_UNLOCKED; int _opal_queue_msg(enum opal_msg_type msg_type, void *data, - void (*consumed)(void *data), size_t num_params, - const u64 *params) + void (*consumed)(void *data, int status), + size_t num_params, const u64 *params) { struct opal_msg_entry *entry; @@ -75,7 +75,7 @@ int _opal_queue_msg(enum opal_msg_type msg_type, void *data, static int64_t opal_get_msg(uint64_t *buffer, uint64_t size) { struct opal_msg_entry *entry; - void (*callback)(void *data); + void (*callback)(void *data, int status); void *data; if (size < sizeof(struct opal_msg) || !buffer) @@ -103,7 +103,7 @@ static int64_t opal_get_msg(uint64_t *buffer, uint64_t size) unlock(&opal_msg_lock); if (callback) - callback(data); + callback(data, OPAL_SUCCESS); return OPAL_SUCCESS; } @@ -113,7 +113,7 @@ static int64_t opal_check_completion(uint64_t *buffer, uint64_t size, uint64_t token) { struct opal_msg_entry *entry, *next_entry; - void (*callback)(void *data) = NULL; + void (*callback)(void *data, int status) = NULL; int rc = OPAL_BUSY; void *data = NULL; @@ -142,7 +142,7 @@ static int64_t opal_check_completion(uint64_t *buffer, uint64_t size, unlock(&opal_msg_lock); if (callback) - callback(data); + callback(data, OPAL_SUCCESS); return rc; diff --git a/core/test/run-msg.c b/core/test/run-msg.c index 67418a917..08e1a019b 100644 --- a/core/test/run-msg.c +++ b/core/test/run-msg.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 IBM Corp. +/* Copyright 2013-2019 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,8 +61,9 @@ void opal_update_pending_evt(uint64_t evt_mask, uint64_t evt_values) } static long magic = 8097883813087437089UL; -static void callback(void *data) +static void callback(void *data, int status) { + assert(status == OPAL_SUCCESS); assert(*(uint64_t *)data == magic); } diff --git a/hw/fsp/fsp-mem-err.c b/hw/fsp/fsp-mem-err.c index a2b0619ff..7f01c5834 100644 --- a/hw/fsp/fsp-mem-err.c +++ b/hw/fsp/fsp-mem-err.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 IBM Corp. +/* Copyright 2013-2019 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,7 +84,7 @@ static bool send_response_to_fsp(u32 cmd_sub_mod) * in that case, at least until we clarify a bit better how * we want to handle things. */ -static void queue_event_for_delivery(void *data __unused) +static void queue_event_for_delivery(void *data __unused, int staus __unused) { struct fsp_mem_err_node *entry; uint64_t *merr_data; @@ -144,7 +144,7 @@ static int queue_mem_err_node(struct OpalMemoryErrorData *merr_evt) unlock(&mem_err_lock); /* Queue up the event for delivery to OS. */ - queue_event_for_delivery(NULL); + queue_event_for_delivery(NULL, OPAL_SUCCESS); return 0; } diff --git a/hw/occ.c b/hw/occ.c index 5dc05d3fb..c892c905f 100644 --- a/hw/occ.c +++ b/hw/occ.c @@ -1,4 +1,4 @@ -/* Copyright 2013-2017 IBM Corp. +/* Copyright 2013-2019 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -852,7 +852,7 @@ static bool cpu_pstates_prepare_core(struct proc_chip *chip, } static bool occ_opal_msg_outstanding = false; -static void occ_msg_consumed(void *data __unused) +static void occ_msg_consumed(void *data __unused, int status __unused) { lock(&occ_lock); occ_opal_msg_outstanding = false; diff --git a/hw/prd.c b/hw/prd.c index c5220196b..da2447544 100644 --- a/hw/prd.c +++ b/hw/prd.c @@ -1,4 +1,4 @@ -/* Copyright 2014-2015 IBM Corp. +/* Copyright 2014-2019 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,7 +81,7 @@ static uint64_t prd_ipoll_mask; static void send_next_pending_event(void); -static void prd_msg_consumed(void *data) +static void prd_msg_consumed(void *data, int status __unused) { struct opal_prd_msg *msg = data; uint32_t proc; diff --git a/include/opal-msg.h b/include/opal-msg.h index 86b6d616e..9be70334d 100644 --- a/include/opal-msg.h +++ b/include/opal-msg.h @@ -1,4 +1,4 @@ -/* Copyright 2013-2014 IBM Corp. +/* Copyright 2013-2019 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,8 @@ #define OPAL_MSG_SIZE (64 * 1024) int _opal_queue_msg(enum opal_msg_type msg_type, void *data, - void (*consumed)(void *data), size_t num_params, - const u64 *params); + void (*consumed)(void *data, int status), + size_t num_params, const u64 *params); #define opal_queue_msg(msg_type, data, cb, ...) \ _opal_queue_msg(msg_type, data, cb, \ From patchwork Thu May 16 17:58:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1100686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fM03gNFz9s9y for ; Fri, 17 May 2019 03:59:24 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454fM01dffzDqQk for ; Fri, 17 May 2019 03:59:24 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454fL91LpJzDqBG for ; Fri, 17 May 2019 03:58:40 +1000 (AEST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GHmnQq020584 for ; Thu, 16 May 2019 13:58:37 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2shbdgk9bw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 13:58:37 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 18:58:35 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 18:58:32 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GHwV7Z50331700 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 17:58:31 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EDFAB4204B; Thu, 16 May 2019 17:58:30 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B61542042; Thu, 16 May 2019 17:58:28 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.102.0.16]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 17:58:28 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 16 May 2019 23:28:09 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> References: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19051617-0020-0000-0000-0000033D702F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051617-0021-0000-0000-000021903916 Message-Id: <20190516175816.10558-3-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-16_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160113 Subject: [Skiboot] [PATCH v4 03/10] opal-msg: Pass parameter size to _opal_queue_msg() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" 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 Cc: Mahesh Salgaonkar Cc: Shilpasri G Bhat Signed-off-by: Vasant Hegde Acked-by Jeremy Kerr --- core/hmi.c | 6 +++--- core/opal-msg.c | 8 ++++---- hw/occ.c | 16 +++++++++------- hw/prd.c | 8 ++++---- include/opal-msg.h | 9 +++++++-- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/core/hmi.c b/core/hmi.c index e81328600..705c573f3 100644 --- a/core/hmi.c +++ b/core/hmi.c @@ -312,7 +312,7 @@ static int setup_scom_addresses(void) static int queue_hmi_event(struct OpalHMIEvent *hmi_evt, int recover, uint64_t *out_flags) { - size_t num_params; + size_t size; /* Don't queue up event if recover == -1 */ if (recover == -1) @@ -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); + size = 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); + size, 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); From patchwork Thu May 16 17:58:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1100687 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fMD3986z9s7h for ; Fri, 17 May 2019 03:59:36 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454fMD2CbHzDqRx for ; Fri, 17 May 2019 03:59:36 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454fLC41Q0zDqQB for ; Fri, 17 May 2019 03:58:43 +1000 (AEST) Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GHlAZM077365 for ; Thu, 16 May 2019 13:58:41 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2shbb63byp-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 13:58:41 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 18:58:38 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 18:58:35 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GHwYeB42991668 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 17:58:34 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 656A24204C; Thu, 16 May 2019 17:58:34 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7CB2A42042; Thu, 16 May 2019 17:58:31 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.102.0.16]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 17:58:31 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 16 May 2019 23:28:10 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> References: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19051617-0012-0000-0000-0000031C71BA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051617-0013-0000-0000-000021551438 Message-Id: <20190516175816.10558-4-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-16_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160113 Subject: [Skiboot] [PATCH v4 04/10] opal-msg: Enhance opal-get-msg API X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Linux uses opal_get_msg (OPAL_GET_MSG) API to get OPAL messages. This interface supports upto 8 params (64 bytes). We have a requirement to send bigger data to Linux. This patch enhances OPAL to send bigger data to Linux. - Linux will use "opal-msg-size" device tree property to allocate memory for OPAL messages (previous patch increased "opal-msg-size" to 64K). - Replaced `reserved` field in "struct opal_msg" with `size`. So that Linux side opal_get_msg user can detect actual data size. - If buffer size < actual message size, then opal_get_msg will copy partial data and return OPAL_PARTIAL to Linux. - Add new variable "extended" to "opal_msg_entry" structure to keep track of messages that has more than 64byte data. We will allocate separate memory for these messages and once kernel consumes message we will release that memory. Cc: Jeremy Kerr Cc: Mahesh Salgaonkar Cc: Oliver O'Halloran Signed-off-by: Vasant Hegde Acked-by: Jeremy Kerr --- core/opal-msg.c | 66 ++++++++++++++++++++++++++++++------------ core/test/run-msg.c | 6 ++-- doc/opal-api/opal-messages.rst | 2 +- include/opal-api.h | 2 +- 4 files changed, 53 insertions(+), 23 deletions(-) diff --git a/core/opal-msg.c b/core/opal-msg.c index 907a9e0af..af1ec7d00 100644 --- a/core/opal-msg.c +++ b/core/opal-msg.c @@ -25,6 +25,7 @@ struct opal_msg_entry { struct list_node link; void (*consumed)(void *data, int status); + bool extended; void *data; struct opal_msg msg; }; @@ -39,37 +40,47 @@ int _opal_queue_msg(enum opal_msg_type msg_type, void *data, size_t params_size, const void *params) { struct opal_msg_entry *entry; + uint64_t entry_size; + + if ((params_size + OPAL_MSG_HDR_SIZE) > OPAL_MSG_SIZE) { + prlog(PR_DEBUG, "param_size (0x%x) > opal_msg param size (0x%x)\n", + (u32)params_size, (u32)(OPAL_MSG_SIZE - OPAL_MSG_HDR_SIZE)); + return OPAL_PARAMETER; + } lock(&opal_msg_lock); - entry = list_pop(&msg_free_list, struct opal_msg_entry, link); - if (!entry) { - prerror("No available node in the free list, allocating\n"); - entry = zalloc(sizeof(struct opal_msg_entry)); + if (params_size > OPAL_MSG_FIXED_PARAMS_SIZE) { + entry_size = sizeof(struct opal_msg_entry) + params_size; + entry_size -= OPAL_MSG_FIXED_PARAMS_SIZE; + entry = zalloc(entry_size); + if (entry) + entry->extended = true; + } else { + entry = list_pop(&msg_free_list, struct opal_msg_entry, link); if (!entry) { - prerror("Allocation failed\n"); - unlock(&opal_msg_lock); - return OPAL_RESOURCE; + prerror("No available node in the free list, allocating\n"); + entry = zalloc(sizeof(struct opal_msg_entry)); } } + if (!entry) { + prerror("Allocation failed\n"); + unlock(&opal_msg_lock); + return OPAL_RESOURCE; + } entry->consumed = consumed; entry->data = data; entry->msg.msg_type = cpu_to_be32(msg_type); - - if (params_size > OPAL_MSG_FIXED_PARAMS_SIZE) { - prerror("Discarding extra parameters\n"); - params_size = OPAL_MSG_FIXED_PARAMS_SIZE; - } + entry->msg.size = cpu_to_be32(params_size); memcpy(entry->msg.params, params, params_size); list_add_tail(&msg_pending_list, &entry->link); opal_update_pending_evt(OPAL_EVENT_MSG_PENDING, OPAL_EVENT_MSG_PENDING); - unlock(&opal_msg_lock); - return 0; + return OPAL_SUCCESS; } static int64_t opal_get_msg(uint64_t *buffer, uint64_t size) @@ -77,6 +88,8 @@ static int64_t opal_get_msg(uint64_t *buffer, uint64_t size) struct opal_msg_entry *entry; void (*callback)(void *data, int status); void *data; + uint64_t msg_size; + int rc = OPAL_SUCCESS; if (size < sizeof(struct opal_msg) || !buffer) return OPAL_PARAMETER; @@ -92,20 +105,37 @@ static int64_t opal_get_msg(uint64_t *buffer, uint64_t size) return OPAL_RESOURCE; } - memcpy(buffer, &entry->msg, sizeof(entry->msg)); + msg_size = OPAL_MSG_HDR_SIZE + be32_to_cpu(entry->msg.size); + if (size < msg_size) { + /* Send partial data to Linux */ + prlog(PR_NOTICE, "Sending partial data [msg_type : 0x%x, " + "msg_size : 0x%x, buf_size : 0x%x]\n", + be32_to_cpu(entry->msg.msg_type), + (u32)msg_size, (u32)size); + + entry->msg.size = cpu_to_be32(size - OPAL_MSG_HDR_SIZE); + msg_size = size; + rc = OPAL_PARTIAL; + } + + memcpy((void *)buffer, (void *)&entry->msg, msg_size); callback = entry->consumed; data = entry->data; - list_add(&msg_free_list, &entry->link); + if (entry->extended) + free(entry); + else + list_add(&msg_free_list, &entry->link); + if (list_empty(&msg_pending_list)) opal_update_pending_evt(OPAL_EVENT_MSG_PENDING, 0); unlock(&opal_msg_lock); if (callback) - callback(data, OPAL_SUCCESS); + callback(data, rc); - return OPAL_SUCCESS; + return rc; } opal_call(OPAL_GET_MSG, opal_get_msg, 2); diff --git a/core/test/run-msg.c b/core/test/run-msg.c index 08e1a019b..f5f948ace 100644 --- a/core/test/run-msg.c +++ b/core/test/run-msg.c @@ -132,13 +132,13 @@ int main(void) assert(r == 0); assert(list_count(&msg_pending_list) == ++npending); - assert(list_count(&msg_free_list) == --nfree); + assert(list_count(&msg_free_list) == nfree); r = opal_get_msg(m_ptr, sizeof(m)); - assert(r == 0); + assert(r == OPAL_PARTIAL); assert(list_count(&msg_pending_list) == --npending); - assert(list_count(&msg_free_list) == ++nfree); + assert(list_count(&msg_free_list) == nfree); assert(m.params[0] == 0); assert(m.params[1] == 1); diff --git a/doc/opal-api/opal-messages.rst b/doc/opal-api/opal-messages.rst index e4e813aad..25acaec2c 100644 --- a/doc/opal-api/opal-messages.rst +++ b/doc/opal-api/opal-messages.rst @@ -11,7 +11,7 @@ An opal_msg is: :: struct opal_msg { __be32 msg_type; - __be32 reserved; + __be32 size; __be64 params[8]; }; diff --git a/include/opal-api.h b/include/opal-api.h index e461c9d27..e15c5b89e 100644 --- a/include/opal-api.h +++ b/include/opal-api.h @@ -555,7 +555,7 @@ enum opal_msg_type { struct opal_msg { __be32 msg_type; - __be32 reserved; + __be32 size; __be64 params[8]; }; From patchwork Thu May 16 17:58:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1100688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fMR51dpz9s7h for ; Fri, 17 May 2019 03:59:47 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454fMR3q6xzDqRJ for ; Fri, 17 May 2019 03:59:47 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454fLC2nHDzDqQ1 for ; Fri, 17 May 2019 03:58:43 +1000 (AEST) Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GHmmQ6020555 for ; Thu, 16 May 2019 13:58:41 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2shbdgk9ee-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 13:58:41 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 18:58:39 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 18:58:37 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GHwaw430932994 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 17:58:36 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9CF8F42049; Thu, 16 May 2019 17:58:36 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C83D442042; Thu, 16 May 2019 17:58:34 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.102.0.16]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 17:58:34 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 16 May 2019 23:28:11 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> References: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19051617-0016-0000-0000-0000027C7793 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051617-0017-0000-0000-000032D94FF2 Message-Id: <20190516175816.10558-5-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-16_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160113 Subject: [Skiboot] [PATCH v4 05/10] core/test/run-msg: Add callback function test X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" - Test callback function - Add test case to test OPAL_PARTIAL return value - Add test for OPAL_PARAMETER return value Signed-off-by: Vasant Hegde --- core/test/run-msg.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/core/test/run-msg.c b/core/test/run-msg.c index f5f948ace..34bb42477 100644 --- a/core/test/run-msg.c +++ b/core/test/run-msg.c @@ -63,7 +63,7 @@ void opal_update_pending_evt(uint64_t evt_mask, uint64_t evt_values) static long magic = 8097883813087437089UL; static void callback(void *data, int status) { - assert(status == OPAL_SUCCESS); + assert((status == OPAL_SUCCESS || status == OPAL_PARTIAL)); assert(*(uint64_t *)data == magic); } @@ -140,6 +140,23 @@ int main(void) assert(list_count(&msg_pending_list) == --npending); assert(list_count(&msg_free_list) == nfree); + /* Return OPAL_PARTIAL to callback */ + r = opal_queue_msg(0, &magic, callback, 0, 1, 2, 3, 4, 5, 6, 7, 0xBADDA7A); + assert(r == 0); + + assert(list_count(&msg_pending_list) == ++npending); + assert(list_count(&msg_free_list) == nfree); + + r = opal_get_msg(m_ptr, sizeof(m)); + assert(r == OPAL_PARTIAL); + + assert(list_count(&msg_pending_list) == --npending); + assert(list_count(&msg_free_list) == nfree); + + /* return OPAL_PARAMETER */ + r = _opal_queue_msg(0, NULL, NULL, OPAL_MSG_SIZE, m_ptr); + assert(r == OPAL_PARAMETER); + assert(m.params[0] == 0); assert(m.params[1] == 1); assert(m.params[2] == 2); From patchwork Thu May 16 17:58:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1100689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fMh3shGz9s7h for ; Fri, 17 May 2019 04:00:00 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454fMh31RgzDqQB for ; Fri, 17 May 2019 04:00:00 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454fLG1c2zzDqQn for ; Fri, 17 May 2019 03:58:46 +1000 (AEST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GHlG00007017 for ; Thu, 16 May 2019 13:58:44 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0b-001b2d01.pphosted.com with ESMTP id 2shajhdrw3-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 13:58:43 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 18:58:41 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp01.uk.ibm.com (192.168.101.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 18:58:40 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GHwdKb42991686 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 17:58:39 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 541D442047; Thu, 16 May 2019 17:58:39 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8440D42049; Thu, 16 May 2019 17:58:37 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.102.0.16]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 17:58:37 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 16 May 2019 23:28:12 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> References: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19051617-4275-0000-0000-0000033589F0 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051617-4276-0000-0000-000038451297 Message-Id: <20190516175816.10558-6-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-16_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160113 Subject: [Skiboot] [PATCH v4 06/10] hostservices: Do not call hservices_init on ZZ X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" We have user space opal-prd running on ZZ. We don't use host services. Hence do not call hservices_init(). CC: Jeremy Kerr Signed-off-by: Vasant Hegde Acked-by: Jeremy Kerr --- platforms/ibm-fsp/zz.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/platforms/ibm-fsp/zz.c b/platforms/ibm-fsp/zz.c index 19fbb6383..29dd6089d 100644 --- a/platforms/ibm-fsp/zz.c +++ b/platforms/ibm-fsp/zz.c @@ -1,4 +1,4 @@ -/* Copyright 2016 IBM Corp. +/* Copyright 2016-2019 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,7 +65,6 @@ static uint32_t ibm_fsp_occ_timeout(void) static void zz_init(void) { - hservices_init(); ibm_fsp_init(); } From patchwork Thu May 16 17:58:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1100690 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fMt4wRXz9s7h for ; Fri, 17 May 2019 04:00:10 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454fMt459DzDqTW for ; Fri, 17 May 2019 04:00:10 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454fLK2j0dzDqQr for ; Fri, 17 May 2019 03:58:49 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GHlXnC070853 for ; Thu, 16 May 2019 13:58:46 -0400 Received: from e06smtp02.uk.ibm.com (e06smtp02.uk.ibm.com [195.75.94.98]) by mx0b-001b2d01.pphosted.com with ESMTP id 2shcgd8gqx-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 13:58:46 -0400 Received: from localhost by e06smtp02.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 18:58:44 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp02.uk.ibm.com (192.168.101.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 18:58:42 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GHwfdm50331720 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 17:58:41 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BABD14203F; Thu, 16 May 2019 17:58:41 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C834B4204C; Thu, 16 May 2019 17:58:39 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.102.0.16]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 17:58:39 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 16 May 2019 23:28:13 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> References: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19051617-0008-0000-0000-000002E76D8E X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051617-0009-0000-0000-0000225413D9 Message-Id: <20190516175816.10558-7-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-16_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160113 Subject: [Skiboot] [PATCH v4 07/10] prd: Validate _opal_queue_msg() return value X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" On safer side, validate _opal_queue_msg() return value. Signed-off-by: Vasant Hegde Acked-by: Jeremy Kerr --- hw/prd.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/hw/prd.c b/hw/prd.c index 9992aecf5..87e1bae92 100644 --- a/hw/prd.c +++ b/hw/prd.c @@ -162,6 +162,7 @@ static void send_next_pending_event(void) { struct proc_chip *chip; uint32_t proc; + int rc; uint8_t event; assert(!prd_msg_inuse); @@ -182,7 +183,6 @@ static void send_next_pending_event(void) if (!event) return; - prd_msg_inuse = true; prd_msg->token = 0; prd_msg->hdr.size = sizeof(*prd_msg); @@ -211,9 +211,12 @@ static void send_next_pending_event(void) * We always need to handle PSI interrupts, but if the is PRD is * 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, - prd_msg->hdr.size, prd_msg); + if (prd_enabled) { + rc = _opal_queue_msg(OPAL_MSG_PRD, prd_msg, prd_msg_consumed, + prd_msg->hdr.size, prd_msg); + if (!rc) + prd_msg_inuse = true; + } } static void __prd_event(uint32_t proc, uint8_t event) @@ -420,11 +423,14 @@ static int prd_msg_handle_firmware_req(struct opal_prd_msg *msg) rc = -ENOSYS; } - if (!rc) + if (!rc) { rc = _opal_queue_msg(OPAL_MSG_PRD, prd_msg, prd_msg_consumed, prd_msg->hdr.size, prd_msg); - else + if (rc) + prd_msg_inuse = false; + } else { prd_msg_inuse = false; + } unlock(&events_lock); From patchwork Thu May 16 17:58:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1100691 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fN552YWz9s7h for ; Fri, 17 May 2019 04:00:21 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454fN549JwzDqMp for ; Fri, 17 May 2019 04:00:21 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454fLN05zWzDqLt for ; Fri, 17 May 2019 03:58:51 +1000 (AEST) Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GHl95x043376 for ; Thu, 16 May 2019 13:58:49 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2shbaskb26-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 13:58:49 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 18:58:47 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 18:58:45 +0100 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GHwihQ51707974 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 17:58:44 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F00564203F; Thu, 16 May 2019 17:58:43 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8DA6342041; Thu, 16 May 2019 17:58:42 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.102.0.16]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 17:58:42 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 16 May 2019 23:28:14 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> References: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19051617-0028-0000-0000-0000036E73B2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051617-0029-0000-0000-0000242E0F79 Message-Id: <20190516175816.10558-8-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-16_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160113 Subject: [Skiboot] [PATCH v4 08/10] prd: Implement generic HBRT - FSP interface X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This patch implements generic interface to pass data from HBRT to FSP during runtime (HBRT -> opal-prd -> kernel -> OPAL -> FSP). HBRT sends data via firmware_request interface. We have to convert that to MBOX format and send it to FSP. OPAL uses TCE mapped memory to send data. FSP will reuse same memory for response. Once processing is complete FSP sends response to OPAL. Finally OPAL calls HBRT with firmware_response message. Also introduces new opal_msg type (OPAL_MSG_PRD2) to pass bigger prd message to kernel. - if (prd_msg > OPAL_MSG_FIXED_PARAMS_SIZE) use OPAL_MSG_PRD2 Signed-off-by: Vasant Hegde --- core/hostservices.c | 77 ++++++++++++++++++++++++ doc/opal-api/opal-messages.rst | 6 ++ hw/prd.c | 130 ++++++++++++++++++++++++++++++++++++++++- include/fsp.h | 6 ++ include/hostservices.h | 1 + include/opal-api.h | 3 + include/prd-fw-msg.h | 3 + include/psi.h | 7 +++ include/skiboot.h | 1 + 9 files changed, 233 insertions(+), 1 deletion(-) diff --git a/core/hostservices.c b/core/hostservices.c index d3a9b3cef..bf1b30818 100644 --- a/core/hostservices.c +++ b/core/hostservices.c @@ -802,3 +802,80 @@ bool hservices_init(void) return true; } + +static void hservice_send_hbrt_msg_resp(struct fsp_msg *msg) +{ + int status = (msg->resp->word1 >> 8) & 0xff; + + fsp_freemsg(msg); + if (status) { + prlog(PR_NOTICE, "HBRT: HBRT to FSP MBOX command failed " + "[rc=0x%x]\n", status); + } + + fsp_tce_unmap(PSI_DMA_HBRT_FSP_MSG, PSI_DMA_HBRT_FSP_MSG_SIZE); + /* Send response data to HBRT */ + prd_fw_resp_fsp_response(status); +} + +#define FSP_STATUS_RR (-8193) +/* Caller takes care of serializing MBOX message */ +int hservice_send_hbrt_msg(void *data, u64 dsize) +{ + uint32_t tce_len, offset; + int rc; + uint64_t addr; + struct fsp_msg *msg; + + prlog(PR_NOTICE, "HBRT: HBRT - FSP message generated\n"); + + /* We only support FSP based system */ + if (!fsp_present()) { + prlog(PR_DEBUG, + "HBRT: Warning, HBRT - FSP message discarded!\n"); + return OPAL_UNSUPPORTED; + } + + /* + * If FSP is in R/R then send specific return code to HBRT (inside + * HBRT message) and return success to caller (opal_prd_msg()). + */ + if (fsp_in_rr()) { + prlog(PR_DEBUG, + "HBRT: FSP is in R/R. Dropping HBRT - FSP message\n"); + prd_fw_resp_fsp_response(FSP_STATUS_RR); + return OPAL_SUCCESS; + } + + /* Adjust address, size for TCE mapping */ + addr = (u64)data & ~TCE_MASK; + offset = (u64)data & TCE_MASK; + tce_len = ALIGN_UP((dsize + offset), TCE_PSIZE); + + if (tce_len > PSI_DMA_HBRT_FSP_MSG_SIZE) { + prlog(PR_DEBUG, + "HBRT: HBRT - FSP message is too big, discarded\n"); + return OPAL_PARAMETER; + } + fsp_tce_map(PSI_DMA_HBRT_FSP_MSG, (void *)addr, tce_len); + + msg = fsp_mkmsg(FSP_CMD_HBRT_TO_FSP, 3, 0, + (PSI_DMA_HBRT_FSP_MSG + offset), dsize); + if (!msg) { + prlog(PR_DEBUG, + "HBRT: Failed to create HBRT - FSP message to FSP\n"); + rc = OPAL_NO_MEM; + goto out_tce_unmap; + } + + rc = fsp_queue_msg(msg, hservice_send_hbrt_msg_resp); + if (rc == 0) + return rc; + + prlog(PR_DEBUG, "HBRT: Failed to queue HBRT message to FSP\n"); + fsp_freemsg(msg); + +out_tce_unmap: + fsp_tce_unmap(PSI_DMA_HBRT_FSP_MSG, PSI_DMA_HBRT_FSP_MSG_SIZE); + return rc; +} diff --git a/doc/opal-api/opal-messages.rst b/doc/opal-api/opal-messages.rst index 25acaec2c..f4ad9756a 100644 --- a/doc/opal-api/opal-messages.rst +++ b/doc/opal-api/opal-messages.rst @@ -219,3 +219,9 @@ these values. If ``opal_occ_msg.type > 2`` then host should ignore the message for now, new events can be defined for ``opal_occ_msg.type`` in the future versions of OPAL. + +OPAL_MSG_PRD2 +------------- + +This message is a OPAL-to-HBRT notification. Its same as OPAL_MSG_PRD except +this one supports passing more than 64bytes (8*8) of data. diff --git a/hw/prd.c b/hw/prd.c index 87e1bae92..042d9779e 100644 --- a/hw/prd.c +++ b/hw/prd.c @@ -39,6 +39,7 @@ static uint64_t ipoll_status[MAX_CHIPS]; static uint8_t _prd_msg_buf[sizeof(struct opal_prd_msg) + sizeof(struct prd_fw_msg)]; static struct opal_prd_msg *prd_msg = (struct opal_prd_msg *)&_prd_msg_buf; +static struct opal_prd_msg *prd_msg_fsp_req; static bool prd_msg_inuse, prd_active; static struct dt_node *prd_node; static bool prd_enabled = false; @@ -112,6 +113,10 @@ static void prd_msg_consumed(void *data, int status __unused) event = EVENT_OCC_RESET; break; case OPAL_PRD_MSG_TYPE_FIRMWARE_RESPONSE: + if (prd_msg_fsp_req) { + free(prd_msg_fsp_req); + prd_msg_fsp_req = NULL; + } break; case OPAL_PRD_MSG_TYPE_SBE_PASSTHROUGH: proc = msg->sbe_passthrough.chip; @@ -309,6 +314,48 @@ void prd_fsp_occ_load_start(uint32_t proc) prd_event(proc, EVENT_FSP_OCC_LOAD_START); } +void prd_fw_resp_fsp_response(int status) +{ + struct prd_fw_msg *fw_resp; + uint64_t fw_resp_len_old; + int rc; + uint16_t hdr_size; + enum opal_msg_type msg_type = OPAL_MSG_PRD2; + + lock(&events_lock); + + /* In case of failure, return code is passed via generic_resp */ + if (status != 0) { + fw_resp = (struct prd_fw_msg *)prd_msg_fsp_req->fw_resp.data; + fw_resp->type = cpu_to_be64(PRD_FW_MSG_TYPE_RESP_GENERIC); + fw_resp->generic_resp.status = cpu_to_be64(status); + + fw_resp_len_old = prd_msg_fsp_req->fw_resp.len; + prd_msg_fsp_req->fw_resp.len = cpu_to_be64(PRD_FW_MSG_BASE_SIZE + + sizeof(fw_resp->generic_resp)); + + /* Update prd message size */ + hdr_size = be16_to_cpu(prd_msg_fsp_req->hdr.size); + hdr_size -= fw_resp_len_old; + hdr_size += be64_to_cpu(prd_msg_fsp_req->fw_resp.len); + prd_msg_fsp_req->hdr.size = cpu_to_be16(hdr_size); + } + + /* + * If prd message size is <= OPAL_MSG_FIXED_PARAMS_SIZE then use + * OPAL_MSG_PRD to pass data to kernel. So that it works fine on + * older kernel (which does not support OPAL_MSG_PRD2). + */ + if (prd_msg_fsp_req->hdr.size < OPAL_MSG_FIXED_PARAMS_SIZE) + msg_type = OPAL_MSG_PRD; + + rc = _opal_queue_msg(msg_type, prd_msg_fsp_req, prd_msg_consumed, + prd_msg_fsp_req->hdr.size, prd_msg_fsp_req); + if (!rc) + prd_msg_inuse = true; + unlock(&events_lock); +} + /* incoming message handlers */ static int prd_msg_handle_attn_ack(struct opal_prd_msg *msg) { @@ -366,9 +413,10 @@ static int prd_msg_handle_fini(void) static int prd_msg_handle_firmware_req(struct opal_prd_msg *msg) { - unsigned long fw_req_len, fw_resp_len; + unsigned long fw_req_len, fw_resp_len, data_len; struct prd_fw_msg *fw_req, *fw_resp; int rc; + uint64_t resp_msg_size; fw_req_len = be64_to_cpu(msg->fw_req.req_len); fw_resp_len = be64_to_cpu(msg->fw_req.resp_len); @@ -417,6 +465,86 @@ static int prd_msg_handle_firmware_req(struct opal_prd_msg *msg) prd_msg->hdr.size = cpu_to_be16(sizeof(*prd_msg)); rc = 0; break; + case PRD_FW_MSG_TYPE_HBRT_FSP: + /* + * HBRT -> FSP messages are serialized. Just to be sure check + * whether fsp_req message is free or not. + */ + if (prd_msg_fsp_req) { + prlog(PR_DEBUG, "PRD: HBRT - FSP message is busy\n"); + rc = OPAL_BUSY; + break; + } + + /* + * FSP interface doesn't tell us the response data size. + * Hence pass response length = request length. + */ + resp_msg_size = sizeof(msg->hdr) + sizeof(msg->token) + + sizeof(msg->fw_resp) + fw_req_len; + + if (resp_msg_size > OPAL_PRD_MSG_SIZE_MAX) { + prlog(PR_DEBUG, "PRD: HBRT - FSP response size (0x%llx)" + " is bigger than prd interface can handle\n", + resp_msg_size); + rc = OPAL_INTERNAL_ERROR; + break; + } + + /* + * We will use fsp_queue_msg() to pass HBRT data to FSP. + * We cannot directly map kernel passed data as kernel + * will release the memory as soon as we return the control. + * Also FSP uses same memory to pass response to HBRT. Hence + * lets copy data to local memory. Then pass this memory to + * FSP via TCE mapping. + */ + prd_msg_fsp_req = zalloc(resp_msg_size); + if (!prd_msg_fsp_req) { + prlog(PR_DEBUG, "PRD: Failed to allocate memory " + "for HBRT - FSP message\n"); + rc = OPAL_RESOURCE; + break; + } + + /* Update message header */ + prd_msg_fsp_req->hdr.type = OPAL_PRD_MSG_TYPE_FIRMWARE_RESPONSE; + prd_msg_fsp_req->hdr.size = cpu_to_be16(resp_msg_size); + prd_msg_fsp_req->token = 0; + prd_msg_fsp_req->fw_resp.len = fw_req_len; + + /* copy HBRT data to local memory */ + fw_resp = (struct prd_fw_msg *)prd_msg_fsp_req->fw_resp.data; + memcpy(fw_resp, fw_req, fw_req_len); + + /* Update response type */ + fw_resp->type = cpu_to_be64(PRD_FW_MSG_TYPE_HBRT_FSP); + + /* Get MBOX message size */ + data_len = fw_req_len - PRD_FW_MSG_BASE_SIZE; + + /* We have to wait until FSP responds */ + prd_msg_inuse = false; + /* Unlock to avoid recursive lock issue */ + unlock(&events_lock); + + /* Send message to FSP */ + rc = hservice_send_hbrt_msg(&(fw_resp->mbox_msg), data_len); + + /* + * Callback handler from hservice_send_hbrt_msg will take + * care of sending response to HBRT. So just send return + * code to Linux. + */ + if (rc == OPAL_SUCCESS) + return rc; + + lock(&events_lock); + if (prd_msg_fsp_req) { + free(prd_msg_fsp_req); + prd_msg_fsp_req = NULL; + } + break; default: prlog(PR_DEBUG, "PRD: Unsupported fw_request type : 0x%llx\n", be64_to_cpu(fw_req->type)); diff --git a/include/fsp.h b/include/fsp.h index ee851eced..751886703 100644 --- a/include/fsp.h +++ b/include/fsp.h @@ -580,6 +580,12 @@ #define FSP_CMD_MEM_DYN_DEALLOC 0x00e40500 /* FSP->HV: Dynamic mem dealloc */ #define FSP_RSP_MEM_DYN_DEALLOC 0x00e48500 /* HV->FSP */ +/* + * Class F2 + */ +#define FSP_CMD_HBRT_TO_FSP 0x1f20100 /* HV->FSP: HBRT message */ + + /* * Functions exposed to the rest of skiboot */ diff --git a/include/hostservices.h b/include/hostservices.h index 10cac63b9..8c54935d7 100644 --- a/include/hostservices.h +++ b/include/hostservices.h @@ -42,5 +42,6 @@ int hservice_send_error_log(uint32_t plid, uint32_t dsize, void *data); int hservice_wakeup(uint32_t i_core, uint32_t i_mode); int fsp_occ_reset_status(u64 chipid, s64 status); int fsp_occ_load_start_status(u64 chipid, s64 status); +int hservice_send_hbrt_msg(void *data, u64 dsize); #endif /* __HOSTSERVICES_H */ diff --git a/include/opal-api.h b/include/opal-api.h index e15c5b89e..11c5afbb5 100644 --- a/include/opal-api.h +++ b/include/opal-api.h @@ -550,6 +550,7 @@ enum opal_msg_type { OPAL_MSG_DPO = 5, OPAL_MSG_PRD = 6, OPAL_MSG_OCC = 7, + OPAL_MSG_PRD2 = 8, OPAL_MSG_TYPE_MAX, }; @@ -1091,6 +1092,8 @@ enum opal_prd_msg_type { OPAL_PRD_MSG_TYPE_FSP_OCC_LOAD_START_STATUS, /* HBRT --> OPAL */ }; +#define OPAL_PRD_MSG_SIZE_MAX (1 << 16) + struct opal_prd_msg_header { uint8_t type; uint8_t pad[1]; diff --git a/include/prd-fw-msg.h b/include/prd-fw-msg.h index 333e594c7..9333a309a 100644 --- a/include/prd-fw-msg.h +++ b/include/prd-fw-msg.h @@ -44,6 +44,9 @@ struct prd_fw_msg { __be32 size; char data[]; } __packed errorlog; + struct { + char data; + } mbox_msg; }; }; diff --git a/include/psi.h b/include/psi.h index d51ab9465..79555ec02 100644 --- a/include/psi.h +++ b/include/psi.h @@ -233,6 +233,13 @@ #define PSI_DMA_PLAT_REQ_BUF_SIZE 0x00001000 #define PSI_DMA_PLAT_RESP_BUF 0x03301000 #define PSI_DMA_PLAT_RESP_BUF_SIZE 0x00001000 +/* + * Our PRD interface can handle upto 64KB data transfer between + * OPAL - opal-prd. Hence adding TCE size as 68KB. If we increase + * OPAL - opal-prd message size, then we have to fix this. + */ +#define PSI_DMA_HBRT_FSP_MSG 0x03302000 +#define PSI_DMA_HBRT_FSP_MSG_SIZE 0x00011000 /* P8 only mappings */ #define PSI_DMA_TRACE_BASE 0x04000000 diff --git a/include/skiboot.h b/include/skiboot.h index e828b1584..0a7c84a8b 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -291,6 +291,7 @@ extern void prd_init(void); extern void prd_register_reserved_memory(void); extern void prd_fsp_occ_reset(uint32_t proc); extern void prd_fsp_occ_load_start(u32 proc); +extern void prd_fw_resp_fsp_response(int status); /* Flatten device-tree */ extern void *create_dtb(const struct dt_node *root, bool exclusive); From patchwork Thu May 16 17:58:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1100693 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fNZ3Hx0z9sB3 for ; Fri, 17 May 2019 04:00:46 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454fNZ2FK5zDqTW for ; Fri, 17 May 2019 04:00:46 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454fLP69sNzDqSn for ; Fri, 17 May 2019 03:58:53 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GHlWI7070754 for ; Thu, 16 May 2019 13:58:51 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2shcgd8gtw-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 13:58:51 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 18:58:49 +0100 Received: from b06cxnps3075.portsmouth.uk.ibm.com (9.149.109.195) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 18:58:46 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GHwjvv39125238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 17:58:45 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A6BDA42049; Thu, 16 May 2019 17:58:45 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 65A0442042; Thu, 16 May 2019 17:58:44 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.102.0.16]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 17:58:44 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 16 May 2019 23:28:15 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> References: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19051617-0020-0000-0000-0000033D703C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051617-0021-0000-0000-000021903922 Message-Id: <20190516175816.10558-9-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-16_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=4 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160113 Subject: [Skiboot] [PATCH v4 09/10] prd: Implement generic FSP - HBRT interface X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This patch implements generic interface to pass data from FSP to HBRT during runtime (FSP -> OPAL -> opal-prd -> HBRT). OPAL gets notification from FSP for new HBRT messages. We will convert MBOX message to firmware_notify format and send it to HBRT. Signed-off-by: Vasant Hegde --- core/hostservices.c | 62 ++++++++++++++++++++++++++++++++++++++++ hw/fsp/fsp.c | 2 ++ hw/prd.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++- include/fsp.h | 6 +++- include/hostservices.h | 2 ++ include/skiboot.h | 1 + platforms/ibm-fsp/zz.c | 1 + 7 files changed, 149 insertions(+), 2 deletions(-) diff --git a/core/hostservices.c b/core/hostservices.c index bf1b30818..d515f1340 100644 --- a/core/hostservices.c +++ b/core/hostservices.c @@ -879,3 +879,65 @@ out_tce_unmap: fsp_tce_unmap(PSI_DMA_HBRT_FSP_MSG, PSI_DMA_HBRT_FSP_MSG_SIZE); return rc; } + +void hservice_hbrt_msg_response(uint32_t rc) +{ + struct fsp_msg *resp; + + resp = fsp_mkmsg(FSP_RSP_FSP_TO_HBRT | (uint8_t)rc, 0); + if (!resp) { + prlog(PR_DEBUG, + "HBRT: Failed to allocate FSP - HBRT response message\n"); + return; + } + + if (fsp_queue_msg(resp, fsp_freemsg)) { + prlog(PR_DEBUG, + "HBRT: Failed to send FSP - HBRT response message\n"); + fsp_freemsg(resp); + return; + } +} + +/* FSP sends HBRT notification message. Pass this message to HBRT */ +static bool hservice_hbrt_msg_notify(uint32_t cmd_sub_mod, struct fsp_msg *msg) +{ + u32 tce_token, len; + void *buf; + + if (cmd_sub_mod != FSP_CMD_FSP_TO_HBRT) + return false; + + prlog(PR_TRACE, "HBRT: FSP - HBRT message generated\n"); + + tce_token = msg->data.words[1]; + len = msg->data.words[2]; + buf = fsp_inbound_buf_from_tce(tce_token); + if (!buf) { + prlog(PR_DEBUG, "HBRT: Invalid inbound data\n"); + hservice_hbrt_msg_response(FSP_STATUS_INVALID_DATA); + return true; + } + + if (prd_hbrt_fsp_msg_notify(buf, len)) + hservice_hbrt_msg_response(FSP_STATUS_GENERIC_FAILURE); + + return true; +} + +static struct fsp_client fsp_hbrt_msg_client = { + .message = hservice_hbrt_msg_notify, +}; + +/* Register for FSP 0xF2 class messages */ +void hservice_fsp_init(void) +{ + if (proc_gen < proc_gen_p9) + return; + + if (!fsp_present()) + return; + + /* Register for Class F2 */ + fsp_register_client(&fsp_hbrt_msg_client, FSP_MCLASS_HBRT); +} diff --git a/hw/fsp/fsp.c b/hw/fsp/fsp.c index f7e674830..8fe2aed2d 100644 --- a/hw/fsp/fsp.c +++ b/hw/fsp/fsp.c @@ -178,6 +178,8 @@ static struct fsp_cmdclass fsp_cmdclass[FSP_MCLASS_LAST - FSP_MCLASS_FIRST + 1] DEF_CLASS(FSP_MCLASS_DIAG, 16), DEF_CLASS(FSP_MCLASS_PCIE_LINK_TOPO, 16), DEF_CLASS(FSP_MCLASS_OCC, 16), + DEF_CLASS(FSP_MCLASS_TRUSTED_BOOT, 2), + DEF_CLASS(FSP_MCLASS_HBRT, 2), }; static void fsp_trace_msg(struct fsp_msg *msg, u8 dir __unused) diff --git a/hw/prd.c b/hw/prd.c index 042d9779e..fea8cf054 100644 --- a/hw/prd.c +++ b/hw/prd.c @@ -40,6 +40,7 @@ static uint8_t _prd_msg_buf[sizeof(struct opal_prd_msg) + sizeof(struct prd_fw_msg)]; static struct opal_prd_msg *prd_msg = (struct opal_prd_msg *)&_prd_msg_buf; static struct opal_prd_msg *prd_msg_fsp_req; +static struct opal_prd_msg *prd_msg_fsp_notify; static bool prd_msg_inuse, prd_active; static struct dt_node *prd_node; static bool prd_enabled = false; @@ -82,10 +83,11 @@ static uint64_t prd_ipoll_mask; static void send_next_pending_event(void); -static void prd_msg_consumed(void *data, int status __unused) +static void prd_msg_consumed(void *data, int status) { struct opal_prd_msg *msg = data; uint32_t proc; + int notify_status = OPAL_SUCCESS; uint8_t event = 0; lock(&events_lock); @@ -118,6 +120,18 @@ static void prd_msg_consumed(void *data, int status __unused) prd_msg_fsp_req = NULL; } break; + case OPAL_PRD_MSG_TYPE_FIRMWARE_NOTIFY: + if (prd_msg_fsp_notify) { + free(prd_msg_fsp_notify); + prd_msg_fsp_notify = NULL; + } + if (status != 0) { + prlog(PR_DEBUG, + "PRD: Failed to send FSP -> HBRT message\n"); + notify_status = FSP_STATUS_GENERIC_FAILURE; + } + hservice_hbrt_msg_response(notify_status); + break; case OPAL_PRD_MSG_TYPE_SBE_PASSTHROUGH: proc = msg->sbe_passthrough.chip; event = EVENT_SBE_PASSTHROUGH; @@ -356,6 +370,67 @@ void prd_fw_resp_fsp_response(int status) unlock(&events_lock); } +int prd_hbrt_fsp_msg_notify(void *data, u32 dsize) +{ + int size; + int rc = FSP_STATUS_GENERIC_FAILURE; + enum opal_msg_type msg_type = OPAL_MSG_PRD2; + + if (!prd_enabled || !prd_active) { + prlog(PR_NOTICE, "PRD: PRD daemon is not ready\n"); + return rc; + } + + /* Calculate prd message size */ + size = sizeof(prd_msg->hdr) + sizeof(prd_msg->token) + + sizeof(prd_msg->fw_notify) + dsize; + + if (size > OPAL_PRD_MSG_SIZE_MAX) { + prlog(PR_DEBUG, "PRD: FSP - HBRT notify message size (0x%x)" + " is bigger than prd interface can handle\n", size); + return rc; + } + + lock(&events_lock); + + /* FSP - HBRT messages are serialized */ + if (prd_msg_fsp_notify) { + prlog(PR_DEBUG, "PRD: FSP - HBRT notify message is busy\n"); + goto unlock_events; + } + + /* Handle message allocation */ + prd_msg_fsp_notify = zalloc(size); + if (!prd_msg_fsp_notify) { + prlog(PR_DEBUG, + "PRD: %s: Failed to allocate memory.\n", __func__); + goto unlock_events; + } + + prd_msg_fsp_notify->hdr.type = OPAL_PRD_MSG_TYPE_FIRMWARE_NOTIFY; + prd_msg_fsp_notify->hdr.size = cpu_to_be16(size); + prd_msg_fsp_notify->token = 0; + prd_msg_fsp_notify->fw_notify.len = cpu_to_be64(dsize); + memcpy(&(prd_msg_fsp_notify->fw_notify.data), data, dsize); + + /* + * If prd message size is <= OPAL_MSG_FIXED_PARAMS_SIZE then use + * OPAL_MSG_PRD to pass data to kernel. So that it works fine on + * older kernel (which does not support OPAL_MSG_PRD2). + */ + if (prd_msg_fsp_notify->hdr.size < OPAL_MSG_FIXED_PARAMS_SIZE) + msg_type = OPAL_MSG_PRD; + + rc = _opal_queue_msg(msg_type, prd_msg_fsp_notify, + prd_msg_consumed, size, prd_msg_fsp_notify); + if (!rc) + prd_msg_inuse = true; + +unlock_events: + unlock(&events_lock); + return rc; +} + /* incoming message handlers */ static int prd_msg_handle_attn_ack(struct opal_prd_msg *msg) { diff --git a/include/fsp.h b/include/fsp.h index 751886703..cfa51afbc 100644 --- a/include/fsp.h +++ b/include/fsp.h @@ -296,7 +296,9 @@ #define FSP_MCLASS_DIAG 0xee #define FSP_MCLASS_PCIE_LINK_TOPO 0xef #define FSP_MCLASS_OCC 0xf0 -#define FSP_MCLASS_LAST 0xf0 +#define FSP_MCLASS_TRUSTED_BOOT 0xf1 +#define FSP_MCLASS_HBRT 0xf2 +#define FSP_MCLASS_LAST 0xf2 /* * Commands are provided in rxxyyzz form where: @@ -584,6 +586,8 @@ * Class F2 */ #define FSP_CMD_HBRT_TO_FSP 0x1f20100 /* HV->FSP: HBRT message */ +#define FSP_CMD_FSP_TO_HBRT 0x0f20200 /* FSP->HV: HBRT message */ +#define FSP_RSP_FSP_TO_HBRT 0x0f28200 /* HV->FSP: HBRT message */ /* diff --git a/include/hostservices.h b/include/hostservices.h index 8c54935d7..bdff9daec 100644 --- a/include/hostservices.h +++ b/include/hostservices.h @@ -43,5 +43,7 @@ int hservice_wakeup(uint32_t i_core, uint32_t i_mode); int fsp_occ_reset_status(u64 chipid, s64 status); int fsp_occ_load_start_status(u64 chipid, s64 status); int hservice_send_hbrt_msg(void *data, u64 dsize); +void hservice_hbrt_msg_response(uint32_t rc); +void hservice_fsp_init(void); #endif /* __HOSTSERVICES_H */ diff --git a/include/skiboot.h b/include/skiboot.h index 0a7c84a8b..d70d82839 100644 --- a/include/skiboot.h +++ b/include/skiboot.h @@ -292,6 +292,7 @@ extern void prd_register_reserved_memory(void); extern void prd_fsp_occ_reset(uint32_t proc); extern void prd_fsp_occ_load_start(u32 proc); extern void prd_fw_resp_fsp_response(int status); +extern int prd_hbrt_fsp_msg_notify(void *data, u32 dsize); /* Flatten device-tree */ extern void *create_dtb(const struct dt_node *root, bool exclusive); diff --git a/platforms/ibm-fsp/zz.c b/platforms/ibm-fsp/zz.c index 29dd6089d..705906a04 100644 --- a/platforms/ibm-fsp/zz.c +++ b/platforms/ibm-fsp/zz.c @@ -66,6 +66,7 @@ static uint32_t ibm_fsp_occ_timeout(void) static void zz_init(void) { ibm_fsp_init(); + hservice_fsp_init(); } DECLARE_PLATFORM(zz) = { From patchwork Thu May 16 17:58:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vasant Hegde X-Patchwork-Id: 1100692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 454fNK4PlGz9s7h for ; Fri, 17 May 2019 04:00:33 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 454fNK3V2pzDqVm for ; Fri, 17 May 2019 04:00:33 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.158.5; helo=mx0a-001b2d01.pphosted.com; envelope-from=hegdevasant@linux.vnet.ibm.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.vnet.ibm.com Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 454fLP5M6WzDqR6 for ; Fri, 17 May 2019 03:58:53 +1000 (AEST) Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4GHlVcL070743 for ; Thu, 16 May 2019 13:58:51 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0b-001b2d01.pphosted.com with ESMTP id 2shcgd8gty-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 16 May 2019 13:58:51 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 16 May 2019 18:58:49 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 16 May 2019 18:58:48 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x4GHwlcP55574710 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 May 2019 17:58:47 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 700E042047; Thu, 16 May 2019 17:58:47 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 139504203F; Thu, 16 May 2019 17:58:46 +0000 (GMT) Received: from hegdevasant.in.ibm.com (unknown [9.102.0.16]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 16 May 2019 17:58:45 +0000 (GMT) From: Vasant Hegde To: skiboot@lists.ozlabs.org Date: Thu, 16 May 2019 23:28:16 +0530 X-Mailer: git-send-email 2.14.3 In-Reply-To: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> References: <20190516175816.10558-1-hegdevasant@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 19051617-0020-0000-0000-0000033D7040 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19051617-0021-0000-0000-000021903925 Message-Id: <20190516175816.10558-10-hegdevasant@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-05-16_14:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=3 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905160113 Subject: [Skiboot] [PATCH v4 10/10] opal-prd: Fix prd message size issue X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" If prd messages size is insufficient then read_prd_msg() call fails with below error. And caller is not reallocating sufficient buffer. Also its hard to guess the size. sample log: ----------- Mar 28 03:31:43 zz24p1 opal-prd: FW: error reading from firmware: alloc 32 rc -1: Invalid argument Mar 28 03:31:43 zz24p1 opal-prd: FW: error reading from firmware: alloc 32 rc -1: Invalid argument Mar 28 03:31:43 zz24p1 opal-prd: FW: error reading from firmware: alloc 32 rc -1: Invalid argument .... Lets use `opal-msg-size` device tree property to allocate memory for prd message. Signed-off-by: Vasant Hegde --- external/opal-prd/opal-prd.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/external/opal-prd/opal-prd.c b/external/opal-prd/opal-prd.c index 33ea5f5a8..9df0d2753 100644 --- a/external/opal-prd/opal-prd.c +++ b/external/opal-prd/opal-prd.c @@ -2120,7 +2120,9 @@ static int init_control_socket(struct opal_prd_ctx *ctx) static int run_prd_daemon(struct opal_prd_ctx *ctx) { - int rc; + char *opal_msg_path; + void *buf; + int rc, len; /* log to syslog */ pr_log_daemon_init(); @@ -2130,8 +2132,25 @@ static int run_prd_daemon(struct opal_prd_ctx *ctx) ctx->fd = -1; ctx->socket = -1; - /* set up our message buffer */ - ctx->msg_alloc_len = sizeof(*ctx->msg); + /* + * Set up our message buffer. Use opal-msg-size device tree + * property to get message buffer size. + */ + rc = asprintf(&opal_msg_path, + "%s/ibm,opal/opal-msg-size", devicetree_base); + if (rc > 0) { + rc = open_and_read(opal_msg_path, &buf, &len); + if (rc == 0) { + ctx->msg_alloc_len = be32toh(*(__be32 *)buf); + free(buf); + } + + free(opal_msg_path); + } + + if (ctx->msg_alloc_len == 0) + ctx->msg_alloc_len = sizeof(*ctx->msg); + ctx->msg = malloc(ctx->msg_alloc_len); if (!ctx->msg) { pr_log(LOG_ERR, "FW: Can't allocate PRD message buffer: %m");