From patchwork Mon Aug 28 08:55:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 111118 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4548144qge; Mon, 28 Aug 2017 01:58:56 -0700 (PDT) X-Received: by 10.107.133.97 with SMTP id h94mr5903561iod.227.1503910736180; Mon, 28 Aug 2017 01:58:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503910736; cv=none; d=google.com; s=arc-20160816; b=Xrs5abGIH51J1V438ivokycS+lqVTeUNpaTaubpMg7SlUF7oSTl5fkdEFEPMyjfoN+ GhjeuSHq/iJ0uUx4MaDTPQ/i0/tAH2/6dGtHKkKvN2WEewv2F7Tu5XpmAKljZD8cVCvn 0iOlA1F0nd2MMTICLx3WjUk5jL12A4Nw0kWVjJaU+37m9We1EWG9SicV0puibVejlK+C jtO2IrsKkyaG3ovR8zcnbeEDEsHo2XzaaY0wYW/xTtSkvh/2TeJn/sPmfRR8BttvpDqL wadPorFBrPooQuOCEEPMyo/0I6x29Fhu9zdRAo7QVwDkwtS06a0Ymn7bpxbgfUCTRCgE lZqw== 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=RBIonTcOwRkHLeFjaA/5ZTqVDWSkdEy4IXZH98gtXnM=; b=OqLnE9HRYWLB6T3CwFN1meRO17B/8EkMTM/AhefVSIFXzKIW7KWOn+oiAcYqV3oCmb kXPqxIxcIUuPmTrrOeqdgmdw9otl4V0rKA4TSo1OtbzCOelbnrMl8yHePEDxfwUSgxJf ny6PNGO3qu/4fc3A7A4uCO+/YdbnYuhmh1LYa4PiFikB/whEJv+M2yXQmk4YYiGgYsNT 1q8jMKj90PBbs6liTSmm0Xvuis5ZvciKySSNoSgmCiIPPnTDpF+LW5wFPzyf2q0Ex848 /u/FkR4DSAAxs/6HVwXMHkWNXLEFnBIPZNW64MpYkXs7F0/5NSmhHI7ersCUdLsI36Pr SX8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EhCTRhrG; 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 9si11783525iob.323.2017.08.28.01.58.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 01:58:56 -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.s=google header.b=EhCTRhrG; 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 1dmFqv-00053J-WF; Mon, 28 Aug 2017 08:57:01 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dmFqv-000529-Ay for xen-devel@lists.xenproject.org; Mon, 28 Aug 2017 08:57:01 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 39/89-01724-CDAD3A95; Mon, 28 Aug 2017 08:57:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprHIsWRWlGSWpSXmKPExsXiVRusp3v71uJ Ig2MfjS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1oy9l+8yF3zjqbj4fD1bA+NDri5GLg4hgZmM Ev0Hm9i7GDk5WATmMUv8PRMEkpAQ6GeV2DhrO2sXIweQkyYx5U48SI2EQIXEg0s7WEBsIQEti aOnZrNCDNrPJLF4/xewejYBE4lZHRIgNSICShL3Vk1mAqlhFpjPKNE0qZcNJCEsECOxf1IvI8 RiVYmjTyeDDeUV8JGY33mVHWKZnMTNc53MIDYnUHzH2rvsEIu9Jbpef2CdwCiwgJFhFaN6cWp RWWqRrpFeUlFmekZJbmJmjq6hgbFebmpxcWJ6ak5iUrFecn7uJkZgWNUzMDDuYDzV7HyIUZKD SUmUd2fF4kghvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErxnbgLlBItS01Mr0jJzgAEOk5bg4FES4 f0AkuYtLkjMLc5Mh0idYtTlmHRg+xcmIZa8/LxUKXHehyBFAiBFGaV5cCNg0XaJUVZKmJeRgY FBiKcgtSg3swRV/hWjOAejkjDvQZApPJl5JXCbXgEdwQR0hKLgQpAjShIRUlINjFtXNa6NWaW wvm5T7/55D34qTVrC5pJR9MT3+aP4UxdeP2VLurtX0s+j3mSH3e1bcd6r9e1C7i09xVD252bk 9yuiK5kcXCNiJ9Z/YYn6b6Wc7rieJUQy1Y6fc2rlpqUWhppzDgexLHm0v67/hbLhJv87ooeD5 xRc9blkE78gwk0tcnryO7FyZSWW4oxEQy3mouJEAB+sDZGxAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-16.tower-31.messagelabs.com!1503910618!104284346!1 X-Originating-IP: [74.125.83.46] 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 3493 invoked from network); 28 Aug 2017 08:56:59 -0000 Received: from mail-pg0-f46.google.com (HELO mail-pg0-f46.google.com) (74.125.83.46) by server-16.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 28 Aug 2017 08:56:59 -0000 Received: by mail-pg0-f46.google.com with SMTP id r133so22212466pgr.3 for ; Mon, 28 Aug 2017 01:56:59 -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=EhCTRhrGhRvxMUPqJxzS0QXqzF/rAMBE8EHf9XuBdXS6Ef1JHPXuo7OkY+qCR5tPkQ NKMjnEBOsP3Jh/qgTjg3w8AewcFDY7aO3fb8/XWD8LtN3p5Q5fySOFvVj4Zyuuu37Sh2 TOQJE6iSHF5o8mmZumKddCsS/XyNunGWn7L2Q= 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=Ms55g+by/mRNaZZ2isQhTvbrrdHXRtagdykxJT7P6aZ96nVYTp2y/EUj2WmKdq3TW1 TLmzvIJwKVYXxDxgO2/6EeiHuDMNTgvVvddJv1gXfK0c89xDRKIaAly/NJaBNprR8LxB Igxv25mwrtQmpCo5v0Hn3ub1+VP/64cUws1KZis1EV8eI8X5KIvRvYTppx7w0ybH8hJF 27/cIJjY/qRQz9nZ2b0sNFxXQwlCPlij/sferGZQCQQAu8xIqJPcSbTClq6MTX1Uq6R9 dSSGKmei9FNPEmm2+TOh5n1Jb2cClj2qFAmleuZsirCeyZl1LwGUVcY7w7MxkeCXLo4n YCQw== X-Gm-Message-State: AHYfb5hw4e6FcW55jGTItWpNn4S9jKB//tKaeH2DGhKmx4KNZU1u7SWn xGBgJezCR7aWLe95dCXXkw== X-Received: by 10.84.141.164 with SMTP id 33mr7401087plv.59.1503910618029; Mon, 28 Aug 2017 01:56:58 -0700 (PDT) Received: from blr-ubuntu-linaro.wlan.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id d88sm21713569pfl.158.2017.08.28.01.56.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 01:56:57 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 28 Aug 2017 14:25:55 +0530 Message-Id: <1503910570-24427-13-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> References: <1503910570-24427-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 12/27 v8] 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 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);