From patchwork Tue May 19 05:46:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292947 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 49R4fs3Bfqz9sTC for ; Tue, 19 May 2020 15:48:05 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=n2C/FdrQ; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4fs0nMYzDqQs for ; Tue, 19 May 2020 15:48:05 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::643; helo=mail-pl1-x643.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=n2C/FdrQ; dkim-atps=neutral Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4dl4NPbzDqsx for ; Tue, 19 May 2020 15:47:07 +1000 (AEST) Received: by mail-pl1-x643.google.com with SMTP id d3so452651pln.1 for ; Mon, 18 May 2020 22:47:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lY/iSM1GY113Xr8QPL7oWJQ6URBXaVeNizyto83yh9I=; b=n2C/FdrQKUL6C9qvL7BCVaO5hGpx0xbmkHwyvQPG8D31nbUbIlAIDFYfOXwn3xcp6r +IpiCGfRYoT+LLEtDu4BOoTpwNIjKMgtDtBSc94iF+OiyBUCskZNckloXAFqhRK8He/F jDcn/nC7oAk3gXPjqPxSaH5ErAkCUNbPf53nYaEx1+eSS2KA5mF4f0mb92Wu4PyTjXc5 9A7gEW3YdIlOaRzLBGF/fC8BeVWmh7Oup1zxuAywAcASdh06B1DkZsuLqa2cC2C+wG/3 vSXiRKsb42lKvAewU4cCvfZy2UsS6RUxg5EHwvpJoRncMibD+BUcuGqSl/67vLM0DAjY 1XmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lY/iSM1GY113Xr8QPL7oWJQ6URBXaVeNizyto83yh9I=; b=f8TsHyISOszA5YqVYGnlzLZiFwkVfl9CwyNIn/z77fd29fL2m57AgYfeEpbqW0qwvh KKXEGm1c7yPRFEVP8vKjQZrcxUR7lolRMl7Z7fHRlA8tXY+8mvypy4cgw3LEdu9Lhaez dKbeJbVoSJdNRDHc3OyQTeQA+8Bm7gOKcnIy0jlMSR20QAkQiF4VHxRUXqW1NsU+Ot3R A1bI/AzG0UZ2MN5jhM79dT6V1DzsPAyE8wzyvfMQLfnobx5toF1u78qg2NeNxgosthmG WjS3O1IXdiQKvSa82UCrpBMtvNsJ18eodtUqKy8f43RBQZTmyYQrSuxd3E99q7+1m+Ji +HdA== X-Gm-Message-State: AOAM530r2OFQCBuEkK3utbJYYlEXO8W1lwfH1WGRPtwCnzZ/QDuIuSKl HqiVk+yPO2Ee2Uf7CUHTllEHW4DL X-Google-Smtp-Source: ABdhPJybrTL0/E27Jbb+1eXaTT3day6B3SKRdUOWJM/kf14mjFqeC5GS7I2yqDj86J4N8v0Ke6DRpA== X-Received: by 2002:a17:902:b202:: with SMTP id t2mr20097076plr.1.1589867223944; Mon, 18 May 2020 22:47:03 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:03 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:22 +1000 Message-Id: <20200519054633.113238-2-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 01/12] platform/mambo: Add a mambo OPAL console driver 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Add a "real" opal_con_driver for the mambo platform instead of using the dummy console. This gets mambo using the same console IO path as every other platform and leaves the dummy console only being used for cronus booted systems. Signed-off-by: Oliver O'Halloran --- Yoinked out of Nick's raw console patch set. --- include/console.h | 1 + platforms/mambo/console.c | 64 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/include/console.h b/include/console.h index 02fc7a4b60a5..c14a2e598191 100644 --- a/include/console.h +++ b/include/console.h @@ -85,6 +85,7 @@ struct dt_node *add_opal_console_node(int index, const char *type, extern struct opal_con_ops uart_opal_con; extern struct opal_con_ops fsp_opal_con; extern struct opal_con_ops dummy_opal_con; +extern struct opal_con_ops mambo_opal_con; void mprintf(const char *fmt, ...); diff --git a/platforms/mambo/console.c b/platforms/mambo/console.c index 6d5b20b56e60..f46272d6973c 100644 --- a/platforms/mambo/console.c +++ b/platforms/mambo/console.c @@ -3,6 +3,7 @@ #include #include +#include #include "mambo.h" @@ -42,9 +43,8 @@ size_t mambo_console_write(const char *buf, size_t len) return len; } +/* used to write out the internal console */ static struct con_ops mambo_con_driver = { - .poll_read = mambo_console_poll, - .read = mambo_console_read, .write = mambo_console_write, }; @@ -54,6 +54,66 @@ void enable_mambo_console(void) set_console(&mambo_con_driver); } + +/* OPAL call interface into the underlying mambo console */ +static int64_t mambo_opal_write(int64_t term_number, __be64 *__length, + const uint8_t *buffer) +{ + size_t len = be64_to_cpu(*__length); + + if (term_number != 0) + return OPAL_PARAMETER; + + mambo_console_write(buffer, len); + + return OPAL_SUCCESS; +} + +static int64_t mambo_opal_write_buffer_space(int64_t term_number, + __be64 *__length) +{ + if (term_number != 0) + return OPAL_PARAMETER; + + *__length = cpu_to_be64(256); + + return OPAL_SUCCESS; +} + +static int64_t mambo_opal_read(int64_t term_number, __be64 *__length, + uint8_t *buffer) +{ + size_t req_count = be64_to_cpu(*__length), read_cnt = 0; + + if (term_number != 0) + return OPAL_PARAMETER; + + read_cnt = mambo_console_read(buffer, req_count); + *__length = cpu_to_be64(read_cnt); + + return OPAL_SUCCESS; +} + +static int64_t mambo_opal_flush(int64_t term_number) +{ + if (term_number != 0) + return OPAL_PARAMETER; + return OPAL_SUCCESS; +} + +static void mambo_init_opal_console(void) +{ +} + +struct opal_con_ops mambo_opal_con = { + .name = "OPAL Mambo console", + .init = mambo_init_opal_console, + .read = mambo_opal_read, + .write = mambo_opal_write, + .space = mambo_opal_write_buffer_space, + .flush = mambo_opal_flush, +}; + /* * mambo console based printf(), this is useful for debugging the console * since mambo_console_write() can be safely called from anywhere. From patchwork Tue May 19 05:46:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292948 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 49R4gN0znbz9sTc for ; Tue, 19 May 2020 15:48:32 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=i65JDhaG; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4gM5jB7zDqWq for ; Tue, 19 May 2020 15:48:31 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::642; helo=mail-pl1-x642.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=i65JDhaG; dkim-atps=neutral Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4dn2B17zDqfv for ; Tue, 19 May 2020 15:47:09 +1000 (AEST) Received: by mail-pl1-x642.google.com with SMTP id f15so5168480plr.3 for ; Mon, 18 May 2020 22:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bQSrRudTnQRYdfooVA5oIptrT3A1XhDFiaWsPondvzA=; b=i65JDhaGkaioY9IUwd7m5PbxFtLHHQV7ok8BDNIlkMmKRBNk2bjy4H/gdI3S0C75Tx ivCc9QTng+zUXhB+YfF5F8Q3OYbwQEoDxltqTJCIz1n/S2Lvsj688p6B49UYsH0kAcrX VOYVfTe0aS0Qn3zkAzmTLPKXKQSm5xQiAe9ry0Z72VqFF8asXyU9quOcj099Nof9Px7c GaQdcGmtZp//3g1DGkKib8aAS8T8QanpnEN0d9TKzDYpbNYqNC2zPeTBAFnc1cJ6wiTP KgkgLyhFJHfE19xZqNwxoC9RzJXplm/WoXVqSzAyeh7O+e+7x1EaQeUnUUvrjGadsERP XvYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bQSrRudTnQRYdfooVA5oIptrT3A1XhDFiaWsPondvzA=; b=OIRAz+XYnFpbomnFrenEpCWX/9XZA4ygqmpvk8QcSt/TXb787DHHCWySPb8wenXrko SAQUJomzGtzpEPFou7lIOiDCv1dSm4DvtsjEM7aGkm1WvxZX95fc2opHB8hcQiHA2AzY dNps8qkMZDie/OYWFXvxQOujST6chhzsH9ujDscPosm5tM0NyyTH88d3x6SptWALt9ix ad2XsvoWki4vAJcpKNnts51ijNCefb37hJnJSoJ8rKz7q2iOEyY/2feDvGWnpWUc9Pkf VpysiqwYnkFrjAXxizZkcNOm8+GgQt4rNl/LITewinLxCkYLTuEs0deA5v4UCeAYxZnM TWGQ== X-Gm-Message-State: AOAM533I52NUnRx4hUKRGQSfzEEQEaKHPCioMIB9ODgzb4lkTiYaJUPg na4mGbaWKGKTAygTjfEGzWXysIjn X-Google-Smtp-Source: ABdhPJxTN5s+O2R72Qjr5H4xMmHwQ0hJUeyrCSiKBa5naqSYN+Q5QyRjxPquez/eb/1EZoog7BqTnA== X-Received: by 2002:a17:90a:344c:: with SMTP id o70mr3404838pjb.23.1589867226268; Mon, 18 May 2020 22:47:06 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:05 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:23 +1000 Message-Id: <20200519054633.113238-3-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 02/12] core/console: Remove the read/poll_read con_ops 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" These were only ever used for the dummy console backed by the mambo console. Now that we have an actual OPAL console driver for mambo we don't need them. Signed-off-by: Oliver O'Halloran --- core/console.c | 4 ---- include/console.h | 2 -- 2 files changed, 6 deletions(-) diff --git a/core/console.c b/core/console.c index 2a1509025b56..42328dbe2d2e 100644 --- a/core/console.c +++ b/core/console.c @@ -260,8 +260,6 @@ ssize_t read(int fd __unused, void *buf, size_t req_count) bool need_unlock = lock_recursive(&con_lock); size_t count = 0; - if (con_driver && con_driver->read) - count = con_driver->read(buf, req_count); if (!count) count = inmem_read(buf, req_count); if (need_unlock) @@ -412,8 +410,6 @@ static void dummy_console_poll(void *data __unused) bool has_data = false; lock(&con_lock); - if (con_driver && con_driver->poll_read) - has_data = con_driver->poll_read(); if (memcons.in_prod != memcons.in_cons) has_data = true; if (has_data) diff --git a/include/console.h b/include/console.h index c14a2e598191..6abd04b77d78 100644 --- a/include/console.h +++ b/include/console.h @@ -35,8 +35,6 @@ extern struct memcons memcons; /* Console driver */ struct con_ops { size_t (*write)(const char *buf, size_t len); - size_t (*read)(char *buf, size_t len); - bool (*poll_read)(void); }; struct opal_con_ops { From patchwork Tue May 19 05:46:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292949 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 49R4gz5x95z9sTC for ; Tue, 19 May 2020 15:49:03 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=lrhYKYJA; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4gz581GzDqW6 for ; Tue, 19 May 2020 15:49:03 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::641; helo=mail-pl1-x641.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=lrhYKYJA; dkim-atps=neutral Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4dp720hzDqtQ for ; Tue, 19 May 2020 15:47:10 +1000 (AEST) Received: by mail-pl1-x641.google.com with SMTP id x10so5163405plr.4 for ; Mon, 18 May 2020 22:47:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2+g073HWNlm6ksnQZ6Ylu6WqlkV3FclGdmBQ9Hta9MM=; b=lrhYKYJA0YuX74+x7SvBN5m7JbUW9o6BhDIO+2PtAzrus9+i0c5sDTHuDlxIrtJ1rw aeIdOfhR4C84afBGaDpYuXIQ597VQlEK6kNWsH2HJgwyjmqqS05F8QG3AhPkcrllT473 E7osygvOPPt8bZMWmzyBDHJMGkLMPjganoOAsF6fSwOCr8j4cjvXTIgjfJldZpGSRO+V Jq87beuqzbj6e4Zxfwngkn6Zr52M1L6hS077hrJCzYOTJXcTY9nuiGwsEht+SPflByp9 dx1cngONiT4umpEU1NTnpPdvtayPyhFLjhbAeN1N+wMUkA6tbgMZwYtJqrVt/hcshBym GvXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2+g073HWNlm6ksnQZ6Ylu6WqlkV3FclGdmBQ9Hta9MM=; b=pfz5SLG1HHLJ0gY0/U+34zFhbwGeuCDj+cfNC2zILmfN7JiFWaleXUEwQIj+Nf53ft BOR8If0tG91z3GKoiz+FoyoC3gcW8h0d6OZTSYMspB+u0nrAj3dMPXqhRbFPG1bHFK5B KH0l/ypaPnS+ETnzG5LUDIDWFQzLide6inhrytteOHUgyWwa+Y0XQ+/67w6HzHZHeAzs dWFYtwFMv9cTAJJPhaV7KORqRX9pMsPqOJIiwYNxGXWHZEy2SfRCVgge3hrT1EaIqw8l lG40NPBhlcohVSd5rnwrUPMgEO6Tuy/dh2ICaBYPmIdHZMgG2TkKFYt2S6TXh5dexEFs ggeA== X-Gm-Message-State: AOAM5304NH58sPYXTX7vgrkNSm0FDIBenWSqrgq8GA6jWWBKD5KPQfoQ EW7H9vdwZGKstB95aDvE5V25zRcA X-Google-Smtp-Source: ABdhPJxFURwPAvDoEtH/22m0GxhzBjHljZc7cZ26R6oFRyCG2rfzQ2KqtT11q9Wut/t3sOpmxJoCMA== X-Received: by 2002:a17:90a:aa8d:: with SMTP id l13mr3393507pjq.92.1589867228403; Mon, 18 May 2020 22:47:08 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:07 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:24 +1000 Message-Id: <20200519054633.113238-4-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 03/12] core/console: Move con_out wrap marking 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The con_out global tracks how much of the skiboot log buffer has been written out to the driver. We'd like to re-use inmem_write() so that we can have multiple memcons instances so move the con_out tracking into write_char() which is used to write a single character into the skiboot log buffer. Signed-off-by: Oliver O'Halloran --- core/console.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/core/console.c b/core/console.c index 42328dbe2d2e..8724c71113a6 100644 --- a/core/console.c +++ b/core/console.c @@ -198,10 +198,6 @@ static void inmem_write(char c) opos |= MEMCONS_OUT_POS_WRAP; lwsync(); memcons.out_pos = cpu_to_be32(opos); - - /* If head reaches tail, push tail around & drop chars */ - if (con_in == con_out) - con_out = (con_in + 1) % INMEM_CON_OUT_LEN; } static size_t inmem_read(char *buf, size_t req) @@ -221,10 +217,11 @@ static size_t inmem_read(char *buf, size_t req) static void write_char(char c) { -#ifdef MAMBO_DEBUG_CONSOLE - mambo_console_write(&c, 1); -#endif inmem_write(c); + + /* If head reaches tail, push tail around & drop chars */ + if (con_out == memcons.out_pos) + con_out = (memcons.out_pos + 1) % memcons.obuf_size; } ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count) From patchwork Tue May 19 05:46:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292950 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 49R4hj0vKwz9sVj for ; Tue, 19 May 2020 15:49:41 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=NSEo+K68; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4hh4J7MzDqR6 for ; Tue, 19 May 2020 15:49:40 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::641; helo=mail-pl1-x641.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=NSEo+K68; dkim-atps=neutral Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4dr4G0szDqLY for ; Tue, 19 May 2020 15:47:12 +1000 (AEST) Received: by mail-pl1-x641.google.com with SMTP id s20so5167126plp.6 for ; Mon, 18 May 2020 22:47:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=s4s0q+ym6wXtizZc3RQXZ2y0YxcGD10iqXq7m5KcceI=; b=NSEo+K68beZsjYSumAcgrfiZ4zGxfZXg4DhdA/HV3Kyyf0YdjfjcEgt+x74GhFtNxo pTPx5eUBbT+xjKB2J6pjZN0PJigPNl8np5buztHvEQdSSxhYplLSlE8V5I8aGwmU2xro 4bbkXBkUwhBQeMQRzVWrZlHhO1G/c2jR3LjQ3Q1hk/uaUVtOvYnUJFmGd2IUWI8xF9Xg rQnKFAbwCwJC3ssfGEOT+21iepEuMZJ11zW36MvbwGStQ2H5bar3VWd9HX42TbH6Q4mM zPZjuRagOMl9wgcgV2LgyTY05/21K2cMCc3h+gfN8lHGBu7sIP6Ab8CJRZJ/4Fu0b56i u71g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s4s0q+ym6wXtizZc3RQXZ2y0YxcGD10iqXq7m5KcceI=; b=HWjy+mWCkhHEZJD1Mz7caX6Bx9IOmWkFgmWA+OTUYkV7C2R/LQwqol4CxES5g5G+WD ov0lL5ffcWSv4x79P/lkSyurrQUZTxcYFCVp0w9nHi/UJDFbwc6r/3UlXhK0FZsL3kwx AmRMr+VgUT+pm04CKGKjrxAn88ogYKwxqqs75xP2ROzPQfxi7gI7saj5aKZe0yLnqeR+ rBuvtPJKLkkluUZGECgPNZGW3LFfY0kG28nXh+FQgPy0oPQplDQF0EXQNdV5PIDsAi2A dFYR+kPMk1Gz7TEVqJ1LMgh7SkxeXAcVT9KEw4rVpQ1JZjfKQmbdaVGxzB9n4+n4oXJx gXUA== X-Gm-Message-State: AOAM530+CTcWuITbmYOQsXQIq0H8lFBaVvi4KnmuVcRpIItQe8t4zxJ9 Wm6sdIDV3FOU7ileLfcWXklGvEVB X-Google-Smtp-Source: ABdhPJyR4Re7Y+VNwnZSN+q0VnSEeVoCazb6K5oHvyVcQX5qIpWzNvu0FNsFuct41hdot9xpqV++BQ== X-Received: by 2002:a17:902:fe87:: with SMTP id x7mr20418001plm.130.1589867230295; Mon, 18 May 2020 22:47:10 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:10 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:25 +1000 Message-Id: <20200519054633.113238-5-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 04/12] core/console: Move inmem_read() 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This is just to clean up the diffs in the following patches. Signed-off-by: Oliver O'Halloran --- core/console.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/core/console.c b/core/console.c index 8724c71113a6..a1ec687cb67e 100644 --- a/core/console.c +++ b/core/console.c @@ -200,21 +200,6 @@ static void inmem_write(char c) memcons.out_pos = cpu_to_be32(opos); } -static size_t inmem_read(char *buf, size_t req) -{ - size_t read = 0; - char *ibuf = (char *)be64_to_cpu(memcons.ibuf_phys); - - while (req && be32_to_cpu(memcons.in_prod) != be32_to_cpu(memcons.in_cons)) { - *(buf++) = ibuf[be32_to_cpu(memcons.in_cons)]; - lwsync(); - memcons.in_cons = cpu_to_be32((be32_to_cpu(memcons.in_cons) + 1) % INMEM_CON_IN_LEN); - req--; - read++; - } - return read; -} - static void write_char(char c) { inmem_write(c); @@ -252,6 +237,21 @@ ssize_t write(int fd __unused, const void *buf, size_t count) return console_write(true, buf, count); } +static size_t inmem_read(char *buf, size_t req) +{ + size_t read = 0; + char *ibuf = (char *)be64_to_cpu(memcons.ibuf_phys); + + while (req && be32_to_cpu(memcons.in_prod) != be32_to_cpu(memcons.in_cons)) { + *(buf++) = ibuf[be32_to_cpu(memcons.in_cons)]; + lwsync(); + memcons.in_cons = cpu_to_be32((be32_to_cpu(memcons.in_cons) + 1) % INMEM_CON_IN_LEN); + req--; + read++; + } + return read; +} + ssize_t read(int fd __unused, void *buf, size_t req_count) { bool need_unlock = lock_recursive(&con_lock); From patchwork Tue May 19 05:46:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292951 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 49R4jK0Mw0z9sVj for ; Tue, 19 May 2020 15:50:13 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=IxS7oG0A; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4jJ6l78zDqWL for ; Tue, 19 May 2020 15:50:12 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::444; helo=mail-pf1-x444.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=IxS7oG0A; dkim-atps=neutral Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4dv2bJYzDqtK for ; Tue, 19 May 2020 15:47:15 +1000 (AEST) Received: by mail-pf1-x444.google.com with SMTP id y198so4442310pfb.4 for ; Mon, 18 May 2020 22:47:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=htyJyqekQkxdqEj67f/Al584bex1Bo5S8gJbJse7UCw=; b=IxS7oG0AI0XXXdP47tKESK9yx2226Dm0GrZiJJeexMeUHdXohUYss7wj6X/kqj4ATQ 3NCNsa+iYsieuPcEJZn/TAULgG5I97plrnxSblLyLVW8u7FcAcolXUcwJQmDr5Snu5xM v3U4G021hlbt0pHUqbxmuUfl5CiVyPMF2U6RZqkfOad6UY1V29K3fHrm1RleqCM4dGdL 15qx5ExIsVVbhELKiY507KclmfDtDXeP5yBF04Sm+E822jzwiduj4ARHV/6kyYM4xDIm 3cDvKXFNxxjBF3aaqdmxkEQR4NpH02Ii/ftFUWrE3lD2cofn5TopV30NKtjjAuQkbpG5 Bqqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=htyJyqekQkxdqEj67f/Al584bex1Bo5S8gJbJse7UCw=; b=L2wjCsK0arSlJXmzsdVVdTqs1aKIYb/2SRiPxX0BMe45XAEhIfvWBEszTiMTFDdjaO oDjiVyWIm0G6COyryPlFuKm5fDVvA/ZS6n/NmpxyLEm3E8jDFEhS94Ieay148gAt95PP zXKTz3LsmkXnsD5aZW7y9ZuzFhu9aYDQ0OSdIaPvYhAhpXipD/KYZJArRUlo11ir01XT EhKpYibPdebDc9dtkUM5k2h4nid9Xg9qW25+PCzaV+o8w4dlnLY0cWNlJLTfIsXPhjn6 av3aLXUG7lOhY4sUOO/IrEVYhe2DfWsq7uBgUs0oUyubGXoM9XJxVsdgUzM6lUBSwdgL RvnQ== X-Gm-Message-State: AOAM530szRnCyOfPMnsawfCvNYn9c8TnXx4NGfjnXRUjxe+N0vF/1LIA ctzEJX/8m4izXh6Rnf+kIhQQnXBA X-Google-Smtp-Source: ABdhPJwIm3xEm6YGQ+/uoJ+/S7RdMZmHz5vBTdShtFSkKmp/nzqG+pX6QxIPnd19vSa4H5Ao4hRACw== X-Received: by 2002:a62:16d5:: with SMTP id 204mr18136223pfw.10.1589867232360; Mon, 18 May 2020 22:47:12 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:11 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:26 +1000 Message-Id: <20200519054633.113238-6-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 05/12] core/console: Add a seperate ABI memcons struct 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This patch renames the existing memcons structure to memcons_desc and adds a new memcons structure that is used internally by skiboot. There's two main reasons for doing this: a) The memcons_desc may be DMA mapped as writable so the FSP/BMC can write to it to implement the "input" portion of the in-memory console. As a result we should not be blindling trusting the buffer pointers from the descriptor and we should validate the offsets are correct. b) Skiboot can be running little endian so we to handle the endian conversions which can get a bit unwieldly. Seperating the external desctriptor (which is ABI) and the internal console state helps to address both issues. We can rely on the internal state since it can never be tampered with externally, and we can use the internal state to regenerate the external descriptor as-needed. Signed-off-by: Oliver O'Halloran --- core/console.c | 39 ++++++++++++++++++++++---------- include/console.h | 22 +++++++++++++++++- platforms/ibm-fsp/common.c | 6 ++--- platforms/ibm-fsp/hostservices.c | 2 +- 4 files changed, 52 insertions(+), 17 deletions(-) diff --git a/core/console.c b/core/console.c index a1ec687cb67e..8be7ee578b18 100644 --- a/core/console.c +++ b/core/console.c @@ -17,6 +17,12 @@ static char *con_buf = (char *)INMEM_CON_START; static size_t con_in; + +/* + * Skiboot is both the producer and consumer of the memcons. On the consumer + * side we need to keep track of how much of the log buffer has been written + * out to the console which is what con_out is for. + */ static size_t con_out; static bool con_wrapped; @@ -29,7 +35,7 @@ static struct opal_con_ops *opal_con_driver = &dummy_opal_con; static struct lock con_lock = LOCK_UNLOCKED; /* This is mapped via TCEs so we keep it alone in a page */ -struct memcons memcons __section(".data.memcons") = { +struct memcons_desc memcons_desc __section(".data.memcons") = { .magic = CPU_TO_BE64(MEMCONS_MAGIC), .obuf_phys = CPU_TO_BE64(INMEM_CON_START), .ibuf_phys = CPU_TO_BE64(INMEM_CON_START + INMEM_CON_OUT_LEN), @@ -37,6 +43,15 @@ struct memcons memcons __section(".data.memcons") = { .ibuf_size = CPU_TO_BE32(INMEM_CON_IN_LEN), }; +struct memcons memcons = { + .desc = &memcons_desc, + .obuf = (char *) INMEM_CON_START, + .obuf_size = INMEM_CON_OUT_LEN, + + .ibuf = (char *) (INMEM_CON_START + INMEM_CON_OUT_LEN), + .ibuf_size = INMEM_CON_IN_LEN, +}; + static bool dummy_console_enabled(void) { #ifdef FORCE_DUMMY_CONSOLE @@ -187,7 +202,7 @@ static void inmem_write(char c) } /* - * We must always re-generate memcons.out_pos because + * We must always re-generate memcons.desc->out_pos because * under some circumstances, the console script will * use a broken putmemproc that does RMW on the full * 8 bytes containing out_pos and in_prod, thus corrupting @@ -197,7 +212,7 @@ static void inmem_write(char c) if (con_wrapped) opos |= MEMCONS_OUT_POS_WRAP; lwsync(); - memcons.out_pos = cpu_to_be32(opos); + memcons.desc->out_pos = cpu_to_be32(opos); } static void write_char(char c) @@ -205,8 +220,8 @@ static void write_char(char c) inmem_write(c); /* If head reaches tail, push tail around & drop chars */ - if (con_out == memcons.out_pos) - con_out = (memcons.out_pos + 1) % memcons.obuf_size; + if (con_out == memcons.desc->out_pos) + con_out = (memcons.desc->out_pos + 1) % memcons.desc->obuf_size; } ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count) @@ -240,12 +255,12 @@ ssize_t write(int fd __unused, const void *buf, size_t count) static size_t inmem_read(char *buf, size_t req) { size_t read = 0; - char *ibuf = (char *)be64_to_cpu(memcons.ibuf_phys); + char *ibuf = (char *)be64_to_cpu(memcons.desc->ibuf_phys); - while (req && be32_to_cpu(memcons.in_prod) != be32_to_cpu(memcons.in_cons)) { - *(buf++) = ibuf[be32_to_cpu(memcons.in_cons)]; + while (req && be32_to_cpu(memcons.desc->in_prod) != be32_to_cpu(memcons.desc->in_cons)) { + *(buf++) = ibuf[be32_to_cpu(memcons.desc->in_cons)]; lwsync(); - memcons.in_cons = cpu_to_be32((be32_to_cpu(memcons.in_cons) + 1) % INMEM_CON_IN_LEN); + memcons.desc->in_cons = cpu_to_be32((be32_to_cpu(memcons.desc->in_cons) + 1) % INMEM_CON_IN_LEN); req--; read++; } @@ -335,7 +350,7 @@ void init_opal_console(void) void memcons_add_properties(void) { - dt_add_property_u64(opal_node, "ibm,opal-memcons", (u64) &memcons); + dt_add_property_u64(opal_node, "ibm,opal-memcons", (u64) &memcons_desc); } /* @@ -407,7 +422,7 @@ static void dummy_console_poll(void *data __unused) bool has_data = false; lock(&con_lock); - if (memcons.in_prod != memcons.in_cons) + if (memcons.desc->in_prod != memcons.desc->in_cons) has_data = true; if (has_data) opal_update_pending_evt(OPAL_EVENT_CONSOLE_INPUT, @@ -421,7 +436,7 @@ void dummy_console_add_nodes(void) { struct dt_property *p; - add_opal_console_node(0, "raw", be32_to_cpu(memcons.obuf_size)); + add_opal_console_node(0, "raw", be32_to_cpu(memcons.desc->obuf_size)); /* Mambo might have left a crap one, clear it */ p = __dt_find_property(dt_chosen, "linux,stdout-path"); diff --git a/include/console.h b/include/console.h index 6abd04b77d78..280f920aba44 100644 --- a/include/console.h +++ b/include/console.h @@ -12,21 +12,41 @@ * facility or FSP. * * (This is v3 of the format, the previous one sucked) + * + * NB: This might be writable from the BMC! Don't blindly trust the contents. */ -struct memcons { +struct memcons_desc { __be64 magic; #define MEMCONS_MAGIC 0x6630696567726173LL __be64 obuf_phys; __be64 ibuf_phys; __be32 obuf_size; __be32 ibuf_size; + + /* Output ring buffer write head. OPAL is the producer */ __be32 out_pos; #define MEMCONS_OUT_POS_WRAP 0x80000000u #define MEMCONS_OUT_POS_MASK 0x00ffffffu + + /* Input ring buffer offsets. OPAL is the consumer */ __be32 in_prod; __be32 in_cons; }; +/* internal version of the above, trustworthy, native endian, etc */ +struct memcons { + struct memcons_desc *desc; + + char *obuf; + uint32_t obuf_size; + + char *ibuf; + uint32_t ibuf_size; + + uint32_t out_pos; + bool has_wrapped; +}; + extern struct memcons memcons; #define INMEM_CON_IN_LEN 16 diff --git a/platforms/ibm-fsp/common.c b/platforms/ibm-fsp/common.c index 4a723b25b064..6a20dc7ac36a 100644 --- a/platforms/ibm-fsp/common.c +++ b/platforms/ibm-fsp/common.c @@ -21,13 +21,13 @@ static void map_debug_areas(void) /* Our memcons is in a section of its own and already * aligned to 4K. The buffers are mapped as a whole */ - fsp_tce_map(PSI_DMA_MEMCONS, &memcons, 0x1000); + fsp_tce_map(PSI_DMA_MEMCONS, memcons.desc, 0x1000); fsp_tce_map(PSI_DMA_LOG_BUF, (void*)INMEM_CON_START, INMEM_CON_LEN); debug_descriptor.memcons_tce = cpu_to_be32(PSI_DMA_MEMCONS); - t = be64_to_cpu(memcons.obuf_phys) - INMEM_CON_START + PSI_DMA_LOG_BUF; + t = be64_to_cpu(memcons.desc->obuf_phys) - INMEM_CON_START + PSI_DMA_LOG_BUF; debug_descriptor.memcons_obuf_tce = cpu_to_be32(t); - t = be64_to_cpu(memcons.ibuf_phys) - INMEM_CON_START + PSI_DMA_LOG_BUF; + t = be64_to_cpu(memcons.desc->ibuf_phys) - INMEM_CON_START + PSI_DMA_LOG_BUF; debug_descriptor.memcons_ibuf_tce = cpu_to_be32(t); t = PSI_DMA_TRACE_BASE; diff --git a/platforms/ibm-fsp/hostservices.c b/platforms/ibm-fsp/hostservices.c index 81fd6bdd3695..c0effc3e4067 100644 --- a/platforms/ibm-fsp/hostservices.c +++ b/platforms/ibm-fsp/hostservices.c @@ -177,7 +177,7 @@ static bool hbrt_con_wrapped; #define HBRT_CON_IN_LEN 0 #define HBRT_CON_OUT_LEN (HBRT_CON_LEN - HBRT_CON_IN_LEN) -static struct memcons hbrt_memcons __section(".data.memcons") = { +static struct memcons_desc hbrt_memcons __section(".data.memcons") = { .magic = CPU_TO_BE64(MEMCONS_MAGIC), .obuf_phys = CPU_TO_BE64(HBRT_CON_START), .ibuf_phys = CPU_TO_BE64(HBRT_CON_START + HBRT_CON_OUT_LEN), From patchwork Tue May 19 05:46:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292952 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 49R4jt56lbz9sVY for ; Tue, 19 May 2020 15:50:42 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Q8G/0WrO; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4jt4C6VzDqS2 for ; Tue, 19 May 2020 15:50:42 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Q8G/0WrO; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4dy5NdczDqv9 for ; Tue, 19 May 2020 15:47:18 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id k22so5160724pls.10 for ; Mon, 18 May 2020 22:47:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=54GQBSuqmXSI5m/epEcfbAFzm5AtwbfBN9FaSEf3ob8=; b=Q8G/0WrO/4ni8QxzOn0ydSIVgrTQh/auxUd4qlSckxrZbQ2g6NgKTLBZCxY0qwCncp 8aiOMr/LTpldlHvHEPLsxr09AOV7p9WI7nPSixn+xNA9OiBZAD2rHIoajK4FxmAcWK/b CAB2Jut7PiDSFxm9CoVmtnSf3TegBFukF7BszFfaWhVGzXuSlwDUAowoT6eIQU2jlaqO M8oO7oTkPTLMWpP60l8frsRL65tfWyKZXDbgfMCS+8kDpnQLQPWzlHdnKbs4xXR3mscK oRo6N775GHD5rwsMC00XDRHN3MIfofieVpXW0rHGx9qoLPwPcKx8rX6VbbUI4mI/lgWn SRIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=54GQBSuqmXSI5m/epEcfbAFzm5AtwbfBN9FaSEf3ob8=; b=c16LzArt8yu5KbiEQg+7QDJYtp4m8wwQeXgdKehKiyH9UEm5XaQ/kqP3O9PdOxiFRx MivmLvmhzAsUwDS5QK3hhN/OFEQ6YCkZYbUdWdGQ702FyMis+FIvCYsPxOmYGbo8PkSF MDgvEQpKfAr1tXwfd4myR4hJvyVMbLSipxPWhqmkg+pGaLuvtt8y2AY7vO/GaA/u3+U+ /9YK253sJQCIHD9scgIsb+um++QhOMxaxpN0yP2xXrjjnIZKhNBqz+z4DrOEehjRwW+5 iJZ8KRhfbpkQxIaUn9WUljc1hoavJvU4fTNF7sfGValKpFRGrwEquD3pAeP4Lvx4SxnN gIwg== X-Gm-Message-State: AOAM532BQwv988rbqnpoxFkpQ9lyoq2ta3T8nQfmCv7MGDwzG5gPm7hq vS7KYNpwzTpBy1OLdHKhKRb2EZIp X-Google-Smtp-Source: ABdhPJzfXzG3fUd1txeRd0BDPqM0yo+kup5VTFFokTIiNdwDLzZR60dzcSB2FL8ayNzP1JOQtpxMmQ== X-Received: by 2002:a17:902:c194:: with SMTP id d20mr1779441pld.213.1589867234403; Mon, 18 May 2020 22:47:14 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:14 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:27 +1000 Message-Id: <20200519054633.113238-7-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 06/12] core/console: Kill con_in 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" The con_in variable is used to keep track of where the write pointer of the skiboot log buffer is. The memcons.out_pos field tracks the same information so we can remove con_in and use the internal field instead. Signed-off-by: Oliver O'Halloran --- core/console.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/core/console.c b/core/console.c index 8be7ee578b18..3ef360fe0c65 100644 --- a/core/console.c +++ b/core/console.c @@ -16,7 +16,6 @@ #include static char *con_buf = (char *)INMEM_CON_START; -static size_t con_in; /* * Skiboot is both the producer and consumer of the memcons. On the consumer @@ -110,7 +109,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) static bool in_flush, more_flush; /* Is there anything to flush ? Bail out early if not */ - if (con_in == con_out || !con_driver) + if (memcons.out_pos == con_out || !con_driver) return false; /* @@ -149,7 +148,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) * con_out. */ if (!flush_to_drivers) { - con_out = con_in; + con_out = memcons.out_pos; in_flush = false; return false; } @@ -157,11 +156,11 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) do { more_flush = false; - if (con_out > con_in) { + if (con_out > memcons.out_pos) { req = INMEM_CON_OUT_LEN - con_out; more_flush = true; } else - req = con_in - con_out; + req = memcons.out_pos - con_out; unlock(&con_lock); len = con_driver->write(con_buf + con_out, req); @@ -175,7 +174,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) } while(more_flush); in_flush = false; - return con_out != con_in; + return con_out != memcons.out_pos; } bool flush_console(void) @@ -195,9 +194,9 @@ static void inmem_write(char c) if (!c) return; - con_buf[con_in++] = c; - if (con_in >= INMEM_CON_OUT_LEN) { - con_in = 0; + memcons.obuf[memcons.out_pos++] = c; + if (memcons.out_pos >= INMEM_CON_OUT_LEN) { + memcons.out_pos = 0; con_wrapped = true; } @@ -208,7 +207,7 @@ static void inmem_write(char c) * 8 bytes containing out_pos and in_prod, thus corrupting * out_pos */ - opos = con_in; + opos = memcons.out_pos; if (con_wrapped) opos |= MEMCONS_OUT_POS_WRAP; lwsync(); From patchwork Tue May 19 05:46:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292953 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 49R4kc1Pg9z9sV9 for ; Tue, 19 May 2020 15:51:20 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=qt4kNT+w; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4kZ3stVzDqV3 for ; Tue, 19 May 2020 15:51:18 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=qt4kNT+w; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4f000nMzDqv4 for ; Tue, 19 May 2020 15:47:19 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id m7so5169110plt.5 for ; Mon, 18 May 2020 22:47:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=d1zE4Om6D2NvPRp8kRWACz2WvtfXUulpanxx3NFqWGo=; b=qt4kNT+wrL908OZo8sbOAkttjRmeUWYQxhiKguoK8wf/2xgbJ1jh6lwjYHJyND/uxJ 7qbvCriZ+YaayVX5P81rn+WSq78e1iImcGK5JwUwJoFrRvFcBDhF1nGc8sQw+/d+6BO3 l/KotFDY8e6wRui8o1u1fwhoKcwb0JP0adueeagOYOUJF6TUchk17rzwLpaWvd78CJ/D pF4/YOhyNljPMDgPTBJT/2ey1wBAMtLanQmbUXQm2zOE9s4WA/tSxTYKZvhGNytda7B4 5a03OlGtgt5cQ8lJCKuMkSDThy4hBADHbLLiolOE0gkoQw6v0vfQRrgdOL96WAxidDLp PUpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=d1zE4Om6D2NvPRp8kRWACz2WvtfXUulpanxx3NFqWGo=; b=spO1hSvZgSWBY3s4tfSehrRcRjf1Dg9qGpMLm9XrefLUmPuo4J6vvI963IaNsJnSZi TpGyUKBEgdZGabmV/tg8qLEseJ4gja1BCGjz/KfeCBaZLriBk30+7bVl9Rh9lg68SUwa jEYWG+AsYOxzABK3DwTwAdd4f71KlQ3GnczeQtXticQNjYi8d0jKi/MCo2JrJ8P8y2dz Yi9kklN6R2fnoEpBE53L9esCo+q6HVpJ11cWP7klJnSUOOa5dbBm+xrIrmo62mLLgDnl sp6wVAIuoFziBHTsYluwVR1b7xCEnv3w7O17RQL71g3WKDUDysjThXKoQl/Dh8laaCkw QyKQ== X-Gm-Message-State: AOAM531GQfAqcQ/W2Uln1mCDQEIKcfZjfIscOXPXCdeKCJ5vLqS+GEcq zQByB58XWodBIUz/Nws4U6x5k9bN X-Google-Smtp-Source: ABdhPJxN+NffOsFm0PU0Sd8g/TzyRSfuRhhh5spQ4HBhOFOQPNlJGURBZTDVaR9tq0IabGDO9vBSnQ== X-Received: by 2002:a17:902:7788:: with SMTP id o8mr19180807pll.339.1589867237356; Mon, 18 May 2020 22:47:17 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:17 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:28 +1000 Message-Id: <20200519054633.113238-8-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 07/12] core/console: Rename con_out to flush_head 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Skiboot acts as a producer and consumer of the skiboot log buffer. In the role of a consumer skiboot writes the contents of the log buffer to the host console using the internal console driver. In order to do that we need to keep track how much of the log buffer has been written to the console. To do that we use con_out to track the offset of the last flushed postition. Rename the variable to reflect it's actual usage. Signed-off-by: Oliver O'Halloran --- core/console.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/core/console.c b/core/console.c index 3ef360fe0c65..e18c4c3213bb 100644 --- a/core/console.c +++ b/core/console.c @@ -20,9 +20,9 @@ static char *con_buf = (char *)INMEM_CON_START; /* * Skiboot is both the producer and consumer of the memcons. On the consumer * side we need to keep track of how much of the log buffer has been written - * out to the console which is what con_out is for. + * out to the console which is what flush_head is for. */ -static size_t con_out; +static size_t flush_head; static bool con_wrapped; /* Internal console driver ops */ @@ -109,7 +109,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) static bool in_flush, more_flush; /* Is there anything to flush ? Bail out early if not */ - if (memcons.out_pos == con_out || !con_driver) + if (memcons.out_pos == flush_head || !con_driver) return false; /* @@ -145,10 +145,10 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) /* * NB: this must appear after the in_flush check since it modifies - * con_out. + * flush_head. */ if (!flush_to_drivers) { - con_out = memcons.out_pos; + flush_head = memcons.out_pos; in_flush = false; return false; } @@ -156,17 +156,17 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) do { more_flush = false; - if (con_out > memcons.out_pos) { - req = INMEM_CON_OUT_LEN - con_out; + if (flush_head > memcons.out_pos) { + req = INMEM_CON_OUT_LEN - flush_head; more_flush = true; } else - req = memcons.out_pos - con_out; + req = memcons.out_pos - flush_head; unlock(&con_lock); - len = con_driver->write(con_buf + con_out, req); + len = con_driver->write(con_buf + flush_head, req); lock(&con_lock); - con_out = (con_out + len) % INMEM_CON_OUT_LEN; + flush_head = (flush_head + len) % INMEM_CON_OUT_LEN; /* write error? */ if (len < req) @@ -174,7 +174,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) } while(more_flush); in_flush = false; - return con_out != memcons.out_pos; + return flush_head != memcons.out_pos; } bool flush_console(void) @@ -219,8 +219,8 @@ static void write_char(char c) inmem_write(c); /* If head reaches tail, push tail around & drop chars */ - if (con_out == memcons.desc->out_pos) - con_out = (memcons.desc->out_pos + 1) % memcons.desc->obuf_size; + if (flush_head == memcons.desc->out_pos) + flush_head = (memcons.desc->out_pos + 1) % memcons.desc->obuf_size; } ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count) From patchwork Tue May 19 05:46:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292954 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 49R4lC4rqsz9sTC for ; Tue, 19 May 2020 15:51:51 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=abi+qRxl; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4lC1nLxzDqLR for ; Tue, 19 May 2020 15:51:51 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::1042; helo=mail-pj1-x1042.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=abi+qRxl; dkim-atps=neutral Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4f235rdzDqw2 for ; Tue, 19 May 2020 15:47:22 +1000 (AEST) Received: by mail-pj1-x1042.google.com with SMTP id z15so800289pjb.0 for ; Mon, 18 May 2020 22:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CZ7CNzdu+EXCu3zP0oShzO4BX9lNFbfLklEyPxkGk8k=; b=abi+qRxlnMf7d6LDlfBESp5KJrj0PFCdYaVcGF9npYBDSJn+hMi7r4SqSVifs6IVw1 6I9hKvCE5dJ3qt0gL13ReJ4YFI5IOemkHnwirTu5u0uyGf6M457wHz57BHZrdjwDTuOr Lvysc09DeP8aZ6+q1Jf3e8hi5/Nwj/A05OOy02xFWxiqE1rW4xnusKwhNRTO0jI2E64t mEJxgFdQuvtqxcoc3Sm5PCgl3UwWxgbF6/2UR41xL9xWwjZjN4TKyDTrs0IPNWufmSNr miejPiIqVlesY5gC9GUq7cnByRbEfVCSReMcSwKWzFBHCXrYMLjSAFKX4igRzizYtvKW KuEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CZ7CNzdu+EXCu3zP0oShzO4BX9lNFbfLklEyPxkGk8k=; b=DMdu6uvZMO9a4Tlx0oivXubEhTycgWIyfnsjAJo0DJbquiySCWn2uhS5JLaO6g6ZjA PPT9pakDSkFLT/dPhzjsfLdNHl5LuKU3VAUyy/u9lw/T11sIsrSvFzfR6dNYPgXE81fz DP1tAGfgemUqm5zRHuufnVJGhN78hdwnlsGksBCyfrL+Pehpu6rG8n1/BsaBqcUvo452 LiDXyGt2DQo2ztXIbI6G/5aUaM6jF2FV8ROo90dCcQ5bKgrAP9v3hxFSVBvjM56IH2MR KuRjUOP/Hw7wWnnp9Wos9kB+sQfDMzYAM68Mc0fWw3MeuXrhlH2MBL0zEnKAw7GATYSW H2Lg== X-Gm-Message-State: AOAM530mVTJfwLlHIkV+RsQ6kjm4t2Zqk4mvpDz0I341IMbLF/QNXgoC yfVWJi0TokqAcg47OL5xcDhP0yF2 X-Google-Smtp-Source: ABdhPJxZWwtI1VWGA2bI/sIxwSM18fV8xYI9o0VHO1GoQTIcNcoaSh2TF89Ru84MNzQbWoOn4WM8TQ== X-Received: by 2002:a17:902:44e:: with SMTP id 72mr16381014ple.301.1589867239358; Mon, 18 May 2020 22:47:19 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:19 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:29 +1000 Message-Id: <20200519054633.113238-9-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 08/12] core/console: Drop has_wrapped 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This same information is tracked in struct memcons so use that instead. Signed-off-by: Oliver O'Halloran --- core/console.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/console.c b/core/console.c index e18c4c3213bb..34944de4f310 100644 --- a/core/console.c +++ b/core/console.c @@ -23,7 +23,6 @@ static char *con_buf = (char *)INMEM_CON_START; * out to the console which is what flush_head is for. */ static size_t flush_head; -static bool con_wrapped; /* Internal console driver ops */ static struct con_ops *con_driver; @@ -197,7 +196,7 @@ static void inmem_write(char c) memcons.obuf[memcons.out_pos++] = c; if (memcons.out_pos >= INMEM_CON_OUT_LEN) { memcons.out_pos = 0; - con_wrapped = true; + memcons.has_wrapped = true; } /* @@ -208,7 +207,7 @@ static void inmem_write(char c) * out_pos */ opos = memcons.out_pos; - if (con_wrapped) + if (memcons.has_wrapped) opos |= MEMCONS_OUT_POS_WRAP; lwsync(); memcons.desc->out_pos = cpu_to_be32(opos); From patchwork Tue May 19 05:46:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292955 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 49R4lk4q9Gz9sTc for ; Tue, 19 May 2020 15:52:18 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=rVNET6xY; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4lj25dzzDqLR for ; Tue, 19 May 2020 15:52:17 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::642; helo=mail-pl1-x642.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=rVNET6xY; dkim-atps=neutral Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4f370X7zDqf6 for ; Tue, 19 May 2020 15:47:23 +1000 (AEST) Received: by mail-pl1-x642.google.com with SMTP id a13so3615960pls.8 for ; Mon, 18 May 2020 22:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VkrLq2n5pL8iWkPVK/OmQ7asQ0a7vWvwIc3zgWmQ51Q=; b=rVNET6xYmIzrlQPf23/O+DEOfvhbxCdvQFXRR1zRB+Bb3ysy/c5179+SZ4sWxI8JQ8 VeYCRuWIzvFu5cUmbHxFFYW/9iNyI0jTzX066vfRvCoX3GAZVit3p2CKDZv3twYIgNHX lGvfAaDu4Y9grkqzFQcAAf/+24E1RtpMfoQvFu/7w14rMtDB+RRVIBEtviriGcX5LGrc codPXLYozJRWhClzeFrVI+YmjOSeyuyOm6thrt/GgGWwT/xGDImzEnMKPI1hkAbDCzue mLpdDNAZGfBRkZgRQehFWx3EFhCDmwz45EVWiYZowpon4Dm+GIuQ3DZ3QL/+VxjgnDto b1Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VkrLq2n5pL8iWkPVK/OmQ7asQ0a7vWvwIc3zgWmQ51Q=; b=ZHMxWHq30+H4+nc3emTq5pCfAGIxNxo2hMhRtEuFZEMdNK1Wznk2LgC82lldLJZjMD 5ePJBEekFc9EAfP9hOiXcXMRjdi/sOFsw72DUkSXdypraEL9vnLlKNNfLnKkYrns3r1T CGuGYNM54vCk9mODl2vRwOcV1azNnjHErMXOVlxbiSqElKyrWWlh5pMhjkKLl49F5BQA 6PnMUynuaGKy4cTVSQXTuMT3Rpi9Z1HxCI/TCn6x60KdoUOtB1Q2Q7KVgaBra3RIRIbO ZtNEZuRN6ni01y8G/ikP4SxHx4jMF2mnBZmEzdqkL3bXpFT10uhdStcIqdKt3S6S4xKA 0Jzg== X-Gm-Message-State: AOAM533TepjeVUQD5fTYgxRHi5fnE+MnbgwBF+8FXjLZ5XW4ggAd6JOS i5/1VRrUQvJv3fRSOz18Z0kWQ1H1 X-Google-Smtp-Source: ABdhPJwhLOvqMEXBKBRTlrAI1UR3A6nUQ+nkRDP5zqx/x5YnQqMrvTiQebzG9tOSrlSWwyaRDUqoMQ== X-Received: by 2002:a17:90a:8506:: with SMTP id l6mr3415392pjn.2.1589867241595; Mon, 18 May 2020 22:47:21 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:21 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:30 +1000 Message-Id: <20200519054633.113238-10-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 09/12] core/console: Make inmem_read/inmem_write take a memcons parameter 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Allow the console ring-buffer read/write functions to be used for any memcons structure. This way we can use them for both the msglog and the cronus in-memory console once they're split apart. Signed-off-by: Oliver O'Halloran --- core/console.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/console.c b/core/console.c index 34944de4f310..719ba67063a0 100644 --- a/core/console.c +++ b/core/console.c @@ -187,35 +187,35 @@ bool flush_console(void) return ret; } -static void inmem_write(char c) +static void inmem_write(struct memcons *mcon, char c) { uint32_t opos; if (!c) return; - memcons.obuf[memcons.out_pos++] = c; - if (memcons.out_pos >= INMEM_CON_OUT_LEN) { - memcons.out_pos = 0; - memcons.has_wrapped = true; + mcon->obuf[mcon->out_pos++] = c; + if (mcon->out_pos >= INMEM_CON_OUT_LEN) { + mcon->out_pos = 0; + mcon->has_wrapped = true; } /* - * We must always re-generate memcons.desc->out_pos because + * We must always re-generate mcon->desc->out_pos because * under some circumstances, the console script will * use a broken putmemproc that does RMW on the full * 8 bytes containing out_pos and in_prod, thus corrupting * out_pos */ - opos = memcons.out_pos; - if (memcons.has_wrapped) + opos = mcon->out_pos; + if (mcon->has_wrapped) opos |= MEMCONS_OUT_POS_WRAP; lwsync(); - memcons.desc->out_pos = cpu_to_be32(opos); + mcon->desc->out_pos = cpu_to_be32(opos); } static void write_char(char c) { - inmem_write(c); + inmem_write(&memcons, c); /* If head reaches tail, push tail around & drop chars */ if (flush_head == memcons.desc->out_pos) @@ -250,15 +250,15 @@ ssize_t write(int fd __unused, const void *buf, size_t count) return console_write(true, buf, count); } -static size_t inmem_read(char *buf, size_t req) +static size_t inmem_read(struct memcons *mcon, char *buf, size_t req) { size_t read = 0; - char *ibuf = (char *)be64_to_cpu(memcons.desc->ibuf_phys); + char *ibuf = (char *)be64_to_cpu(mcon->desc->ibuf_phys); - while (req && be32_to_cpu(memcons.desc->in_prod) != be32_to_cpu(memcons.desc->in_cons)) { - *(buf++) = ibuf[be32_to_cpu(memcons.desc->in_cons)]; + while (req && be32_to_cpu(mcon->desc->in_prod) != be32_to_cpu(mcon->desc->in_cons)) { + *(buf++) = ibuf[be32_to_cpu(mcon->desc->in_cons)]; lwsync(); - memcons.desc->in_cons = cpu_to_be32((be32_to_cpu(memcons.desc->in_cons) + 1) % INMEM_CON_IN_LEN); + mcon->desc->in_cons = cpu_to_be32((be32_to_cpu(mcon->desc->in_cons) + 1) % INMEM_CON_IN_LEN); req--; read++; } @@ -271,7 +271,7 @@ ssize_t read(int fd __unused, void *buf, size_t req_count) size_t count = 0; if (!count) - count = inmem_read(buf, req_count); + count = inmem_read(&memcons, buf, req_count); if (need_unlock) unlock(&con_lock); return count; From patchwork Tue May 19 05:46:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292956 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 49R4mF70nmz9sTc for ; Tue, 19 May 2020 15:52:45 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=cYzHXnE/; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4mD5hl0zDqLd for ; Tue, 19 May 2020 15:52:44 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::441; helo=mail-pf1-x441.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=cYzHXnE/; dkim-atps=neutral Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4f64TrNzDqfG for ; Tue, 19 May 2020 15:47:26 +1000 (AEST) Received: by mail-pf1-x441.google.com with SMTP id b190so6023035pfg.6 for ; Mon, 18 May 2020 22:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FTDiMrRzvWiT0c7pYNCwHY++tQYnU7q2C3i9iqsa8fA=; b=cYzHXnE/WUm8w34NWIkJVwgmjM1deQvcxv+0K4RGM99jWZBxta/byCFR9qVKtYtJD4 GOIw5gr4wFL+zN17a65jU1ZaGZrk9XXr6I/11kpHmmAz4cc/TsQgCggPCTGH8YKXz590 QahEdwgTv6pwnC2+ucGP3Xa7w9y+kmwwiljr2Ul+VBqra3mc/u14F/rw1CdGroj83MyW X17KGo3RYTeaTG0ZwBzmLIEgb00oZlSuBL/4iHyb6k3VCIpPTxdJm1Q4I4Av07oxBe9B T2/EdUuDN6rWZnUF3dT1goIFHQx+VGxR843xuV9NcMivJvc0JLPDgYqouammeZS3ciuh n7vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FTDiMrRzvWiT0c7pYNCwHY++tQYnU7q2C3i9iqsa8fA=; b=Oq8fy3/1dJHl5rcnh8uKa2pt4IUpPziieZwWsduAq6KdBmEomJ2W5yGzY0na6kSagH 4X2t0flIDrvMYWPT3gw5GYnVAQxAJQFIXc0YK+kZ9fT9LkQJ6bNHV/EbM6yS2ojL1w2A Vz5nTRpDMeR80+IaCKkN7E+eipwxEeu4sa7uGOIYII6V2Ks3iNvVSO3E2dUVmz0mMU+v e44YE4XJqKqjeCuRPcLVUoiy3qVYVX6LQ0pfazwSiknyr6042Pqqcu6kzOI5QOxGyMfu TBRlh91p73WU26MupJidlmXlsjoxvnVlfhHIZqJSL4aefik4ntH36S6kooKcQfKQEI+e HrCA== X-Gm-Message-State: AOAM5301XG/hQ00qLvfOuVXWEvMopOEM2xrd1t2W9CkQXvVDbYEgf9Qf vAIvirazTYIhbojKaBF7tIqOxlH9 X-Google-Smtp-Source: ABdhPJygty+YTviNRH2PqFD7brFT1DOfuGLF/IvAzPkpkaf9MAtOM1Gw7Kx5YvtQ/34hRPLzblbBvg== X-Received: by 2002:a65:480c:: with SMTP id h12mr18713311pgs.106.1589867243642; Mon, 18 May 2020 22:47:23 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:23 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:31 +1000 Message-Id: <20200519054633.113238-11-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 10/12] core/console: Drop con_buf 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" We can use the buffer pointer in memcons instead. Signed-off-by: Oliver O'Halloran --- core/console.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/core/console.c b/core/console.c index 719ba67063a0..d37a4cb128e2 100644 --- a/core/console.c +++ b/core/console.c @@ -15,8 +15,6 @@ #include #include -static char *con_buf = (char *)INMEM_CON_START; - /* * Skiboot is both the producer and consumer of the memcons. On the consumer * side we need to keep track of how much of the log buffer has been written @@ -92,7 +90,7 @@ struct dt_node *add_opal_console_node(int index, const char *type, void clear_console(void) { - memset(con_buf, 0, INMEM_CON_LEN); + memset(memcons.obuf, 0, memcons.obuf_size); } /* @@ -162,7 +160,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) req = memcons.out_pos - flush_head; unlock(&con_lock); - len = con_driver->write(con_buf + flush_head, req); + len = con_driver->write(memcons.obuf + flush_head, req); lock(&con_lock); flush_head = (flush_head + len) % INMEM_CON_OUT_LEN; From patchwork Tue May 19 05:46:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292957 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 49R4mn1fknz9sTc for ; Tue, 19 May 2020 15:53:13 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ZCE0mwCB; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4mm5lQJzDqJM for ; Tue, 19 May 2020 15:53:12 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::543; helo=mail-pg1-x543.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ZCE0mwCB; dkim-atps=neutral Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4f92DrRzDqV3 for ; Tue, 19 May 2020 15:47:29 +1000 (AEST) Received: by mail-pg1-x543.google.com with SMTP id b8so5880000pgi.11 for ; Mon, 18 May 2020 22:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=HWKEimtazOyf/9U/dA34kYUQaYXJIAGRDm/CSv2mq/M=; b=ZCE0mwCBImKK5yiYXZeHrraLda6bZood+r+87BFeSont8tIgLn9lb1qBPRggW1Z130 DJSqaHYaR/Ey7MOOCzDF6oHoXgZwtuBNebeSJnnO3A8qeW3pM4MfdPCyt6hFE+0Xl55E zqtC9cnHdBUMoJuVCyWexSLpq3/gojarYxmtlxSYFO6oXuZ3pD/HtENFMc7zUlYSsr/N KquITM5roMkijydEzUEBZ189OkpUoGoUWHxcuhisHbLejr8awHCF+IzCsIt9buhMvJpn nrKcRihMMi9G3cBGiAPSqK+m4IHw+d2rTAmo7/h2LtB9JgW17WqR91iz/5u9DeSGKOnE EDHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HWKEimtazOyf/9U/dA34kYUQaYXJIAGRDm/CSv2mq/M=; b=HaPptM/cqlBUSKeYjC7WpMtLaoFJpV4Cq9tC3T826FmB/J+wE7+dIfpxV+VewmdI8Q WphHhUyIIoB8836V5he7DRRBMvn4ylCviQfTFNV1oKC/5tx1uh+VTwUdGyGH7SDrTerc Lxyl/kYvtqw9yiOUV8dMnMJMBrE/RmP4qV6A5aPAJiPOTmEb3VrAzs9FicjQeaEOH3XG X7osmUPDQ7dpx3n8zJyZIzjOJUlB/UKci3MZm4cDT46i3zkPTcUV3GtH1+4BLUfbnuYE oJCvXqMi66VG3Tdm6UJIwI6FucP9/WU4gDDXtfcn19KyB3Y25Pb0LMywtNXC7safp3NT c2sg== X-Gm-Message-State: AOAM530OCFJRmDbdqzBXZOL6h6l2n5kdKOt+bkPDgzizn+z9K3pCLwR0 swAbHoJ22yU7JkhO7q5t15Eh9/s6 X-Google-Smtp-Source: ABdhPJw3IF/iDiaM0km1kXml6TvexahG26fupz+Q4WOPCeBmOmPhfQLCtysh14maPrkgyCDw9x1lcw== X-Received: by 2002:aa7:81d1:: with SMTP id c17mr20375580pfn.58.1589867245534; Mon, 18 May 2020 22:47:25 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:25 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:32 +1000 Message-Id: <20200519054633.113238-12-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 11/12] core/console: Split memcons into msglog and inmem_con 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Seperate the single "memcons" into "msglog" for the skiboot log buffer and "inmem_con" for the in-memory console that's used for systems without a console (i.e. cronus booted systems). Signed-off-by: Oliver O'Halloran --- core/console.c | 68 ++++++++++++++++++++++++++++---------- core/init.c | 2 +- core/opal.c | 2 +- include/console.h | 5 +-- include/mem-map.h | 10 ++++-- platforms/ibm-fsp/common.c | 11 ++++-- 6 files changed, 70 insertions(+), 28 deletions(-) diff --git a/core/console.c b/core/console.c index d37a4cb128e2..bfeb7aae39e0 100644 --- a/core/console.c +++ b/core/console.c @@ -30,8 +30,21 @@ static struct opal_con_ops *opal_con_driver = &dummy_opal_con; static struct lock con_lock = LOCK_UNLOCKED; +/* The descriptors are is mapped via TCEs so we keep it alone in a page */ +struct memcons_desc msglog_desc __section(".data.memcons") = { + .magic = CPU_TO_BE64(MEMCONS_MAGIC), + .obuf_phys = CPU_TO_BE64(MSGLOG_START), + .obuf_size = CPU_TO_BE32(MSGLOG_LEN), +}; + +struct memcons msglog = { + .desc = &msglog_desc, + .obuf = (char *) MSGLOG_START, + .obuf_size = MSGLOG_LEN, +}; + /* This is mapped via TCEs so we keep it alone in a page */ -struct memcons_desc memcons_desc __section(".data.memcons") = { +struct memcons_desc inmem_con_desc __section(".data.memcons") = { .magic = CPU_TO_BE64(MEMCONS_MAGIC), .obuf_phys = CPU_TO_BE64(INMEM_CON_START), .ibuf_phys = CPU_TO_BE64(INMEM_CON_START + INMEM_CON_OUT_LEN), @@ -39,8 +52,8 @@ struct memcons_desc memcons_desc __section(".data.memcons") = { .ibuf_size = CPU_TO_BE32(INMEM_CON_IN_LEN), }; -struct memcons memcons = { - .desc = &memcons_desc, +struct memcons inmem_con = { + .desc = &inmem_con_desc, .obuf = (char *) INMEM_CON_START, .obuf_size = INMEM_CON_OUT_LEN, @@ -90,7 +103,7 @@ struct dt_node *add_opal_console_node(int index, const char *type, void clear_console(void) { - memset(memcons.obuf, 0, memcons.obuf_size); + memset(msglog.obuf, 0, msglog.obuf_size); } /* @@ -106,7 +119,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) static bool in_flush, more_flush; /* Is there anything to flush ? Bail out early if not */ - if (memcons.out_pos == flush_head || !con_driver) + if (msglog.out_pos == flush_head || !con_driver) return false; /* @@ -145,7 +158,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) * flush_head. */ if (!flush_to_drivers) { - flush_head = memcons.out_pos; + flush_head = msglog.out_pos; in_flush = false; return false; } @@ -153,14 +166,14 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) do { more_flush = false; - if (flush_head > memcons.out_pos) { + if (flush_head > msglog.out_pos) { req = INMEM_CON_OUT_LEN - flush_head; more_flush = true; } else - req = memcons.out_pos - flush_head; + req = msglog.out_pos - flush_head; unlock(&con_lock); - len = con_driver->write(memcons.obuf + flush_head, req); + len = con_driver->write(msglog.obuf + flush_head, req); lock(&con_lock); flush_head = (flush_head + len) % INMEM_CON_OUT_LEN; @@ -171,7 +184,7 @@ static bool __flush_console(bool flush_to_drivers, bool need_unlock) } while(more_flush); in_flush = false; - return flush_head != memcons.out_pos; + return flush_head != msglog.out_pos; } bool flush_console(void) @@ -213,11 +226,11 @@ static void inmem_write(struct memcons *mcon, char c) static void write_char(char c) { - inmem_write(&memcons, c); + inmem_write(&msglog, c); /* If head reaches tail, push tail around & drop chars */ - if (flush_head == memcons.desc->out_pos) - flush_head = (memcons.desc->out_pos + 1) % memcons.desc->obuf_size; + if (flush_head == msglog.desc->out_pos) + flush_head = (msglog.desc->out_pos + 1) % msglog.desc->obuf_size; } ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count) @@ -248,6 +261,16 @@ ssize_t write(int fd __unused, const void *buf, size_t count) return console_write(true, buf, count); } +/* flushes the msglog into the inmem_con */ +static size_t msglog_glue(const char *buf, size_t len) +{ + return write(0, buf, len); +} + +static struct con_ops dummy_con_glue = { + .write = msglog_glue, +}; + static size_t inmem_read(struct memcons *mcon, char *buf, size_t req) { size_t read = 0; @@ -268,8 +291,9 @@ ssize_t read(int fd __unused, void *buf, size_t req_count) bool need_unlock = lock_recursive(&con_lock); size_t count = 0; + /* NB: we are reading the input buffer of inmem_con, *not* msglog */ if (!count) - count = inmem_read(&memcons, buf, req_count); + count = inmem_read(&inmem_con, buf, req_count); if (need_unlock) unlock(&con_lock); return count; @@ -329,6 +353,8 @@ void init_opal_console(void) prlog(PR_WARNING, "OPAL: Dummy console forced, %s ignored\n", opal_con_driver->name); + /* FIXME: Do this earlier? */ + set_console(&dummy_con_glue); opal_con_driver = &dummy_opal_con; } @@ -344,9 +370,15 @@ void init_opal_console(void) opal_con_driver->space, 2); } -void memcons_add_properties(void) +void msglog_add_properties(void) { - dt_add_property_u64(opal_node, "ibm,opal-memcons", (u64) &memcons_desc); + /* + * This property is poorly named for historical reasons. OSes (Linux + * at least) use this to read the skiboot msglog so it should point + * at that. The input buffer is pointed to by the descriptor never referenced directly by the OS + * since all console IO goes via the OPAL API calls. + */ + dt_add_property_u64(opal_node, "ibm,opal-memcons", (u64) &msglog_desc); } /* @@ -418,7 +450,7 @@ static void dummy_console_poll(void *data __unused) bool has_data = false; lock(&con_lock); - if (memcons.desc->in_prod != memcons.desc->in_cons) + if (inmem_con.desc->in_prod != inmem_con.desc->in_cons) has_data = true; if (has_data) opal_update_pending_evt(OPAL_EVENT_CONSOLE_INPUT, @@ -432,7 +464,7 @@ void dummy_console_add_nodes(void) { struct dt_property *p; - add_opal_console_node(0, "raw", be32_to_cpu(memcons.desc->obuf_size)); + add_opal_console_node(0, "raw", be32_to_cpu(inmem_con.desc->obuf_size)); /* Mambo might have left a crap one, clear it */ p = __dt_find_property(dt_chosen, "linux,stdout-path"); diff --git a/core/init.c b/core/init.c index 595d087fa4f3..bcc2bd78a46c 100644 --- a/core/init.c +++ b/core/init.c @@ -1013,7 +1013,7 @@ void __noreturn __nomcount main_cpu_entry(const void *fdt) /* * Point to our mem console */ - debug_descriptor.memcons_phys = cpu_to_be64((uint64_t)&memcons); + debug_descriptor.memcons_phys = cpu_to_be64((uint64_t)&inmem_con); /* * Before first printk, ensure console buffer is clear or diff --git a/core/opal.c b/core/opal.c index 64fdfe62aff2..b46369a68b22 100644 --- a/core/opal.c +++ b/core/opal.c @@ -419,7 +419,7 @@ void add_opal_node(void) add_opal_firmware_node(); add_associativity_ref_point(); - memcons_add_properties(); + msglog_add_properties(); } static struct lock evt_lock = LOCK_UNLOCKED; diff --git a/include/console.h b/include/console.h index 280f920aba44..820cb1de6452 100644 --- a/include/console.h +++ b/include/console.h @@ -47,7 +47,8 @@ struct memcons { bool has_wrapped; }; -extern struct memcons memcons; +extern struct memcons msglog; +extern struct memcons inmem_con; #define INMEM_CON_IN_LEN 16 #define INMEM_CON_OUT_LEN (INMEM_CON_LEN - INMEM_CON_IN_LEN) @@ -93,7 +94,7 @@ extern void enable_mambo_console(void); ssize_t console_write(bool flush_to_drivers, const void *buf, size_t count); extern void clear_console(void); -extern void memcons_add_properties(void); +extern void msglog_add_properties(void); extern void dummy_console_add_nodes(void); struct dt_node *add_opal_console_node(int index, const char *type, diff --git a/include/mem-map.h b/include/mem-map.h index b654012576b9..797117d7bc82 100644 --- a/include/mem-map.h +++ b/include/mem-map.h @@ -88,12 +88,16 @@ #define HEAP_SIZE 0x00b00000 /* This is the location of our console buffer at base + 16M */ -#define INMEM_CON_START (SKIBOOT_BASE + 0x01000000) -#define INMEM_CON_LEN 0x100000 +#define MSGLOG_START (SKIBOOT_BASE + 0x01000000) +#define MSGLOG_LEN 0x100000 /* This is the location of HBRT console buffer at base + 17M */ #define HBRT_CON_START (SKIBOOT_BASE + 0x01100000) -#define HBRT_CON_LEN 0x100000 +#define HBRT_CON_LEN 0x080000 + +/* This is the location of HBRT console buffer at base + 17.5M */ +#define INMEM_CON_START (SKIBOOT_BASE + 0x01180000) +#define INMEM_CON_LEN 0x080000 /* Tell FSP to put the init data at base + 20M, allocate 8M */ #define SPIRA_HEAP_BASE (SKIBOOT_BASE + 0x01200000) diff --git a/platforms/ibm-fsp/common.c b/platforms/ibm-fsp/common.c index 6a20dc7ac36a..3cf18b0e56bf 100644 --- a/platforms/ibm-fsp/common.c +++ b/platforms/ibm-fsp/common.c @@ -21,13 +21,18 @@ static void map_debug_areas(void) /* Our memcons is in a section of its own and already * aligned to 4K. The buffers are mapped as a whole */ - fsp_tce_map(PSI_DMA_MEMCONS, memcons.desc, 0x1000); + fsp_tce_map(PSI_DMA_MEMCONS, inmem_con.desc, 0x1000); fsp_tce_map(PSI_DMA_LOG_BUF, (void*)INMEM_CON_START, INMEM_CON_LEN); + /* + * FIXME: should this be mapping the msglog, or the inmem console, + * or both? What actually does DMAs here? + */ + debug_descriptor.memcons_tce = cpu_to_be32(PSI_DMA_MEMCONS); - t = be64_to_cpu(memcons.desc->obuf_phys) - INMEM_CON_START + PSI_DMA_LOG_BUF; + t = be64_to_cpu(inmem_con.desc->obuf_phys) - INMEM_CON_START + PSI_DMA_LOG_BUF; debug_descriptor.memcons_obuf_tce = cpu_to_be32(t); - t = be64_to_cpu(memcons.desc->ibuf_phys) - INMEM_CON_START + PSI_DMA_LOG_BUF; + t = be64_to_cpu(inmem_con.desc->ibuf_phys) - INMEM_CON_START + PSI_DMA_LOG_BUF; debug_descriptor.memcons_ibuf_tce = cpu_to_be32(t); t = PSI_DMA_TRACE_BASE; From patchwork Tue May 19 05:46:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 1292958 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 49R4nB1WxNz9sTc for ; Tue, 19 May 2020 15:53:34 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=U2bjI3Ou; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49R4nB1CCtzDqQb for ; Tue, 19 May 2020 15:53:34 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::644; helo=mail-pl1-x644.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=U2bjI3Ou; dkim-atps=neutral Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49R4f94LYHzDqrq for ; Tue, 19 May 2020 15:47:29 +1000 (AEST) Received: by mail-pl1-x644.google.com with SMTP id u22so5152729plq.12 for ; Mon, 18 May 2020 22:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=72W8SjqxntklFcdK2QNeKoe8eRqtJzmEXo9haxb8le4=; b=U2bjI3OugKU3qp+k+Kqqoz8wMq/20x6abQZbdH9zUqAnh8u38y/Djpd8Qr3a3EQMLL 45z+bAjoq54+1q4j4GkWwrc5+hnINNek6lNKOv1rlITqGnzPEbZgk6i7U+tNM23xYJVb ria6w6mqeuvnB9pQKksf4nf6Xas4I7GVEYugKUDZIQKB0gI9BXsC28f7y9F1o3lU7mQQ mnCLTaRoZsUit8XtZcnn5Jpq359GwGPgYogdKkQLJ8XOAt01F6wvy7lctfEzH8vduR5m IrJ6D1fxpPFPkRDwwf5JrtNAXMcNNOBoX8GvEZ+GdyChPxDGb3FK9dn9EYf60+6eD0L0 aK+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=72W8SjqxntklFcdK2QNeKoe8eRqtJzmEXo9haxb8le4=; b=MCV/KT5sSU4el6QKje2gvz70eKe7E05XNp32daFRgbXbI1wVkwQlmG1iY7lHn5CGh1 ykwuILWwzFz1NmmgrBEoQUT0AIgEESV1M+QViCQV3xdPPgtL4G81n3VH5O1OdPOhADA9 JZZP2pYRV59U81l+rLDqCC+5lN45/1TVL9RK5MiHTm9scB2W22aFDSKgRZqwVdLmSl5+ b/FJE38ms8+Vl8e3o8KjBEcxhiFFNNNWofJ0jKo40WfFwa7xZtWG45tTIovphGfbtVh3 z8QemDa9hccqmvqKZMsOAn5BSOqRMnV6UXknzu32n7xHVRq3Er0rfx72a8QrDVCAtfNs V/bg== X-Gm-Message-State: AOAM532yWjJKymp/zedRK6Y2BG/EMlo2Xm3PNtP77zoSdqEKjEKovQjm 8wHBarcd0oEsyJtsW5V/F7Ro0mDJ X-Google-Smtp-Source: ABdhPJyDtsEffBKj/PXESp7oLs3SdqExAH+KBo9kyHFLAOcaNFYlal+Txt6YSHv4JTK4nHg3tXSjVQ== X-Received: by 2002:a17:902:d689:: with SMTP id v9mr9702352ply.283.1589867247526; Mon, 18 May 2020 22:47:27 -0700 (PDT) Received: from 192-168-1-12.tpgi.com.au ([203.221.252.191]) by smtp.gmail.com with ESMTPSA id p12sm2798358pgj.22.2020.05.18.22.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 22:47:27 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Tue, 19 May 2020 15:46:33 +1000 Message-Id: <20200519054633.113238-13-oohall@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200519054633.113238-1-oohall@gmail.com> References: <20200519054633.113238-1-oohall@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [RFC PATCH 12/12] core/console: Add a seperate lock for the in-memory console 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: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" With the msglog split from the in-mem console we shouldn't be using the same lock for both. Add a seperate dummy_con_lock() which is used for the in-memory console driver. Signed-off-by: Oliver O'Halloran --- Renaming con_lock to msglog_lock would probably make sense. Folding this into the previous patch might also make sense. --- core/console.c | 64 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/core/console.c b/core/console.c index bfeb7aae39e0..226ed57f0d36 100644 --- a/core/console.c +++ b/core/console.c @@ -29,6 +29,7 @@ static struct con_ops *con_driver; static struct opal_con_ops *opal_con_driver = &dummy_opal_con; static struct lock con_lock = LOCK_UNLOCKED; +static struct lock dummy_con_lock = LOCK_UNLOCKED; /* The descriptors are is mapped via TCEs so we keep it alone in a page */ struct memcons_desc msglog_desc __section(".data.memcons") = { @@ -264,7 +265,17 @@ ssize_t write(int fd __unused, const void *buf, size_t count) /* flushes the msglog into the inmem_con */ static size_t msglog_glue(const char *buf, size_t len) { - return write(0, buf, len); + int i; + + lock(&dummy_con_lock); + for (i = 0; i < len; i++) + inmem_write(&inmem_con, buf[i]); +#ifdef MAMBO_DEBUG_CONSOLE + mambo_console_write(buf, len); +#endif + unlock(&dummy_con_lock); + + return len; } static struct con_ops dummy_con_glue = { @@ -286,17 +297,20 @@ static size_t inmem_read(struct memcons *mcon, char *buf, size_t req) return read; } -ssize_t read(int fd __unused, void *buf, size_t req_count) +ssize_t __noreturn read(int fd, void *buf, size_t req_count) { - bool need_unlock = lock_recursive(&con_lock); - size_t count = 0; + /* + * We keep write() around because our libc stdio functions need it, and + * there's a few bits of library code that call fprintf and friends. + * + * There's no real use case for read() inside skiboot so we should + * never hit this path. + */ + (void) fd; + (void) buf; + (void) req_count; - /* NB: we are reading the input buffer of inmem_con, *not* msglog */ - if (!count) - count = inmem_read(&inmem_con, buf, req_count); - if (need_unlock) - unlock(&con_lock); - return count; + abort(); } /* Helper function to perform a full synchronous flush */ @@ -385,14 +399,13 @@ void msglog_add_properties(void) * The default OPAL console. * * In the absence of a "real" OPAL console driver we handle the OPAL_CONSOLE_* - * calls by writing into the skiboot log buffer. Reads are a little more - * complicated since they can come from the in-memory console (BML) or from the - * internal skiboot console driver. + * calls by writing into the in-memory console. Since this is entirely in-memory + * some external tooling is required to actually read the console. */ static int64_t dummy_console_write(int64_t term_number, __be64 *length, const uint8_t *buffer) { - uint64_t l; + uint64_t i, l; if (term_number != 0) return OPAL_PARAMETER; @@ -401,7 +414,17 @@ static int64_t dummy_console_write(int64_t term_number, __be64 *length, return OPAL_PARAMETER; l = be64_to_cpu(*length); - write(0, buffer, l); + + lock(&dummy_con_lock); + + for (i = 0; i < l; i++) + inmem_write(&inmem_con, buffer[i]); +#ifdef MAMBO_DEBUG_CONSOLE + mambo_console_write(buffer, l); +#endif + + /* updating l isn't required since we used all of the buffer */ + unlock(&dummy_con_lock); return OPAL_SUCCESS; } @@ -432,11 +455,16 @@ static int64_t dummy_console_read(int64_t term_number, __be64 *length, if (!opal_addr_valid(length) || !opal_addr_valid(buffer)) return OPAL_PARAMETER; + lock(&dummy_con_lock); + l = be64_to_cpu(*length); - l = read(0, buffer, l); + l = inmem_read(&inmem_con, buffer, l); + *length = cpu_to_be64(l); opal_update_pending_evt(OPAL_EVENT_CONSOLE_INPUT, 0); + unlock(&dummy_con_lock); + return OPAL_SUCCESS; } @@ -449,7 +477,7 @@ static void dummy_console_poll(void *data __unused) { bool has_data = false; - lock(&con_lock); + lock(&dummy_con_lock); if (inmem_con.desc->in_prod != inmem_con.desc->in_cons) has_data = true; if (has_data) @@ -457,7 +485,7 @@ static void dummy_console_poll(void *data __unused) OPAL_EVENT_CONSOLE_INPUT); else opal_update_pending_evt(OPAL_EVENT_CONSOLE_INPUT, 0); - unlock(&con_lock); + unlock(&dummy_con_lock); } void dummy_console_add_nodes(void)