[v4] net/i40e: fix the issue caused by PF and VF release order

Message ID 20220715090359.76538-1-ke1x.zhang@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Qi Zhang
Headers
Series [v4] net/i40e: fix the issue caused by PF and VF release order |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-abi-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Zhang, Ke1X July 15, 2022, 9:03 a.m. UTC
  A segmentation fault occurs when testpmd exit.

This is due to fetching the device name from PF, PF
is freed firstly and then VF representor is called
later.

This commit fixes the bug by fetching the device
name from VF representor not PF.

Fixes: e391a7b7f815 ("net/i40e: fix multi-process shared data")
Cc: stable@dpdk.org

Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>

---
v4: Update the commit log
v3: Change the design and fix code in driver
v2: Change the testpmd code to fix this issue
---
---
 drivers/net/i40e/i40e_vf_representor.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
  

Comments

Zhang, Yuying Aug. 2, 2022, 2:16 a.m. UTC | #1
Hi Ke,

Please update commit log.
LGTM.

> -----Original Message-----
> From: Zhang, Ke1X <ke1x.zhang@intel.com>
> Sent: Friday, July 15, 2022 5:04 PM
> To: thomas@monjalon.net; Zhang, Yuying <yuying.zhang@intel.com>; Xing,
> Beilei <beilei.xing@intel.com>; ferruh.yigit@xilinx.com; Zhou, YidingX
> <yidingx.zhou@intel.com>; dev@dpdk.org
> Cc: Zhang, Ke1X <ke1x.zhang@intel.com>; stable@dpdk.org
> Subject: [PATCH v4] net/i40e: fix the issue caused by PF and VF release order
> 
> A segmentation fault occurs when testpmd exit.
> 
> This is due to fetching the device name from PF, PF is freed firstly and then VF
> representor is called later.
> 
> This commit fixes the bug by fetching the device name from VF representor
> not PF.

instead of PF

> 
> Fixes: e391a7b7f815 ("net/i40e: fix multi-process shared data")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
Acked-by: Yuying Zhang <yuying.zhang@intel.com>

