From patchwork Mon Sep 18 10:32:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 112881 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp3501077qgf; Mon, 18 Sep 2017 03:34:46 -0700 (PDT) X-Received: by 10.107.149.143 with SMTP id x137mr20627903iod.266.1505730886213; Mon, 18 Sep 2017 03:34:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505730886; cv=none; d=google.com; s=arc-20160816; b=kCxP4vMG1qMYDCWUoUIQeZSqhUeHKE0DQWr1VByj8C2EI7O11LTjYO3NhNhOgXK7w8 uRyscllFyoiggOzkxcNaFNhERsYAsLPgPt3kWn0D5V4SURGxu6qbbQpsVw7vOpNa1L/s 1JNil94OBAOdnYSwFxQvcgfRIfcPQPWmnoLae6c5PhyS174QXVgV3Oj8xaZ8/nqQABqL Ca62ubZZJQVnV8J3OqBskKj2t8GiR1V2x5UFQD29eDOYAXsGINegsfI8vyoeOyqtCz66 plDLx5pbk0MFopeSY1gFGTODGr/aLDgikU8k2pa4os3RhTxc4ysPXIfvfX3KS6x6sT0o Ok6w== 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=GCwa/gkQ+E7SKoiInGs++cf6PNAtsj+M23Bj3i/wbxA=; b=ANhoXhtb2JOPUhsbrI8Y3TMIBLAY8WcbbiLo1jdfJiZzqZ18pjw9ihD8UoM7k9RvE3 XmGNkfkJjEmpuxY5MISGWvEwX/ZcYDsVvY9NnvLmHmyuxOzDpfDRLRA6cPO47Yp+ac+2 XMyT4P6fINjo6kJ2STY0gvjsGReRRLkpvVm7wUntvdckMfAeqjarL5ap/OOY4rFY+9Cl QrpdYcyDC4qF77Mla/C6dARKc/U9gjWsYhNt8wntpb0mkninaL+z5gxV5dhQILOwR9q4 J4O1P6GnHE4sXAwBDGSbYisD9jIeoHHSTWNPm2M6RxAH8v+b+Hmq9bpqYEN/FqAQE82u t3TA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=VwLnr/C2; 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 v132si2827903iod.87.2017.09.18.03.34.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Sep 2017 03:34:46 -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=VwLnr/C2; 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 1dttMV-0002JR-9d; Mon, 18 Sep 2017 10:33:11 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dttMT-0002GF-UZ for xen-devel@lists.xenproject.org; Mon, 18 Sep 2017 10:33:10 +0000 Received: from [85.158.137.68] by server-7.bemta-3.messagelabs.com id 6B/EC-02224-5E0AFB95; Mon, 18 Sep 2017 10:33:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEIsWRWlGSWpSXmKPExsXiVRusq/tkwf5 Ig/W71S2+b5nM5MDocfjDFZYAxijWzLyk/IoE1owLm3QLJotX7P/Qy9jA+FOoi5GLQ0hgCqPE od1tjCAOi8A8Zol7u44wgzgSAv2sEusXLGLpYuQEctIkuh9OYoOx33S8ZYKwqyRu3pgAViMko CVx9NRsVoixO5gkNjTcBiri4GATMJGY1SEBUiMioCRxb9VkJpAaZoH5jBJNk3rBhgoLxEus+7 2aEcRmEVCVaN6zkh3E5hXwkbh5eTrUMjmJm+c6mUFsTqD4+fUPWCEWe0vM+3WFcQKj4AJGhlW MGsWpRWWpRbqGlnpJRZnpGSW5iZk5uoYGxnq5qcXFiempOYlJxXrJ+bmbGIEhV8/AwLiD8fdx v0OMkhxMSqK8opH7I4X4kvJTKjMSizPii0pzUosPMcpwcChJ8IoDQ1hIsCg1PbUiLTMHGPwwa QkOHiUR3nXzgdK8xQWJucWZ6RCpU4zGHPv23PrDxNFx8+4fJiGWvPy8VClx3ncgpQIgpRmleX CDYFF5iVFWSpiXkYGBQYinILUoN7MEVf4VozgHo5Iw7yOQKTyZeSVw+14BncIEdErLjj0gp5Q kIqSkGhj3/Vu2Tywqw6fnifOS4Lb1Eh8O/cr9VBLFzh728uEeQSbb3jD250I8i+WiWnf4H+Rh Ey678IYlgWd3MldxfZhaQYB13oGIORyM6pweLZK6F1KvLuRYMMVwa2mN77nmnY4fj2z24lp76 libYI6JYpWksKYu49+buvycjTtDKl9PU5Xcn29WqsRSnJFoqMVcVJwIAMZClSDFAgAA X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-11.tower-31.messagelabs.com!1505730787!84414138!1 X-Originating-IP: [74.125.83.45] 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 59635 invoked from network); 18 Sep 2017 10:33:08 -0000 Received: from mail-pg0-f45.google.com (HELO mail-pg0-f45.google.com) (74.125.83.45) by server-11.tower-31.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 18 Sep 2017 10:33:08 -0000 Received: by mail-pg0-f45.google.com with SMTP id 7so22948pgd.13 for ; Mon, 18 Sep 2017 03:33:08 -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=YOnVbf2KQHJUvnXkY+8NWwhSqgBo0gewN4GYDNIiV08=; b=VwLnr/C2tamQzJJsjw7K9zPy3YPr4EvSAblUdS3wzIUQE6bTsjNNYh6ux3HTLQBasl qww8UAK1Yjfpxlw32IY7P/zPJihKgHTevAvTYGt+A+Zalq8W/dUZ3QBNd4Zd3uzEWvgJ zFmDfXu7JIYViAW8LqnwxU+NlFZbTbaP4DSDQ= 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=YOnVbf2KQHJUvnXkY+8NWwhSqgBo0gewN4GYDNIiV08=; b=LmE0Vi+n+g/ZXcgUsK5VdfiXncb/BPtqqVfQiTdviRJjXEyXdHwVqPeMZE+e9PUpsa LjY4kA0OgHuHS1sANUtJ5nzJENsNxXST17sGMsmKnzMDngCdyD9PkSHAc8LiMDMKI0pL 1CjJgZUjXbGyAynJO6ZeJDnNMe/veB9fuC85IGK2HwoXSk2lmjk015pHj0v4Fsvn16mI 2/Z6HOSxmGjA7C/e8UHVj+lD4KV7e+mAubdQmWdc3qKdITRq6Ke3PW6Ao6bBzTDjv+MH svEKhHTyOEs0r9UeFvf3cl9hRZnzXgrxWR3vSRIswu9CkluIzjWF0Q3pI5/t9zQcB/NM B2Cg== X-Gm-Message-State: AHPjjUjw+9fRccnXtII4p4oRbd64K2E0ZLotH5wasHAyPbDefWWmhYcl G6+pEVRLGjUyzbnegAorDg== X-Google-Smtp-Source: ADKCNb56FFnTxyEJdi0O0GPNAKTzJCfeuBd+va4bNgCei5QoCl0YNCmrjhRsuQRckXnYW48qaz8A3Q== X-Received: by 10.98.139.134 with SMTP id e6mr32650902pfl.259.1505730786933; Mon, 18 Sep 2017 03:33:06 -0700 (PDT) Received: from blr-ubuntu-linaro.qualcomm.com (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com. [103.229.18.19]) by smtp.gmail.com with ESMTPSA id b7sm12937845pge.79.2017.09.18.03.33.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 18 Sep 2017 03:33:06 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 18 Sep 2017 16:02:00 +0530 Message-Id: <1505730731-10947-17-git-send-email-bhupinder.thakur@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505730731-10947-1-git-send-email-bhupinder.thakur@linaro.org> References: <1505730731-10947-1-git-send-email-bhupinder.thakur@linaro.org> Cc: Wei Liu , Julien Grall , Stefano Stabellini , Ian Jackson Subject: [Xen-devel] [PATCH 16/27 v9] xen/arm: vpl011: Add a new handle_console_ring 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 handle_console_ring function. This function reads the data from the ring buffer on receiving an event. The initialization of event channel poll fd to -1 is moved inside the handle_console_ring function as they are related. There should be no change in the behavior as there is no functional change. 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 | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 2dcaee6..c361b42 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -934,17 +934,23 @@ static void console_evtchn_unmask(struct console *con, void *data) } } -static void handle_ring_read(struct domain *dom) +static void handle_ring_read(struct console *con) { xenevtchn_port_or_error_t port; - struct console *con = &dom->console; - if (dom->is_dead) + if (con->d->is_dead) return; if ((port = xenevtchn_pending(con->xce_handle)) == -1) return; + if (port != con->local_port) { + dolog(LOG_ERR, + "Event received for invalid port %d, Expected port is %d\n", + port, con->local_port); + return; + } + con->event_count++; buffer_append(con); @@ -953,6 +959,21 @@ static void handle_ring_read(struct domain *dom) (void)xenevtchn_unmask(con->xce_handle, port); } +static void handle_console_ring(struct console *con) +{ + if (con->event_count < RATE_LIMIT_ALLOWANCE) { + if (con->xce_handle != NULL && + con->xce_pollfd_idx != -1 && + !(fds[con->xce_pollfd_idx].revents & + ~(POLLIN|POLLOUT|POLLPRI)) && + (fds[con->xce_pollfd_idx].revents & + POLLIN)) + handle_ring_read(con); + } + + con->xce_pollfd_idx = -1; +} + static void handle_xs(void) { char **vec; @@ -1236,15 +1257,8 @@ void handle_io(void) struct console *con = &d->console; n = d->next; - if (con->event_count < RATE_LIMIT_ALLOWANCE) { - if (con->xce_handle != NULL && - con->xce_pollfd_idx != -1 && - !(fds[con->xce_pollfd_idx].revents & - ~(POLLIN|POLLOUT|POLLPRI)) && - (fds[con->xce_pollfd_idx].revents & - POLLIN)) - handle_ring_read(d); - } + + handle_console_ring(con); if (con->master_fd != -1 && con->master_pollfd_idx != -1) { if (fds[con->master_pollfd_idx].revents & @@ -1261,7 +1275,7 @@ void handle_io(void) } } - con->xce_pollfd_idx = con->master_pollfd_idx = -1; + con->master_pollfd_idx = -1; if (d->last_seen != enum_pass) shutdown_domain(d);