From patchwork Wed Jun 12 05:42:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenbaodong X-Patchwork-Id: 10988469 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42EC01398 for ; Wed, 12 Jun 2019 05:45:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 208CB26E3A for ; Wed, 12 Jun 2019 05:45:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EECA628927; Wed, 12 Jun 2019 05:45:25 +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=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2D31026E3A for ; Wed, 12 Jun 2019 05:45:25 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haw2N-0001Xw-Am; Wed, 12 Jun 2019 05:43:07 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1haw2M-0001Xr-KV for xen-devel@lists.xenproject.org; Wed, 12 Jun 2019 05:43:06 +0000 X-Inumbo-ID: ecab2262-8cd4-11e9-b3c1-aba32656215d Received: from mxnavi-mail.mxnavi.com (unknown [116.90.87.199]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ecab2262-8cd4-11e9-b3c1-aba32656215d; Wed, 12 Jun 2019 05:42:56 +0000 (UTC) Received: from localhost.localdomain (61.161.186.150) by mxnavi-mail.mxnavi.com (116.90.87.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Wed, 12 Jun 2019 13:39:44 +0800 From: Baodong Chen To: Date: Wed, 12 Jun 2019 13:42:34 +0800 Message-ID: <1560318154-19095-1-git-send-email-chenbaodong@mxnavi.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [61.161.186.150] X-ClientProxiedBy: mxnavi-mail.mxnavi.com (116.90.87.199) To mxnavi-mail.mxnavi.com (116.90.87.199) Subject: [Xen-devel] [PATCH] xen/arm: io: add function swap_mmio_handler() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Baodong Chen , Julien Grall , Stefano Stabellini Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Swap function can be used when calling sort(). or else, the default swap function generic_swap() is used, which is a little inefficient. Signed-off-by: Baodong Chen --- xen/arch/arm/io.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/io.c b/xen/arch/arm/io.c index ae7ef96..5ce7dc4 100644 --- a/xen/arch/arm/io.c +++ b/xen/arch/arm/io.c @@ -92,6 +92,17 @@ static int cmp_mmio_handler(const void *key, const void *elem) return 0; } +static void swap_mmio_handler(void *a, void *b, int size) +{ + struct mmio_handler *handler0 = a; + struct mmio_handler *handler1 = b; + struct mmio_handler tmp; + + tmp = *handler0; + *handler0 = *handler1; + *handler1 = tmp; +} + static const struct mmio_handler *find_mmio_handler(struct domain *d, paddr_t gpa) { @@ -174,7 +185,7 @@ void register_mmio_handler(struct domain *d, /* Sort mmio handlers in ascending order based on base address */ sort(vmmio->handlers, vmmio->num_entries, sizeof(struct mmio_handler), - cmp_mmio_handler, NULL); + cmp_mmio_handler, swap_mmio_handler); write_unlock(&vmmio->lock); }