diff mbox series

[12/19] RDMA/siw: Introduce siw_free_cm_id

Message ID 20231009071801.10210-13-guoqing.jiang@linux.dev (mailing list archive)
State Superseded
Headers show
Series Cleanup for siw | expand

Commit Message

Guoqing Jiang Oct. 9, 2023, 7:17 a.m. UTC
Factor out a helper to simplify code.

Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
---
 drivers/infiniband/sw/siw/siw_cm.c | 36 +++++++++++++-----------------
 1 file changed, 16 insertions(+), 20 deletions(-)

Comments

kernel test robot Oct. 9, 2023, 9:02 a.m. UTC | #1
Hi Guoqing,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.6-rc5 next-20231009]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Guoqing-Jiang/RDMA-siw-Introduce-siw_get_page/20231009-152705
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
patch link:    https://lore.kernel.org/r/20231009071801.10210-13-guoqing.jiang%40linux.dev
patch subject: [PATCH 12/19] RDMA/siw: Introduce siw_free_cm_id
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20231009/202310091656.JlrmcNXB-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231009/202310091656.JlrmcNXB-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310091656.JlrmcNXB-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/infiniband/sw/siw/siw_cm.c:367:6: warning: no previous prototype for 'siw_free_cm_id' [-Wmissing-prototypes]
     367 | void siw_free_cm_id(struct siw_cep *cep, bool put_cep)
         |      ^~~~~~~~~~~~~~


vim +/siw_free_cm_id +367 drivers/infiniband/sw/siw/siw_cm.c

   366	
 > 367	void siw_free_cm_id(struct siw_cep *cep, bool put_cep)
   368	{
   369		if (!cep->cm_id)
   370			return;
   371	
   372		cep->cm_id->rem_ref(cep->cm_id);
   373		cep->cm_id = NULL;
   374		if (put_cep)
   375			siw_cep_put(cep);
   376	}
   377
kernel test robot Oct. 9, 2023, 2:39 p.m. UTC | #2
Hi Guoqing,

kernel test robot noticed the following build warnings:

