From patchwork Mon Jul 17 13:06:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107953 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4495405qge; Mon, 17 Jul 2017 06:09:38 -0700 (PDT) X-Received: by 10.107.199.70 with SMTP id x67mr4893272iof.113.1500296978755; Mon, 17 Jul 2017 06:09:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296978; cv=none; d=google.com; s=arc-20160816; b=DuoHuD+2RPKa3XqHZZLk5LyqX48tTOIqBvP5Jl4ywxHv0E94vRhRrbVA70dDtsZMYf MOpGjImxoiQh3JyRZ+pcdBFcRxiGLOMu29GA3l+xqXKcYsCnitovH+KHSddEjuRB2KsD jeV/6ok8ddwS9H7mZtX5n0E6bf6QyUKjxQlRjL7hERFyinBGEOkaNiwN50j1PfEM3MrG z0ZRfvvT7mm67OWUT+5mYs6zp9wtCVGyBP6Fb5+1UBn2ut85/COFIhVqRY74nJr5GOal DVirHV59O9i4k2FazaCfN6dNTDzyVZbpI0EpljFWnT3f+1ys6o+JM6ovE85d3lUVS90a aflw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:dkim-signature:arc-authentication-results; bh=76uW/On4uo+MGDexRuA/NlYGr03xCtPcEII7BLo8F7o=; b=yRBMzTGpx0gJ5qCVyl8Ef/xDXR7/IE1iJwb3t8eFAhIFjtCshdpe7eVqLFRjkfQNJp wREJZ1Q+Q+ZEepb6vVGGQS9iM2sOVBs5jKKS6aWrZENoIyoHGsSgytJ74Gm1rc5cTy/1 6zZwfCi1LewtvfA3IrxSsoSwBWxQZtzIkNws2XV/9/0H1rosdsaX8opcvUSI/8z/s4LO HfojFyi1QrndCoww5elG6DioCQ+QyvuyytCJ+hEgicUkTjbe7fs0GYCHh/iixhralLeK 1LxexmT89syaRyHcw0tO5gfS2bc+BaIBK9NtQc6HFYHuGyAl57w8YUBVOAw8B0rCj+uS Ud3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=f7VUbHxR; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 71si17264762iok.161.2017.07.17.06.09.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:38 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=f7VUbHxR; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kU-0004TF-I2; Mon, 17 Jul 2017 13:07:42 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kT-0004Rq-Jc for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:41 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 55/2B-01862-C96BC695; Mon, 17 Jul 2017 13:07:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRWlGSWpSXmKPExsVyMfTAZt0523I iDfb+E7P4vmUykwOjx+EPV1gCGKNYM/OS8isSWDOen1zBVDCVp2LdjsAGxg6uLkYuDiGBmYwS 1x6vZO9i5ORgEZjHLNHQxgqSkBDoZ5U43rGGCSQhIZAmcejGSUYIu1ri74keZhBbSEBL4uip2 awQk1qZJJ7+PgCU4OBgEzCRmNUhAVIjIqAkcW/VZCaQGmaB+YwSTZN62UASwgIxErtuHmKD2K wqcXvZFXaQXl4BH4nrJ8sgdslJ3DzXCbaLEyh8ZsNqJoi93hI3j0xkmsAosICRYRWjenFqUVl qka6RXlJRZnpGSW5iZo6uoYGxXm5qcXFiempOYlKxXnJ+7iZGYFDVMzAw7mA81ex8iFGSg0lJ lPciW3akEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQle9605kUKCRanpqRVpmTnA8IZJS3DwKInwV oOkeYsLEnOLM9MhUqcYLTmuXFn3hYljyoHtQPLVhP/fmIRY8vLzUqXEefVAGgRAGjJK8+DGwW LwEqOslDAvIwMDgxBPQWpRbmYJqvwrRnEORiVh3kyQKTyZeSVwW18BHcQEdJCwL9hBJYkIKak GxtpbnvGKV11LGQznrzOYEqHr0+22ZfsP96ef7iZxrLgy260n3fnB9E8feIUF3hx9lPHHo/1K iHrRPbev/ZVKWgsTF0TaXKqMElgQsc33QU16zXOtiYZ5KXOaH51c7Ll01/ETzy6Y+ZhmSvzie vLo2TqD8BfRAg37Zd8X7nl36kzzftu5YeKd2kosxRmJhlrMRcWJALamZhC8AgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-5.tower-31.messagelabs.com!1500296859!102568778!1 X-Originating-IP: [209.85.192.179] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64310 invoked from network); 17 Jul 2017 13:07:40 -0000 Received: from mail-pf0-f179.google.com (HELO mail-pf0-f179.google.com) (209.85.192.179) by server-5.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:40 -0000 Received: by mail-pf0-f179.google.com with SMTP id q86so76270839pfl.3 for ; Mon, 17 Jul 2017 06:07:40 -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=Bp2KeyISDm8F00CWkRPVKLBIMQo3xxEHTOTb71G7vEM=; b=f7VUbHxR92oJdVnc752dK0QkPl9Ao69ObW9zmYjygVw9eGqHff1PxCJA6KXuIBgIfQ g94InrOJTQSVq9m9rZ0dg7Ic7hVvjfOEkNkXHEVqlTJDf7S9Srv9ZlGMrAcCFwyulofA XUXBiAqbkayTGifJ4s6lDHjQC/az+txhGIdkU= 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=Bp2KeyISDm8F00CWkRPVKLBIMQo3xxEHTOTb71G7vEM=; b=WCOp8CjWZMKiFV2HPbwg+GqeH1sNmACwK1bgrGBNvhCM4GiENDRHOq/1Y8kVVotXXv 1Dce1webopu1azWeoGGP9TzaCvYffYHTe1uUrBMXgXNMiYSUq+nB0gH2XzTbF+dLzh9a oeM7i76mgiATY29K8pE7WG+3OtKu1no8BuSQgm1l9sqPs5lyvPITDv84K1BVizeBSsxb IxHLEQgLMD2ZHL3OhXYWXRcN/jIaZwQk562bGajtQGzdk7FG81z19SHln4Ai/fE9qpPq TlWJwnDLwc7cMhf+KM1l+QVv8xPH2Vd+D0z+16UONdqtBr1wA5q8lTk1L7BqTPTwIZ+t Y9+w== X-Gm-Message-State: AIVw113I1fRpd6b+Ft15lg5em3KaPRMB2pxCh/hrH+xHSjPWxRqxMIBV PFoGbGuRONPYJj2V4RERww== X-Received: by 10.99.42.141 with SMTP id q135mr28597285pgq.175.1500296858703; Mon, 17 Jul 2017 06:07:38 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com ([103.5.19.18]) by smtp.gmail.com with ESMTPSA id z69sm15705665pgz.42.2017.07.17.06.07.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:38 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:42 +0530 Message-Id: <1500296815-10243-13-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> References: <1500296815-10243-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 12/25 v6] 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" This patch introduces a new buffer_available function to check if more data is allowed to be buffered. Signed-off-by: Bhupinder Thakur Acked-by: Wei Liu Reviewed-by: Stefano Stabellini --- 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 9e92097..e4882e2 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; @@ -1121,9 +1131,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);