aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/mthca/mthca_memfree.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/infiniband/hw/mthca/mthca_memfree.c')
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c36
1 files changed, 18 insertions, 18 deletions
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index 9fb985a016e9..d709cb162a72 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -50,7 +50,7 @@ enum {
50}; 50};
51 51
52struct mthca_user_db_table { 52struct mthca_user_db_table {
53 struct semaphore mutex; 53 struct mutex mutex;
54 struct { 54 struct {
55 u64 uvirt; 55 u64 uvirt;
56 struct scatterlist mem; 56 struct scatterlist mem;
@@ -158,7 +158,7 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob
158 int ret = 0; 158 int ret = 0;
159 u8 status; 159 u8 status;
160 160
161 down(&table->mutex); 161 mutex_lock(&table->mutex);
162 162
163 if (table->icm[i]) { 163 if (table->icm[i]) {
164 ++table->icm[i]->refcount; 164 ++table->icm[i]->refcount;
@@ -184,7 +184,7 @@ int mthca_table_get(struct mthca_dev *dev, struct mthca_icm_table *table, int ob
184 ++table->icm[i]->refcount; 184 ++table->icm[i]->refcount;
185 185
186out: 186out:
187 up(&table->mutex); 187 mutex_unlock(&table->mutex);
188 return ret; 188 return ret;
189} 189}
190 190
@@ -198,7 +198,7 @@ void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int o
198 198
199 i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE; 199 i = (obj & (table->num_obj - 1)) * table->obj_size / MTHCA_TABLE_CHUNK_SIZE;
200 200
201 down(&table->mutex); 201 mutex_lock(&table->mutex);
202 202
203 if (--table->icm[i]->refcount == 0) { 203 if (--table->icm[i]->refcount == 0) {
204 mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE, 204 mthca_UNMAP_ICM(dev, table->virt + i * MTHCA_TABLE_CHUNK_SIZE,
@@ -207,7 +207,7 @@ void mthca_table_put(struct mthca_dev *dev, struct mthca_icm_table *table, int o
207 table->icm[i] = NULL; 207 table->icm[i] = NULL;
208 } 208 }
209 209
210 up(&table->mutex); 210 mutex_unlock(&table->mutex);
211} 211}
212 212
213void *mthca_table_find(struct mthca_icm_table *table, int obj) 213void *mthca_table_find(struct mthca_icm_table *table, int obj)
@@ -220,7 +220,7 @@ void *mthca_table_find(struct mthca_icm_table *table, int obj)
220 if (!table->lowmem) 220 if (!table->lowmem)
221 return NULL; 221 return NULL;
222 222
223 down(&table->mutex); 223 mutex_lock(&table->mutex);
224 224
225 idx = (obj & (table->num_obj - 1)) * table->obj_size; 225 idx = (obj & (table->num_obj - 1)) * table->obj_size;
226 icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE]; 226 icm = table->icm[idx / MTHCA_TABLE_CHUNK_SIZE];
@@ -240,7 +240,7 @@ void *mthca_table_find(struct mthca_icm_table *table, int obj)
240 } 240 }
241 241
242out: 242out:
243 up(&table->mutex); 243 mutex_unlock(&table->mutex);
244 return page ? lowmem_page_address(page) + offset : NULL; 244 return page ? lowmem_page_address(page) + offset : NULL;
245} 245}
246 246
@@ -301,7 +301,7 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
301 table->num_obj = nobj; 301 table->num_obj = nobj;
302 table->obj_size = obj_size; 302 table->obj_size = obj_size;
303 table->lowmem = use_lowmem; 303 table->lowmem = use_lowmem;
304 init_MUTEX(&table->mutex); 304 mutex_init(&table->mutex);
305 305
306 for (i = 0; i < num_icm; ++i) 306 for (i = 0; i < num_icm; ++i)
307 table->icm[i] = NULL; 307 table->icm[i] = NULL;
@@ -380,7 +380,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
380 if (index < 0 || index > dev->uar_table.uarc_size / 8) 380 if (index < 0 || index > dev->uar_table.uarc_size / 8)
381 return -EINVAL; 381 return -EINVAL;
382 382
383 down(&db_tab->mutex); 383 mutex_lock(&db_tab->mutex);
384 384
385 i = index / MTHCA_DB_REC_PER_PAGE; 385 i = index / MTHCA_DB_REC_PER_PAGE;
386 386
@@ -424,7 +424,7 @@ int mthca_map_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
424 db_tab->page[i].refcount = 1; 424 db_tab->page[i].refcount = 1;
425 425
426out: 426out:
427 up(&db_tab->mutex); 427 mutex_unlock(&db_tab->mutex);
428 return ret; 428 return ret;
429} 429}
430 430
@@ -439,11 +439,11 @@ void mthca_unmap_user_db(struct mthca_dev *dev, struct mthca_uar *uar,
439 * pages until we clean up the whole db table. 439 * pages until we clean up the whole db table.
440 */ 440 */
441 441
442 down(&db_tab->mutex); 442 mutex_lock(&db_tab->mutex);
443 443
444 --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount; 444 --db_tab->page[index / MTHCA_DB_REC_PER_PAGE].refcount;
445 445
446 up(&db_tab->mutex); 446 mutex_unlock(&db_tab->mutex);
447} 447}
448 448
449struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev) 449struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev)
@@ -460,7 +460,7 @@ struct mthca_user_db_table *mthca_init_user_db_tab(struct mthca_dev *dev)
460 if (!db_tab) 460 if (!db_tab)
461 return ERR_PTR(-ENOMEM); 461 return ERR_PTR(-ENOMEM);
462 462
463 init_MUTEX(&db_tab->mutex); 463 mutex_init(&db_tab->mutex);
464 for (i = 0; i < npages; ++i) { 464 for (i = 0; i < npages; ++i) {
465 db_tab->page[i].refcount = 0; 465 db_tab->page[i].refcount = 0;
466 db_tab->page[i].uvirt = 0; 466 db_tab->page[i].uvirt = 0;
@@ -499,7 +499,7 @@ int mthca_alloc_db(struct mthca_dev *dev, enum mthca_db_type type,
499 int ret = 0; 499 int ret = 0;
500 u8 status; 500 u8 status;
501 501
502 down(&dev->db_tab->mutex); 502 mutex_lock(&dev->db_tab->mutex);
503 503
504 switch (type) { 504 switch (type) {
505 case MTHCA_DB_TYPE_CQ_ARM: 505 case MTHCA_DB_TYPE_CQ_ARM:
@@ -585,7 +585,7 @@ found:
585 *db = (__be32 *) &page->db_rec[j]; 585 *db = (__be32 *) &page->db_rec[j];
586 586
587out: 587out:
588 up(&dev->db_tab->mutex); 588 mutex_unlock(&dev->db_tab->mutex);
589 589
590 return ret; 590 return ret;
591} 591}
@@ -601,7 +601,7 @@ void mthca_free_db(struct mthca_dev *dev, int type, int db_index)
601 601
602 page = dev->db_tab->page + i; 602 page = dev->db_tab->page + i;
603 603
604 down(&dev->db_tab->mutex); 604 mutex_lock(&dev->db_tab->mutex);
605 605
606 page->db_rec[j] = 0; 606 page->db_rec[j] = 0;
607 if (i >= dev->db_tab->min_group2) 607 if (i >= dev->db_tab->min_group2)
@@ -624,7 +624,7 @@ void mthca_free_db(struct mthca_dev *dev, int type, int db_index)
624 ++dev->db_tab->min_group2; 624 ++dev->db_tab->min_group2;
625 } 625 }
626 626
627 up(&dev->db_tab->mutex); 627 mutex_unlock(&dev->db_tab->mutex);
628} 628}
629 629
630int mthca_init_db_tab(struct mthca_dev *dev) 630int mthca_init_db_tab(struct mthca_dev *dev)
@@ -638,7 +638,7 @@ int mthca_init_db_tab(struct mthca_dev *dev)
638 if (!dev->db_tab) 638 if (!dev->db_tab)
639 return -ENOMEM; 639 return -ENOMEM;
640 640
641 init_MUTEX(&dev->db_tab->mutex); 641 mutex_init(&dev->db_tab->mutex);
642 642
643 dev->db_tab->npages = dev->uar_table.uarc_size / 4096; 643 dev->db_tab->npages = dev->uar_table.uarc_size / 4096;
644 dev->db_tab->max_group1 = 0; 644 dev->db_tab->max_group1 = 0;