[v8,09/12] vdpa/ifc: change some driver logic

Message ID 1666094871-25721-10-git-send-email-andy.pei@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series vdpa/ifc: add multi queue support |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Pei, Andy Oct. 18, 2022, 12:07 p.m. UTC
  Insert internal list element to internal list before
register vdpa device, in order to call vdpa ops during
vdpa device registration.

Signed-off-by: Andy Pei <andy.pei@intel.com>
---
 drivers/vdpa/ifc/ifcvf_vdpa.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
  

Comments

Maxime Coquelin Oct. 18, 2022, 1:57 p.m. UTC | #1
On 10/18/22 14:07, Andy Pei wrote:
> Insert internal list element to internal list before
> register vdpa device, in order to call vdpa ops during
> vdpa device registration.
> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>   drivers/vdpa/ifc/ifcvf_vdpa.c | 11 +++++++----
>   1 file changed, 7 insertions(+), 4 deletions(-)
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime
  
Pei, Andy Oct. 18, 2022, 2:01 p.m. UTC | #2
Hi Maxime,

Thanks.

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Tuesday, October 18, 2022 9:57 PM
> To: Pei, Andy <andy.pei@intel.com>; dev@dpdk.org
> Cc: Xia, Chenbo <Chenbo.Xia@intel.com>; Xu, Rosen <rosen.xu@intel.com>;
> Huang, Wei <wei.huang@intel.com>; Cao, Gang <gang.cao@intel.com>
> Subject: Re: [PATCH v8 09/12] vdpa/ifc: change some driver logic
> 
> 
> 
> On 10/18/22 14:07, Andy Pei wrote:
> > Insert internal list element to internal list before register vdpa
> > device, in order to call vdpa ops during vdpa device registration.
> >
> > Signed-off-by: Andy Pei <andy.pei@intel.com>
> > ---
> >   drivers/vdpa/ifc/ifcvf_vdpa.c | 11 +++++++----
> >   1 file changed, 7 insertions(+), 4 deletions(-)
> >
> 
> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> 
> Thanks,
> Maxime
  
Chenbo Xia Oct. 19, 2022, 9:13 a.m. UTC | #3
> -----Original Message-----
> From: Pei, Andy <andy.pei@intel.com>
> Sent: Tuesday, October 18, 2022 8:08 PM
> To: dev@dpdk.org
> Cc: Xia, Chenbo <chenbo.xia@intel.com>; Xu, Rosen <rosen.xu@intel.com>;
> Huang, Wei <wei.huang@intel.com>; Cao, Gang <gang.cao@intel.com>;
> maxime.coquelin@redhat.com
> Subject: [PATCH v8 09/12] vdpa/ifc: change some driver logic
> 
> Insert internal list element to internal list before
> register vdpa device, in order to call vdpa ops during
> vdpa device registration.

Patch seems good but title may be too general..

Maybe: improve internal list logic ?

Thanks,
Chenbo

> 
> Signed-off-by: Andy Pei <andy.pei@intel.com>
> ---
>  drivers/vdpa/ifc/ifcvf_vdpa.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
> index c16e263..8dfd493 100644
> --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> @@ -1737,17 +1737,20 @@ struct rte_vdpa_dev_info dev_info[] = {
>  	}
>  	internal->sw_lm = sw_fallback_lm;
> 
> +	pthread_mutex_lock(&internal_list_lock);
> +	TAILQ_INSERT_TAIL(&internal_list, list, next);
> +	pthread_mutex_unlock(&internal_list_lock);
> +
>  	internal->vdev = rte_vdpa_register_device(&pci_dev->device,
>  				dev_info[internal->hw.device_type].ops);
>  	if (internal->vdev == NULL) {
>  		DRV_LOG(ERR, "failed to register device %s", pci_dev->name);
> +		pthread_mutex_lock(&internal_list_lock);
> +		TAILQ_REMOVE(&internal_list, list, next);
> +		pthread_mutex_unlock(&internal_list_lock);
>  		goto error;
>  	}
> 
> -	pthread_mutex_lock(&internal_list_lock);
> -	TAILQ_INSERT_TAIL(&internal_list, list, next);
> -	pthread_mutex_unlock(&internal_list_lock);
> -
>  	rte_atomic32_set(&internal->started, 1);
>  	update_datapath(internal);
> 
> --
> 1.8.3.1
  
