[v7,2/3] net/iavf: enable PCI bus master after reset

Message ID 20210524012346.496560-3-haiyue.wang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series fix PF reset causes VF memory request failure |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Wang, Haiyue May 24, 2021, 1:23 a.m. UTC
  The VF reset can be triggered by the PF reset event, then the PCI bus
master will be cleared, the VF will be not allowed to issue any Memory
or I/O Requests.

So after the reset event is detected, always enable the PCI bus master.
And if failed, the device or system may be in an invalid state, so keep
the VF reset state to mark it as I/O error.

Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
---
 drivers/net/iavf/iavf_ethdev.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
  

Comments

Xing, Beilei June 4, 2021, 2:07 a.m. UTC | #1
> -----Original Message-----
> From: Wang, Haiyue <haiyue.wang@intel.com>
> Sent: Monday, May 24, 2021 9:24 AM
> To: dev@dpdk.org
> Cc: Zhang, Qi Z <qi.z.zhang@intel.com>; Wang, Liang-min <liang-
> min.wang@intel.com>; david.marchand@redhat.com; Wang, Haiyue
> <haiyue.wang@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Xing, Beilei
> <beilei.xing@intel.com>
> Subject: [PATCH v7 2/3] net/iavf: enable PCI bus master after reset
> 
> The VF reset can be triggered by the PF reset event, then the PCI bus master
> will be cleared, the VF will be not allowed to issue any Memory or I/O
> Requests.
> 
> So after the reset event is detected, always enable the PCI bus master.
> And if failed, the device or system may be in an invalid state, so keep the VF
> reset state to mark it as I/O error.
> 
> Signed-off-by: Haiyue Wang <haiyue.wang@intel.com>
> ---
>  drivers/net/iavf/iavf_ethdev.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
> index d688c31cfb..a7ef7a6d4d 100644
> --- a/drivers/net/iavf/iavf_ethdev.c
> +++ b/drivers/net/iavf/iavf_ethdev.c
> @@ -2356,7 +2356,15 @@ iavf_dev_close(struct rte_eth_dev *dev)
>  	rte_free(vf->aq_resp);
>  	vf->aq_resp = NULL;
> 
> -	vf->vf_reset = false;
> +	/*
> +	 * If the VF is reset via VFLR, the device will be knocked out of bus
> +	 * master mode, and the driver will fail to recover from the reset. Fix
> +	 * this by enabling bus mastering after every reset. In a non-VFLR
> case,
> +	 * the bus master bit will not be disabled, and this call will have no
> +	 * effect.
> +	 */
> +	if (vf->vf_reset && !rte_pci_set_bus_master(pci_dev, true))
> +		vf->vf_reset = false;
> 
>  	return ret;
>  }
> --
> 2.31.1

Acked-by: Beilei Xing <beilei.xing@intel.com>
  

Patch

diff --git a/drivers/net/iavf/iavf_ethdev.c b/drivers/net/iavf/iavf_ethdev.c
index d688c31cfb..a7ef7a6d4d 100644
--- a/drivers/net/iavf/iavf_ethdev.c
+++ b/drivers/net/iavf/iavf_ethdev.c
@@ -2356,7 +2356,15 @@  iavf_dev_close(struct rte_eth_dev *dev)
 	rte_free(vf->aq_resp);
 	vf->aq_resp = NULL;
 
-	vf->vf_reset = false;
+	/*
+	 * If the VF is reset via VFLR, the device will be knocked out of bus
+	 * master mode, and the driver will fail to recover from the reset. Fix
+	 * this by enabling bus mastering after every reset. In a non-VFLR case,
+	 * the bus master bit will not be disabled, and this call will have no
+	 * effect.
+	 */
+	if (vf->vf_reset && !rte_pci_set_bus_master(pci_dev, true))
+		vf->vf_reset = false;
 
 	return ret;
 }