[auto build test WARNING on rdma/for-next]
[also build test WARNING on linus/master v6.6-rc5 next-20231009]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Guoqing-Jiang/RDMA-siw-Introduce-siw_get_page/20231009-152705
base:   https://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git for-next
patch link:    https://lore.kernel.org/r/20231009071801.10210-13-guoqing.jiang%40linux.dev
patch subject: [PATCH 12/19] RDMA/siw: Introduce siw_free_cm_id
config: x86_64-randconfig-071-20231009 (https://download.01.org/0day-ci/archive/20231009/202310092226.zEUwIrFa-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20231009/202310092226.zEUwIrFa-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202310092226.zEUwIrFa-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/infiniband/sw/siw/siw_cm.c:367:6: warning: no previous declaration for 'siw_free_cm_id' [-Wmissing-declarations]
    void siw_free_cm_id(struct siw_cep *cep, bool put_cep)
         ^~~~~~~~~~~~~~


vim +/siw_free_cm_id +367 drivers/infiniband/sw/siw/siw_cm.c

   366	
 > 367	void siw_free_cm_id(struct siw_cep *cep, bool put_cep)
   368	{
   369		if (!cep->cm_id)
   370			return;
   371	
   372		cep->cm_id->rem_ref(cep->cm_id);
   373		cep->cm_id = NULL;
   374		if (put_cep)
   375			siw_cep_put(cep);
   376	}
   377
Bernard Metzler Oct. 25, 2023, 1:02 p.m. UTC | #3
> -----Original Message-----
> From: Guoqing Jiang <guoqing.jiang@linux.dev>
> Sent: Monday, October 9, 2023 9:18 AM
> To: Bernard Metzler <BMT@zurich.ibm.com>; jgg@ziepe.ca; leon@kernel.org
> Cc: linux-rdma@vger.kernel.org
> Subject: [EXTERNAL] [PATCH 12/19] RDMA/siw: Introduce siw_free_cm_id
> 
> Factor out a helper to simplify code.
> 
> Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
> ---
>  drivers/infiniband/sw/siw/siw_cm.c | 36 +++++++++++++-----------------
>  1 file changed, 16 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/siw/siw_cm.c
> b/drivers/infiniband/sw/siw/siw_cm.c
> index 2f338bb3a24c..987084828786 100644
> --- a/drivers/infiniband/sw/siw/siw_cm.c
> +++ b/drivers/infiniband/sw/siw/siw_cm.c
> @@ -364,6 +364,17 @@ static int siw_cm_upcall(struct siw_cep *cep, enum
> iw_cm_event_type reason,
>  	return id->event_handler(id, &event);
>  }
> 
> +void siw_free_cm_id(struct siw_cep *cep, bool put_cep)
> +{
> +	if (!cep->cm_id)
> +		return;
> +
> +	cep->cm_id->rem_ref(cep->cm_id);
> +	cep->cm_id = NULL;

I suggest not including cep_put() here, but to keep
cep reference counting explicit in the code.

> +	if (put_cep)
> +		siw_cep_put(cep);
> +}
> +
>  /*
>   * siw_qp_cm_drop()
>   *
> @@ -415,9 +426,7 @@ void siw_qp_cm_drop(struct siw_qp *qp, int schedule)
>  			default:
>  				break;
>  			}
> -			cep->cm_id->rem_ref(cep->cm_id);
> -			cep->cm_id = NULL;
> -			siw_cep_put(cep);
> +			siw_free_cm_id(cep, true);
>  		}
>  		cep->state = SIW_EPSTATE_CLOSED;
> 
> @@ -1175,11 +1184,7 @@ static void siw_cm_work_handler(struct work_struct
> *w)
>  			sock_release(cep->sock);
>  			cep->sock = NULL;
>  		}
> -		if (cep->cm_id) {
> -			cep->cm_id->rem_ref(cep->cm_id);
> -			cep->cm_id = NULL;
> -			siw_cep_put(cep);
> -		}
> +		siw_free_cm_id(cep, true);
>  	}
>  	siw_cep_set_free(cep);
>  	siw_put_work(work);
> @@ -1702,10 +1707,7 @@ int siw_accept(struct iw_cm_id *id, struct
> iw_cm_conn_param *params)
> 
>  	cep->state = SIW_EPSTATE_CLOSED;
> 
> -	if (cep->cm_id) {
> -		cep->cm_id->rem_ref(id);
> -		cep->cm_id = NULL;
> -	}
> +	siw_free_cm_id(cep, false);
>  	if (qp->cep) {
>  		siw_cep_put(cep);
>  		qp->cep = NULL;
> @@ -1880,10 +1882,7 @@ int siw_create_listen(struct iw_cm_id *id, int
> backlog)
>  	if (cep) {
>  		siw_cep_set_inuse(cep);
> 
> -		if (cep->cm_id) {
> -			cep->cm_id->rem_ref(cep->cm_id);
> -			cep->cm_id = NULL;
> -		}
> +		siw_free_cm_id(cep, false);
>  		cep->sock = NULL;
>  		siw_socket_disassoc(s);
>  		cep->state = SIW_EPSTATE_CLOSED;
> @@ -1912,10 +1911,7 @@ static void siw_drop_listeners(struct iw_cm_id *id)
> 
>  		siw_cep_set_inuse(cep);
> 
> -		if (cep->cm_id) {
> -			cep->cm_id->rem_ref(cep->cm_id);
> -			cep->cm_id = NULL;
> -		}
> +		siw_free_cm_id(cep, false);
>  		if (cep->sock) {
>  			siw_socket_disassoc(cep->sock);
>  			sock_release(cep->sock);
> --
> 2.35.3
Guoqing Jiang Oct. 26, 2023, 6:41 a.m. UTC | #4
On 10/25/23 21:02, Bernard Metzler wrote:
>> -----Original Message-----
>> From: Guoqing Jiang<guoqing.jiang@linux.dev>
>> Sent: Monday, October 9, 2023 9:18 AM
>> To: Bernard Metzler<BMT@zurich.ibm.com>;jgg@ziepe.ca;leon@kernel.org
>> Cc:linux-rdma@vger.kernel.org
>> Subject: [EXTERNAL] [PATCH 12/19] RDMA/siw: Introduce siw_free_cm_id
>>
>> Factor out a helper to simplify code.
>>
>> Signed-off-by: Guoqing Jiang<guoqing.jiang@linux.dev>
>> ---
>>   drivers/infiniband/sw/siw/siw_cm.c | 36 +++++++++++++-----------------
>>   1 file changed, 16 insertions(+), 20 deletions(-)
>>
>> diff --git a/drivers/infiniband/sw/siw/siw_cm.c
>> b/drivers/infiniband/sw/siw/siw_cm.c
>> index 2f338bb3a24c..987084828786 100644
>> --- a/drivers/infiniband/sw/siw/siw_cm.c
>> +++ b/drivers/infiniband/sw/siw/siw_cm.c
>> @@ -364,6 +364,17 @@ static int siw_cm_upcall(struct siw_cep *cep, enum
>> iw_cm_event_type reason,
>>   	return id->event_handler(id, &event);
>>   }
>>
>> +void siw_free_cm_id(struct siw_cep *cep, bool put_cep)
>> +{
>> +	if (!cep->cm_id)
>> +		return;
>> +
>> +	cep->cm_id->rem_ref(cep->cm_id);
>> +	cep->cm_id = NULL;
> I suggest not including cep_put() here, but to keep
> cep reference counting explicit in the code.
>
>> +	if (put_cep)
>> +		siw_cep_put(cep);
>> +}

Ok, will remove it in next version.

Thanks,
Guoqing
diff mbox series

Patch

diff --git a/drivers/infiniband/sw/siw/siw_cm.c b/drivers/infiniband/sw/siw/siw_cm.c
index 2f338bb3a24c..987084828786 100644
--- a/drivers/infiniband/sw/siw/siw_cm.c
+++ b/drivers/infiniband/sw/siw/siw_cm.c
@@ -364,6 +364,17 @@  static int siw_cm_upcall(struct siw_cep *cep, enum iw_cm_event_type reason,
 	return id->event_handler(id, &event);
 }
 
+void siw_free_cm_id(struct siw_cep *cep, bool put_cep)
+{
+	if (!cep->cm_id)
+		return;
+
+	cep->cm_id->rem_ref(cep->cm_id);
+	cep->cm_id = NULL;
+	if (put_cep)
+		siw_cep_put(cep);
+}
+
 /*
  * siw_qp_cm_drop()
  *
@@ -415,9 +426,7 @@  void siw_qp_cm_drop(struct siw_qp *qp, int schedule)
 			default:
 				break;
 			}
-			cep->cm_id->rem_ref(cep->cm_id);
-			cep->cm_id = NULL;
-			siw_cep_put(cep);
+			siw_free_cm_id(cep, true);
 		}
 		cep->state = SIW_EPSTATE_CLOSED;
 
@@ -1175,11 +1184,7 @@  static void siw_cm_work_handler(struct work_struct *w)
 			sock_release(cep->sock);
 			cep->sock = NULL;
 		}
-		if (cep->cm_id) {
-			cep->cm_id->rem_ref(cep->cm_id);
-			cep->cm_id = NULL;
-			siw_cep_put(cep);
-		}
+		siw_free_cm_id(cep, true);
 	}
 	siw_cep_set_free(cep);
 	siw_put_work(work);
@@ -1702,10 +1707,7 @@  int siw_accept(struct iw_cm_id *id, struct iw_cm_conn_param *params)
 
 	cep->state = SIW_EPSTATE_CLOSED;
 
-	if (cep->cm_id) {
-		cep->cm_id->rem_ref(id);
-		cep->cm_id = NULL;
-	}
+	siw_free_cm_id(cep, false);
 	if (qp->cep) {
 		siw_cep_put(cep);
 		qp->cep = NULL;
@@ -1880,10 +1882,7 @@  int siw_create_listen(struct iw_cm_id *id, int backlog)
 	if (cep) {
 		siw_cep_set_inuse(cep);
 
-		if (cep->cm_id) {
-			cep->cm_id->rem_ref(cep->cm_id);
-			cep->cm_id = NULL;
-		}
+		siw_free_cm_id(cep, false);
 		cep->sock = NULL;
 		siw_socket_disassoc(s);
 		cep->state = SIW_EPSTATE_CLOSED;
@@ -1912,10 +1911,7 @@  static void siw_drop_listeners(struct iw_cm_id *id)
 
 		siw_cep_set_inuse(cep);
 
-		if (cep->cm_id) {
-			cep->cm_id->rem_ref(cep->cm_id);
-			cep->cm_id = NULL;
-		}
+		siw_free_cm_id(cep, false);
 		if (cep->sock) {
 			siw_socket_disassoc(cep->sock);
 			sock_release(cep->sock);