[ofw] [RFC] [PATCH] uvp/ci_umv_buf: always allocate uvp buffer
Sean Hefty
sean.hefty at intel.com
Wed Jun 18 23:31:12 PDT 2008
FYI, I've added the following patch to the patches directly in the winverbs branch.
This is compile tested only, but I was seeing application crashes over winverbs
related to this issue. If there's a reason for these checks, please let me know.
---
The UVP controls the ci_umv_buf, but does 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 at intel.com>
---
diff -up trunk\hw\mthca\user/mlnx_ual_av.c branches\winverbs\hw\mthca\user/mlnx_ual_av.c
--- trunk\hw\mthca\user/mlnx_ual_av.c 2008-05-20 00:30:00.036125000 -0700
+++ branches\winverbs\hw\mthca\user/mlnx_ual_av.c 2008-06-18 22:58:54.296875000 -0700
@@ -168,13 +168,11 @@ __pre_create_av (
}
// allocate parameters
- if( !p_umv_buf->p_inout_buf ) {
- p_umv_buf->p_inout_buf = cl_zalloc( size );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_mem;
- }
+ p_umv_buf->p_inout_buf = cl_zalloc( size );
+ if( !p_umv_buf->p_inout_buf )
+ {
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_mem;
}
// fill the parameters
diff -up trunk\hw\mthca\user/mlnx_ual_ca.c branches\winverbs\hw\mthca\user/mlnx_ual_ca.c
--- trunk\hw\mthca\user/mlnx_ual_ca.c 2008-05-05 09:47:15.842125000 -0700
+++ branches\winverbs\hw\mthca\user/mlnx_ual_ca.c 2008-06-18 22:58:54.203125000 -0700
@@ -55,14 +55,11 @@ __pre_open_ca (
UVP_ENTER(UVP_DBG_SHIM);
if( p_umv_buf )
{
+ p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_get_context_resp) );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_get_context_resp) );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_memory;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_memory;
}
p_umv_buf->input_size = p_umv_buf->output_size = sizeof(struct ibv_get_context_resp);
p_umv_buf->command = TRUE;
diff -up trunk\hw\mthca\user/mlnx_ual_cq.c branches\winverbs\hw\mthca\user/mlnx_ual_cq.c
--- trunk\hw\mthca\user/mlnx_ual_cq.c 2008-05-05 09:47:15.904625000 -0700
+++ branches\winverbs\hw\mthca\user/mlnx_ual_cq.c 2008-06-18 22:58:54.125000000 -0700
@@ -62,14 +62,11 @@ __pre_create_cq (
CL_ASSERT(p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_zalloc( size );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_zalloc( size );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_memory;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_memory;
}
p_umv_buf->input_size = sizeof(struct ibv_create_cq);
p_umv_buf->output_size = sizeof(struct ibv_create_cq_resp);
diff -up trunk\hw\mthca\user/mlnx_ual_pd.c branches\winverbs\hw\mthca\user/mlnx_ual_pd.c
--- trunk\hw\mthca\user/mlnx_ual_pd.c 2008-05-05 09:47:15.779625000 -0700
+++ branches\winverbs\hw\mthca\user/mlnx_ual_pd.c 2008-06-18 22:58:54.062500000 -0700
@@ -54,14 +54,11 @@ __pre_allocate_pd (
CL_ASSERT(p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_alloc_pd_resp) );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_alloc_pd_resp) );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_memory;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_memory;
}
p_umv_buf->input_size = p_umv_buf->output_size = sizeof(struct ibv_alloc_pd_resp);
p_umv_buf->command = TRUE;
diff -up trunk\hw\mthca\user/mlnx_ual_qp.c branches\winverbs\hw\mthca\user/mlnx_ual_qp.c
--- trunk\hw\mthca\user/mlnx_ual_qp.c 2008-06-18 22:53:44.015625000 -0700
+++ branches\winverbs\hw\mthca\user/mlnx_ual_qp.c 2008-06-18 22:58:53.984375000 -0700
@@ -99,14 +99,11 @@ __pre_create_qp (
CL_ASSERT(p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_zalloc( size );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_zalloc( size );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_memory;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_memory;
}
p_umv_buf->input_size = sizeof(struct ibv_create_qp);
p_umv_buf->output_size = sizeof(struct ibv_create_qp_resp);
@@ -224,14 +221,11 @@ __pre_modify_qp (
CL_ASSERT(p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_modify_qp_resp) );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_modify_qp_resp) );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_memory;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_memory;
}
p_umv_buf->input_size = 0;
p_umv_buf->output_size = sizeof(struct ibv_modify_qp_resp);
diff -up trunk\hw\mthca\user/mlnx_ual_srq.c branches\winverbs\hw\mthca\user/mlnx_ual_srq.c
--- trunk\hw\mthca\user/mlnx_ual_srq.c 2008-05-05 09:47:16.123375000 -0700
+++ branches\winverbs\hw\mthca\user/mlnx_ual_srq.c 2008-06-18 22:58:53.843750000 -0700
@@ -96,14 +96,11 @@ __pre_create_srq (
goto err_params;
}
+ p_umv_buf->p_inout_buf = cl_zalloc( size );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_zalloc( size );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_memory;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_memory;
}
p_umv_buf->input_size = sizeof(struct ibv_create_srq);
p_umv_buf->output_size = sizeof(struct ibv_create_srq_resp);
--- trunk\hw\mlx4\user\hca\verbs.c 2008-06-18 22:53:44.000000000 -0700
+++ branches\winverbs\hw\mlx4\user\hca\verbs.c 2008-06-18 23:17:03.453125000 -0700
@@ -59,14 +59,11 @@ mlx4_pre_open_ca (
if( p_umv_buf )
{
+ p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_get_context_resp) );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_zalloc( sizeof(struct ibv_get_context_resp) );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto end;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto end;
}
p_umv_buf->input_size = 0;
p_umv_buf->output_size = sizeof(struct ibv_get_context_resp);
@@ -233,14 +230,11 @@ mlx4_pre_alloc_pd (
CL_ASSERT(context && p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_malloc( sizeof(struct ibv_alloc_pd_resp) );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_malloc( sizeof(struct ibv_alloc_pd_resp) );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto end;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto end;
}
p_umv_buf->input_size = 0;
p_umv_buf->output_size = sizeof(struct ibv_alloc_pd_resp);
@@ -333,14 +327,11 @@ mlx4_pre_create_cq (
CL_ASSERT(h_uvp_ca && p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_malloc( size );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_malloc( size );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_umv_buf;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_umv_buf;
}
p_umv_buf->input_size = sizeof(struct ibv_create_cq);
p_umv_buf->output_size = sizeof(struct ibv_create_cq_resp);
@@ -492,14 +483,11 @@ mlx4_pre_create_srq (
CL_ASSERT(p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_malloc( size );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_malloc( size );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_memory;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_memory;
}
p_umv_buf->input_size = sizeof(struct ibv_create_srq);
p_umv_buf->output_size = sizeof(struct ibv_create_srq_resp);
@@ -694,14 +682,11 @@ mlx4_pre_create_qp (
CL_ASSERT(p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_malloc(size);
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_malloc(size);
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_memory;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_memory;
}
p_umv_buf->input_size = sizeof(struct ibv_create_qp);
p_umv_buf->output_size = sizeof(struct ibv_create_qp_resp);
@@ -947,14 +932,11 @@ mlx4_pre_modify_qp (
CL_ASSERT(p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_malloc(sizeof(struct ibv_modify_qp_resp));
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_malloc(sizeof(struct ibv_modify_qp_resp));
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_memory;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_memory;
}
p_umv_buf->input_size = 0;
p_umv_buf->output_size = sizeof(struct ibv_modify_qp_resp);
@@ -1415,14 +1397,11 @@ mlx4_pre_create_xrc_srq (
CL_ASSERT(p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_malloc( size );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_malloc( size );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_memory;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_memory;
}
p_umv_buf->input_size = sizeof(struct ibv_create_srq);
p_umv_buf->output_size = sizeof(struct ibv_create_srq_resp);
@@ -1551,14 +1530,11 @@ mlx4_pre_open_xrc_domain (
CL_ASSERT(h_uvp_ca && p_umv_buf);
+ p_umv_buf->p_inout_buf = cl_malloc( size );
if( !p_umv_buf->p_inout_buf )
{
- p_umv_buf->p_inout_buf = cl_malloc( size );
- if( !p_umv_buf->p_inout_buf )
- {
- status = IB_INSUFFICIENT_MEMORY;
- goto err_umv_buf;
- }
+ status = IB_INSUFFICIENT_MEMORY;
+ goto err_umv_buf;
}
p_umv_buf->input_size = sizeof(struct ibv_open_xrc_domain);
p_umv_buf->output_size = sizeof(struct ibv_open_xrc_domain_resp);
More information about the ofw
mailing list