[dpdk-dev,v3,01/13] crypto: replace rte_panic instances in crypto driver

Message ID 1523644244-17511-2-git-send-email-arnon@qwilt.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply patch file failure

Commit Message

Arnon Warshavsky April 13, 2018, 6:30 p.m. UTC
  replace panic calls with log and return value.

--
v2:
- reformat error message to include literal string in a single line

Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
---
 drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++++---
 drivers/crypto/dpaa_sec/dpaa_sec.c          | 8 +++++---
 2 files changed, 10 insertions(+), 6 deletions(-)
  

Comments

Neil Horman April 16, 2018, 11:49 a.m. UTC | #1
On Fri, Apr 13, 2018 at 09:30:32PM +0300, Arnon Warshavsky wrote:
> replace panic calls with log and return value.
> 
> --
> v2:
> - reformat error message to include literal string in a single line
> 
> Signed-off-by: Arnon Warshavsky <arnon@qwilt.com>
> ---
>  drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 8 +++++---
>  drivers/crypto/dpaa_sec/dpaa_sec.c          | 8 +++++---
>  2 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> index 784b96d..9e0ca7f 100644
> --- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> +++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
> @@ -2861,9 +2861,11 @@ struct rte_security_ops dpaa2_sec_security_ops = {
>  					RTE_CACHE_LINE_SIZE,
>  					rte_socket_id());
>  
> -		if (cryptodev->data->dev_private == NULL)
> -			rte_panic("Cannot allocate memzone for private "
> -				  "device data");
> +		if (cryptodev->data->dev_private == NULL) {
> +			RTE_LOG(ERR, PMD, "%s() Cannot allocate memzone for private device data",
> +			__func__);
> +			return -1;
> +		}
>  	}
>  
>  	dpaa2_dev->cryptodev = cryptodev;
> diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
> index c5191ce..793891a 100644
> --- a/drivers/crypto/dpaa_sec/dpaa_sec.c
> +++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
> @@ -2374,9 +2374,11 @@ struct rte_security_ops dpaa_sec_security_ops = {
>  					RTE_CACHE_LINE_SIZE,
>  					rte_socket_id());
>  
> -		if (cryptodev->data->dev_private == NULL)
> -			rte_panic("Cannot allocate memzone for private "
> -					"device data");
> +		if (cryptodev->data->dev_private == NULL) {
> +			RTE_LOG(ERR, PMD, "%s() Cannot allocate memzone for private device data",
> +			__func__);
> +			return -1;
> +		}
>  	}
>  
This function is only called from locations that return a -errno code, not just
-1.

Neil

>  	dpaa_dev->crypto_dev = cryptodev;
> -- 
> 1.8.3.1
> 
>
  
Arnon Warshavsky April 16, 2018, 2:24 p.m. UTC | #2
This function is only called from locations that return a -errno code, not
just

> -1.
>
> Neil

Hi Neil

Looking up the references I see that some of the places looking at this
return value from the probe function
simply return their own -1 , and some return different enums relevant for
their context.
As they all look at  !=0 or < 0 , but not all propagate the value they got
I used an explicit -1.
Do you have a specific enum in mind I should replace it with?

/Arnon
  

Patch

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 784b96d..9e0ca7f 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -2861,9 +2861,11 @@  struct rte_security_ops dpaa2_sec_security_ops = {
 					RTE_CACHE_LINE_SIZE,
 					rte_socket_id());
 
-		if (cryptodev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-				  "device data");
+		if (cryptodev->data->dev_private == NULL) {
+			RTE_LOG(ERR, PMD, "%s() Cannot allocate memzone for private device data",
+			__func__);
+			return -1;
+		}
 	}
 
 	dpaa2_dev->cryptodev = cryptodev;
diff --git a/drivers/crypto/dpaa_sec/dpaa_sec.c b/drivers/crypto/dpaa_sec/dpaa_sec.c
index c5191ce..793891a 100644
--- a/drivers/crypto/dpaa_sec/dpaa_sec.c
+++ b/drivers/crypto/dpaa_sec/dpaa_sec.c
@@ -2374,9 +2374,11 @@  struct rte_security_ops dpaa_sec_security_ops = {
 					RTE_CACHE_LINE_SIZE,
 					rte_socket_id());
 
-		if (cryptodev->data->dev_private == NULL)
-			rte_panic("Cannot allocate memzone for private "
-					"device data");
+		if (cryptodev->data->dev_private == NULL) {
+			RTE_LOG(ERR, PMD, "%s() Cannot allocate memzone for private device data",
+			__func__);
+			return -1;
+		}
 	}
 
 	dpaa_dev->crypto_dev = cryptodev;