From patchwork Mon Nov 28 19:42:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9450133 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 6063A60235 for ; Mon, 28 Nov 2016 19:44:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4F9A427F9C for ; Mon, 28 Nov 2016 19:44:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4468A27FA1; Mon, 28 Nov 2016 19:44:51 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED 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 6F7F827FAD for ; Mon, 28 Nov 2016 19:44:49 +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 1cBRoz-0000VO-RD; Mon, 28 Nov 2016 19:42:37 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cBRoy-0000Ua-0x for xen-devel@lists.xenproject.org; Mon, 28 Nov 2016 19:42:36 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id A4/B6-30393-BA88C385; Mon, 28 Nov 2016 19:42:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsVybKJsh+6qDps Ig1s/lCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1ozTS/8wFkwUrDi40aCBsYe3i5GLQ0hgKqPE r7v32CCc7UwS7559Zexi5ORgEzCU+PtkExuILSIgJnF69zQmkCJmgSeMEq1988GKhAVsJB42L 2PpYuTgYBFQlXg5ORskzCvgJrGh8QwLiC0hICdx8thkVhCbU8Bd4vv/j2CtQgLtjBK/T9ZA1G RIzOuZwwphe0ksunEJylaTuHpuE/MERr4FjAyrGDWKU4vKUot0jcz0kooy0zNKchMzc3QNDUz 1clOLixPTU3MSk4r1kvNzNzECw6SegYFxB+PtyX6HGCU5mJREeae72UQI8SXlp1RmJBZnxBeV 5qQWH2KU4eBQkuD91g6UEyxKTU+tSMvMAQYsTFqCg0dJhFcQGLRCvMUFibnFmekQqVOMilLiv GdB+gRAEhmleXBtsCi5xCgrJczLyMDAIMRTkFqUm1mCKv+KUZyDUUmYdx7IFJ7MvBK46a+AFj MBLX772hpkcUkiQkqqgTFrSmfFlvd6x0tFp75h+Kl44hTPqwNJ/8r3fd8pJbTjkcLC1nM3Kz+ 8Yotp6/xr7CjLUszutoPZ1qKyILtt8eWuSIHqAzM6J+0VySs7qRgnrJAbY7Wqtv/B1UAtP6d5 V5ivfT0lsc/irv7FpnmVe2W2zPlimK1S1eH6RSmwaPtF8cNZczJbbyuxFGckGmoxFxUnAgDl7 SCljQIAAA== X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-16.tower-206.messagelabs.com!1480362152!56787366!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.5 required=7.0 tests=BODY_RANDOM_LONG X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20226 invoked from network); 28 Nov 2016 19:42:33 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-16.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 28 Nov 2016 19:42:33 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 26A162017D; Mon, 28 Nov 2016 19:42:32 +0000 (UTC) Received: from sstabellini-ThinkPad-X260.hsd1.ca.comcast.net (96-82-76-110-static.hfc.comcastbusiness.net [96.82.76.110]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6E122201BC; Mon, 28 Nov 2016 19:42:30 +0000 (UTC) From: Stefano Stabellini To: stefanha@gmail.com Date: Mon, 28 Nov 2016 11:42:25 -0800 Message-Id: <1480362146-14873-3-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1480362146-14873-1-git-send-email-sstabellini@kernel.org> References: <1480362146-14873-1-git-send-email-sstabellini@kernel.org> X-Virus-Scanned: ClamAV using ClamSMTP Cc: peter.maydell@linaro.org, sstabellini@kernel.org, Jan Beulich , qemu-devel@nongnu.org, stefanha@redhat.com, anthony.perard@citrix.com, xen-devel@lists.xenproject.org Subject: [Xen-devel] [PULL 3/4] xen: slightly simplify bufioreq handling 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 From: Jan Beulich There's no point setting fields always receiving the same value on each iteration, as handle_ioreq() doesn't alter them anyway. Set state and count once ahead of the loop, drop the redundant clearing of data_is_ptr, and avoid the meaningless (because count is 1) setting of df altogether. Also avoid doing an unsigned long calculation of size when the field to be initialized is only 32 bits wide (and the shift value in the range 0...3). Signed-off-by: Jan Beulich Reviewed-by: Paul Durrant Reviewed-by: Stefano Stabellini Signed-off-by: Stefano Stabellini --- xen-hvm.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/xen-hvm.c b/xen-hvm.c index d74e233..124ae10 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -995,6 +995,8 @@ static int handle_buffered_iopage(XenIOState *state) } memset(&req, 0x00, sizeof(req)); + req.state = STATE_IOREQ_READY; + req.count = 1; for (;;) { uint32_t rdptr = buf_page->read_pointer, wrptr; @@ -1009,15 +1011,11 @@ static int handle_buffered_iopage(XenIOState *state) break; } buf_req = &buf_page->buf_ioreq[rdptr % IOREQ_BUFFER_SLOT_NUM]; - req.size = 1UL << buf_req->size; - req.count = 1; + req.size = 1U << buf_req->size; req.addr = buf_req->addr; req.data = buf_req->data; - req.state = STATE_IOREQ_READY; req.dir = buf_req->dir; - req.df = 1; req.type = buf_req->type; - req.data_is_ptr = 0; xen_rmb(); qw = (req.size == 8); if (qw) { @@ -1032,6 +1030,13 @@ static int handle_buffered_iopage(XenIOState *state) handle_ioreq(state, &req); + /* Only req.data may get updated by handle_ioreq(), albeit even that + * should not happen as such data would never make it to the guest. + */ + assert(req.state == STATE_IOREQ_READY); + assert(req.count == 1); + assert(!req.data_is_ptr); + atomic_add(&buf_page->read_pointer, qw + 1); }