Commit 6676b3f7 authored by Mike Marciniszyn's avatar Mike Marciniszyn Committed by Roland Dreier

IB/qib: Fix context allocation with multiple HCAs

The driver was incorrectly choosing HCAs on which to allocate new user
contexts based on overall count of usable ports regardless whether the
usable port was on the currently selected HCA.
Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@qlogic.com>
Signed-off-by: default avatarRoland Dreier <rolandd@cisco.com>
parent 5dbbcb97
...@@ -1379,17 +1379,17 @@ static int get_a_ctxt(struct file *fp, const struct qib_user_info *uinfo, ...@@ -1379,17 +1379,17 @@ static int get_a_ctxt(struct file *fp, const struct qib_user_info *uinfo,
/* find device (with ACTIVE ports) with fewest ctxts in use */ /* find device (with ACTIVE ports) with fewest ctxts in use */
for (ndev = 0; ndev < devmax; ndev++) { for (ndev = 0; ndev < devmax; ndev++) {
struct qib_devdata *dd = qib_lookup(ndev); struct qib_devdata *dd = qib_lookup(ndev);
unsigned cused = 0, cfree = 0; unsigned cused = 0, cfree = 0, pusable = 0;
if (!dd) if (!dd)
continue; continue;
if (port && port <= dd->num_pports && if (port && port <= dd->num_pports &&
usable(dd->pport + port - 1)) usable(dd->pport + port - 1))
dusable = 1; pusable = 1;
else else
for (i = 0; i < dd->num_pports; i++) for (i = 0; i < dd->num_pports; i++)
if (usable(dd->pport + i)) if (usable(dd->pport + i))
dusable++; pusable++;
if (!dusable) if (!pusable)
continue; continue;
for (ctxt = dd->first_user_ctxt; ctxt < dd->cfgctxts; for (ctxt = dd->first_user_ctxt; ctxt < dd->cfgctxts;
ctxt++) ctxt++)
...@@ -1397,7 +1397,7 @@ static int get_a_ctxt(struct file *fp, const struct qib_user_info *uinfo, ...@@ -1397,7 +1397,7 @@ static int get_a_ctxt(struct file *fp, const struct qib_user_info *uinfo,
cused++; cused++;
else else
cfree++; cfree++;
if (cfree && cused < inuse) { if (pusable && cfree && cused < inuse) {
udd = dd; udd = dd;
inuse = cused; inuse = cused;
} }
......
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