uvp/ci_umv_buf: always allocate uvp buffer
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 23 Jul 2008 21:08:13 +0000 (21:08 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 23 Jul 2008 21:08:13 +0000 (21:08 +0000)
The UVP controls the ci_umv_buf, but does not allocate the p_inout_buf if it
is non-zero.  However, the uvp frees the buffer later.  It should always
allocate the buffer, since the caller does not know the required size and
cannot allocate it on the uvp's behalf.  This avoids an unneeded
initialization by the caller, and the if check by the uvp.

Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@1441 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

hw/mlx4/user/hca/verbs.c
hw/mthca/user/mlnx_ual_av.c
hw/mthca/user/mlnx_ual_ca.c
hw/mthca/user/mlnx_ual_cq.c
hw/mthca/user/mlnx_ual_pd.c
hw/mthca/user/mlnx_ual_qp.c
hw/mthca/user/mlnx_ual_srq.c

index df46f5d..e7c6b4e 100644 (file)
@@ -57,15 +57,11 @@ mlx4_pre_open_ca (
        \r
        if( p_umv_buf )\r
        {\r
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( sizeof(struct ibv_get_context_resp) );\r
                if( !p_umv_buf->p_inout_buf )\r
                {\r
-                       p_umv_buf->p_inout_buf =\r
-                               (ULONG_PTR)cl_zalloc( sizeof(struct ibv_get_context_resp) );\r
-                       if( !p_umv_buf->p_inout_buf )\r
-                       {\r
-                               status = IB_INSUFFICIENT_MEMORY;\r
-                               goto end;\r
-                       }\r
+                       status = IB_INSUFFICIENT_MEMORY;\r
+                       goto end;\r
                }\r
                p_umv_buf->input_size = 0;\r
                p_umv_buf->output_size = sizeof(struct ibv_get_context_resp);\r
@@ -232,14 +228,11 @@ mlx4_pre_alloc_pd (
 \r
        CL_ASSERT(context && p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc( sizeof(struct ibv_alloc_pd_resp) );\r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc( sizeof(struct ibv_alloc_pd_resp) );\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto end;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto end;\r
        }\r
        p_umv_buf->input_size = 0;\r
        p_umv_buf->output_size = sizeof(struct ibv_alloc_pd_resp);\r
@@ -332,14 +325,11 @@ mlx4_pre_create_cq (
 \r
        CL_ASSERT(h_uvp_ca && p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc( size );\r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc( size );\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_umv_buf;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_umv_buf;\r
        }\r
        p_umv_buf->input_size = sizeof(struct ibv_create_cq);\r
        p_umv_buf->output_size = sizeof(struct ibv_create_cq_resp);\r
@@ -489,14 +479,11 @@ mlx4_pre_create_srq (
 \r
        CL_ASSERT(p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc( size ); \r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc( size ); \r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_memory;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_memory;\r
        }\r
        p_umv_buf->input_size = sizeof(struct ibv_create_srq);\r
        p_umv_buf->output_size = sizeof(struct ibv_create_srq_resp);\r
@@ -691,14 +678,11 @@ mlx4_pre_create_qp (
 \r
        CL_ASSERT(p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc(size);\r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc(size);\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_memory;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_memory;\r
        }\r
        p_umv_buf->input_size = sizeof(struct ibv_create_qp);\r
        p_umv_buf->output_size = sizeof(struct ibv_create_qp_resp);\r
@@ -944,14 +928,11 @@ mlx4_pre_modify_qp (
 \r
        CL_ASSERT(p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc(sizeof(struct ibv_modify_qp_resp));\r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_malloc(sizeof(struct ibv_modify_qp_resp));\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_memory;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_memory;\r
        }\r
        p_umv_buf->input_size = 0;\r
        p_umv_buf->output_size = sizeof(struct ibv_modify_qp_resp);\r
@@ -1412,14 +1393,11 @@ mlx4_pre_create_xrc_srq (
 \r
        CL_ASSERT(p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = cl_malloc( size ); \r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = cl_malloc( size ); \r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_memory;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_memory;\r
        }\r
        p_umv_buf->input_size = sizeof(struct ibv_create_srq);\r
        p_umv_buf->output_size = sizeof(struct ibv_create_srq_resp);\r
@@ -1548,14 +1526,11 @@ mlx4_pre_open_xrc_domain (
 \r
        CL_ASSERT(h_uvp_ca && p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = cl_malloc( size );\r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = cl_malloc( size );\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_umv_buf;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_umv_buf;\r
        }\r
        p_umv_buf->input_size = sizeof(struct ibv_open_xrc_domain);\r
        p_umv_buf->output_size = sizeof(struct ibv_open_xrc_domain_resp);\r
index 0b3208b..25c8ebd 100644 (file)
@@ -169,13 +169,11 @@ __pre_create_av (
        }\r
 \r
        // allocate parameters\r
-       if( !p_umv_buf->p_inout_buf ) {\r
-               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_mem;\r
-               }\r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );\r
+       if( !p_umv_buf->p_inout_buf )\r
+       {\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_mem;\r
        }\r
 \r
        // fill the parameters\r
index c178687..dc73169 100644 (file)
@@ -56,15 +56,11 @@ __pre_open_ca (
        UVP_ENTER(UVP_DBG_SHIM);\r
        if( p_umv_buf )\r
        {\r
+               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( sizeof(struct ibv_get_context_resp) );\r
                if( !p_umv_buf->p_inout_buf )\r
                {\r
-                       p_umv_buf->p_inout_buf =\r
-                               (ULONG_PTR)cl_zalloc( sizeof(struct ibv_get_context_resp) );\r
-                       if( !p_umv_buf->p_inout_buf )\r
-                       {\r
-                               status = IB_INSUFFICIENT_MEMORY;\r
-                               goto err_memory;\r
-                       }\r
+                       status = IB_INSUFFICIENT_MEMORY;\r
+                       goto err_memory;\r
                }\r
                p_umv_buf->input_size = p_umv_buf->output_size = sizeof(struct ibv_get_context_resp);\r
                p_umv_buf->command = TRUE;\r
index 198c16e..a99c6e7 100644 (file)
@@ -63,14 +63,11 @@ __pre_create_cq (
 \r
        CL_ASSERT(p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );\r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_memory;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_memory;\r
        }\r
        p_umv_buf->input_size = sizeof(struct ibv_create_cq);\r
        p_umv_buf->output_size = sizeof(struct ibv_create_cq_resp);\r
index a7665a3..2b53f75 100644 (file)
@@ -55,14 +55,11 @@ __pre_allocate_pd (
 \r
        CL_ASSERT(p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( sizeof(struct ibv_alloc_pd_resp) );\r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( sizeof(struct ibv_alloc_pd_resp) );\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_memory;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_memory;\r
        }\r
        p_umv_buf->input_size = p_umv_buf->output_size = sizeof(struct ibv_alloc_pd_resp);\r
        p_umv_buf->command = TRUE;\r
index 23293b6..5379215 100644 (file)
@@ -98,14 +98,11 @@ __pre_create_qp (
 \r
        CL_ASSERT(p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );\r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_memory;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_memory;\r
        }\r
        p_umv_buf->input_size = sizeof(struct ibv_create_qp);\r
        p_umv_buf->output_size = sizeof(struct ibv_create_qp_resp);\r
@@ -223,15 +220,11 @@ __pre_modify_qp (
 \r
        CL_ASSERT(p_umv_buf);\r
 \r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( sizeof(struct ibv_modify_qp_resp) );\r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf =\r
-                       (ULONG_PTR)cl_zalloc( sizeof(struct ibv_modify_qp_resp) );\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_memory;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_memory;\r
        }\r
        p_umv_buf->input_size = 0;\r
        p_umv_buf->output_size = sizeof(struct ibv_modify_qp_resp);\r
index fc09058..7d5ff1d 100644 (file)
@@ -93,14 +93,11 @@ __pre_create_srq (
                goto err_params;\r
        }\r
 \r
+       p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );\r
        if( !p_umv_buf->p_inout_buf )\r
        {\r
-               p_umv_buf->p_inout_buf = (ULONG_PTR)cl_zalloc( size );\r
-               if( !p_umv_buf->p_inout_buf )\r
-               {\r
-                       status = IB_INSUFFICIENT_MEMORY;\r
-                       goto err_memory;\r
-               }\r
+               status = IB_INSUFFICIENT_MEMORY;\r
+               goto err_memory;\r
        }\r
        p_umv_buf->input_size = sizeof(struct ibv_create_srq);\r
        p_umv_buf->output_size = sizeof(struct ibv_create_srq_resp);\r