From patchwork Tue Jul 25 21:22:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9863835 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 A47FE6038C for ; Tue, 25 Jul 2017 21:24:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E39126E97 for ; Tue, 25 Jul 2017 21:24:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8311E2860F; Tue, 25 Jul 2017 21:24:39 +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 3694926E97 for ; Tue, 25 Jul 2017 21:24:39 +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 1da7Hc-0004eJ-ED; Tue, 25 Jul 2017 21:22:24 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1da7Hb-0004bJ-Bp for xen-devel@lists.xen.org; Tue, 25 Jul 2017 21:22:23 +0000 Received: from [193.109.254.147] by server-9.bemta-6.messagelabs.com id E6/DC-03406-E86B7795; Tue, 25 Jul 2017 21:22:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeJIrShJLcpLzFFi42I5NlE2WbdvW3m kwdSPnBZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a2jo1sBbd5Ki48nMDawLiQu4uRi0NIYB2T xOkVX9i7GDk5WAQcJH4fmczYxcjBwSgQI/HghzVImFEgTGLy5SWsIDabgKHE3yeb2EBsEQFpi WufLzOCzGEWmMwo8frdL2aQhLCAi8TMDTuYIWaqSty8sh/M5hVwl3h84CvYLgkBOYmTxyaDDe UEis+fuZ0F4qB2RomPW08zT2DkXcDIsIpRvTi1qCy1SNdIL6koMz2jJDcxM0fX0MBMLze1uDg xPTUnMalYLzk/dxMjMBwYgGAH47K/TocYJTmYlER5v+mWRwrxJeWnVGYkFmfEF5XmpBYfYpTh 4FCS4P22BSgnWJSanlqRlpkDDEyYtAQHj5IIb+9WoDRvcUFibnFmOkTqFKMxx4bV678wcbya8 P8bkxBLXn5eqpQ4rwFIqQBIaUZpHtwgWMRcYpSVEuZlBDpNiKcgtSg3swRV/hWjOAejkjBvJM gUnsy8Erh9r4BOYQI6Zc6MUpBTShIRUlINjJOEgw8kz7vEWObzY2H/4ScMXe94shtZtKdlrZn 0QrBKJ2vOt3/mCZdWNWivlPSI+LjwK9vjF40MwqemzllcIhOw0/foUcOn0lVRC1621rddj7vz r/z/854fVfbKzqmPLGeX+fKc/blBQLj8hJ3y2Yp7ghlrM+Je+5dMPa8z8b3DqSi1wvXchkosx RmJhlrMRcWJANenabWTAgAA X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-6.tower-27.messagelabs.com!1501017740!109023695!1 X-Originating-IP: [198.145.29.99] 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 36073 invoked from network); 25 Jul 2017 21:22:22 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.99) by server-6.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 25 Jul 2017 21:22:22 -0000 Received: from localhost.localdomain (162-198-228-33.lightspeed.wlfrct.sbcglobal.net [162.198.228.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5EDDA22C93; Tue, 25 Jul 2017 21:22:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5EDDA22C93 From: Stefano Stabellini To: xen-devel@lists.xen.org Date: Tue, 25 Jul 2017 14:22:09 -0700 Message-Id: <1501017730-12797-12-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1501017730-12797-1-git-send-email-sstabellini@kernel.org> References: <1501017730-12797-1-git-send-email-sstabellini@kernel.org> Cc: jgross@suse.com, Stefano Stabellini , boris.ostrovsky@oracle.com, sstabellini@kernel.org, linux-kernel@vger.kernel.org Subject: [Xen-devel] [PATCH v2 12/13] xen/pvcalls: implement frontend disconnect 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 Implement pvcalls frontend removal function. Go through the list of active and passive sockets and free them all, one at a time. Signed-off-by: Stefano Stabellini Reviewed-by: Juergen Gross CC: boris.ostrovsky@oracle.com CC: jgross@suse.com --- drivers/xen/pvcalls-front.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c index 5a4040e..b3d4675 100644 --- a/drivers/xen/pvcalls-front.c +++ b/drivers/xen/pvcalls-front.c @@ -911,6 +911,34 @@ int pvcalls_front_release(struct socket *sock) static int pvcalls_front_remove(struct xenbus_device *dev) { + struct pvcalls_bedata *bedata; + struct sock_mapping *map = NULL, *n; + + bedata = dev_get_drvdata(&pvcalls_front_dev->dev); + + list_for_each_entry_safe(map, n, &bedata->socket_mappings, list) { + mutex_lock(&map->active.in_mutex); + mutex_lock(&map->active.out_mutex); + pvcalls_front_free_map(bedata, map); + mutex_unlock(&map->active.out_mutex); + mutex_unlock(&map->active.in_mutex); + kfree(map); + } + list_for_each_entry_safe(map, n, &bedata->socketpass_mappings, list) { + spin_lock(&bedata->pvcallss_lock); + list_del_init(&map->list); + spin_unlock(&bedata->pvcallss_lock); + kfree(map); + } + if (bedata->irq > 0) + unbind_from_irqhandler(bedata->irq, dev); + if (bedata->ref >= 0) + gnttab_end_foreign_access(bedata->ref, 0, 0); + kfree(bedata->ring.sring); + kfree(bedata); + dev_set_drvdata(&dev->dev, NULL); + xenbus_switch_state(dev, XenbusStateClosed); + pvcalls_front_dev = NULL; return 0; }