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();