aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/cxgb3
diff options
context:
space:
mode:
authorStefani Seibold <stefani@seibold.net>2009-12-21 17:37:27 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-12-22 17:17:56 -0500
commitc1e13f25674ed564948ecb7dfe5f83e578892896 (patch)
tree24fac07b3e2b66dff01c3127b34077de1de4c101 /drivers/infiniband/hw/cxgb3
parent45465487897a1c6d508b14b904dc5777f7ec7e04 (diff)
kfifo: move out spinlock
Move the pointer to the spinlock out of struct kfifo. Most users in tree do not actually use a spinlock, so the few exceptions now have to call kfifo_{get,put}_locked, which takes an extra argument to a spinlock. Signed-off-by: Stefani Seibold <stefani@seibold.net> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Acked-by: Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by: Andi Kleen <ak@linux.intel.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/infiniband/hw/cxgb3')
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_resource.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/drivers/infiniband/hw/cxgb3/cxio_resource.c b/drivers/infiniband/hw/cxgb3/cxio_resource.c
index 65072bdfc1bf..98f24e6d906e 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_resource.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_resource.c
@@ -55,7 +55,7 @@ static int __cxio_init_resource_fifo(struct kfifo *fifo,
55 u32 rarray[16]; 55 u32 rarray[16];
56 spin_lock_init(fifo_lock); 56 spin_lock_init(fifo_lock);
57 57
58 if (kfifo_alloc(fifo, nr * sizeof(u32), GFP_KERNEL, fifo_lock)) 58 if (kfifo_alloc(fifo, nr * sizeof(u32), GFP_KERNEL))
59 return -ENOMEM; 59 return -ENOMEM;
60 60
61 for (i = 0; i < skip_low + skip_high; i++) 61 for (i = 0; i < skip_low + skip_high; i++)
@@ -86,7 +86,8 @@ static int __cxio_init_resource_fifo(struct kfifo *fifo,
86 __kfifo_put(fifo, (unsigned char *) &i, sizeof(u32)); 86 __kfifo_put(fifo, (unsigned char *) &i, sizeof(u32));
87 87
88 for (i = 0; i < skip_low + skip_high; i++) 88 for (i = 0; i < skip_low + skip_high; i++)
89 kfifo_get(fifo, (unsigned char *) &entry, sizeof(u32)); 89 kfifo_get_locked(fifo, (unsigned char *) &entry,
90 sizeof(u32), fifo_lock);
90 return 0; 91 return 0;
91} 92}
92 93
@@ -113,8 +114,7 @@ static int cxio_init_qpid_fifo(struct cxio_rdev *rdev_p)
113 spin_lock_init(&rdev_p->rscp->qpid_fifo_lock); 114 spin_lock_init(&rdev_p->rscp->qpid_fifo_lock);
114 115
115 if (kfifo_alloc(&rdev_p->rscp->qpid_fifo, T3_MAX_NUM_QP * sizeof(u32), 116 if (kfifo_alloc(&rdev_p->rscp->qpid_fifo, T3_MAX_NUM_QP * sizeof(u32),
116 GFP_KERNEL, 117 GFP_KERNEL))
117 &rdev_p->rscp->qpid_fifo_lock))
118 return -ENOMEM; 118 return -ENOMEM;
119 119
120 for (i = 16; i < T3_MAX_NUM_QP; i++) 120 for (i = 16; i < T3_MAX_NUM_QP; i++)
@@ -177,33 +177,37 @@ tpt_err:
177/* 177/*
178 * returns 0 if no resource available 178 * returns 0 if no resource available
179 */ 179 */
180static u32 cxio_hal_get_resource(struct kfifo *fifo) 180static u32 cxio_hal_get_resource(struct kfifo *fifo, spinlock_t * lock)
181{ 181{
182 u32 entry; 182 u32 entry;
183 if (kfifo_get(fifo, (unsigned char *) &entry, sizeof(u32))) 183 if (kfifo_get_locked(fifo, (unsigned char *) &entry, sizeof(u32), lock))
184 return entry; 184 return entry;
185 else 185 else
186 return 0; /* fifo emptry */ 186 return 0; /* fifo emptry */
187} 187}
188 188
189static void cxio_hal_put_resource(struct kfifo *fifo, u32 entry) 189static void cxio_hal_put_resource(struct kfifo *fifo, spinlock_t * lock,
190 u32 entry)
190{ 191{
191 BUG_ON(kfifo_put(fifo, (unsigned char *) &entry, sizeof(u32)) == 0); 192 BUG_ON(
193 kfifo_put_locked(fifo, (unsigned char *) &entry, sizeof(u32), lock)
194 == 0);
192} 195}
193 196
194u32 cxio_hal_get_stag(struct cxio_hal_resource *rscp) 197u32 cxio_hal_get_stag(struct cxio_hal_resource *rscp)
195{ 198{
196 return cxio_hal_get_resource(&rscp->tpt_fifo); 199 return cxio_hal_get_resource(&rscp->tpt_fifo, &rscp->tpt_fifo_lock);
197} 200}
198 201
199void cxio_hal_put_stag(struct cxio_hal_resource *rscp, u32 stag) 202void cxio_hal_put_stag(struct cxio_hal_resource *rscp, u32 stag)
200{ 203{
201 cxio_hal_put_resource(&rscp->tpt_fifo, stag); 204 cxio_hal_put_resource(&rscp->tpt_fifo, &rscp->tpt_fifo_lock, stag);
202} 205}
203 206
204u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp) 207u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp)
205{ 208{
206 u32 qpid = cxio_hal_get_resource(&rscp->qpid_fifo); 209 u32 qpid = cxio_hal_get_resource(&rscp->qpid_fifo,
210 &rscp->qpid_fifo_lock);
207 PDBG("%s qpid 0x%x\n", __func__, qpid); 211 PDBG("%s qpid 0x%x\n", __func__, qpid);
208 return qpid; 212 return qpid;
209} 213}
@@ -211,27 +215,27 @@ u32 cxio_hal_get_qpid(struct cxio_hal_resource *rscp)
211void cxio_hal_put_qpid(struct cxio_hal_resource *rscp, u32 qpid) 215void cxio_hal_put_qpid(struct cxio_hal_resource *rscp, u32 qpid)
212{ 216{
213 PDBG("%s qpid 0x%x\n", __func__, qpid); 217 PDBG("%s qpid 0x%x\n", __func__, qpid);
214 cxio_hal_put_resource(&rscp->qpid_fifo, qpid); 218 cxio_hal_put_resource(&rscp->qpid_fifo, &rscp->qpid_fifo_lock, qpid);
215} 219}
216 220
217u32 cxio_hal_get_cqid(struct cxio_hal_resource *rscp) 221u32 cxio_hal_get_cqid(struct cxio_hal_resource *rscp)
218{ 222{
219 return cxio_hal_get_resource(&rscp->cqid_fifo); 223 return cxio_hal_get_resource(&rscp->cqid_fifo, &rscp->cqid_fifo_lock);
220} 224}
221 225
222void cxio_hal_put_cqid(struct cxio_hal_resource *rscp, u32 cqid) 226void cxio_hal_put_cqid(struct cxio_hal_resource *rscp, u32 cqid)
223{ 227{
224 cxio_hal_put_resource(&rscp->cqid_fifo, cqid); 228 cxio_hal_put_resource(&rscp->cqid_fifo, &rscp->cqid_fifo_lock, cqid);
225} 229}
226 230
227u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp) 231u32 cxio_hal_get_pdid(struct cxio_hal_resource *rscp)
228{ 232{
229 return cxio_hal_get_resource(&rscp->pdid_fifo); 233 return cxio_hal_get_resource(&rscp->pdid_fifo, &rscp->pdid_fifo_lock);
230} 234}
231 235
232void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid) 236void cxio_hal_put_pdid(struct cxio_hal_resource *rscp, u32 pdid)
233{ 237{
234 cxio_hal_put_resource(&rscp->pdid_fifo, pdid); 238 cxio_hal_put_resource(&rscp->pdid_fifo, &rscp->pdid_fifo_lock, pdid);
235} 239}
236 240
237void cxio_hal_destroy_resource(struct cxio_hal_resource *rscp) 241void cxio_hal_destroy_resource(struct cxio_hal_resource *rscp)