From patchwork Mon Jul 17 13:06:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bhupinder Thakur X-Patchwork-Id: 107935 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4494905qge; Mon, 17 Jul 2017 06:09:19 -0700 (PDT) X-Received: by 10.107.12.97 with SMTP id w94mr18274679ioi.153.1500296959086; Mon, 17 Jul 2017 06:09:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296959; cv=none; d=google.com; s=arc-20160816; b=M36coECuBdfzFc/4J5XDunGOJMx+YTC3WP/s0Y5LVQ3Imxcd2+bV39lOLGyvF0Rvzf 7jlS9R3o7FW2ibXruuTqqmCsaA23UVbWMXAtQ5/4/wzyD2D4D6vYDmJDjj9+dJZFDlmL TiyqdxJo86X7KBeslvgXPqbbiEhJxG4erF2Pp2MqJgQArpH9iueSd2CTn3SCzgzDAdtI gbEQxAe03m7c6Ne3Uqt0mstQGbtllNYVMLoo1U8mxrAt11XKFbodBAyOLQ9B0z0TzUU8 /aH+IwPJHqtFdnX27FTv/4ZlkraDG6LIisjlK2yCsujFFEHCHHyK0iHjvF0aU5D10WDw xGEQ== 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=Hn3ajf98UmHDe/5Dks/kCt42evGuV66meW+O8r5bYQQ=; b=TpNlGlr+gUUJuR3eTlYzPcmPzcBTVeCfoOVYA/BeVZZ9ZMbdakXS1KyTezdlfBkZoZ RIqmBiaKPIbTIs1vOCRwy3lcrzTWilG1AIKjDJlB68xKyQlCByC15EE2mj1ycyP/snZy KkCA3SGSCSuixUL8ya59sk78QEH2rNxSKCaMpHAZXh6cStQ+8O+zDp3YykGJ1TUgIUiX xcmfNSQjNkbzFmXfM8JGWVAj5Yaro0LRCAlzPZfK3T7JMKk7dcUF1dXLGUUfhxVByBy1 KOkBfrccEelNbJhwpxycUNd3d2FHytwLn4SyHqY4t+H/GyzenWYMBOoR5jynaZEkb/uy TS/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.b=ezVHte+W; 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 o130si16755145ioe.98.2017.07.17.06.09.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jul 2017 06:09:19 -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=ezVHte+W; 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 1dX5ke-0004ez-Dt; Mon, 17 Jul 2017 13:07:52 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dX5kc-0004cp-RF for xen-devel@lists.xenproject.org; Mon, 17 Jul 2017 13:07:50 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id 80/D0-02176-6A6BC695; Mon, 17 Jul 2017 13:07:50 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsXiVRusqbt0W06 kwZZzUhbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bfh+tZCs6KVNxZINHA2CDYxcjFISQwnVHi 9OxTzCAOi8A8ZolTnzeBORIC/awSrZPesXUxcgI5aRI3PnWwQthVEnc/XWUGsYUEtCSOnprNC jGqlUni1d3T7F2MHBxsAiYSszokQGpEBJQk7q2azARSwywwn1GiaVIv2FBhgUSJ7Vv/MILYLA KqEseP3gFbwCvgIzH/yS5miGVyEjfPdYLZnEDxMxtWM0Es9pa4eWQi0wRGgQWMDKsY1YtTi8p Si3SN9ZKKMtMzSnITM3N0DQ1M9XJTi4sT01NzEpOK9ZLzczcxAgOLAQh2MO7953SIUZKDSUmU 9yJbdqQQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV73rTmRQoJFqempFWmZOcAQh0lLcPAoifBWg 6R5iwsSc4sz0yFSpxiNOSYd2P6FiePVhP/fmIRY8vLzUqXEefVASgVASjNK8+AGwWLvEqOslD AvI9BpQjwFqUW5mSWo8q8YxTkYlYR5M0Gm8GTmlcDtewV0ChPQKcK+YKeUJCKkpBoYQ47/PHN +AtuSVKuXh+sCivpMWzIvf7s85Qzj4cLzIZ++vLAtYpO/7sAjy2yez95nXHkyZYHNB+63t51X LNRP317y95v+24rTN/Y6Roov6bx/Uf7xTKce4WoRh/Luu+bvprcm+iWeNkx893h5ha4ov/zvN QbsLRuffJCtvDt1Q0flr5leRY7flFiKMxINtZiLihMBd6yz+rgCAAA= X-Env-Sender: bhupinder.thakur@linaro.org X-Msg-Ref: server-12.tower-206.messagelabs.com!1500296868!66950070!1 X-Originating-IP: [74.125.83.41] 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 4367 invoked from network); 17 Jul 2017 13:07:49 -0000 Received: from mail-pg0-f41.google.com (HELO mail-pg0-f41.google.com) (74.125.83.41) by server-12.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 17 Jul 2017 13:07:49 -0000 Received: by mail-pg0-f41.google.com with SMTP id u5so17087770pgq.3 for ; Mon, 17 Jul 2017 06:07:49 -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=B0Rdu55YhR3X+417VyorRwdTJIn2jgYynzblJ6Vef3U=; b=ezVHte+WJHfmzgeCtYTtVB7WEA+NLnnAh1f0PtTzojCoXNuoktGwLSeHuRYWKlgG/k P54yXI2jOrEaqIgVImh8vONX/CEBEOu9jJJry3G/1Y/0UKEg8DPWGK7sWA/M0jcmN6KR n/5rK6X/owBeAs2fTqc7SHSNkf1nNXJbs7vCc= 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=B0Rdu55YhR3X+417VyorRwdTJIn2jgYynzblJ6Vef3U=; b=W/KQtSspmihH2O8xkxV6xOLzljbgwoaJcpB7KVfnWqFvEnbL3kiD5cW39LvhrfJMLn JuY62QWX92o52CAhV9zBTayLnAs3RvzUp3F4HvXLGOuVOW9w1uw3QrQr+2ytFoTALPKY cyR6ndEIzRckzqx8auJZuyjDDe/rkHOagjxLqj+nT55BxzpNCidG0Fv9D43pAYNrVtJs agfoxNZ0QXmvRRBN4YlDXp5w+TsAOZ5kVLUk6cSIZEnibMtwjx4ueYAnakSZS29PJxMC yt+vJtmTFiwRgQBBlHAEEvRpVTwuNeRVT8T+OmzORwpUP8eVY0o5EgnjcOXktsVFyNst lkgQ== X-Gm-Message-State: AIVw111nyUwGdX/uh4Dee+ZFGXifIu9GeA3lxyx/5KXs5//x2fi5vkh9 7FI3NFJyt2t76zHTBotv5A== X-Received: by 10.101.90.197 with SMTP id d5mr28052521pgt.223.1500296867629; Mon, 17 Jul 2017 06:07:47 -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.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Jul 2017 06:07:47 -0700 (PDT) From: Bhupinder Thakur To: xen-devel@lists.xenproject.org Date: Mon, 17 Jul 2017 18:36:45 +0530 Message-Id: <1500296815-10243-16-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 15/25 v6] xen/arm: vpl011: Add a new console_evtchn_unmask 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 console_evtchn_unmask function. This function unmasks the console event channel if it is masked for some timeout period. Signed-off-by: Bhupinder Thakur --- 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 | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c index 6321d78..c272fe6 100644 --- a/tools/console/daemon/io.c +++ b/tools/console/daemon/io.c @@ -117,6 +117,11 @@ struct domain { static struct domain *dom_head; +static inline bool console_enabled(struct console *con) +{ + return con->local_port != -1; +} + static int write_all(int fd, const char* buf, size_t len) { while (len) { @@ -909,6 +914,27 @@ static void handle_tty_write(struct console *con) } } +static void console_evtchn_unmask(struct console *con, void *data) +{ + long long now = (long long)data; + + if (!console_enabled(con)) + return; + + /* CS 16257:955ee4fa1345 introduces a 5ms fuzz + * for select(), it is not clear poll() has + * similar behavior (returning a couple of ms + * sooner than requested) as well. Just leave + * the fuzz here. Remove it with a separate + * patch if necessary */ + if ((now+5) > con->next_period) { + con->next_period = now + RATE_LIMIT_PERIOD; + if (con->event_count >= RATE_LIMIT_ALLOWANCE) + (void)xenevtchn_unmask(con->xce_handle, con->local_port); + con->event_count = 0; + } +} + static void handle_ring_read(struct domain *dom) { xenevtchn_port_or_error_t port; @@ -1144,23 +1170,7 @@ void handle_io(void) for (d = dom_head; d; d = d->next) { struct console *con = &d->console; - /* CS 16257:955ee4fa1345 introduces a 5ms fuzz - * for select(), it is not clear poll() has - * similar behavior (returning a couple of ms - * sooner than requested) as well. Just leave - * the fuzz here. Remove it with a separate - * patch if necessary */ - if ((now+5) > con->next_period) { - con->next_period = now + RATE_LIMIT_PERIOD; - if (con->event_count >= RATE_LIMIT_ALLOWANCE) { - (void)xenevtchn_unmask(con->xce_handle, con->local_port); - } - con->event_count = 0; - } - } - - for (d = dom_head; d; d = d->next) { - struct console *con = &d->console; + console_evtchn_unmask(con, (void *)now); add_console_evtchn_fd(con, (void *)&next_timeout);