From: Sergey Gorenko Date: Mon, 25 Sep 2017 15:51:43 +0000 (+0300) Subject: ib_srp: Fixed backport X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=refs%2Fremotes%2Forigin%2FHEAD;p=~tnikolova%2Fcompat-rdma%2F.git ib_srp: Fixed backport This patch fixes http://bugs.openfabrics.org/show_bug.cgi?id=2635 Signed-off-by: Sergey Gorenko Signed-off-by: Vladimir Sokolovsky --- diff --git a/patches/0008-BACKPORT-ib_srp.patch b/patches/0008-BACKPORT-ib_srp.patch index 486885f..ced4a0a 100644 --- a/patches/0008-BACKPORT-ib_srp.patch +++ b/patches/0008-BACKPORT-ib_srp.patch @@ -4,9 +4,9 @@ Subject: [PATCH] BACKPORT: ib_srp Change-Id: Ic90bc43f6bd61818530da7fb700962a8e1ef4aa5 Signed-off-by: Israel Rukshin --- - drivers/infiniband/ulp/srp/ib_srp.c | 193 +++++++++++++++++++++++++++++++++++- - drivers/infiniband/ulp/srp/ib_srp.h | 24 +++++ - 2 files changed, 213 insertions(+), 4 deletions(-) + drivers/infiniband/ulp/srp/ib_srp.c | 166 +++++++++++++++++++++++++++++++++++- + drivers/infiniband/ulp/srp/ib_srp.h | 24 ++++++ + 2 files changed, 186 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index xxxxxxx..xxxxxxx xxxxxx @@ -22,17 +22,8 @@ index xxxxxxx..xxxxxxx xxxxxx #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #include -@@ -77,12 +80,22 @@ module_param(srp_sg_tablesize, uint, 0444); - MODULE_PARM_DESC(srp_sg_tablesize, "Deprecated name for cmd_sg_entries"); - - module_param(cmd_sg_entries, uint, 0444); -+#ifdef HAVE_BLK_QUEUE_VIRT_BOUNDARY - MODULE_PARM_DESC(cmd_sg_entries, +@@ -81,8 +84,13 @@ MODULE_PARM_DESC(cmd_sg_entries, "Default number of gather/scatter entries in the SRP command (default is 12, max 255)"); -+#else -+MODULE_PARM_DESC(cmd_sg_entries, -+ "Default number of gather/scatter entries in the SRP command (default is 12, max 12)"); -+#endif module_param(indirect_sg_entries, uint, 0444); +#ifdef HAVE_SG_MAX_SEGMENTS @@ -45,7 +36,7 @@ index xxxxxxx..xxxxxxx xxxxxx module_param(allow_ext_sg, bool, 0444); MODULE_PARM_DESC(allow_ext_sg, -@@ -105,7 +118,7 @@ MODULE_PARM_DESC(never_register, "Never register memory"); +@@ -105,7 +113,7 @@ MODULE_PARM_DESC(never_register, "Never register memory"); static const struct kernel_param_ops srp_tmo_ops; @@ -54,7 +45,7 @@ index xxxxxxx..xxxxxxx xxxxxx module_param_cb(reconnect_delay, &srp_tmo_ops, &srp_reconnect_delay, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(reconnect_delay, "Time between successive reconnect attempts"); -@@ -758,7 +771,7 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich) +@@ -758,7 +766,7 @@ static int srp_send_req(struct srp_rdma_ch *ch, bool multich) shost_printk(KERN_DEBUG, target->scsi_host, PFX "Topspin/Cisco initiator port ID workaround " "activated for target GUID %016llx\n", @@ -63,7 +54,7 @@ index xxxxxxx..xxxxxxx xxxxxx memset(req->priv.initiator_port_id, 0, 8); memcpy(req->priv.initiator_port_id + 8, &target->srp_host->srp_dev->dev->node_guid, 8); -@@ -846,6 +859,9 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) +@@ -846,6 +854,9 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) dma_addr_t dma_addr; int i, ret = -ENOMEM; @@ -73,7 +64,7 @@ index xxxxxxx..xxxxxxx xxxxxx ch->req_ring = kcalloc(target->req_ring_size, sizeof(*ch->req_ring), GFP_KERNEL); if (!ch->req_ring) -@@ -877,6 +893,10 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) +@@ -877,6 +888,10 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) goto out; req->indirect_dma_addr = dma_addr; @@ -84,7 +75,7 @@ index xxxxxxx..xxxxxxx xxxxxx } ret = 0; -@@ -1130,6 +1150,9 @@ static void srp_free_req(struct srp_rdma_ch *ch, struct srp_request *req, +@@ -1130,6 +1145,9 @@ static void srp_free_req(struct srp_rdma_ch *ch, struct srp_request *req, spin_lock_irqsave(&ch->lock, flags); ch->req_lim += req_lim_delta; @@ -94,7 +85,7 @@ index xxxxxxx..xxxxxxx xxxxxx spin_unlock_irqrestore(&ch->lock, flags); } -@@ -1874,11 +1897,18 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp) +@@ -1874,11 +1892,18 @@ static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp) ch->tsk_mgmt_status = rsp->data[3]; complete(&ch->tsk_mgmt_done); } else { @@ -114,22 +105,22 @@ index xxxxxxx..xxxxxxx xxxxxx if (!scmnd) { shost_printk(KERN_ERR, target->scsi_host, "Null scmnd for RSP w/tag %#016llx received on ch %td / QP %#x\n", -@@ -1974,8 +2004,13 @@ static void srp_process_aer_req(struct srp_rdma_ch *ch, +@@ -1974,8 +1999,13 @@ static void srp_process_aer_req(struct srp_rdma_ch *ch, }; s32 delta = be32_to_cpu(req->req_lim_delta); +#ifdef HAVE_SCSI_DEVICE_U64_LUN -+ shost_printk(KERN_ERR, target->scsi_host, PFX -+ "ignoring AER for LUN %u\n", scsilun_to_int(&req->lun)); -+#else shost_printk(KERN_ERR, target->scsi_host, PFX - "ignoring AER for LUN %llu\n", scsilun_to_int(&req->lun)); + "ignoring AER for LUN %u\n", scsilun_to_int(&req->lun)); ++#else ++ shost_printk(KERN_ERR, target->scsi_host, PFX ++ "ignoring AER for LUN %u\n", scsilun_to_int(&req->lun)); +#endif if (srp_response_common(ch, delta, &rsp, sizeof(rsp))) shost_printk(KERN_ERR, target->scsi_host, PFX -@@ -2085,7 +2120,9 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) +@@ -2085,7 +2115,9 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) struct ib_device *dev; unsigned long flags; u32 tag; @@ -139,7 +130,7 @@ index xxxxxxx..xxxxxxx xxxxxx int len, ret; const bool in_scsi_eh = !in_interrupt() && current == shost->ehandler; -@@ -2102,6 +2139,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) +@@ -2102,6 +2134,7 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) if (unlikely(scmnd->result)) goto err; @@ -147,7 +138,7 @@ index xxxxxxx..xxxxxxx xxxxxx WARN_ON_ONCE(scmnd->request->tag < 0); tag = blk_mq_unique_tag(scmnd->request); ch = &target->ch[blk_mq_unique_tag_to_hwq(tag)]; -@@ -2109,15 +2147,28 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) +@@ -2109,15 +2142,28 @@ static int srp_queuecommand(struct Scsi_Host *shost, struct scsi_cmnd *scmnd) WARN_ONCE(idx >= target->req_ring_size, "%s: tag %#x: idx %d >= %d\n", dev_name(&shost->shost_gendev), tag, idx, target->req_ring_size); @@ -176,7 +167,7 @@ index xxxxxxx..xxxxxxx xxxxxx dev = target->srp_host->srp_dev->dev; ib_dma_sync_single_for_cpu(dev, iu->dma, target->max_iu_len, DMA_TO_DEVICE); -@@ -2178,6 +2229,14 @@ err_iu: +@@ -2178,6 +2224,14 @@ err_iu: */ req->scmnd = NULL; @@ -191,7 +182,7 @@ index xxxxxxx..xxxxxxx xxxxxx err: if (scmnd->result) { scmnd->scsi_done(scmnd); -@@ -2493,6 +2552,31 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) +@@ -2493,6 +2547,31 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) return 0; } @@ -223,7 +214,7 @@ index xxxxxxx..xxxxxxx xxxxxx /** * srp_change_queue_depth - setting device queue depth * @sdev: scsi device struct -@@ -2500,13 +2584,40 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) +@@ -2500,13 +2579,40 @@ static int srp_cm_handler(struct ib_cm_id *cm_id, struct ib_cm_event *event) * * Returns queue depth. */ @@ -264,7 +255,7 @@ index xxxxxxx..xxxxxxx xxxxxx static int srp_send_tsk_mgmt(struct srp_rdma_ch *ch, u64 req_tag, u64 lun, u8 func) -@@ -2578,8 +2689,13 @@ static int srp_abort(struct scsi_cmnd *scmnd) +@@ -2578,8 +2684,13 @@ static int srp_abort(struct scsi_cmnd *scmnd) if (!req) return SUCCESS; @@ -278,7 +269,7 @@ index xxxxxxx..xxxxxxx xxxxxx if (WARN_ON_ONCE(ch_idx >= target->ch_count)) return SUCCESS; ch = &target->ch[ch_idx]; -@@ -2637,6 +2753,7 @@ static int srp_reset_host(struct scsi_cmnd *scmnd) +@@ -2637,6 +2748,7 @@ static int srp_reset_host(struct scsi_cmnd *scmnd) return srp_reconnect_rport(target->rport) == 0 ? SUCCESS : FAILED; } @@ -286,7 +277,7 @@ index xxxxxxx..xxxxxxx xxxxxx static int srp_slave_alloc(struct scsi_device *sdev) { struct Scsi_Host *shost = sdev->host; -@@ -2650,6 +2767,7 @@ static int srp_slave_alloc(struct scsi_device *sdev) +@@ -2650,6 +2762,7 @@ static int srp_slave_alloc(struct scsi_device *sdev) return 0; } @@ -294,7 +285,7 @@ index xxxxxxx..xxxxxxx xxxxxx static int srp_slave_configure(struct scsi_device *sdev) { -@@ -2842,11 +2960,20 @@ static struct scsi_host_template srp_template = { +@@ -2842,11 +2955,20 @@ static struct scsi_host_template srp_template = { .module = THIS_MODULE, .name = "InfiniBand SRP initiator", .proc_name = DRV_NAME, @@ -315,7 +306,7 @@ index xxxxxxx..xxxxxxx xxxxxx .eh_abort_handler = srp_abort, .eh_device_reset_handler = srp_reset_device, .eh_host_reset_handler = srp_reset_host, -@@ -2857,7 +2984,15 @@ static struct scsi_host_template srp_template = { +@@ -2857,7 +2979,15 @@ static struct scsi_host_template srp_template = { .cmd_per_lun = SRP_DEFAULT_CMD_SQ_SIZE, .use_clustering = ENABLE_CLUSTERING, .shost_attrs = srp_host_attrs, @@ -331,7 +322,7 @@ index xxxxxxx..xxxxxxx xxxxxx }; static int srp_sdev_count(struct Scsi_Host *host) -@@ -2906,8 +3041,13 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) +@@ -2906,8 +3036,13 @@ static int srp_add_target(struct srp_host *host, struct srp_target_port *target) list_add_tail(&target->list, &host->target_list); spin_unlock(&host->target_lock); @@ -345,27 +336,7 @@ index xxxxxxx..xxxxxxx xxxxxx if (srp_connected_ch(target) < target->ch_count || target->qp_in_error) { -@@ -3167,11 +3307,19 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target) - break; - - case SRP_OPT_CMD_SG_ENTRIES: -+#ifdef HAVE_BLK_QUEUE_VIRT_BOUNDARY - if (match_int(args, &token) || token < 1 || token > 255) { - pr_warn("bad max cmd_sg_entries parameter '%s'\n", - p); - goto out; - } -+#else -+ if (match_int(args, &token) || token < 1 || token > 12) { -+ pr_warn("bad max cmd_sg_entries parameter '%s'\n", -+ p); -+ goto out; -+ } -+#endif - target->cmd_sg_cnt = token; - break; - -@@ -3184,12 +3332,21 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target) +@@ -3184,12 +3319,21 @@ static int srp_parse_options(const char *buf, struct srp_target_port *target) break; case SRP_OPT_SG_TABLESIZE: @@ -387,19 +358,7 @@ index xxxxxxx..xxxxxxx xxxxxx target->sg_tablesize = token; break; -@@ -3249,7 +3406,11 @@ static ssize_t srp_create_target(struct device *dev, - struct srp_device *srp_dev = host->srp_dev; - struct ib_device *ibdev = srp_dev->dev; - int ret, node_idx, node, cpu, i; -+#ifdef HAVE_BLK_QUEUE_VIRT_BOUNDARY - unsigned int max_sectors_per_mr, mr_per_cmd = 0; -+#else -+ unsigned int mr_per_cmd = 0; -+#endif - bool multich = false; - - target_host = scsi_host_alloc(&srp_template, -@@ -3257,6 +3418,11 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3257,6 +3401,11 @@ static ssize_t srp_create_target(struct device *dev, if (!target_host) return -ENOMEM; @@ -411,7 +370,7 @@ index xxxxxxx..xxxxxxx xxxxxx target_host->transportt = ib_srp_transport_template; target_host->max_channel = 0; target_host->max_id = 1; -@@ -3288,6 +3454,12 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3288,6 +3437,12 @@ static ssize_t srp_create_target(struct device *dev, if (ret) goto out; @@ -424,25 +383,15 @@ index xxxxxxx..xxxxxxx xxxxxx target->req_ring_size = target->queue_size - SRP_TSK_MGMT_SQ_SIZE; if (!srp_conn_unique(target->srp_host, target)) { -@@ -3319,6 +3491,7 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3319,6 +3474,7 @@ static ssize_t srp_create_target(struct device *dev, * register_always is true. Hence add one to mr_per_cmd if * register_always has been set. */ -+#ifdef HAVE_BLK_QUEUE_VIRT_BOUNDARY ++ max_sectors_per_mr = srp_dev->max_pages_per_mr << (ilog2(srp_dev->mr_page_size) - 9); mr_per_cmd = register_always + -@@ -3328,6 +3501,9 @@ static ssize_t srp_create_target(struct device *dev, - target->scsi_host->max_sectors, - srp_dev->max_pages_per_mr, srp_dev->mr_page_size, - max_sectors_per_mr, mr_per_cmd); -+#else -+ mr_per_cmd = 1; -+#endif - } - - target_host->sg_tablesize = target->sg_tablesize; -@@ -3417,7 +3593,9 @@ static ssize_t srp_create_target(struct device *dev, +@@ -3417,7 +3573,9 @@ static ssize_t srp_create_target(struct device *dev, } connected: @@ -452,24 +401,6 @@ index xxxxxxx..xxxxxxx xxxxxx ret = srp_add_target(host, target); if (ret) -@@ -3669,10 +3847,17 @@ static int __init srp_init_module(void) - if (!cmd_sg_entries) - cmd_sg_entries = SRP_DEF_SG_TABLESIZE; - -+#ifdef HAVE_BLK_QUEUE_VIRT_BOUNDARY - if (cmd_sg_entries > 255) { - pr_warn("Clamping cmd_sg_entries to 255\n"); - cmd_sg_entries = 255; - } -+#else -+ if (cmd_sg_entries > 12) { -+ pr_warn("Clamping cmd_sg_entries to 12\n"); -+ cmd_sg_entries = 12; -+ } -+#endif - - if (!indirect_sg_entries) - indirect_sg_entries = cmd_sg_entries; diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h index xxxxxxx..xxxxxxx xxxxxx --- a/drivers/infiniband/ulp/srp/ib_srp.h