From patchwork Mon Jul 2 16:58:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10502113 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 E074760284 for ; Mon, 2 Jul 2018 17:06:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C799A28531 for ; Mon, 2 Jul 2018 17:06:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8D4828D75; Mon, 2 Jul 2018 17:06:15 +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=-7.8 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED, MAILING_LIST_MULTI, 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 3118128531 for ; Mon, 2 Jul 2018 17:06:15 +0000 (UTC) Received: from localhost ([::1]:34363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2HG-0004oz-DA for patchwork-qemu-devel@patchwork.kernel.org; Mon, 02 Jul 2018 13:06:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fa2AQ-0007xP-NI for qemu-devel@nongnu.org; Mon, 02 Jul 2018 12:59:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fa2AO-00049W-Rr for qemu-devel@nongnu.org; Mon, 02 Jul 2018 12:59:10 -0400 Received: from mail-db5eur01on070c.outbound.protection.outlook.com ([2a01:111:f400:fe02::70c]:55516 helo=EUR01-DB5-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 1fa2AO-00048w-I7 for qemu-devel@nongnu.org; Mon, 02 Jul 2018 12:59:08 -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:X-MS-Exchange-SenderADCheck; bh=OM3JJuZ1TxousfhSzslfB8Tz3pjfxyoj1jGiDjJqIZE=; b=VszyNrqiRw61Mi2YAshLDeLP3UaUMVZya4j02rXhQt7JyweoPJI7yw0pMl9OVRXnuI3ecigYcbihhXgD98Ro42H5t+mEceAkV3iXZwhhaG113beFEFfXGn1AsCEm6l2yEpkN8fQYQFJOlo+ugMZQPbGYo7glRviwZTbAVi3G4h8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; Received: from rkaganb.sw.ru (185.231.240.5) by DB6PR0801MB1974.eurprd08.prod.outlook.com (2603:10a6:4:75::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.26; Mon, 2 Jul 2018 16:59:04 +0000 From: Roman Kagan To: qemu-devel@nongnu.org Date: Mon, 2 Jul 2018 19:58:42 +0300 Message-Id: <20180702165842.11423-7-rkagan@virtuozzo.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180702165842.11423-1-rkagan@virtuozzo.com> References: <20180702165842.11423-1-rkagan@virtuozzo.com> MIME-Version: 1.0 X-Originating-IP: [185.231.240.5] X-ClientProxiedBy: VI1PR08CA0234.eurprd08.prod.outlook.com (2603:10a6:802:15::43) To DB6PR0801MB1974.eurprd08.prod.outlook.com (2603:10a6:4:75::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fc8e9057-df31-4096-5cbf-08d5e03d1f19 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:DB6PR0801MB1974; X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1974; 3:iaXgjrfCmDtzEjbhl++GT4+U1j0xdIWyaBXr0Zu9GFDSkHRMFaFJXKTpND8Ew6E1BOAbAYHG26ELPc1wmbe/xLiHO3QvB0YYFnGtS/ys7LUjYYU5Nd4t3lKjrfL6MVN/DPVmPi+qBSLYhj9fYYYeSAVCjLJ3vtxWJjSq2dDCtOyT9K7Psp23dfPBXOV0IpQXRBsAnRVk11RuYYmN91OMAJz6Xv5Z0M7keOphH5sfiMkG9IwEtDUtrevEHGJemzhT; 25:2yP0NGIdtxiWKp3BigvywsR8KECuVMK2cAkuQX1MjZxGP4HVysBPFK1AVR2V3WNq1i7nWh+mprQoPw66Jr+ZfhafsA35ckZ8XEpBFm8elO1VJRSAlSW7KdZhUppOgcbUcAwwLKWTfhVicez9JZ9wbMocyoEC7GJ9iTlK85GwWrGSNmoQ/I1ah4zMHngcl6bpgr/c6IiFi1H+s5Equ7IoarMFnxSklcUz54zvtGAGMiJWxf8NpijWH5WszVypDm6XIBcXNOY/eOBuUFmqnYbQ46UgEfgQNfpk1klf09z1s4mH64lLm4WqALJ3UULHZuPDVYh60y4vvQfUjGoVCVtmWA==; 31:uXi+v3zhA57RDhqtdpjReQsqm1dMxzPqvCQzeErZbIuwZBdi/HEwGpUwpoDEZi5JhNPkqLbHn1SjK7hfgmMBxufVpiCm/MN8qXb0tgKsnN3s7pMerznluaBoEnBe4+w9coustoaDm+fYupJNRdI6wa1bFfp6rWNbx3r6XSu2kJXaZ/Mtk+2vMgP9E8l1c/gBvvgXE25wQjmwso2g+mfFCbj1sKr+/WZ+VxQ8ldkjo4A= X-MS-TrafficTypeDiagnostic: DB6PR0801MB1974: X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1974; 20:gtfjLWXoNatqpqhPV/8i3RIJK43T1995d53gdP8JQeSjCkJ1y6nVFqh0FzXJZVUmCr52eCccneA8dAjjrponjFumGlQ7dtP9Yj9kPK3bH5AlrxKGCUzzfL47sifqyWP1h+2uGezxaFgkjc1zDprzrIRhQeBX+8iEUR7TDT5mPkbHCz6Mg8CJNrMSZAI9m5gurWps0PwVOhtD0kLcM8XBaFdkMZv5uCA8TDHbNqcDftqjxKbIGEjeh7iZROLsDjc6sC68lPdhI8GL2A71hiAUaSHvhUV5WNNYz9DhPaxbdRZAFn+OdAu5seM1j+aksA4QjT8RuRGcTB+vOc9nK3KjF5nCSkczhVjbPF0zIrLVEQLFnlupRRlCVHCkS0IxdDSC2RMdZgeSiIRtDc7Jpv595ZGnMyfupNzGTvoVGldBRwk4tMBfeRA+pAGwe8GAj9JRAabAU5KYjGG/JrrsRgieHiMJcv5Dm9qzaTEtO6oyBWGq6LNdTNZcEiR+UBwxhXow; 4:B3pk4g+SfBYby5VpJqIF5ZLjKA1R+l9r0ITIJvjxKP2MhjfWW/5pkbjiXopJ1Ws0BVdwQmBVFPuf4NvOLwCEYtEK9BailAhSLEJbA2W+ebXLaiWhs8nCjzACL2rLXA9lYnN4vyKgfGLp2gIc89i6H9OMdZoUZRTP09Vvbla21O1mBJTpFSSIqVmuiu+XcevzUzDq13gk6cJHOp81z5NUL2Ay+KsiCjEV/r6YRyxux4W04dobrVrTUf1v4Z7Yo6GUBd8cqjTI/3tbtsTXPnBEOCn9IBIvCvUIEKXbr5glQRgbAp2ghxjZzSdo7dQ/0ExY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(60795455431006); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3231254)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(149027)(150027)(6041310)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011)(7699016); SRVR:DB6PR0801MB1974; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0801MB1974; X-Forefront-PRVS: 07215D0470 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(6029001)(39850400004)(136003)(396003)(376002)(366004)(346002)(189003)(199004)(7736002)(26005)(53936002)(305945005)(4326008)(50466002)(39060400002)(478600001)(6506007)(386003)(186003)(6512007)(51416003)(6486002)(66066001)(47776003)(25786009)(76176011)(97736004)(2906002)(2351001)(52116002)(16526019)(11346002)(105586002)(36756003)(8936002)(69596002)(53416004)(3846002)(6116002)(106356001)(81156014)(81166006)(446003)(2361001)(7416002)(86362001)(54906003)(2616005)(6666003)(16586007)(956004)(316002)(486006)(48376002)(68736007)(1076002)(50226002)(8676002)(476003)(5660300001)(6916009); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0801MB1974; H:rkaganb.sw.ru; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB6PR0801MB1974; 23:6G2Yj9vBfT0nNLPJB9gFFFNzgfVlOcOBdVCARpD?= =?us-ascii?Q?EDfCJku50k8tuJ+70ru76u5f/w2TPosLw6qYPq/tBi1zWpw6UckUlC0oVVEq?= =?us-ascii?Q?slff45NuLsCNxzNKIx3GbTiox1L3Jk7ijUd76SJ/25TSStjnNLGwmBTy4BTr?= =?us-ascii?Q?3nnAgeYdGcngIvm1f42E4oPOHXOI1hoEbV9b8vEKRJM2YcRA26k2zYyzFV+6?= =?us-ascii?Q?39lcjZjbYsE5a1N28OmqGU5R1XdGO5Us3AwUg+3UV6Jky8Ug+jSc8Lm58/An?= =?us-ascii?Q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d5DUR2lgOz0cfG7MI3B7NlyJT0/pKiqs7R+T/sWIlPt77XTbZPQPDW3i43q1zGe6s7GcNOj8E7hT7Bn6Lb2MZBL0uk7DlRvsg==; 5:MS7iZk5FEtPb2jPqQIW/i0zdv0Q796ZJng4Dc+5QrU+7LwRYvMYcVgaGgkPV3HUWlZNMKii6eqYM07G9PoASdWi6pt40oC2s13hHROFCLRA2JWSmEVOnackezRltnqymSXw/6THUOVMRXTJNkXTPIE0VuBsTWIeo8tpl5jw172Y=; 24:c89zQm7MmJB9b0npGZnhTC1f7cKmpWqFl7o4ESoIwGGOIRPNnhiMp7eKHDM5z8lGztoylPm+YfvMcNxZVTnCgUBcPO3SArRiuiWLgR7ERuY= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DB6PR0801MB1974; 7:liqeNQIj1WpUNzx8GAZ0kBeE8s5CccOhy54uAQQuDKwERv7CaOAKPZn/+OEdTYdbOFxZxgsZV6HT51JHVDgxjiQmaCpgYM3L8Sbt/1q/O/zWRYeKYeGZuBv2tN4ShDHaaa/TjcKcsvH++eAaYyORKmook62QtAVIYbZs4jca+QVRK5yD9hARY491uirlKcJVsUKnfMBeiujEdCQbJHrOqeLZTYnXpb3oDWM+zhgNHHFjahGTc5V+mRf/Zzrv9DJ9; 20:pf0ncvu7I5R72XDnaAt6OolXI4YdzL1BQHPDteW0GvpnDwwaXQpJp8fcPsoKvuUutB9Y1igGgA4mxZhbEX64BW13e2aqvrn5Ulnl2uUrhEMB9/JtNFzYR+47rzkHQ+9Nekd/MhxUGAFDJMdiIjaGgB+WlXxT+nkkUFbr8TsfAwc= X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jul 2018 16:59:04.4721 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fc8e9057-df31-4096-5cbf-08d5e03d1f19 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1974 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 2a01:111:f400:fe02::70c Subject: [Qemu-devel] [PATCH 6/6] 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: Vijayabhaskar Balakrishna , Eduardo Habkost , "Michael S. Tsirkin" , Konrad Rzeszutek Wilk , Venu Busireddy , Liran Alon , Igor Mammedov , Si-Wei Liu , Paolo Bonzini , Boris Ostrovsky , Karl Heubaum , Richard Henderson 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 93f7300dd6..af5fc05ea4 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(uint32_t vp_index, 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(uint32_t vp_index, 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 50dfa6af64..d29201b5ee 100644 --- a/hw/misc/hyperv_testdev.c +++ b/hw/misc/hyperv_testdev.c @@ -56,7 +56,7 @@ static void sint_route_create(HypervTestDev *dev, sint_route->vp_index = vp_index; sint_route->sint = sint; - sint_route->sint_route = kvm_hv_sint_route_create(vp_index, sint, NULL, NULL); + sint_route->sint_route = hyperv_sint_route_new(vp_index, sint, NULL, NULL); assert(sint_route->sint_route); QLIST_INSERT_HEAD(&dev->sint_routes, sint_route, le); @@ -83,7 +83,7 @@ static void sint_route_destroy(HypervTestDev *dev, sint_route = sint_route_find(dev, vp_index, 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 0ce8a7aa2f..4d8ef6f2da 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(uint32_t vp_index, uint32_t sint, - HvSintAckClb sint_ack_clb, - void *sint_ack_clb_data) +HvSintRoute *hyperv_sint_route_new(uint32_t vp_index, uint32_t sint, + HvSintAckClb sint_ack_clb, + void *sint_ack_clb_data) { HvSintRoute *sint_route; EventNotifier *ack_notifier; @@ -136,6 +137,7 @@ HvSintRoute *kvm_hv_sint_route_create(uint32_t vp_index, 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; @@ -154,8 +156,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);