diff mbox series

[for-next,V2,03/13] net/mlx5e: Wait for FPGA command responses with a timeout

Message ID 20180307063516.22773-4-saeedm@mellanox.com
State Accepted, archived
Delegated to: David Miller
Headers show
Series [for-next,V2,01/13] IB/mlx5: Removed not used parameters | expand

Commit Message

Saeed Mahameed March 7, 2018, 6:35 a.m. UTC
From: Aviad Yehezkel <aviadye@mellanox.com>

Generally, FPGA IPSec commands must always complete.
We want to wait for one minute for them to complete gracefully also
when killing a process.

Signed-off-by: Aviad Yehezkel <aviadye@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Kirill Tkhai March 7, 2018, 10:25 a.m. UTC | #1
On 07.03.2018 09:35, Saeed Mahameed wrote:
> From: Aviad Yehezkel <aviadye@mellanox.com>
> 
> Generally, FPGA IPSec commands must always complete.
> We want to wait for one minute for them to complete gracefully also
> when killing a process.
> 
> Signed-off-by: Aviad Yehezkel <aviadye@mellanox.com>
> Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
> index 35d0e33381ca..95f9c5a8619b 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
> @@ -39,6 +39,7 @@
>  #include "fpga/core.h"
>  
>  #define SBU_QP_QUEUE_SIZE 8
> +#define MLX5_FPGA_IPSEC_CMD_TIMEOUT_MSEC	(60 * 1000)
>  
>  enum mlx5_ipsec_response_syndrome {
>  	MLX5_IPSEC_RESPONSE_SUCCESS = 0,
> @@ -217,12 +218,14 @@ void *mlx5_fpga_ipsec_sa_cmd_exec(struct mlx5_core_dev *mdev,
>  int mlx5_fpga_ipsec_sa_cmd_wait(void *ctx)
>  {
>  	struct mlx5_ipsec_command_context *context = ctx;
> +	unsigned long timeout =
> +		msecs_to_jiffies(MLX5_FPGA_IPSEC_CMD_TIMEOUT_MSEC);
>  	int res;
>  
> -	res = wait_for_completion_killable(&context->complete);
> -	if (res) {
> +	res = wait_for_completion_timeout(&context->complete, timeout);

You had a possibility to kill the waiting task before the patch, but it gets lost after the patch.
Why not wait_for_completion_killable_timeout()?

> +	if (!res) {
>  		mlx5_fpga_warn(context->dev, "Failure waiting for IPSec command response\n");
> -		return -EINTR;
> +		return -ETIMEDOUT;
>  	}
>  
>  	if (context->status == MLX5_FPGA_IPSEC_SACMD_COMPLETE)

Thanks,
Kirill
Saeed Mahameed March 7, 2018, 8:01 p.m. UTC | #2
On Wed, 2018-03-07 at 13:25 +0300, Kirill Tkhai wrote:
> On 07.03.2018 09:35, Saeed Mahameed wrote:

> > From: Aviad Yehezkel <aviadye@mellanox.com>

> > 

> > Generally, FPGA IPSec commands must always complete.

> > We want to wait for one minute for them to complete gracefully also

> > when killing a process.

> > 

> > Signed-off-by: Aviad Yehezkel <aviadye@mellanox.com>

> > Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>

> > ---

> >  drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | 9 ++++++---

> >  1 file changed, 6 insertions(+), 3 deletions(-)

> > 

> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c

> > b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c

> > index 35d0e33381ca..95f9c5a8619b 100644

> > --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c

> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c

> > @@ -39,6 +39,7 @@

> >  #include "fpga/core.h"

> >  

> >  #define SBU_QP_QUEUE_SIZE 8

> > +#define MLX5_FPGA_IPSEC_CMD_TIMEOUT_MSEC	(60 * 1000)

> >  

> >  enum mlx5_ipsec_response_syndrome {

> >  	MLX5_IPSEC_RESPONSE_SUCCESS = 0,

> > @@ -217,12 +218,14 @@ void *mlx5_fpga_ipsec_sa_cmd_exec(struct

> > mlx5_core_dev *mdev,

> >  int mlx5_fpga_ipsec_sa_cmd_wait(void *ctx)

> >  {

> >  	struct mlx5_ipsec_command_context *context = ctx;

> > +	unsigned long timeout =

> > +		msecs_to_jiffies(MLX5_FPGA_IPSEC_CMD_TIMEOUT_MSEC)

> > ;

> >  	int res;

> >  

> > -	res = wait_for_completion_killable(&context->complete);

> > -	if (res) {

> > +	res = wait_for_completion_timeout(&context->complete,

> > timeout);

> 

> You had a possibility to kill the waiting task before the patch, but

> it gets lost after the patch.

> Why not wait_for_completion_killable_timeout()?

> 


Actually allowing the process to kill while an FPGA command execution
is in progress is a bug, see commit message:
"We want to wait for one minute for them to complete gracefully also
when killing a process."

Abandoning the command execution from this function is wrong, which is
exactly what this patch is for.

> > +	if (!res) {

> >  		mlx5_fpga_warn(context->dev, "Failure waiting for

> > IPSec command response\n");

> > -		return -EINTR;

> > +		return -ETIMEDOUT;

> >  	}

> >  

> >  	if (context->status == MLX5_FPGA_IPSEC_SACMD_COMPLETE)

> 

> Thanks,

> Kirill
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
index 35d0e33381ca..95f9c5a8619b 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
@@ -39,6 +39,7 @@ 
 #include "fpga/core.h"
 
 #define SBU_QP_QUEUE_SIZE 8
+#define MLX5_FPGA_IPSEC_CMD_TIMEOUT_MSEC	(60 * 1000)
 
 enum mlx5_ipsec_response_syndrome {
 	MLX5_IPSEC_RESPONSE_SUCCESS = 0,
@@ -217,12 +218,14 @@  void *mlx5_fpga_ipsec_sa_cmd_exec(struct mlx5_core_dev *mdev,
 int mlx5_fpga_ipsec_sa_cmd_wait(void *ctx)
 {
 	struct mlx5_ipsec_command_context *context = ctx;
+	unsigned long timeout =
+		msecs_to_jiffies(MLX5_FPGA_IPSEC_CMD_TIMEOUT_MSEC);
 	int res;
 
-	res = wait_for_completion_killable(&context->complete);
-	if (res) {
+	res = wait_for_completion_timeout(&context->complete, timeout);
+	if (!res) {
 		mlx5_fpga_warn(context->dev, "Failure waiting for IPSec command response\n");
-		return -EINTR;
+		return -ETIMEDOUT;
 	}
 
 	if (context->status == MLX5_FPGA_IPSEC_SACMD_COMPLETE)