Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752736AbdFOTLc (ORCPT ); Thu, 15 Jun 2017 15:11:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:52566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752541AbdFOTKC (ORCPT ); Thu, 15 Jun 2017 15:10:02 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FD80239CC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=sstabellini@kernel.org From: Stefano Stabellini To: xen-devel@lists.xen.org Cc: linux-kernel@vger.kernel.org, sstabellini@kernel.org, jgross@suse.com, boris.ostrovsky@oracle.com, Stefano Stabellini Subject: [PATCH v4 14/18] xen/pvcalls: disconnect and module_exit Date: Thu, 15 Jun 2017 12:09:43 -0700 Message-Id: <1497553787-3709-14-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1497553787-3709-1-git-send-email-sstabellini@kernel.org> References: <1497553787-3709-1-git-send-email-sstabellini@kernel.org> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2143 Lines: 77 Implement backend_disconnect. Call pvcalls_back_release_active on active sockets and pvcalls_back_release_passive on passive sockets. Implement module_exit by calling backend_disconnect on frontend connections. Signed-off-by: Stefano Stabellini CC: boris.ostrovsky@oracle.com CC: jgross@suse.com --- drivers/xen/pvcalls-back.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c index afc9575..94e4c3f 100644 --- a/drivers/xen/pvcalls-back.c +++ b/drivers/xen/pvcalls-back.c @@ -806,6 +806,37 @@ static int backend_connect(struct xenbus_device *dev) static int backend_disconnect(struct xenbus_device *dev) { + struct pvcalls_fedata *fedata; + struct sock_mapping *map, *n; + struct sockpass_mapping *mappass; + struct radix_tree_iter iter; + void **slot; + + + fedata = dev_get_drvdata(&dev->dev); + + list_for_each_entry_safe(map, n, &fedata->socket_mappings, list) + pvcalls_back_release_active(dev, fedata, map); + + radix_tree_for_each_slot(slot, &fedata->socketpass_mappings, &iter, 0) { + mappass = radix_tree_deref_slot(slot); + if (!mappass) + continue; + if (radix_tree_exception(mappass)) { + if (radix_tree_deref_retry(mappass)) + slot = radix_tree_iter_retry(&iter); + } else + pvcalls_back_release_passive(dev, fedata, mappass); + } + + xenbus_unmap_ring_vfree(dev, fedata->sring); + unbind_from_irqhandler(fedata->irq, dev); + + list_del(&fedata->list); + destroy_workqueue(fedata->wq); + kfree(fedata); + dev_set_drvdata(&dev->dev, NULL); + return 0; } @@ -999,3 +1030,19 @@ static int __init pvcalls_back_init(void) return 0; } module_init(pvcalls_back_init); + +static void __exit pvcalls_back_fin(void) +{ + struct pvcalls_fedata *fedata, *nfedata; + + down(&pvcalls_back_global.frontends_lock); + list_for_each_entry_safe(fedata, nfedata, &pvcalls_back_global.frontends, + list) { + backend_disconnect(fedata->dev); + } + up(&pvcalls_back_global.frontends_lock); + + xenbus_unregister_driver(&pvcalls_back_driver); +} + +module_exit(pvcalls_back_fin); -- 1.9.1