> 
> ---
> v4: Update the commit log
> v3: Change the design and fix code in driver
> v2: Change the testpmd code to fix this issue
> ---
> ---
>  drivers/net/i40e/i40e_vf_representor.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/i40e/i40e_vf_representor.c
> b/drivers/net/i40e/i40e_vf_representor.c
> index 7f8e81858e..bcd445bcdd 100644
> --- a/drivers/net/i40e/i40e_vf_representor.c
> +++ b/drivers/net/i40e/i40e_vf_representor.c
> @@ -29,8 +29,6 @@ i40e_vf_representor_dev_infos_get(struct rte_eth_dev
> *ethdev,
>  	struct rte_eth_dev_info *dev_info)
>  {
>  	struct i40e_vf_representor *representor = ethdev->data-
> >dev_private;
> -	struct rte_eth_dev_data *pf_dev_data =
> -		representor->adapter->pf.dev_data;
> 
>  	/* get dev info for the vdev */
>  	dev_info->device = ethdev->device;
> @@ -104,7 +102,7 @@ i40e_vf_representor_dev_infos_get(struct
> rte_eth_dev *ethdev,
>  	};
> 
>  	dev_info->switch_info.name =
> -		rte_eth_devices[pf_dev_data->port_id].device->name;
> +		rte_eth_devices[ethdev->data->port_id].device->name;
>  	dev_info->switch_info.domain_id = representor->switch_domain_id;
>  	dev_info->switch_info.port_id = representor->vf_id;
> 
> --
> 2.25.1
  
Qi Zhang Aug. 8, 2022, 12:06 a.m. UTC | #2
> -----Original Message-----
> From: Zhang, Yuying <yuying.zhang@intel.com>
> Sent: Tuesday, August 2, 2022 10:16 AM
> To: Zhang, Ke1X <ke1x.zhang@intel.com>; thomas@monjalon.net; Xing,
> Beilei <beilei.xing@intel.com>; ferruh.yigit@xilinx.com; Zhou, YidingX
> <yidingx.zhou@intel.com>; dev@dpdk.org
> Cc: stable@dpdk.org
> Subject: RE: [PATCH v4] net/i40e: fix the issue caused by PF and VF release
> order
> 
> Hi Ke,
> 
> Please update commit log.
> LGTM.
> 
> > -----Original Message-----
> > From: Zhang, Ke1X <ke1x.zhang@intel.com>
> > Sent: Friday, July 15, 2022 5:04 PM
> > To: thomas@monjalon.net; Zhang, Yuying <yuying.zhang@intel.com>; Xing,
> > Beilei <beilei.xing@intel.com>; ferruh.yigit@xilinx.com; Zhou, YidingX
> > <yidingx.zhou@intel.com>; dev@dpdk.org
> > Cc: Zhang, Ke1X <ke1x.zhang@intel.com>; stable@dpdk.org
> > Subject: [PATCH v4] net/i40e: fix the issue caused by PF and VF
> > release order
> >
> > A segmentation fault occurs when testpmd exit.
> >
> > This is due to fetching the device name from PF, PF is freed firstly
> > and then VF representor is called later.
> >
> > This commit fixes the bug by fetching the device name from VF
> > representor not PF.
> 
> instead of PF
> 
> >
> > Fixes: e391a7b7f815 ("net/i40e: fix multi-process shared data")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
> Acked-by: Yuying Zhang <yuying.zhang@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
  
Qi Zhang Aug. 8, 2022, 12:30 a.m. UTC | #3
> -----Original Message-----
> From: Zhang, Qi Z
> Sent: Monday, August 8, 2022 8:06 AM
> To: Zhang, Yuying <yuying.zhang@intel.com>; Zhang, Ke1X
> <ke1x.zhang@intel.com>; thomas@monjalon.net; Xing, Beilei
> <beilei.xing@intel.com>; ferruh.yigit@xilinx.com; Zhou, YidingX
> <yidingx.zhou@intel.com>; dev@dpdk.org
> Cc: stable@dpdk.org
> Subject: RE: [PATCH v4] net/i40e: fix the issue caused by PF and VF release
> order
> 
> 
> 
> > -----Original Message-----
> > From: Zhang, Yuying <yuying.zhang@intel.com>
> > Sent: Tuesday, August 2, 2022 10:16 AM
> > To: Zhang, Ke1X <ke1x.zhang@intel.com>; thomas@monjalon.net; Xing,
> > Beilei <beilei.xing@intel.com>; ferruh.yigit@xilinx.com; Zhou, YidingX
> > <yidingx.zhou@intel.com>; dev@dpdk.org
> > Cc: stable@dpdk.org
> > Subject: RE: [PATCH v4] net/i40e: fix the issue caused by PF and VF
> > release order
> >
> > Hi Ke,
> >
> > Please update commit log.
> > LGTM.
> >
> > > -----Original Message-----
> > > From: Zhang, Ke1X <ke1x.zhang@intel.com>
> > > Sent: Friday, July 15, 2022 5:04 PM
> > > To: thomas@monjalon.net; Zhang, Yuying <yuying.zhang@intel.com>;
> > > Xing, Beilei <beilei.xing@intel.com>; ferruh.yigit@xilinx.com; Zhou,
> > > YidingX <yidingx.zhou@intel.com>; dev@dpdk.org
> > > Cc: Zhang, Ke1X <ke1x.zhang@intel.com>; stable@dpdk.org
> > > Subject: [PATCH v4] net/i40e: fix the issue caused by PF and VF
> > > release order
> > >
> > > A segmentation fault occurs when testpmd exit.
> > >
> > > This is due to fetching the device name from PF, PF is freed firstly
> > > and then VF representor is called later.
> > >
> > > This commit fixes the bug by fetching the device name from VF
> > > representor not PF.
> >
> > instead of PF
> >
> > >
> > > Fixes: e391a7b7f815 ("net/i40e: fix multi-process shared data")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Ke Zhang <ke1x.zhang@intel.com>
> > Acked-by: Yuying Zhang <yuying.zhang@intel.com>
> 
> Applied to dpdk-next-net-intel.

Overwritten by v5 with refined commit log
> 
> Thanks
> Qi
  

Patch

diff --git a/drivers/net/i40e/i40e_vf_representor.c b/drivers/net/i40e/i40e_vf_representor.c
index 7f8e81858e..bcd445bcdd 100644
--- a/drivers/net/i40e/i40e_vf_representor.c
+++ b/drivers/net/i40e/i40e_vf_representor.c
@@ -29,8 +29,6 @@  i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	struct rte_eth_dev_info *dev_info)
 {
 	struct i40e_vf_representor *representor = ethdev->data->dev_private;
-	struct rte_eth_dev_data *pf_dev_data =
-		representor->adapter->pf.dev_data;
 
 	/* get dev info for the vdev */
 	dev_info->device = ethdev->device;
@@ -104,7 +102,7 @@  i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
 	};
 
 	dev_info->switch_info.name =
-		rte_eth_devices[pf_dev_data->port_id].device->name;
+		rte_eth_devices[ethdev->data->port_id].device->name;
 	dev_info->switch_info.domain_id = representor->switch_domain_id;
 	dev_info->switch_info.port_id = representor->vf_id;