Commit 463e6ebc authored by Mitko Haralanov's avatar Mitko Haralanov Committed by Doug Ledford

staging/hfi1: Convert lock to mutex

The exp_lock lock does not need to be a spinlock as
all its uses are in process context and allowing the
process to sleep when the mutex is contended might
be beneficial.
Signed-off-by: default avatarMitko Haralanov <mitko.haralanov@intel.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent f88e0c8a
...@@ -1611,14 +1611,14 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo) ...@@ -1611,14 +1611,14 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo)
* reserved, we don't need the lock anymore since we * reserved, we don't need the lock anymore since we
* are guaranteed the groups. * are guaranteed the groups.
*/ */
spin_lock(&uctxt->exp_lock); mutex_lock(&uctxt->exp_lock);
if (uctxt->tidusemap[useidx] == -1ULL || if (uctxt->tidusemap[useidx] == -1ULL ||
bitidx >= BITS_PER_LONG) { bitidx >= BITS_PER_LONG) {
/* no free groups in the set, use the next */ /* no free groups in the set, use the next */
useidx = (useidx + 1) % uctxt->tidmapcnt; useidx = (useidx + 1) % uctxt->tidmapcnt;
idx++; idx++;
bitidx = 0; bitidx = 0;
spin_unlock(&uctxt->exp_lock); mutex_unlock(&uctxt->exp_lock);
continue; continue;
} }
ngroups = ((npages - mapped) / dd->rcv_entries.group_size) + ngroups = ((npages - mapped) / dd->rcv_entries.group_size) +
...@@ -1635,13 +1635,13 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo) ...@@ -1635,13 +1635,13 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo)
* as 0 because we don't check the entire bitmap but * as 0 because we don't check the entire bitmap but
* we start from bitidx. * we start from bitidx.
*/ */
spin_unlock(&uctxt->exp_lock); mutex_unlock(&uctxt->exp_lock);
continue; continue;
} }
bits_used = min(free, ngroups); bits_used = min(free, ngroups);
tidmap[useidx] |= ((1ULL << bits_used) - 1) << bitidx; tidmap[useidx] |= ((1ULL << bits_used) - 1) << bitidx;
uctxt->tidusemap[useidx] |= tidmap[useidx]; uctxt->tidusemap[useidx] |= tidmap[useidx];
spin_unlock(&uctxt->exp_lock); mutex_unlock(&uctxt->exp_lock);
/* /*
* At this point, we know where in the map we have free bits. * At this point, we know where in the map we have free bits.
...@@ -1677,10 +1677,10 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo) ...@@ -1677,10 +1677,10 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo)
* Let go of the bits that we reserved since we are not * Let go of the bits that we reserved since we are not
* going to use them. * going to use them.
*/ */
spin_lock(&uctxt->exp_lock); mutex_lock(&uctxt->exp_lock);
uctxt->tidusemap[useidx] &= uctxt->tidusemap[useidx] &=
~(((1ULL << bits_used) - 1) << bitidx); ~(((1ULL << bits_used) - 1) << bitidx);
spin_unlock(&uctxt->exp_lock); mutex_unlock(&uctxt->exp_lock);
goto done; goto done;
} }
/* /*
......
...@@ -258,7 +258,7 @@ struct hfi1_ctxtdata { ...@@ -258,7 +258,7 @@ struct hfi1_ctxtdata {
struct exp_tid_set tid_full_list; struct exp_tid_set tid_full_list;
/* lock protecting all Expected TID data */ /* lock protecting all Expected TID data */
spinlock_t exp_lock; struct mutex exp_lock;
/* number of pio bufs for this ctxt (all procs, if shared) */ /* number of pio bufs for this ctxt (all procs, if shared) */
u32 piocnt; u32 piocnt;
/* first pio buffer for this ctxt */ /* first pio buffer for this ctxt */
......
...@@ -227,7 +227,7 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt) ...@@ -227,7 +227,7 @@ struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt)
rcd->numa_id = numa_node_id(); rcd->numa_id = numa_node_id();
rcd->rcv_array_groups = dd->rcv_entries.ngroups; rcd->rcv_array_groups = dd->rcv_entries.ngroups;
spin_lock_init(&rcd->exp_lock); mutex_init(&rcd->exp_lock);
/* /*
* Calculate the context's RcvArray entry starting point. * Calculate the context's RcvArray entry starting point.
......
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