Pei, Andy Oct. 19, 2022, 9:21 a.m. UTC | #4
Hi Chenbo,

Thanks for your review, I will send v9 to do this.

> -----Original Message-----
> From: Xia, Chenbo <chenbo.xia@intel.com>
> Sent: Wednesday, October 19, 2022 5:13 PM
> To: Pei, Andy <andy.pei@intel.com>; dev@dpdk.org
> Cc: Xu, Rosen <rosen.xu@intel.com>; Huang, Wei <wei.huang@intel.com>;
> Cao, Gang <gang.cao@intel.com>; maxime.coquelin@redhat.com
> Subject: RE: [PATCH v8 09/12] vdpa/ifc: change some driver logic
> 
> > -----Original Message-----
> > From: Pei, Andy <andy.pei@intel.com>
> > Sent: Tuesday, October 18, 2022 8:08 PM
> > To: dev@dpdk.org
> > Cc: Xia, Chenbo <chenbo.xia@intel.com>; Xu, Rosen
> > <rosen.xu@intel.com>; Huang, Wei <wei.huang@intel.com>; Cao, Gang
> > <gang.cao@intel.com>; maxime.coquelin@redhat.com
> > Subject: [PATCH v8 09/12] vdpa/ifc: change some driver logic
> >
> > Insert internal list element to internal list before register vdpa
> > device, in order to call vdpa ops during vdpa device registration.
> 
> Patch seems good but title may be too general..
> 
> Maybe: improve internal list logic ?
> 
> Thanks,
> Chenbo
> 
> >
> > Signed-off-by: Andy Pei <andy.pei@intel.com>
> > ---
> >  drivers/vdpa/ifc/ifcvf_vdpa.c | 11 +++++++----
> >  1 file changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > b/drivers/vdpa/ifc/ifcvf_vdpa.c index c16e263..8dfd493 100644
> > --- a/drivers/vdpa/ifc/ifcvf_vdpa.c
> > +++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
> > @@ -1737,17 +1737,20 @@ struct rte_vdpa_dev_info dev_info[] = {
> >  	}
> >  	internal->sw_lm = sw_fallback_lm;
> >
> > +	pthread_mutex_lock(&internal_list_lock);
> > +	TAILQ_INSERT_TAIL(&internal_list, list, next);
> > +	pthread_mutex_unlock(&internal_list_lock);
> > +
> >  	internal->vdev = rte_vdpa_register_device(&pci_dev->device,
> >  				dev_info[internal->hw.device_type].ops);
> >  	if (internal->vdev == NULL) {
> >  		DRV_LOG(ERR, "failed to register device %s", pci_dev->name);
> > +		pthread_mutex_lock(&internal_list_lock);
> > +		TAILQ_REMOVE(&internal_list, list, next);
> > +		pthread_mutex_unlock(&internal_list_lock);
> >  		goto error;
> >  	}
> >
> > -	pthread_mutex_lock(&internal_list_lock);
> > -	TAILQ_INSERT_TAIL(&internal_list, list, next);
> > -	pthread_mutex_unlock(&internal_list_lock);
> > -
> >  	rte_atomic32_set(&internal->started, 1);
> >  	update_datapath(internal);
> >
> > --
> > 1.8.3.1
  

Patch

diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index c16e263..8dfd493 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -1737,17 +1737,20 @@  struct rte_vdpa_dev_info dev_info[] = {
 	}
 	internal->sw_lm = sw_fallback_lm;
 
+	pthread_mutex_lock(&internal_list_lock);
+	TAILQ_INSERT_TAIL(&internal_list, list, next);
+	pthread_mutex_unlock(&internal_list_lock);
+
 	internal->vdev = rte_vdpa_register_device(&pci_dev->device,
 				dev_info[internal->hw.device_type].ops);
 	if (internal->vdev == NULL) {
 		DRV_LOG(ERR, "failed to register device %s", pci_dev->name);
+		pthread_mutex_lock(&internal_list_lock);
+		TAILQ_REMOVE(&internal_list, list, next);
+		pthread_mutex_unlock(&internal_list_lock);
 		goto error;
 	}
 
-	pthread_mutex_lock(&internal_list_lock);
-	TAILQ_INSERT_TAIL(&internal_list, list, next);
-	pthread_mutex_unlock(&internal_list_lock);
-
 	rte_atomic32_set(&internal->started, 1);
 	update_datapath(internal);