From patchwork Wed Sep 27 06:13:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 9973139 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 934A86037F for ; Wed, 27 Sep 2017 06:17:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8722E2909D for ; Wed, 27 Sep 2017 06:17:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A57F290A3; Wed, 27 Sep 2017 06:17:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1CCAE2909D for ; Wed, 27 Sep 2017 06:17:54 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dx5bb-0002eQ-G8; Wed, 27 Sep 2017 06:13:59 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dx5bZ-0002b2-Jf for xen-devel@lists.xenproject.org; Wed, 27 Sep 2017 06:13:57 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id F0/2A-03454-4A14BC95; Wed, 27 Sep 2017 06:13:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsXiVRtsprvE8XS kwY+9Ihbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bey3eZC77xVFx8vp6tgfEhVxcjJ4eQwAxG iY4DOl2MXBwsAvOYJfZ8OcgO4kgI9LNK3F6xlaWLkQPIyZN4sUkBpEFCIE3i6qYpTBB2mUTDm mcsEIO0JI6ems0K0isksIJJ4trqSUwgvWwCJhKzOiRAakQElCTurZrMBFLDLDCfUaJpUi8bSE JYIFbiXMd1RpB6FgFViYf/UkDCvAI+Et+v7GeH2CUncfNcJzOIzQkUP91/mw1ir7fEpZX9rBM YBRcwMqxi1ChOLSpLLdI1MtdLKspMzyjJTczM0TU0MNPLTS0uTkxPzUlMKtZLzs/dxAgMNwYg 2MG4eG3gIUZJDiYlUd6a/6cihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwznM4HSkkWJSanlqRl pkDDHyYtAQHj5IIbxRImre4IDG3ODMdInWK0ZLjS++NP0wc+/bcApIdN+/+YRJiycvPS5US56 0CaRAAacgozYMbB4vOS4yyUsK8jEAHCvEUpBblZpagyr9iFOdgVBLmXQgyhSczrwRu6yugg5i ADuqdegLkoJJEhJRUA2Oo8Mx1Nyyb1RuZU3nEOIovPm39m3fsVpbgsmuzJix8nXHpC2tDiS6z qSLj8ugXabzz+HXi/LpeGW36aXaP50ChBPPWBJOeBckZjgrqlu5bdnf+vJ/Fd/Okx9+yDW82C vcu96vf+83MJu5Fm+KaV5beQpOKplkltV6d5zZJq0M0U2oFS7l/jhJLcUaioRZzUXEiAB0PBI jJAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-4.tower-27.messagelabs.com!1506492835!117902735!1 X-Originating-IP: [74.125.83.54] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8302 invoked from network); 27 Sep 2017 06:13:56 -0000 Received: from mail-pg0-f54.google.com (HELO mail-pg0-f54.google.com) (74.125.83.54) by server-4.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 27 Sep 2017 06:13:56 -0000 Received: by mail-pg0-f54.google.com with SMTP id i130so7220540pgc.3 for ; Tue, 26 Sep 2017 23:13:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yB+nxIvgk8UjZRr/CwimK1H7zFddzpCzBRq7KGA1phI=; b=OWP8kGBdShsB2FfJjqbETfUTALPZ9rQXNFBN0kbc1zsE/9gQwuY8LzzNAkD5dsnOHP MHfNEbdSWqxt/bXGeT/Twd5D6vhMJ2IdLXbYxbulSkKwr4yOuP8g95bWChxOTkX7xEcM IZRlzLuLf8GRijB6h2b5vgpdjjxITbgjdxUsY= 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; bh=yB+nxIvgk8UjZRr/CwimK1H7zFddzpCzBRq7KGA1phI=; b=QNtZlKZhgX3QujoJhEZiyMeOgzzErpxU05fdP4pwtKTQeqd6I03+QCZhh0faHn5xFg fD+juxBdzUEoA9w0mMzorU+hVjG31fO9i/6/9XSLFGyg4VnXQzqu3/TgoEoXTPSi1mvH X9BG8Vu+zDqpXii56WVMLu5DSNrQ/lTuCiTvWQkTjTKlt4kj2v9+dv5/TgPhfdJGtvOI aWRZEp6RceojeR+uoxPLFrwoApEBLyOWkv8nT4BdC0Kk5Q/l1AT7nUe3+zJylWmW9tPz 841m4SeBNpHDhr6eiCyKRl4JgYm8sGo07p6HBlAcNZJBET72cPh4sb9CL/3TFBaueqAa tspg== X-Gm-Message-State: AHPjjUhS9BLshksn4+5oJJh8mGy1qUAweCK8gWpWsEkV7qVYwzKGjV/6 3VjMOB5xI7ifekj/SO4JsMfZfkZ+Irs= X-Google-Smtp-Source: AOwi7QAV23G+LeEu8Fxh/Hgcr93T9ko3GJ/MpgOEYm4qpRE2gI+K5VIvjf1K8aYB35L2m5kea2pikA== X-Received: by 10.84.254.4 with SMTP id b4mr307280plm.285.1506492834504; Tue, 26 Sep 2017 23:13:54 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (h3.248.139.40.ip.windstream.net. [40.139.248.3]) by smtp.gmail.com with ESMTPSA id s187sm18013485pgb.82.2017.09.26.23.13.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Sep 2017 23:13:54 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Wed, 27 Sep 2017 11:43:21 +0530 Message-Id: <1506492816-25954-13-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> References: <1506492816-25954-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 12/27 v11] xen/arm: vpl011: Add a new buffer_available function in xenconsole X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces a new buffer_available function to check if more data is allowed to be buffered. Signed-off-by: Bhupinder Thakur Reviewed-by: Stefano Stabellini Acked-by: Wei Liu --- CC: Ian Jackson CC: Wei Liu CC: Stefano Stabellini CC: Julien Grall Changes since v5: - Split this change in a separate patch. tools/console/daemon/io.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 1da08d7..0009bbe 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -163,6 +163,16 @@ static int write_with_timestamp(int fd, const char *data, size_t sz, return 0; } +static inline bool buffer_available(struct console *con) +{ + if (discard_overflowed_data || + !con->buffer.max_capacity || + con->buffer.size < con->buffer.max_capacity) + return true; + else + return false; +} + static void buffer_append(struct console *con) { struct buffer *buffer = &con->buffer; @@ -1120,9 +1130,7 @@ void handle_io(void) con->next_period < next_timeout) next_timeout = con->next_period; } else if (con->xce_handle != NULL) { - if (discard_overflowed_data || - !con->buffer.max_capacity || - con->buffer.size < con->buffer.max_capacity) { + if (buffer_available(con)) { int evtchn_fd = xenevtchn_fd(con->xce_handle); con->xce_pollfd_idx = set_fds(evtchn_fd, POLLIN|POLLPRI);