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;