From patchwork Mon Jul 25 04:16:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 652161 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.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rySct1lWKz9t0M for ; Mon, 25 Jul 2016 14:16:46 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=AXafNgid; dkim-atps=neutral Received: from ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3rySct0sY6zDqf0 for ; Mon, 25 Jul 2016 14:16:46 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=AXafNgid; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3ryScn5T7QzDqdf for ; Mon, 25 Jul 2016 14:16:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=AXafNgid; dkim-atps=neutral Received: by mail-pf0-x243.google.com with SMTP id i6so11164151pfe.0 for ; Sun, 24 Jul 2016 21:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UqAwA62v8KZiyn4Envzg/d9crFPQpOQtS53luXUWXjI=; b=AXafNgidXCZZHFEUawGVKaRHOKquE1S6mIbTkvP9a3gUffactyRerrB/3zSaryRr8U cRH2tLcvu9ZFmKvJg/Qc2j70g8/1Wm0wPYgQ9caTadYC/Cfi7f3d+5opK68IsgPYkWBg bWKS/hHeJD4DiXj62QkB7e1LC6rf8dVFOOorMgVBUqkBB7W0j4zUpZVmHn7u2W8cwqlq drGVLFg37XP3DZZiY6CX/xOedUHzWvi4OIK5clSz7eSJ1l+Z4pUHmBSORmnHIKzPTk3v ciVzzVyj4S8e6ZecLFsHTFnnvXquxdnmDVkBhKEff74ZD+F33nDeyuWq9Qx8yr/x8EIM 82tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=UqAwA62v8KZiyn4Envzg/d9crFPQpOQtS53luXUWXjI=; b=eVdoDh50gD0pRORsFCWpByBS/kg2l22W8PzgdXFRyRUsQzNFez3jgPtGvWDlRmNUnA M2fudyaM2lzQMyTi1PgMjmcNGGxb4hsrj7d7YenEwb5wXc/V366gEGFgDsZXqxcyVL0T r+qYlXV4PqT3FT2l5s4A1gWq4Sim3aGOKPCykFsb/SmLlQaWva2Yr/7CdcYa9sxuNSyN EY1rw9dBvXe8mqoqZd9Z5tec4Gcmi/14yI/StA+65KwujeaFjxrgLjOZqsVoaN6qsFZP KGp+CDbhQo/pWz6icoXQr7FaVyppGq1lzbybTOFyOM/DMxnCFsCsR36EmXWNX6ObMqAB RUdw== X-Gm-Message-State: AEkoousBQO/dlBnZFM2hPxQSPc0DZpFLdMtkUJwe4KCN1CEdah6y4hgv17js1WDMgkkPVA== X-Received: by 10.98.71.140 with SMTP id p12mr26030696pfi.93.1469420197588; Sun, 24 Jul 2016 21:16:37 -0700 (PDT) Received: from canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id z1sm35832953pab.19.2016.07.24.21.16.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 24 Jul 2016 21:16:36 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Mon, 25 Jul 2016 14:16:25 +1000 Message-Id: <1469420185-24862-1-git-send-email-oohall@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1469416774-16419-1-git-send-email-oohall@gmail.com> References: <1469416774-16419-1-git-send-email-oohall@gmail.com> Subject: [Skiboot] [PATCH v2] core/console: refactor __flush_console() X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Simplifies the flushing logic so that we only call into con_driver->write() once. The existing implementation splits the function into a normal path and a separate path when the in memory console has wrapped. The logic is the same in both branches and __flush_console() has enough bizarre crap happening with it's not-a-lock-but-actually-a-lock flag variable. Signed-off-by: Oliver O'Halloran Spelling-corrected-by: Andrew Donnellan --- core/console.c | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/core/console.c b/core/console.c index 730ac245fd94..73ee922b0a50 100644 --- a/core/console.c +++ b/core/console.c @@ -151,35 +151,36 @@ bool __flush_console(bool flush_to_drivers) } in_flush = true; + /* + * NB: this must appear after the in_flush check since it modifies + * con_out. + */ + if (!flush_to_drivers) { + con_out = con_in; + in_flush = false; + return false; + } + do { more_flush = false; + if (con_out > con_in) { req = INMEM_CON_OUT_LEN - con_out; - if (!flush_to_drivers) { - len = req; - } else { - unlock(&con_lock); - len = con_driver->write(con_buf + con_out, - req); - lock(&con_lock); - } - con_out = (con_out + len) % INMEM_CON_OUT_LEN; - if (len < req) - goto bail; - } - if (con_out < con_in) { - if (!flush_to_drivers) { - len = con_in - con_out; - } else { - unlock(&con_lock); - len = con_driver->write(con_buf + con_out, - con_in - con_out); - lock(&con_lock); - } - con_out = (con_out + len) % INMEM_CON_OUT_LEN; - } + more_flush = true; + } else + req = con_in - con_out; + + unlock(&con_lock); + len = con_driver->write(con_buf + con_out, req); + lock(&con_lock); + + con_out = (con_out + len) % INMEM_CON_OUT_LEN; + + /* write error? */ + if (len < req) + break; } while(more_flush); -bail: + in_flush = false; return con_out != con_in; }