From patchwork Mon Aug 7 08:53:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 9884765 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 B01C560364 for ; Mon, 7 Aug 2017 08:56:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3738285D1 for ; Mon, 7 Aug 2017 08:56:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 984EE285E6; Mon, 7 Aug 2017 08:56:16 +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=-2.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, RCVD_IN_SORBS_WEB, 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 433D6285D1 for ; Mon, 7 Aug 2017 08:56:16 +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 1dednb-0004e5-U8; Mon, 07 Aug 2017 08:54:07 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dedna-0004cg-QC for xen-devel@lists.xenproject.org; Mon, 07 Aug 2017 08:54:06 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id D9/FD-27137-EAA28895; Mon, 07 Aug 2017 08:54:06 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXiVRtspLtWqyP S4NI9IYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNWPv5bvMBd94Ki4+X8/WwPiQq4uRi0NIYDqj xOb+BSwgDovAPGaJY+/us4M4EgL9rBIf591i7GLkBHLSJI5duMAEYVdI/L59HywuJKAlcfTUb FaIUW1MEk+/dgF1c3CwCZhIzOqQAKkREVCSuLdqMhNIDbPAfEaJpkm9bCAJYYEYiR8nLrKB1L MIqEq0flUECfMK+EisnHOIGWKXnMTNc51gNidQ/PylNywQe70lbh/rY5zAKLCAkWEVo3pxalF ZapGuqV5SUWZ6RkluYmaOrqGBmV5uanFxYnpqTmJSsV5yfu4mRmBgMQDBDsbpl/0PMUpyMCmJ 8savaIsU4kvKT6nMSCzOiC8qzUktPsQow8GhJMH7WbMjUkiwKDU9tSItMwcY4jBpCQ4eJRHeF +pAad7igsTc4sx0iNQpRmOOSQe2f2HieDXh/zcmIZa8/LxUKXHecyCTBEBKM0rz4AbBYu8So6 yUMC8j0GlCPAWpRbmZJajyrxjFORiVhHnPg0zhycwrgdv3CugUJqBT3iS2gpxSkoiQkmpg3KF VUPmylaH/dptTz/bcJUuc5p9b+y3fuMboVOEFJn7d9/tFJm6ubfd8VneQaVtK2vvCecnhB+el bZi9cR3HBoYQRu5TmlfLmCclzuFZPN/dReaMDovl0WwpH2+JfDtxlmPn59Rvz12VNdtl872mo /Yz3a+1nuU+u/SNs6sTg9iC7dO+pOf5KLEUZyQaajEXFScCAFSd93K4AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-15.tower-27.messagelabs.com!1502096044!57774556!1 X-Originating-IP: [74.125.83.50] 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 23824 invoked from network); 7 Aug 2017 08:54:05 -0000 Received: from mail-pg0-f50.google.com (HELO mail-pg0-f50.google.com) (74.125.83.50) by server-15.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 7 Aug 2017 08:54:05 -0000 Received: by mail-pg0-f50.google.com with SMTP id u5so31663226pgn.0 for ; Mon, 07 Aug 2017 01:54:05 -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=gGhW/U6EeLvZ0ym58RYyB1lPeSbhPo28noGy0QUsKiQJs80Wrzw+haKrNNTbNdjJhE nNA0zKc+Iu3OcqiSFC/rz6E7kq+9f1kR3xjrJBMZX+YRMVLwaSfu0NvqFpcPfZ96jf1q siZp70Tcuj4/k+i37LSBCiivWbsxKuCp9anQc= 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=J90mvSxjzd/CgXy3biPY+ZOkGT35cfHVXeREb9MeRkEyhbAUhPZXn6ATsMBERCmWX2 ato9420LJ9Z2Lqqu4JSCCzYa7OBogl+j1uq5We/vOvlrvauYsYiMJaCVnwwwV/kmoa29 9Ak4Q42Na+AuS97H6jfVo/iu+0kEI3Ljpb6J4WGqT0AWtpI/z8GMLW1D/ktta6Qi4uhF JWQ91XYbs7qiYYjpPkZGQ6c+mJ+Ee6jeKK7BI0Dpw8GYRYgiQsDqHa17udN1Po3DAtLV C9lWwBCmbwyG9X+jurWMrF3/S4cWHq9/zCHtTLm7DbV9cbSXkuNOTg2RsspI1g9fXDk9 2mGw== X-Gm-Message-State: AIVw112QZ7RUVaLlZp7cNvZSQJYG2rqm4M3kXPGYd5Tgh1f0fyUqEGcG D9e8ufNGaxpzgtoOFL1Qvw== X-Received: by 10.84.241.70 with SMTP id u6mr12969748plm.96.1502096043621; Mon, 07 Aug 2017 01:54:03 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id p77sm12604047pfi.153.2017.08.07.01.54.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Aug 2017 01:54:03 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 7 Aug 2017 14:23:04 +0530 Message-Id: <1502095997-31219-13-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> References: <1502095997-31219-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 12/25 v7] 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);