aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband/hw/nes/nes_verbs.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2009-03-26 18:47:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-03-26 18:47:08 -0400
commit39b566eedbe9e35d38502cc5e62ef7abf1aff9c9 (patch)
tree114d963f3eb4e8aff401ed74ae0429aefc55c9fd /drivers/infiniband/hw/nes/nes_verbs.c
parent39f15003c7b268e4199d5ddce60a6944a74a14b7 (diff)
parent09f98bafea792644f2dea39eb080aa57d854f5b3 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/roland/infiniband: (30 commits) RDMA/cxgb3: Enforce required firmware IB/mlx4: Unregister IB device prior to CLOSE PORT command mlx4_core: Add link type autosensing mlx4_core: Don't perform SET_PORT command for Ethernet ports RDMA/nes: Handle MPA Reject message properly RDMA/nes: Improve use of PBLs RDMA/nes: Remove LLTX RDMA/nes: Inform hardware that asynchronous event has been handled RDMA/nes: Fix tmp_addr compilation warning RDMA/nes: Report correct vendor_id and vendor_part_id RDMA/nes: Update copyright to new legal entity and year RDMA/nes: Account for freed PBL after HW operation IB: Remove useless ibdev_is_alive() tests from sysfs code IB/sa_query: Fix AH leak due to update_sm_ah() race IB/mad: Fix ib_post_send_mad() returning 0 with no generate send comp IB/mad: initialize mad_agent_priv before putting on lists IB/mad: Fix null pointer dereference in local_completions() IB/mad: Fix RMPP header RRespTime manipulation IB/iser: Remove hard setting of path MTU mlx4_core: Add device IDs for MT25458 10GigE devices ...
Diffstat (limited to 'drivers/infiniband/hw/nes/nes_verbs.c')
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c249
1 files changed, 170 insertions, 79 deletions
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index d93a6562817c..7e5b5ba13a74 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 - 2008 NetEffect, Inc. All rights reserved. 2 * Copyright (c) 2006 - 2009 Intel-NE, Inc. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
@@ -551,6 +551,7 @@ static int nes_dealloc_fmr(struct ib_fmr *ibfmr)
551 struct nes_device *nesdev = nesvnic->nesdev; 551 struct nes_device *nesdev = nesvnic->nesdev;
552 struct nes_adapter *nesadapter = nesdev->nesadapter; 552 struct nes_adapter *nesadapter = nesdev->nesadapter;
553 int i = 0; 553 int i = 0;
554 int rc;
554 555
555 /* free the resources */ 556 /* free the resources */
556 if (nesfmr->leaf_pbl_cnt == 0) { 557 if (nesfmr->leaf_pbl_cnt == 0) {
@@ -572,7 +573,9 @@ static int nes_dealloc_fmr(struct ib_fmr *ibfmr)
572 nesmr->ibmw.rkey = ibfmr->rkey; 573 nesmr->ibmw.rkey = ibfmr->rkey;
573 nesmr->ibmw.uobject = NULL; 574 nesmr->ibmw.uobject = NULL;
574 575
575 if (nesfmr->nesmr.pbls_used != 0) { 576 rc = nes_dealloc_mw(&nesmr->ibmw);
577
578 if ((rc == 0) && (nesfmr->nesmr.pbls_used != 0)) {
576 spin_lock_irqsave(&nesadapter->pbl_lock, flags); 579 spin_lock_irqsave(&nesadapter->pbl_lock, flags);
577 if (nesfmr->nesmr.pbl_4k) { 580 if (nesfmr->nesmr.pbl_4k) {
578 nesadapter->free_4kpbl += nesfmr->nesmr.pbls_used; 581 nesadapter->free_4kpbl += nesfmr->nesmr.pbls_used;
@@ -584,7 +587,7 @@ static int nes_dealloc_fmr(struct ib_fmr *ibfmr)
584 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); 587 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
585 } 588 }
586 589
587 return nes_dealloc_mw(&nesmr->ibmw); 590 return rc;
588} 591}
589 592
590 593
@@ -1886,21 +1889,75 @@ static int nes_destroy_cq(struct ib_cq *ib_cq)
1886 return ret; 1889 return ret;
1887} 1890}
1888 1891
1892/**
1893 * root_256
1894 */
1895static u32 root_256(struct nes_device *nesdev,
1896 struct nes_root_vpbl *root_vpbl,
1897 struct nes_root_vpbl *new_root,
1898 u16 pbl_count_4k,
1899 u16 pbl_count_256)
1900{
1901 u64 leaf_pbl;
1902 int i, j, k;
1903
1904 if (pbl_count_4k == 1) {
1905 new_root->pbl_vbase = pci_alloc_consistent(nesdev->pcidev,
1906 512, &new_root->pbl_pbase);
1907
1908 if (new_root->pbl_vbase == NULL)
1909 return 0;
1910
1911 leaf_pbl = (u64)root_vpbl->pbl_pbase;
1912 for (i = 0; i < 16; i++) {
1913 new_root->pbl_vbase[i].pa_low =
1914 cpu_to_le32((u32)leaf_pbl);
1915 new_root->pbl_vbase[i].pa_high =
1916 cpu_to_le32((u32)((((u64)leaf_pbl) >> 32)));
1917 leaf_pbl += 256;
1918 }
1919 } else {
1920 for (i = 3; i >= 0; i--) {
1921 j = i * 16;
1922 root_vpbl->pbl_vbase[j] = root_vpbl->pbl_vbase[i];
1923 leaf_pbl = le32_to_cpu(root_vpbl->pbl_vbase[j].pa_low) +
1924 (((u64)le32_to_cpu(root_vpbl->pbl_vbase[j].pa_high))
1925 << 32);
1926 for (k = 1; k < 16; k++) {
1927 leaf_pbl += 256;
1928 root_vpbl->pbl_vbase[j + k].pa_low =
1929 cpu_to_le32((u32)leaf_pbl);
1930 root_vpbl->pbl_vbase[j + k].pa_high =
1931 cpu_to_le32((u32)((((u64)leaf_pbl) >> 32)));
1932 }
1933 }
1934 }
1935
1936 return 1;
1937}
1938
1889 1939
1890/** 1940/**
1891 * nes_reg_mr 1941 * nes_reg_mr
1892 */ 1942 */
1893static int nes_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd, 1943static int nes_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd,
1894 u32 stag, u64 region_length, struct nes_root_vpbl *root_vpbl, 1944 u32 stag, u64 region_length, struct nes_root_vpbl *root_vpbl,
1895 dma_addr_t single_buffer, u16 pbl_count, u16 residual_page_count, 1945 dma_addr_t single_buffer, u16 pbl_count_4k,
1896 int acc, u64 *iova_start) 1946 u16 residual_page_count_4k, int acc, u64 *iova_start,
1947 u16 *actual_pbl_cnt, u8 *used_4k_pbls)
1897{ 1948{
1898 struct nes_hw_cqp_wqe *cqp_wqe; 1949 struct nes_hw_cqp_wqe *cqp_wqe;
1899 struct nes_cqp_request *cqp_request; 1950 struct nes_cqp_request *cqp_request;
1900 unsigned long flags; 1951 unsigned long flags;
1901 int ret; 1952 int ret;
1902 struct nes_adapter *nesadapter = nesdev->nesadapter; 1953 struct nes_adapter *nesadapter = nesdev->nesadapter;
1903 /* int count; */ 1954 uint pg_cnt = 0;
1955 u16 pbl_count_256;
1956 u16 pbl_count = 0;
1957 u8 use_256_pbls = 0;
1958 u8 use_4k_pbls = 0;
1959 u16 use_two_level = (pbl_count_4k > 1) ? 1 : 0;
1960 struct nes_root_vpbl new_root = {0, 0, 0};
1904 u32 opcode = 0; 1961 u32 opcode = 0;
1905 u16 major_code; 1962 u16 major_code;
1906 1963
@@ -1913,41 +1970,70 @@ static int nes_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd,
1913 cqp_request->waiting = 1; 1970 cqp_request->waiting = 1;
1914 cqp_wqe = &cqp_request->cqp_wqe; 1971 cqp_wqe = &cqp_request->cqp_wqe;
1915 1972
1916 spin_lock_irqsave(&nesadapter->pbl_lock, flags); 1973 if (pbl_count_4k) {
1917 /* track PBL resources */ 1974 spin_lock_irqsave(&nesadapter->pbl_lock, flags);
1918 if (pbl_count != 0) { 1975
1919 if (pbl_count > 1) { 1976 pg_cnt = ((pbl_count_4k - 1) * 512) + residual_page_count_4k;
1920 /* Two level PBL */ 1977 pbl_count_256 = (pg_cnt + 31) / 32;
1921 if ((pbl_count+1) > nesadapter->free_4kpbl) { 1978 if (pg_cnt <= 32) {
1922 nes_debug(NES_DBG_MR, "Out of 4KB Pbls for two level request.\n"); 1979 if (pbl_count_256 <= nesadapter->free_256pbl)
1923 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); 1980 use_256_pbls = 1;
1924 nes_free_cqp_request(nesdev, cqp_request); 1981 else if (pbl_count_4k <= nesadapter->free_4kpbl)
1925 return -ENOMEM; 1982 use_4k_pbls = 1;
1926 } else { 1983 } else if (pg_cnt <= 2048) {
1927 nesadapter->free_4kpbl -= pbl_count+1; 1984 if (((pbl_count_4k + use_two_level) <= nesadapter->free_4kpbl) &&
1928 } 1985 (nesadapter->free_4kpbl > (nesadapter->max_4kpbl >> 1))) {
1929 } else if (residual_page_count > 32) { 1986 use_4k_pbls = 1;
1930 if (pbl_count > nesadapter->free_4kpbl) { 1987 } else if ((pbl_count_256 + 1) <= nesadapter->free_256pbl) {
1931 nes_debug(NES_DBG_MR, "Out of 4KB Pbls.\n"); 1988 use_256_pbls = 1;
1932 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); 1989 use_two_level = 1;
1933 nes_free_cqp_request(nesdev, cqp_request); 1990 } else if ((pbl_count_4k + use_two_level) <= nesadapter->free_4kpbl) {
1934 return -ENOMEM; 1991 use_4k_pbls = 1;
1935 } else {
1936 nesadapter->free_4kpbl -= pbl_count;
1937 } 1992 }
1938 } else { 1993 } else {
1939 if (pbl_count > nesadapter->free_256pbl) { 1994 if ((pbl_count_4k + 1) <= nesadapter->free_4kpbl)
1940 nes_debug(NES_DBG_MR, "Out of 256B Pbls.\n"); 1995 use_4k_pbls = 1;
1941 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
1942 nes_free_cqp_request(nesdev, cqp_request);
1943 return -ENOMEM;
1944 } else {
1945 nesadapter->free_256pbl -= pbl_count;
1946 }
1947 } 1996 }
1997
1998 if (use_256_pbls) {
1999 pbl_count = pbl_count_256;
2000 nesadapter->free_256pbl -= pbl_count + use_two_level;
2001 } else if (use_4k_pbls) {
2002 pbl_count = pbl_count_4k;
2003 nesadapter->free_4kpbl -= pbl_count + use_two_level;
2004 } else {
2005 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
2006 nes_debug(NES_DBG_MR, "Out of Pbls\n");
2007 nes_free_cqp_request(nesdev, cqp_request);
2008 return -ENOMEM;
2009 }
2010
2011 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
1948 } 2012 }
1949 2013
1950 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags); 2014 if (use_256_pbls && use_two_level) {
2015 if (root_256(nesdev, root_vpbl, &new_root, pbl_count_4k, pbl_count_256) == 1) {
2016 if (new_root.pbl_pbase != 0)
2017 root_vpbl = &new_root;
2018 } else {
2019 spin_lock_irqsave(&nesadapter->pbl_lock, flags);
2020 nesadapter->free_256pbl += pbl_count_256 + use_two_level;
2021 use_256_pbls = 0;
2022
2023 if (pbl_count_4k == 1)
2024 use_two_level = 0;
2025 pbl_count = pbl_count_4k;
2026
2027 if ((pbl_count_4k + use_two_level) <= nesadapter->free_4kpbl) {
2028 nesadapter->free_4kpbl -= pbl_count + use_two_level;
2029 use_4k_pbls = 1;
2030 }
2031 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
2032
2033 if (use_4k_pbls == 0)
2034 return -ENOMEM;
2035 }
2036 }
1951 2037
1952 opcode = NES_CQP_REGISTER_STAG | NES_CQP_STAG_RIGHTS_LOCAL_READ | 2038 opcode = NES_CQP_REGISTER_STAG | NES_CQP_STAG_RIGHTS_LOCAL_READ |
1953 NES_CQP_STAG_VA_TO | NES_CQP_STAG_MR; 2039 NES_CQP_STAG_VA_TO | NES_CQP_STAG_MR;
@@ -1976,10 +2062,9 @@ static int nes_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd,
1976 } else { 2062 } else {
1977 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_PA_LOW_IDX, root_vpbl->pbl_pbase); 2063 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_PA_LOW_IDX, root_vpbl->pbl_pbase);
1978 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_PBL_BLK_COUNT_IDX, pbl_count); 2064 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_PBL_BLK_COUNT_IDX, pbl_count);
1979 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_PBL_LEN_IDX, 2065 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_PBL_LEN_IDX, (pg_cnt * 8));
1980 (((pbl_count - 1) * 4096) + (residual_page_count*8)));
1981 2066
1982 if ((pbl_count > 1) || (residual_page_count > 32)) 2067 if (use_4k_pbls)
1983 cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX] |= cpu_to_le32(NES_CQP_STAG_PBL_BLK_SIZE); 2068 cqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX] |= cpu_to_le32(NES_CQP_STAG_PBL_BLK_SIZE);
1984 } 2069 }
1985 barrier(); 2070 barrier();
@@ -1996,13 +2081,25 @@ static int nes_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd,
1996 major_code = cqp_request->major_code; 2081 major_code = cqp_request->major_code;
1997 nes_put_cqp_request(nesdev, cqp_request); 2082 nes_put_cqp_request(nesdev, cqp_request);
1998 2083
2084 if ((!ret || major_code) && pbl_count != 0) {
2085 spin_lock_irqsave(&nesadapter->pbl_lock, flags);
2086 if (use_256_pbls)
2087 nesadapter->free_256pbl += pbl_count + use_two_level;
2088 else if (use_4k_pbls)
2089 nesadapter->free_4kpbl += pbl_count + use_two_level;
2090 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
2091 }
2092 if (new_root.pbl_pbase)
2093 pci_free_consistent(nesdev->pcidev, 512, new_root.pbl_vbase,
2094 new_root.pbl_pbase);
2095
1999 if (!ret) 2096 if (!ret)
2000 return -ETIME; 2097 return -ETIME;
2001 else if (major_code) 2098 else if (major_code)
2002 return -EIO; 2099 return -EIO;
2003 else
2004 return 0;
2005 2100
2101 *actual_pbl_cnt = pbl_count + use_two_level;
2102 *used_4k_pbls = use_4k_pbls;
2006 return 0; 2103 return 0;
2007} 2104}
2008 2105
@@ -2167,18 +2264,14 @@ static struct ib_mr *nes_reg_phys_mr(struct ib_pd *ib_pd,
2167 pbl_count = root_pbl_index; 2264 pbl_count = root_pbl_index;
2168 } 2265 }
2169 ret = nes_reg_mr(nesdev, nespd, stag, region_length, &root_vpbl, 2266 ret = nes_reg_mr(nesdev, nespd, stag, region_length, &root_vpbl,
2170 buffer_list[0].addr, pbl_count, (u16)cur_pbl_index, acc, iova_start); 2267 buffer_list[0].addr, pbl_count, (u16)cur_pbl_index, acc, iova_start,
2268 &nesmr->pbls_used, &nesmr->pbl_4k);
2171 2269
2172 if (ret == 0) { 2270 if (ret == 0) {
2173 nesmr->ibmr.rkey = stag; 2271 nesmr->ibmr.rkey = stag;
2174 nesmr->ibmr.lkey = stag; 2272 nesmr->ibmr.lkey = stag;
2175 nesmr->mode = IWNES_MEMREG_TYPE_MEM; 2273 nesmr->mode = IWNES_MEMREG_TYPE_MEM;
2176 ibmr = &nesmr->ibmr; 2274 ibmr = &nesmr->ibmr;
2177 nesmr->pbl_4k = ((pbl_count > 1) || (cur_pbl_index > 32)) ? 1 : 0;
2178 nesmr->pbls_used = pbl_count;
2179 if (pbl_count > 1) {
2180 nesmr->pbls_used++;
2181 }
2182 } else { 2275 } else {
2183 kfree(nesmr); 2276 kfree(nesmr);
2184 ibmr = ERR_PTR(-ENOMEM); 2277 ibmr = ERR_PTR(-ENOMEM);
@@ -2456,8 +2549,9 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
2456 stag, (unsigned int)iova_start, 2549 stag, (unsigned int)iova_start,
2457 (unsigned int)region_length, stag_index, 2550 (unsigned int)region_length, stag_index,
2458 (unsigned long long)region->length, pbl_count); 2551 (unsigned long long)region->length, pbl_count);
2459 ret = nes_reg_mr( nesdev, nespd, stag, region->length, &root_vpbl, 2552 ret = nes_reg_mr(nesdev, nespd, stag, region->length, &root_vpbl,
2460 first_dma_addr, pbl_count, (u16)cur_pbl_index, acc, &iova_start); 2553 first_dma_addr, pbl_count, (u16)cur_pbl_index, acc,
2554 &iova_start, &nesmr->pbls_used, &nesmr->pbl_4k);
2461 2555
2462 nes_debug(NES_DBG_MR, "ret=%d\n", ret); 2556 nes_debug(NES_DBG_MR, "ret=%d\n", ret);
2463 2557
@@ -2466,11 +2560,6 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
2466 nesmr->ibmr.lkey = stag; 2560 nesmr->ibmr.lkey = stag;
2467 nesmr->mode = IWNES_MEMREG_TYPE_MEM; 2561 nesmr->mode = IWNES_MEMREG_TYPE_MEM;
2468 ibmr = &nesmr->ibmr; 2562 ibmr = &nesmr->ibmr;
2469 nesmr->pbl_4k = ((pbl_count > 1) || (cur_pbl_index > 32)) ? 1 : 0;
2470 nesmr->pbls_used = pbl_count;
2471 if (pbl_count > 1) {
2472 nesmr->pbls_used++;
2473 }
2474 } else { 2563 } else {
2475 ib_umem_release(region); 2564 ib_umem_release(region);
2476 kfree(nesmr); 2565 kfree(nesmr);
@@ -2609,24 +2698,6 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
2609 cqp_request->waiting = 1; 2698 cqp_request->waiting = 1;
2610 cqp_wqe = &cqp_request->cqp_wqe; 2699 cqp_wqe = &cqp_request->cqp_wqe;
2611 2700
2612 spin_lock_irqsave(&nesadapter->pbl_lock, flags);
2613 if (nesmr->pbls_used != 0) {
2614 if (nesmr->pbl_4k) {
2615 nesadapter->free_4kpbl += nesmr->pbls_used;
2616 if (nesadapter->free_4kpbl > nesadapter->max_4kpbl) {
2617 printk(KERN_ERR PFX "free 4KB PBLs(%u) has exceeded the max(%u)\n",
2618 nesadapter->free_4kpbl, nesadapter->max_4kpbl);
2619 }
2620 } else {
2621 nesadapter->free_256pbl += nesmr->pbls_used;
2622 if (nesadapter->free_256pbl > nesadapter->max_256pbl) {
2623 printk(KERN_ERR PFX "free 256B PBLs(%u) has exceeded the max(%u)\n",
2624 nesadapter->free_256pbl, nesadapter->max_256pbl);
2625 }
2626 }
2627 }
2628
2629 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
2630 nes_fill_init_cqp_wqe(cqp_wqe, nesdev); 2701 nes_fill_init_cqp_wqe(cqp_wqe, nesdev);
2631 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_OPCODE_IDX, 2702 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_OPCODE_IDX,
2632 NES_CQP_DEALLOCATE_STAG | NES_CQP_STAG_VA_TO | 2703 NES_CQP_DEALLOCATE_STAG | NES_CQP_STAG_VA_TO |
@@ -2644,11 +2715,6 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
2644 " CQP Major:Minor codes = 0x%04X:0x%04X\n", 2715 " CQP Major:Minor codes = 0x%04X:0x%04X\n",
2645 ib_mr->rkey, ret, cqp_request->major_code, cqp_request->minor_code); 2716 ib_mr->rkey, ret, cqp_request->major_code, cqp_request->minor_code);
2646 2717
2647 nes_free_resource(nesadapter, nesadapter->allocated_mrs,
2648 (ib_mr->rkey & 0x0fffff00) >> 8);
2649
2650 kfree(nesmr);
2651
2652 major_code = cqp_request->major_code; 2718 major_code = cqp_request->major_code;
2653 minor_code = cqp_request->minor_code; 2719 minor_code = cqp_request->minor_code;
2654 2720
@@ -2664,8 +2730,33 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
2664 " to destroy STag, ib_mr=%p, rkey = 0x%08X\n", 2730 " to destroy STag, ib_mr=%p, rkey = 0x%08X\n",
2665 major_code, minor_code, ib_mr, ib_mr->rkey); 2731 major_code, minor_code, ib_mr, ib_mr->rkey);
2666 return -EIO; 2732 return -EIO;
2667 } else 2733 }
2668 return 0; 2734
2735 if (nesmr->pbls_used != 0) {
2736 spin_lock_irqsave(&nesadapter->pbl_lock, flags);
2737 if (nesmr->pbl_4k) {
2738 nesadapter->free_4kpbl += nesmr->pbls_used;
2739 if (nesadapter->free_4kpbl > nesadapter->max_4kpbl)
2740 printk(KERN_ERR PFX "free 4KB PBLs(%u) has "
2741 "exceeded the max(%u)\n",
2742 nesadapter->free_4kpbl,
2743 nesadapter->max_4kpbl);
2744 } else {
2745 nesadapter->free_256pbl += nesmr->pbls_used;
2746 if (nesadapter->free_256pbl > nesadapter->max_256pbl)
2747 printk(KERN_ERR PFX "free 256B PBLs(%u) has "
2748 "exceeded the max(%u)\n",
2749 nesadapter->free_256pbl,
2750 nesadapter->max_256pbl);
2751 }
2752 spin_unlock_irqrestore(&nesadapter->pbl_lock, flags);
2753 }
2754 nes_free_resource(nesadapter, nesadapter->allocated_mrs,
2755 (ib_mr->rkey & 0x0fffff00) >> 8);
2756
2757 kfree(nesmr);
2758
2759 return 0;
2669} 2760}
2670 2761
2671 2762