IB/srp: Do not register memory if never_register has been set
authorBart Van Assche <bart.vanassche@sandisk.com>
Thu, 12 May 2016 17:51:01 +0000 (10:51 -0700)
committerDoug Ledford <dledford@redhat.com>
Fri, 13 May 2016 17:47:07 +0000 (13:47 -0400)
This makes it easier to test the code path that does not use
memory registration (srp_map_sg_dma()).

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/ulp/srp/ib_srp.c

index 6a5ccd4c7e6321a1b97a336e5d1d7f58509ba7b4..0b576c50e866a84ac39e8f26a92a7211396f96dd 100644 (file)
@@ -70,6 +70,7 @@ static unsigned int indirect_sg_entries;
 static bool allow_ext_sg;
 static bool prefer_fr = true;
 static bool register_always = true;
+static bool never_register;
 static int topspin_workarounds = 1;
 
 module_param(srp_sg_tablesize, uint, 0444);
@@ -99,6 +100,9 @@ module_param(register_always, bool, 0444);
 MODULE_PARM_DESC(register_always,
                 "Use memory registration even for contiguous memory regions");
 
+module_param(never_register, bool, 0444);
+MODULE_PARM_DESC(never_register, "Never register memory");
+
 static const struct kernel_param_ops srp_tmo_ops;
 
 static int srp_reconnect_delay = 10;
@@ -3546,9 +3550,10 @@ static void srp_add_one(struct ib_device *device)
                            device->map_phys_fmr && device->unmap_fmr);
        srp_dev->has_fr = (device->attrs.device_cap_flags &
                           IB_DEVICE_MEM_MGT_EXTENSIONS);
-       if (!srp_dev->has_fmr && !srp_dev->has_fr) {
+       if (!never_register && !srp_dev->has_fmr && !srp_dev->has_fr) {
                dev_warn(&device->dev, "neither FMR nor FR is supported\n");
-       } else if (device->attrs.max_mr_size >= 2 * srp_dev->mr_page_size) {
+       } else if (!never_register &&
+                  device->attrs.max_mr_size >= 2 * srp_dev->mr_page_size) {
                srp_dev->use_fast_reg = (srp_dev->has_fr &&
                                         (!srp_dev->has_fmr || prefer_fr));
                srp_dev->use_fmr = !srp_dev->use_fast_reg && srp_dev->has_fmr;
@@ -3573,7 +3578,8 @@ static void srp_add_one(struct ib_device *device)
        if (IS_ERR(srp_dev->pd))
                goto free_dev;
 
-       if (!register_always || (!srp_dev->has_fmr && !srp_dev->has_fr)) {
+       if (never_register || !register_always ||
+           (!srp_dev->has_fmr && !srp_dev->has_fr)) {
                srp_dev->global_mr = ib_get_dma_mr(srp_dev->pd,
                                                   IB_ACCESS_LOCAL_WRITE |
                                                   IB_ACCESS_REMOTE_READ |