aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/ulp/srp/ib_srp.c
diff options
context:
space:
mode:
authorBart Van Assche <bvanassche@acm.org>2011-09-03 03:34:48 -0400
committerRoland Dreier <roland@purestorage.com>2012-11-30 20:40:29 -0500
commitc9b03c1ae55decc721310b79d8f50d44fbb37dc7 (patch)
treea7f2174f0c1977ddc5a1a634727cdb17cdf90546 /drivers/infiniband/ulp/srp/ib_srp.c
parentf4a75d2eb7b1e2206094b901be09adb31ba63681 (diff)
IB/srp: Increase block layer timeout
Increase the block layer timeout for disks so that it is above the InfiniBand transport layer timeout. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Acked-by: David Dillow <dillowda@ornl.gov> Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband/ulp/srp/ib_srp.c')
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c45
1 files changed, 45 insertions, 0 deletions
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 922d845f76b0..5aa70e96ec90 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1419,6 +1419,33 @@ err:
1419 return -ENOMEM; 1419 return -ENOMEM;
1420} 1420}
1421 1421
1422static uint32_t srp_compute_rq_tmo(struct ib_qp_attr *qp_attr, int attr_mask)
1423{
1424 uint64_t T_tr_ns, max_compl_time_ms;
1425 uint32_t rq_tmo_jiffies;
1426
1427 /*
1428 * According to section 11.2.4.2 in the IBTA spec (Modify Queue Pair,
1429 * table 91), both the QP timeout and the retry count have to be set
1430 * for RC QP's during the RTR to RTS transition.
1431 */
1432 WARN_ON_ONCE((attr_mask & (IB_QP_TIMEOUT | IB_QP_RETRY_CNT)) !=
1433 (IB_QP_TIMEOUT | IB_QP_RETRY_CNT));
1434
1435 /*
1436 * Set target->rq_tmo_jiffies to one second more than the largest time
1437 * it can take before an error completion is generated. See also
1438 * C9-140..142 in the IBTA spec for more information about how to
1439 * convert the QP Local ACK Timeout value to nanoseconds.
1440 */
1441 T_tr_ns = 4096 * (1ULL << qp_attr->timeout);
1442 max_compl_time_ms = qp_attr->retry_cnt * 4 * T_tr_ns;
1443 do_div(max_compl_time_ms, NSEC_PER_MSEC);
1444 rq_tmo_jiffies = msecs_to_jiffies(max_compl_time_ms + 1000);
1445
1446 return rq_tmo_jiffies;
1447}
1448
1422static void srp_cm_rep_handler(struct ib_cm_id *cm_id, 1449static void srp_cm_rep_handler(struct ib_cm_id *cm_id,
1423 struct srp_login_rsp *lrsp, 1450 struct srp_login_rsp *lrsp,
1424 struct srp_target_port *target) 1451 struct srp_target_port *target)
@@ -1478,6 +1505,8 @@ static void srp_cm_rep_handler(struct ib_cm_id *cm_id,
1478 if (ret) 1505 if (ret)
1479 goto error_free; 1506 goto error_free;
1480 1507
1508 target->rq_tmo_jiffies = srp_compute_rq_tmo(qp_attr, attr_mask);
1509
1481 ret = ib_modify_qp(target->qp, qp_attr, attr_mask); 1510 ret = ib_modify_qp(target->qp, qp_attr, attr_mask);
1482 if (ret) 1511 if (ret)
1483 goto error_free; 1512 goto error_free;
@@ -1729,6 +1758,21 @@ static int srp_reset_host(struct scsi_cmnd *scmnd)
1729 return ret; 1758 return ret;
1730} 1759}
1731 1760
1761static int srp_slave_configure(struct scsi_device *sdev)
1762{
1763 struct Scsi_Host *shost = sdev->host;
1764 struct srp_target_port *target = host_to_target(shost);
1765 struct request_queue *q = sdev->request_queue;
1766 unsigned long timeout;
1767
1768 if (sdev->type == TYPE_DISK) {
1769 timeout = max_t(unsigned, 30 * HZ, target->rq_tmo_jiffies);
1770 blk_queue_rq_timeout(q, timeout);
1771 }
1772
1773 return 0;
1774}
1775
1732static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr, 1776static ssize_t show_id_ext(struct device *dev, struct device_attribute *attr,
1733 char *buf) 1777 char *buf)
1734{ 1778{
@@ -1861,6 +1905,7 @@ static struct scsi_host_template srp_template = {
1861 .module = THIS_MODULE, 1905 .module = THIS_MODULE,
1862 .name = "InfiniBand SRP initiator", 1906 .name = "InfiniBand SRP initiator",
1863 .proc_name = DRV_NAME, 1907 .proc_name = DRV_NAME,
1908 .slave_configure = srp_slave_configure,
1864 .info = srp_target_info, 1909 .info = srp_target_info,
1865 .queuecommand = srp_queuecommand, 1910 .queuecommand = srp_queuecommand,
1866 .eh_abort_handler = srp_abort, 1911 .eh_abort_handler = srp_abort,