From patchwork Tue Jun 6 18:19:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 9769557 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 8689460364 for ; Tue, 6 Jun 2017 18:26:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 82CD222B1F for ; Tue, 6 Jun 2017 18:26:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7747427C05; Tue, 6 Jun 2017 18:26:32 +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=-6.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E772C22B1F for ; Tue, 6 Jun 2017 18:26:31 +0000 (UTC) Received: from localhost ([::1]:39649 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJBW-0002R2-Te for patchwork-qemu-devel@patchwork.kernel.org; Tue, 06 Jun 2017 14:26:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dIJ5R-0005tl-D3 for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:20:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dIJ5N-0007Lq-2e for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:20:13 -0400 Received: from mail-eopbgr30096.outbound.protection.outlook.com ([40.107.3.96]:6976 helo=EUR03-AM5-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dIJ5M-0007IW-Rh for qemu-devel@nongnu.org; Tue, 06 Jun 2017 14:20:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=MCxQFT1IjsGYOnMfxPbc230xQvD8+fKKU3XnW2B2u2Q=; b=ZbTB7XsQ+aFIwHyI4zdRJHs+O9P/yvA4hbK7aVxf7dkzORL9fXfM/9RQLV2YHS5tDVV3+R0SeRGjpejs01ha1oD3a1zsq0HUiWDuczJIinjxj0rzEGqp4+tP++eDv28bJInH6XeMgNovZbrboHgr2DuAny2mjrjiVMBPIQXVpdI= Authentication-Results: nongnu.org; dkim=none (message not signed) header.d=none; nongnu.org; dmarc=none action=none header.from=virtuozzo.com; Received: from rkaganb.sw.ru (195.214.232.6) by VI1PR08MB0847.eurprd08.prod.outlook.com (2a01:111:e400:5a05::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1143.10; Tue, 6 Jun 2017 18:20:06 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Tue, 6 Jun 2017 21:19:37 +0300 Message-Id: <20170606181948.16238-13-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170606181948.16238-1-rkagan@virtuozzo.com> References: <20170606181948.16238-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: DB6PR1001CA0042.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:55::28) To VI1PR08MB0847.eurprd08.prod.outlook.com (2a01:111:e400:5a05::17) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR08MB0847: X-MS-Office365-Filtering-Correlation-Id: 133fecb7-4866-4e25-9051-08d4ad08a8fa X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131423075)(201703031133081); SRVR:VI1PR08MB0847; X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0847; 3:w6A2Ecu1rUbJ68pJ1RKSPCvA4R7XVCYYqnefJ/YNUsCozKclxRFkel3nbQVOKI+pN/I+Qhw6lgzElkfZDR/eEyQzc2mUzlyFh2JItsnW+VASNBFwkOY3vV26/yiCTACAECxPzVjzDDF9z9sjVhyi9ifL+CJiVP6KjpU1Z5+qlBQK1fbldOf3mNBuTigm1/rfqDX5ouOHSvbibDxOqBR6bU5SKFo2CXCQVyBMFE+m/t2mqaDAv6de47qY/k0H/Xac2a738SEJsjqXAnuHxw8Rs9FMXJ/31tEnV6X3eyARrJOKXL1eW6lnnbrwpPrsn7vQEY/liu0FCl5PCzrgQ9/ovA==; 25:2hhSMaX6wJQUCBZ3PPN46IRXEETrJ9Yjzcc8ZFHjFgPj6IbRUuQvzbh7wSG47K3KWq/9eRA9lIAt/9t7DGVraejo3zLTfPP2wOcYRIGoD6JHWYn1Gi+F9IxGMnr5/LEUiuVSlBxe/WPNcU9D/pGxHbBCfeqOFAoIGrQHRK0/fFVyfc7Q9fTK511KtgUBc7lh4pj0A/iTAZUxfabeFNggST8mr9l/7MDswQ6XdIKemnoFyA2/HBOOSlTo3mdEEytjpncwZ5QsdvnGzZ2hWDtjknRT78m9+NnNwkzRu6yNRQbBz3aNlhk816ZhC+4QCGaNS4aZGRs3yLLDpNXa5hGCqwXOolZKCBUydefFRNMnngoWw2ldVjU/UD7LoMo6LmjdenQL6nAmbzmwrribc3fFkhyHHYld7b8zoWXlIjz3j256UOSnM8OT2zB1+/MERI15mF1lry5vr7K44BMtjbf4goyggipq2Qi7uNC5Ggvd4Wo= X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0847; 31:5HWhiXNmRnmwheS/lTQb+yD9oQAHabAV4+jWz2qLK0RgIhcj4LsVxjLwoxDqRQPd8cVRpZZiey3QFes6tgnDQlAdu1o4GX4g+zHTUnnJmTH93W+bQO9UmlZRUjmyPleEPEjY5hvbZP80VOCSGYbekiDgtPYCcLXtjVtOdO1yjkPjSHspuJoD2hbHfc2WZbLbrUotS2luFpdtAAtdfd051XVIkhZ2XeyI0yWyKv/yowY=; 20:iliK1TLzo1VycVU/SgdXavwb1nwWJ0TSSL+BMJbeznWGiPr0LSCiCr4cZ+2YTWZAI0ggFetUY6Aq+8Q7M4j3zB8oGLDFeZW8YOzwdYnJwGegQnfVVSZv5hD8aVKC/yPa4mddh9+MJ0UUyDvTrvSDUrUW3Gz/2ozj7lIL87XNMaljRUIHuX+iOv1spd7BdqTx9XOIay9xHFMACB8KXT9LkNjSj+B1+DTYU8TkxDDX42YlA10oCQSuUvSt4vERuVBpwQXVCntQ68ms53qgwPmbr6MoguNxLKcRbOoB/TiOeEKffvhfhKY6+nEySu+p+mNNd2+UmwFMfZwOBKp5tSCgigdEzLyvVwi+dntigpFlXK39X94N+c8rb+d5N8BZR1p5+Edjc8zBnLqBqzzfjuT4jue5ngfk9QAcccsaSH7L27U= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(60795455431006); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(100000703101)(100105400095)(6041248)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123555025)(20161123562025)(6072148)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR08MB0847; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR08MB0847; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB0847; 4:/m/KgXuAk3ziO1XXJKJKg4smccvcaDyVh0JpRnJsR/?= =?us-ascii?Q?jmgs+VazhHVRbwM+skR0GbloW7MOau6txeto/KHw25T09I3tIREIref8UOl4?= =?us-ascii?Q?5QFgehQ7eQQGVegDuTu2cHGdAlHWAhSiTq8f6YFRZmtw1mZH2vZc6uFmW7QZ?= =?us-ascii?Q?REKwZbdKE3ku+gdWEQVuioXdzafEmy3rw3lO/1ItpeooDW5GTSkBwsP30QM3?= =?us-ascii?Q?SC11O2D+nH+G+x0SPsk50yjMpNlbbbhkjmwNsth3aBA04Wxq/TMALHtY6dXL?= =?us-ascii?Q?CbKrwSkf0PcavEfv5yps9XqFJFmZc0MML6dRXHk177RvjTl+yL5omO0SwzZH?= =?us-ascii?Q?pUQx8g9YQMF7ced+lEM81EehPp2zuMgDh3AWE6qM7zRscjdXIFvK1BPwiWq2?= =?us-ascii?Q?F0z63fmHhM1peU8+jro1BQy0DHPdgOHTPxxEnkIWQG8z45M9YXINCgTLaG7C?= =?us-ascii?Q?aW6zY450sSs7Vp5jS1f+t/lOZEIIaEFM0ZDMEEoRXfhJ/BDyuL/1QQlVH4EW?= =?us-ascii?Q?5a9V9T8ZpAcJ3rxhmiRnybyysPjLfMEth2cptkOsHSkjo5x2pp1TFLGOKlMz?= =?us-ascii?Q?0rHClTTtdlvhvsZ6ttQ24aTaNTmQ7cAlZUdJqcE2MSWxvSQVj531dtryg5vJ?= =?us-ascii?Q?cq3uZ9JN5aeLi0yHycN0MXQeNcMLsISOw9FXF8gsVVxerOvVYgFOsa4GBCrW?= =?us-ascii?Q?M7SqRoRyC/M7r5AkGSKPIImLQHj45WDgx/PXIfz6ZYbEZviPWejIAuEZavWE?= =?us-ascii?Q?+C5AQJraCXHd8/kXfLvIBjCnl5d3M/ShIOZS6NbnEfdqyit5ooccg6z/OW/z?= =?us-ascii?Q?PpEz4WbyghaltUfnzIJNoDy5YAaGlcm3ISE9z9Tl4ZTfBY9eZA3wbe8WITrL?= =?us-ascii?Q?jqVzM1NWF613oGelNmKPXrONkaHiBCFWiny0hoWLVcFLXuHpTBYQQe09XE5G?= =?us-ascii?Q?rh5ppFKm7S/t0ETEVfrC5fFeyWceC9Uswk189wvEPIDtUN/+9P20s2XxcmnT?= =?us-ascii?Q?PeDlsYGMLwDY6jjzB4RLT2Z36zZ6fu4RH7OhGsUu2A4/yfarX24uU7UKFpU7?= =?us-ascii?Q?Z/NS7e/Ntbr3T/3F1OgoHAMWE0A+Gn0XAEjupgjYaOIwlR0xyhvSA884n9cP?= =?us-ascii?Q?0nTHfAulR3afcalKHmPJhdZswY7ZI8YvNPc0lD/VFzW1gkB5oQHVlp+b6/zs?= =?us-ascii?Q?FSbXOxS9Njsr4=3D?= X-Forefront-PRVS: 033054F29A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6029001)(6009001)(39410400002)(39400400002)(39840400002)(39450400003)(48376002)(33646002)(36756003)(47776003)(6486002)(478600001)(66066001)(5003940100001)(2361001)(2906002)(5660300001)(2351001)(50226002)(81166006)(8676002)(25786009)(1076002)(6512007)(6916009)(53416004)(76176999)(42186005)(189998001)(38730400002)(53936002)(4326008)(50986999)(107886003)(7736002)(110136004)(6666003)(6116002)(3846002)(54906002)(2950100002)(86362001)(6506006)(305945005); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB0847; H:rkaganb.sw.ru; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; VI1PR08MB0847; 23:lDPj6yB1Q3p3Dft521kOSXBs8KqRr66TCshT6BJNI?= =?us-ascii?Q?+g04qgrylyD2UuZeDx0v9EDanpg6B3ldoeFaMTXAngn1wdl3vF1fq3AlDgjh?= =?us-ascii?Q?chIioZokVQwk1OrfaKXvAUsiKg+4s352plS7I0p1xEzAQKAT6Xir4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VE4I2Roab+sybqnoVqXGhnBOWrY2xkAX6GQdNt46DNu7KKoc+VW/DfDG4fGaIKCp946I74znDT4yIs7NeP6/gHpQd7z8ftXkQHzNQllx4MmCtV5KI5DSMbVo3GuQ+0r18JkzWDd1F7MZaPp+AEP2FEzvOWI3wZ5pSgzfJcgs; 24:YQcR/0MN5WnUurek6xV/CqS/6MOFeOSyeTzzZIYZ4HcJOWaT+g2wsI6kV32n0H7mObBIHfihZX2TwaMZ0R5eb03VzDTpXIgVcqeaZ/sP5UQ= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; VI1PR08MB0847; 7:xvDXkgrsZaTKa4ukj3PPAYOXIFlSKsByuwUapRlp+AIYesA4t5311CgYkmTPzzqq8DMMteEAa5Sdp5oJqLFkgT5lNJfOlXHMx/P02W6zfQWDpn3gUZfRNaqPeRiLlupnQuPLiahUyRz4UNWoFqG+c3pn1yIwdrMxvkkSw9MhN4N+ldQ+gdGMHLTgOs0+wbCcylWumaNWz0o+Y/e2P+O5p8KFZGmztbknv/Uhqxazt1ErcoBgnFru2oSDj6OJsO8wCGi3Ikr5Z6/WXPkA+7kQsmAAR3Uq7VI/y0ivU8IBY94HpmPT1dyH922HRTFvpbDOmuS2nZNrjxzhEqj9du9dYg==; 20:HIdM8vwMF8D1k55xYGFosqgw4PKFsIqXg2ED5CM4xod5Ke/s9f5kSiaeiSieYNz8StH+PptQR3YUFHpVA1/hDHimQjjxR5ZciYBTNtrAX34FBH9NH4XNOSqd9Nh8GNm9XuJjsvsAwB1Pm6x32QFhwJX2BvwXqzhU4l98ViMAGSw= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jun 2017 18:20:06.5075 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB0847 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.3.96 Subject: [Qemu-devel] [PATCH 12/23] hyperv: make HvSintRoute reference-counted X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Evgeny Yakovlev , Eduardo Habkost , "Denis V . Lunev" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Multiple entities (e.g. VMBus devices) can use the same SINT route. To make their lives easier in maintaining SINT route ownership, make it reference-counted. Adjust the respective API names accordingly. Signed-off-by: Roman Kagan --- target/i386/hyperv.h | 10 +++++----- hw/misc/hyperv_testdev.c | 4 ++-- target/i386/hyperv.c | 25 +++++++++++++++++++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/target/i386/hyperv.h b/target/i386/hyperv.h index bc071da..ca5a32d 100644 --- a/target/i386/hyperv.h +++ b/target/i386/hyperv.h @@ -23,11 +23,11 @@ typedef void (*HvSintAckClb)(void *data); int kvm_hv_handle_exit(X86CPU *cpu, struct kvm_hyperv_exit *exit); -HvSintRoute *kvm_hv_sint_route_create(X86CPU *cpu, uint32_t sint, - HvSintAckClb sint_ack_clb, - void *sint_ack_clb_data); - -void kvm_hv_sint_route_destroy(HvSintRoute *sint_route); +HvSintRoute *hyperv_sint_route_new(X86CPU *cpu, uint32_t sint, + HvSintAckClb sint_ack_clb, + void *sint_ack_clb_data); +void hyperv_sint_route_ref(HvSintRoute *sint_route); +void hyperv_sint_route_unref(HvSintRoute *sint_route); int kvm_hv_sint_route_set_sint(HvSintRoute *sint_route); diff --git a/hw/misc/hyperv_testdev.c b/hw/misc/hyperv_testdev.c index 1b12295..929bf4f 100644 --- a/hw/misc/hyperv_testdev.c +++ b/hw/misc/hyperv_testdev.c @@ -55,7 +55,7 @@ static void sint_route_create(HypervTestDev *dev, X86CPU *cpu, uint8_t sint) sint_route->cpu = cpu; sint_route->sint = sint; - sint_route->sint_route = kvm_hv_sint_route_create(cpu, sint, NULL, NULL); + sint_route->sint_route = hyperv_sint_route_new(cpu, sint, NULL, NULL); assert(sint_route->sint_route); QLIST_INSERT_HEAD(&dev->sint_routes, sint_route, le); @@ -81,7 +81,7 @@ static void sint_route_destroy(HypervTestDev *dev, X86CPU *cpu, uint8_t sint) sint_route = sint_route_find(dev, cpu, sint); QLIST_REMOVE(sint_route, le); - kvm_hv_sint_route_destroy(sint_route->sint_route); + hyperv_sint_route_unref(sint_route->sint_route); g_free(sint_route); } diff --git a/target/i386/hyperv.c b/target/i386/hyperv.c index a150401..ae67f82 100644 --- a/target/i386/hyperv.c +++ b/target/i386/hyperv.c @@ -24,6 +24,7 @@ struct HvSintRoute { EventNotifier sint_ack_notifier; HvSintAckClb sint_ack_clb; void *sint_ack_clb_data; + unsigned refcount; }; uint32_t hyperv_vp_index(X86CPU *cpu) @@ -90,9 +91,9 @@ static void kvm_hv_sint_ack_handler(EventNotifier *notifier) sint_route->sint_ack_clb(sint_route->sint_ack_clb_data); } -HvSintRoute *kvm_hv_sint_route_create(X86CPU *cpu, uint32_t sint, - HvSintAckClb sint_ack_clb, - void *sint_ack_clb_data) +HvSintRoute *hyperv_sint_route_new(X86CPU *cpu, uint32_t sint, + HvSintAckClb sint_ack_clb, + void *sint_ack_clb_data) { HvSintRoute *sint_route; EventNotifier *ack_notifier; @@ -130,6 +131,7 @@ HvSintRoute *kvm_hv_sint_route_create(X86CPU *cpu, uint32_t sint, sint_route->sint_ack_clb_data = sint_ack_clb_data; sint_route->cpu = cpu; sint_route->sint = sint; + sint_route->refcount = 1; return sint_route; @@ -148,8 +150,23 @@ err: return NULL; } -void kvm_hv_sint_route_destroy(HvSintRoute *sint_route) +void hyperv_sint_route_ref(HvSintRoute *sint_route) { + sint_route->refcount++; +} + +void hyperv_sint_route_unref(HvSintRoute *sint_route) +{ + if (!sint_route) { + return; + } + + assert(sint_route->refcount > 0); + + if (--sint_route->refcount) { + return; + } + kvm_irqchip_remove_irqfd_notifier_gsi(kvm_state, &sint_route->sint_set_notifier, sint_route->gsi);