vdpa/mlx5: fix event setup

Message ID 1582620228-25629-1-git-send-email-matan@mellanox.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series vdpa/mlx5: fix event setup |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/iol-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/travis-robot success Travis build: passed

Commit Message

Matan Azrad Feb. 25, 2020, 8:43 a.m. UTC
The completion event mechanism should work only if at least one of the
virtqs has valid callfd to be notified on.

When all the virtqs works with poll mode, the event mechanism should not
be configured.

The driver didn't take it into account and crashed in the above case.

Do not configure event interrupt when all the virtqs are in poll mode.

Fixes: 8395927cdfaf ("vdpa/mlx5: prepare HW queues")

Signed-off-by: Matan Azrad <matan@mellanox.com>
---
 drivers/vdpa/mlx5/mlx5_vdpa_event.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
  

Comments

Slava Ovsiienko Feb. 25, 2020, 9:46 a.m. UTC | #1
> -----Original Message-----
> From: Matan Azrad <matan@mellanox.com>
> Sent: Tuesday, February 25, 2020 10:44
> To: dev@dpdk.org
> Cc: Slava Ovsiienko <viacheslavo@mellanox.com>; Thomas Monjalon
> <thomas@monjalon.net>; Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH] vdpa/mlx5: fix event setup
> 
> The completion event mechanism should work only if at least one of the
> virtqs has valid callfd to be notified on.
> 
> When all the virtqs works with poll mode, the event mechanism should not
> be configured.
> 
> The driver didn't take it into account and crashed in the above case.
> 
> Do not configure event interrupt when all the virtqs are in poll mode.
> 
> Fixes: 8395927cdfaf ("vdpa/mlx5: prepare HW queues")
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>


> ---
>  drivers/vdpa/mlx5/mlx5_vdpa_event.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
> b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
> index 16276f5..dd60150 100644
> --- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
> +++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
> @@ -237,8 +237,14 @@
>  int
>  mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)  {
> -	int flags = fcntl(priv->eventc->fd, F_GETFL);
> -	int ret = fcntl(priv->eventc->fd, F_SETFL, flags | O_NONBLOCK);
> +	int flags;
> +	int ret;
> +
> +	if (!priv->eventc)
> +		/* All virtqs are in poll mode. */
> +		return 0;
> +	flags = fcntl(priv->eventc->fd, F_GETFL);
> +	ret = fcntl(priv->eventc->fd, F_SETFL, flags | O_NONBLOCK);
>  	if (ret) {
>  		DRV_LOG(ERR, "Failed to change event channel FD.");
>  		rte_errno = errno;
> --
> 1.8.3.1
  
Thomas Monjalon Feb. 25, 2020, 9:46 a.m. UTC | #2
25/02/2020 09:43, Matan Azrad:
> The completion event mechanism should work only if at least one of the
> virtqs has valid callfd to be notified on.
> 
> When all the virtqs works with poll mode, the event mechanism should not
> be configured.
> 
> The driver didn't take it into account and crashed in the above case.
> 
> Do not configure event interrupt when all the virtqs are in poll mode.
> 
> Fixes: 8395927cdfaf ("vdpa/mlx5: prepare HW queues")
> 
> Signed-off-by: Matan Azrad <matan@mellanox.com>

Applied, thanks
Note: there is no regression risk because it is fixing a new driver.
  

Patch

diff --git a/drivers/vdpa/mlx5/mlx5_vdpa_event.c b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
index 16276f5..dd60150 100644
--- a/drivers/vdpa/mlx5/mlx5_vdpa_event.c
+++ b/drivers/vdpa/mlx5/mlx5_vdpa_event.c
@@ -237,8 +237,14 @@ 
 int
 mlx5_vdpa_cqe_event_setup(struct mlx5_vdpa_priv *priv)
 {
-	int flags = fcntl(priv->eventc->fd, F_GETFL);
-	int ret = fcntl(priv->eventc->fd, F_SETFL, flags | O_NONBLOCK);
+	int flags;
+	int ret;
+
+	if (!priv->eventc)
+		/* All virtqs are in poll mode. */
+		return 0;
+	flags = fcntl(priv->eventc->fd, F_GETFL);
+	ret = fcntl(priv->eventc->fd, F_SETFL, flags | O_NONBLOCK);
 	if (ret) {
 		DRV_LOG(ERR, "Failed to change event channel FD.");
 		rte_errno = errno;