[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1494880570-14209-14-git-send-email-sstabellini@kernel.org>
Date: Mon, 15 May 2017 13:36:06 -0700
From: Stefano Stabellini <sstabellini@...nel.org>
To: xen-devel@...ts.xen.org
Cc: linux-kernel@...r.kernel.org, sstabellini@...nel.org,
jgross@...e.com, boris.ostrovsky@...cle.com,
Stefano Stabellini <stefano@...reto.com>
Subject: [PATCH 14/18] xen/pvcalls: disconnect and module_exit
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 <stefano@...reto.com>
CC: boris.ostrovsky@...cle.com
CC: jgross@...e.com
---
drivers/xen/pvcalls-back.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/drivers/xen/pvcalls-back.c b/drivers/xen/pvcalls-back.c
index 22c6426..0daa90a 100644
--- a/drivers/xen/pvcalls-back.c
+++ b/drivers/xen/pvcalls-back.c
@@ -855,6 +855,35 @@ static int backend_connect(struct xenbus_device *dev)
static int backend_disconnect(struct xenbus_device *dev)
{
+ struct pvcalls_back_priv *priv;
+ struct sock_mapping *map, *n;
+ struct sockpass_mapping *mappass;
+ struct radix_tree_iter iter;
+ void **slot;
+
+
+ priv = dev_get_drvdata(&dev->dev);
+
+ list_for_each_entry_safe(map, n, &priv->socket_mappings, list) {
+ pvcalls_back_release_active(dev, priv, map);
+ }
+ radix_tree_for_each_slot(slot, &priv->socketpass_mappings, &iter, 0) {
+ mappass = radix_tree_deref_slot(slot);
+ if (!mappass || radix_tree_exception(mappass)) {
+ if (radix_tree_deref_retry(mappass)) {
+ slot = radix_tree_iter_retry(&iter);
+ continue;
+ }
+ } else
+ pvcalls_back_release_passive(dev, priv, mappass);
+ }
+ xenbus_unmap_ring_vfree(dev, (void *)priv->sring);
+ unbind_from_irqhandler(priv->irq, dev);
+ list_del(&priv->list);
+ destroy_workqueue(priv->wq);
+ kfree(priv);
+ dev_set_drvdata(&dev->dev, NULL);
+
return 0;
}
@@ -1056,3 +1085,22 @@ static int __init pvcalls_back_init(void)
return -ENOMEM;
}
module_init(pvcalls_back_init);
+
+static void __exit pvcalls_back_fin(void)
+{
+ struct pvcalls_back_priv *priv, *npriv;
+
+ down_write(&pvcalls_back_global.privs_lock);
+ list_for_each_entry_safe(priv, npriv, &pvcalls_back_global.privs,
+ list) {
+ backend_disconnect(priv->dev);
+ }
+ up_write(&pvcalls_back_global.privs_lock);
+
+ xenbus_unregister_driver(&pvcalls_back_driver);
+ destroy_workqueue(pvcalls_back_global.wq);
+ kfree(pvcalls_back_global.ioworkers);
+ memset(&pvcalls_back_global, 0, sizeof(pvcalls_back_global));
+}
+
+module_exit(pvcalls_back_fin);
--
1.9.1
Powered by blists - more mailing lists