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: 9844915 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 6E7D56037F for ; Mon, 17 Jul 2017 13:09:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60ED826E4A for ; Mon, 17 Jul 2017 13:09:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 55AA42850E; Mon, 17 Jul 2017 13:09:38 +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 E943226E4A for ; Mon, 17 Jul 2017 13:09:36 +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 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" X-Virus-Scanned: ClamAV using ClamSMTP 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);