Commit 53ab1c64 authored by Mike Marciniszyn's avatar Mike Marciniszyn Committed by Roland Dreier

IB/qib: Correct nfreectxts for multiple HCAs

The code that was recently introduced to report the number
of free contexts is flawed for multiple HCAs:

       /* Return the number of free user ports (contexts) available. */
       return scnprintf(buf, PAGE_SIZE, "%u\n", dd->cfgctxts -
                dd->first_user_ctxt - (u32)qib_stats.sps_ctxts);

The qib_stats is global to the module, not per HCA, so the code is broken
for multiple HCAs.

This patch adds a qib_devdata field, freectxts, that reflects the free
contexts for this HCA.
Signed-off-by: default avatarMike Marciniszyn <mike.marciniszyn@qlogic.com>
Reviewed-by: default avatarRam Vepa <ram.vepa@qlogic.com>
Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
parent 976d1676
...@@ -807,6 +807,10 @@ struct qib_devdata { ...@@ -807,6 +807,10 @@ struct qib_devdata {
* supports, less gives more pio bufs/ctxt, etc. * supports, less gives more pio bufs/ctxt, etc.
*/ */
u32 cfgctxts; u32 cfgctxts;
/*
* number of ctxts available for PSM open
*/
u32 freectxts;
/* /*
* hint that we should update pioavailshadow before * hint that we should update pioavailshadow before
......
...@@ -1284,6 +1284,7 @@ static int setup_ctxt(struct qib_pportdata *ppd, int ctxt, ...@@ -1284,6 +1284,7 @@ static int setup_ctxt(struct qib_pportdata *ppd, int ctxt,
strlcpy(rcd->comm, current->comm, sizeof(rcd->comm)); strlcpy(rcd->comm, current->comm, sizeof(rcd->comm));
ctxt_fp(fp) = rcd; ctxt_fp(fp) = rcd;
qib_stats.sps_ctxts++; qib_stats.sps_ctxts++;
dd->freectxts++;
ret = 0; ret = 0;
goto bail; goto bail;
...@@ -1792,6 +1793,7 @@ static int qib_close(struct inode *in, struct file *fp) ...@@ -1792,6 +1793,7 @@ static int qib_close(struct inode *in, struct file *fp)
if (dd->pageshadow) if (dd->pageshadow)
unlock_expected_tids(rcd); unlock_expected_tids(rcd);
qib_stats.sps_ctxts--; qib_stats.sps_ctxts--;
dd->freectxts--;
} }
mutex_unlock(&qib_mutex); mutex_unlock(&qib_mutex);
......
...@@ -398,6 +398,7 @@ static void enable_chip(struct qib_devdata *dd) ...@@ -398,6 +398,7 @@ static void enable_chip(struct qib_devdata *dd)
if (rcd) if (rcd)
dd->f_rcvctrl(rcd->ppd, rcvmask, i); dd->f_rcvctrl(rcd->ppd, rcvmask, i);
} }
dd->freectxts = dd->cfgctxts - dd->first_user_ctxt;
} }
static void verify_interrupt(unsigned long opaque) static void verify_interrupt(unsigned long opaque)
......
...@@ -515,8 +515,7 @@ static ssize_t show_nfreectxts(struct device *device, ...@@ -515,8 +515,7 @@ static ssize_t show_nfreectxts(struct device *device,
struct qib_devdata *dd = dd_from_dev(dev); struct qib_devdata *dd = dd_from_dev(dev);
/* Return the number of free user ports (contexts) available. */ /* Return the number of free user ports (contexts) available. */
return scnprintf(buf, PAGE_SIZE, "%u\n", dd->cfgctxts - return scnprintf(buf, PAGE_SIZE, "%u\n", dd->freectxts);
dd->first_user_ctxt - (u32)qib_stats.sps_ctxts);
} }
static ssize_t show_serial(struct device *device, static ssize_t show_serial(struct device *device,
......
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