Commit a25ce427 authored by Kaike Wan's avatar Kaike Wan Committed by Doug Ledford

IB/rdmavt: Setting of QP timeout can overflow jiffies computation

Current computation of qp->timeout_jiffies in rvt_modify_qp() will cause
overflow due to the fact that the input to the function usecs_to_jiffies
is only 32-bit ( unsigned int). Overflow will occur when attr->timeout is
equal to or greater than 30. The consequence is unnecessarily excessive
retry and thus degradation of the system performance.

This patch fixes the problem by limiting the input to 5-bit and calling
usecs_to_jiffies() before multiplying the scaling factor.
Reviewed-by: default avatarMike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: default avatarKaike Wan <kaike.wan@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 266098b8
...@@ -1258,9 +1258,7 @@ int rvt_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, ...@@ -1258,9 +1258,7 @@ int rvt_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
if (attr_mask & IB_QP_TIMEOUT) { if (attr_mask & IB_QP_TIMEOUT) {
qp->timeout = attr->timeout; qp->timeout = attr->timeout;
qp->timeout_jiffies = qp->timeout_jiffies = rvt_timeout_to_jiffies(qp->timeout);
usecs_to_jiffies((4096UL * (1UL << qp->timeout)) /
1000UL);
} }
if (attr_mask & IB_QP_QKEY) if (attr_mask & IB_QP_QKEY)
......
...@@ -647,6 +647,20 @@ static inline u32 rvt_div_mtu(struct rvt_qp *qp, u32 len) ...@@ -647,6 +647,20 @@ static inline u32 rvt_div_mtu(struct rvt_qp *qp, u32 len)
return len >> qp->log_pmtu; return len >> qp->log_pmtu;
} }
/**
* rvt_timeout_to_jiffies - Convert a ULP timeout input into jiffies
* @timeout - timeout input(0 - 31).
*
* Return a timeout value in jiffies.
*/
static inline unsigned long rvt_timeout_to_jiffies(u8 timeout)
{
if (timeout > 31)
timeout = 31;
return usecs_to_jiffies(1U << timeout) * 4096UL / 1000UL;
}
extern const int ib_rvt_state_ops[]; extern const int ib_rvt_state_ops[];
struct rvt_dev_info; struct rvt_dev_info;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment