diff options
author | Mike Marciniszyn <mike.marciniszyn@qlogic.com> | 2011-10-06 12:33:35 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2011-10-06 12:33:35 -0400 |
commit | 53ab1c6498371723c31b18400fab10a902a15a63 (patch) | |
tree | df710c8c65b897c6738263f976da825d00e406af /drivers/infiniband | |
parent | 976d167615b64e14bc1491ca51d424e2ba9a5e84 (diff) |
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: Mike Marciniszyn <mike.marciniszyn@qlogic.com>
Reviewed-by: Ram Vepa <ram.vepa@qlogic.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/qib/qib.h | 4 | ||||
-rw-r--r-- | drivers/infiniband/hw/qib/qib_file_ops.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/qib/qib_init.c | 1 | ||||
-rw-r--r-- | drivers/infiniband/hw/qib/qib_sysfs.c | 3 |
4 files changed, 8 insertions, 2 deletions
diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h index c9624ea87209..ee993e725d38 100644 --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h | |||
@@ -807,6 +807,10 @@ struct qib_devdata { | |||
807 | * supports, less gives more pio bufs/ctxt, etc. | 807 | * supports, less gives more pio bufs/ctxt, etc. |
808 | */ | 808 | */ |
809 | u32 cfgctxts; | 809 | u32 cfgctxts; |
810 | /* | ||
811 | * number of ctxts available for PSM open | ||
812 | */ | ||
813 | u32 freectxts; | ||
810 | 814 | ||
811 | /* | 815 | /* |
812 | * hint that we should update pioavailshadow before | 816 | * hint that we should update pioavailshadow before |
diff --git a/drivers/infiniband/hw/qib/qib_file_ops.c b/drivers/infiniband/hw/qib/qib_file_ops.c index 26253039d2c7..77633666f81c 100644 --- a/drivers/infiniband/hw/qib/qib_file_ops.c +++ b/drivers/infiniband/hw/qib/qib_file_ops.c | |||
@@ -1284,6 +1284,7 @@ static int setup_ctxt(struct qib_pportdata *ppd, int ctxt, | |||
1284 | strlcpy(rcd->comm, current->comm, sizeof(rcd->comm)); | 1284 | strlcpy(rcd->comm, current->comm, sizeof(rcd->comm)); |
1285 | ctxt_fp(fp) = rcd; | 1285 | ctxt_fp(fp) = rcd; |
1286 | qib_stats.sps_ctxts++; | 1286 | qib_stats.sps_ctxts++; |
1287 | dd->freectxts++; | ||
1287 | ret = 0; | 1288 | ret = 0; |
1288 | goto bail; | 1289 | goto bail; |
1289 | 1290 | ||
@@ -1792,6 +1793,7 @@ static int qib_close(struct inode *in, struct file *fp) | |||
1792 | if (dd->pageshadow) | 1793 | if (dd->pageshadow) |
1793 | unlock_expected_tids(rcd); | 1794 | unlock_expected_tids(rcd); |
1794 | qib_stats.sps_ctxts--; | 1795 | qib_stats.sps_ctxts--; |
1796 | dd->freectxts--; | ||
1795 | } | 1797 | } |
1796 | 1798 | ||
1797 | mutex_unlock(&qib_mutex); | 1799 | mutex_unlock(&qib_mutex); |
diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index a01f3fce8eb3..021636dbeae6 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c | |||
@@ -398,6 +398,7 @@ static void enable_chip(struct qib_devdata *dd) | |||
398 | if (rcd) | 398 | if (rcd) |
399 | dd->f_rcvctrl(rcd->ppd, rcvmask, i); | 399 | dd->f_rcvctrl(rcd->ppd, rcvmask, i); |
400 | } | 400 | } |
401 | dd->freectxts = dd->cfgctxts - dd->first_user_ctxt; | ||
401 | } | 402 | } |
402 | 403 | ||
403 | static void verify_interrupt(unsigned long opaque) | 404 | static void verify_interrupt(unsigned long opaque) |
diff --git a/drivers/infiniband/hw/qib/qib_sysfs.c b/drivers/infiniband/hw/qib/qib_sysfs.c index 14d129de4320..78fbd56879d4 100644 --- a/drivers/infiniband/hw/qib/qib_sysfs.c +++ b/drivers/infiniband/hw/qib/qib_sysfs.c | |||
@@ -515,8 +515,7 @@ static ssize_t show_nfreectxts(struct device *device, | |||
515 | struct qib_devdata *dd = dd_from_dev(dev); | 515 | struct qib_devdata *dd = dd_from_dev(dev); |
516 | 516 | ||
517 | /* Return the number of free user ports (contexts) available. */ | 517 | /* Return the number of free user ports (contexts) available. */ |
518 | return scnprintf(buf, PAGE_SIZE, "%u\n", dd->cfgctxts - | 518 | return scnprintf(buf, PAGE_SIZE, "%u\n", dd->freectxts); |
519 | dd->first_user_ctxt - (u32)qib_stats.sps_ctxts); | ||
520 | } | 519 | } |
521 | 520 | ||
522 | static ssize_t show_serial(struct device *device, | 521 | static ssize_t show_serial(struct device *device, |