]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
RDS: add module parameter to allow module unload or not
authorWengang Wang <wen.gang.wang@oracle.com>
Fri, 31 Oct 2014 02:58:07 +0000 (10:58 +0800)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Wed, 8 Jul 2015 21:00:08 +0000 (14:00 -0700)
orabug: 19665303

This patch adds the following feature to ib_ipoib, rds_rdma, ib_core and
mlx4_core.

Adds a module parameter "module_unload_allowed". If the parameter is 1(the
default value), moudles can be unloaded(same behavior as before); other-
wise if it's 0, the module is not allowed to be unloaded. The paramter can't
be changed when module is loaded until the module is unloaded(if it can be).

default values:
ib_ipoib: 1 for YES
rds_rdma: 0 for NO
ib_core: 1 for YES
mlx4_core: 0 for NO

Signed-off-by: Wengang Wang <wen.gang.wang@oracle.com>
Acked-by: Joe Jin <joe.jin@oracle.com>
Acked-by: Todd Vierling <todd.vierling@oracle.com>
Acked-by: Yuval Shaia <yuval.shaia@oracle.com>
Signed-off-by: Guangyu Sun <guangyu.sun@oracle.com>
(cherry picked from commit cf1a00039e6fea116e9ea7c82f55ee3ee5319cec)

Conflicts:
drivers/infiniband/core/device.c
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/net/ethernet/mellanox/mlx4/main.c

drivers/infiniband/core/device.c
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/net/ethernet/mellanox/mlx4/main.c
net/rds/rdma_transport.c

index 18c1ece765f2c55b8317fba4daa5716df0ab814f..928e31f40f871e58cee5ca6e58b36661bcfceb2b 100644 (file)
@@ -46,6 +46,11 @@ MODULE_AUTHOR("Roland Dreier");
 MODULE_DESCRIPTION("core kernel InfiniBand API");
 MODULE_LICENSE("Dual BSD/GPL");
 
+int unload_allowed __read_mostly = 1;
+
+module_param_named(module_unload_allowed, unload_allowed, int, 0444);
+MODULE_PARM_DESC(module_unload_allowed, "Allow this module to be unloaded or not (default 1 for YES)");
+
 struct ib_client_data {
        struct list_head  list;
        struct ib_client *client;
@@ -733,6 +738,8 @@ int ib_find_pkey(struct ib_device *device,
 }
 EXPORT_SYMBOL(ib_find_pkey);
 
+#define MODULE_NAME "ib_core"
+
 static int __init ib_core_init(void)
 {
        int ret;
@@ -759,6 +766,12 @@ static int __init ib_core_init(void)
                goto err_nl;
        }
 
+       if (!unload_allowed) {
+               printk(KERN_NOTICE "Module %s locked in memory until next boot\n",
+                               MODULE_NAME);
+               __module_get(THIS_MODULE);
+       }
+
        return 0;
 
 err_nl:
index 9e1b203d756d272dfd4c8066b3f4bf64d681e0d5..798e4922e5753ce066c506c07ca95663e33a415f 100644 (file)
@@ -60,6 +60,10 @@ MODULE_VERSION(DRV_VERSION);
 
 int ipoib_sendq_size __read_mostly = IPOIB_TX_RING_SIZE;
 int ipoib_recvq_size __read_mostly = IPOIB_RX_RING_SIZE;
+int unload_allowed __read_mostly = 1;
+
+module_param_named(module_unload_allowed, unload_allowed, int, 0444);
+MODULE_PARM_DESC(module_unload_allowed, "Allow this module to be unloaded or not (default 1 for YES)");
 
 module_param_named(send_queue_size, ipoib_sendq_size, int, 0444);
 MODULE_PARM_DESC(send_queue_size, "Number of descriptors in send queue");
@@ -1748,6 +1752,8 @@ static void ipoib_remove_one(struct ib_device *device)
        kfree(dev_list);
 }
 
+#define MODULE_NAME "ib_ipoib"
+
 static int __init ipoib_init_module(void)
 {
        int ret;
@@ -1799,6 +1805,12 @@ static int __init ipoib_init_module(void)
        if (ret)
                goto err_client;
 
+       if (!unload_allowed) {
+               printk(KERN_NOTICE "Module %s locked in memory until next boot\n",
+                               MODULE_NAME);
+               __module_get(THIS_MODULE);
+       }
+
        return 0;
 
 err_client:
index ced5ecab5aa754ad44ae055464608bba66d6b137..d9b70138bef6d358655d66a2983752c48ea52060 100644 (file)
@@ -65,6 +65,10 @@ MODULE_PARM_DESC(debug_level, "Enable debug tracing if > 0");
 
 #endif /* CONFIG_MLX4_DEBUG */
 
+int unload_allowed __read_mostly;
+module_param_named(module_unload_allowed, unload_allowed, int, 0444);
+MODULE_PARM_DESC(module_unload_allowed, "Allow this module to be unloaded or not (default 0 for NO)");
+
 #ifdef CONFIG_PCI_MSI
 
 static int msi_x = 1;
@@ -3720,6 +3724,8 @@ static int __init mlx4_verify_params(void)
        return 0;
 }
 
+#define MODULE_NAME "mlx4_core"
+
 static int __init mlx4_init(void)
 {
        int ret;
@@ -3733,6 +3739,11 @@ static int __init mlx4_init(void)
                return -ENOMEM;
 
        ret = pci_register_driver(&mlx4_driver);
+       if (!ret && !unload_allowed) {
+               printk(KERN_NOTICE "Module %s locked in memory until next boot\n",
+                               MODULE_NAME);
+               __module_get(THIS_MODULE);
+       }
        if (ret < 0)
                destroy_workqueue(mlx4_wq);
        return ret < 0 ? ret : 0;
index 00d88a5696dff0341fa71fdaa22228a92b4d416c..7e3fc7526c5026fd6d0f4848f3508857a379c346 100644 (file)
 
 static struct rdma_cm_id *rds_iw_listen_id;
 
+int unload_allowed __read_mostly;
+
+module_param_named(module_unload_allowed, unload_allowed, int, 0444);
+MODULE_PARM_DESC(module_unload_allowed, "Allow this module to be unloaded or not (default 0 for NO)");
+
 int rds_rdma_resolve_to_ms[] = {1000, 1000, 2000, 4000, 5000};
 
 int rds_rdma_cm_event_handler(struct rdma_cm_id *cm_id,
@@ -337,6 +342,8 @@ static void rds_rdma_listen_stop(void)
        }
 }
 
+#define MODULE_NAME "rds_rdma"
+
 int rds_rdma_init(void)
 {
        int ret;
@@ -353,6 +360,12 @@ int rds_rdma_init(void)
        if (ret)
                goto err_ib_init;
 
+       if (!unload_allowed) {
+               printk(KERN_NOTICE "Module %s locked in memory until next boot\n",
+                      MODULE_NAME);
+               __module_get(THIS_MODULE);
+       }
+
        goto out;
 
 err_ib_init: