diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/infiniband/hw/nes/nes_verbs.c | 44 |
1 files changed, 33 insertions, 11 deletions
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index ffdd141efe3e..a8c2193a0261 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c | |||
@@ -349,7 +349,7 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd, | |||
349 | if (nesfmr->nesmr.pbls_used > nesadapter->free_4kpbl) { | 349 | if (nesfmr->nesmr.pbls_used > nesadapter->free_4kpbl) { |
350 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); | 350 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); |
351 | ret = -ENOMEM; | 351 | ret = -ENOMEM; |
352 | goto failed_vpbl_alloc; | 352 | goto failed_vpbl_avail; |
353 | } else { | 353 | } else { |
354 | nesadapter->free_4kpbl -= nesfmr->nesmr.pbls_used; | 354 | nesadapter->free_4kpbl -= nesfmr->nesmr.pbls_used; |
355 | } | 355 | } |
@@ -357,7 +357,7 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd, | |||
357 | if (nesfmr->nesmr.pbls_used > nesadapter->free_256pbl) { | 357 | if (nesfmr->nesmr.pbls_used > nesadapter->free_256pbl) { |
358 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); | 358 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); |
359 | ret = -ENOMEM; | 359 | ret = -ENOMEM; |
360 | goto failed_vpbl_alloc; | 360 | goto failed_vpbl_avail; |
361 | } else { | 361 | } else { |
362 | nesadapter->free_256pbl -= nesfmr->nesmr.pbls_used; | 362 | nesadapter->free_256pbl -= nesfmr->nesmr.pbls_used; |
363 | } | 363 | } |
@@ -391,14 +391,14 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd, | |||
391 | goto failed_vpbl_alloc; | 391 | goto failed_vpbl_alloc; |
392 | } | 392 | } |
393 | 393 | ||
394 | nesfmr->root_vpbl.leaf_vpbl = kzalloc(sizeof(*nesfmr->root_vpbl.leaf_vpbl)*1024, GFP_KERNEL); | 394 | nesfmr->leaf_pbl_cnt = nesfmr->nesmr.pbls_used-1; |
395 | nesfmr->root_vpbl.leaf_vpbl = kzalloc(sizeof(*nesfmr->root_vpbl.leaf_vpbl)*1024, GFP_ATOMIC); | ||
395 | if (!nesfmr->root_vpbl.leaf_vpbl) { | 396 | if (!nesfmr->root_vpbl.leaf_vpbl) { |
396 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); | 397 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); |
397 | ret = -ENOMEM; | 398 | ret = -ENOMEM; |
398 | goto failed_leaf_vpbl_alloc; | 399 | goto failed_leaf_vpbl_alloc; |
399 | } | 400 | } |
400 | 401 | ||
401 | nesfmr->leaf_pbl_cnt = nesfmr->nesmr.pbls_used-1; | ||
402 | nes_debug(NES_DBG_MR, "two level pbl, root_vpbl.pbl_vbase=%p" | 402 | nes_debug(NES_DBG_MR, "two level pbl, root_vpbl.pbl_vbase=%p" |
403 | " leaf_pbl_cnt=%d root_vpbl.leaf_vpbl=%p\n", | 403 | " leaf_pbl_cnt=%d root_vpbl.leaf_vpbl=%p\n", |
404 | nesfmr->root_vpbl.pbl_vbase, nesfmr->leaf_pbl_cnt, nesfmr->root_vpbl.leaf_vpbl); | 404 | nesfmr->root_vpbl.pbl_vbase, nesfmr->leaf_pbl_cnt, nesfmr->root_vpbl.leaf_vpbl); |
@@ -519,6 +519,16 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd, | |||
519 | nesfmr->root_vpbl.pbl_pbase); | 519 | nesfmr->root_vpbl.pbl_pbase); |
520 | 520 | ||
521 | failed_vpbl_alloc: | 521 | failed_vpbl_alloc: |
522 | if (nesfmr->nesmr.pbls_used != 0) { | ||
523 | spin_lock_irqsave(&nesadapter->pbl_lock, flags); | ||
524 | if (nesfmr->nesmr.pbl_4k) | ||
525 | nesadapter->free_4kpbl += nesfmr->nesmr.pbls_used; | ||
526 | else | ||
527 | nesadapter->free_256pbl += nesfmr->nesmr.pbls_used; | ||
528 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); | ||
529 | } | ||
530 | |||
531 | failed_vpbl_avail: | ||
522 | kfree(nesfmr); | 532 | kfree(nesfmr); |
523 | 533 | ||
524 | failed_fmr_alloc: | 534 | failed_fmr_alloc: |
@@ -534,18 +544,14 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd, | |||
534 | */ | 544 | */ |
535 | static int nes_dealloc_fmr(struct ib_fmr *ibfmr) | 545 | static int nes_dealloc_fmr(struct ib_fmr *ibfmr) |
536 | { | 546 | { |
547 | unsigned long flags; | ||
537 | struct nes_mr *nesmr = to_nesmr_from_ibfmr(ibfmr); | 548 | struct nes_mr *nesmr = to_nesmr_from_ibfmr(ibfmr); |
538 | struct nes_fmr *nesfmr = to_nesfmr(nesmr); | 549 | struct nes_fmr *nesfmr = to_nesfmr(nesmr); |
539 | struct nes_vnic *nesvnic = to_nesvnic(ibfmr->device); | 550 | struct nes_vnic *nesvnic = to_nesvnic(ibfmr->device); |
540 | struct nes_device *nesdev = nesvnic->nesdev; | 551 | struct nes_device *nesdev = nesvnic->nesdev; |
541 | struct nes_mr temp_nesmr = *nesmr; | 552 | struct nes_adapter *nesadapter = nesdev->nesadapter; |
542 | int i = 0; | 553 | int i = 0; |
543 | 554 | ||
544 | temp_nesmr.ibmw.device = ibfmr->device; | ||
545 | temp_nesmr.ibmw.pd = ibfmr->pd; | ||
546 | temp_nesmr.ibmw.rkey = ibfmr->rkey; | ||
547 | temp_nesmr.ibmw.uobject = NULL; | ||
548 | |||
549 | /* free the resources */ | 555 | /* free the resources */ |
550 | if (nesfmr->leaf_pbl_cnt == 0) { | 556 | if (nesfmr->leaf_pbl_cnt == 0) { |
551 | /* single PBL case */ | 557 | /* single PBL case */ |
@@ -561,8 +567,24 @@ static int nes_dealloc_fmr(struct ib_fmr *ibfmr) | |||
561 | pci_free_consistent(nesdev->pcidev, 8192, nesfmr->root_vpbl.pbl_vbase, | 567 | pci_free_consistent(nesdev->pcidev, 8192, nesfmr->root_vpbl.pbl_vbase, |
562 | nesfmr->root_vpbl.pbl_pbase); | 568 | nesfmr->root_vpbl.pbl_pbase); |
563 | } | 569 | } |
570 | nesmr->ibmw.device = ibfmr->device; | ||
571 | nesmr->ibmw.pd = ibfmr->pd; | ||
572 | nesmr->ibmw.rkey = ibfmr->rkey; | ||
573 | nesmr->ibmw.uobject = NULL; | ||
574 | |||
575 | if (nesfmr->nesmr.pbls_used != 0) { | ||
576 | spin_lock_irqsave(&nesadapter->pbl_lock, flags); | ||
577 | if (nesfmr->nesmr.pbl_4k) { | ||
578 | nesadapter->free_4kpbl += nesfmr->nesmr.pbls_used; | ||
579 | WARN_ON(nesadapter->free_4kpbl > nesadapter->max_4kpbl); | ||
580 | } else { | ||
581 | nesadapter->free_256pbl += nesfmr->nesmr.pbls_used; | ||
582 | WARN_ON(nesadapter->free_256pbl > nesadapter->max_256pbl); | ||
583 | } | ||
584 | spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); | ||
585 | } | ||
564 | 586 | ||
565 | return nes_dealloc_mw(&temp_nesmr.ibmw); | 587 | return nes_dealloc_mw(&nesmr->ibmw); |
566 | } | 588 | } |
567 | 589 | ||
568 | 590 | ||