diff mbox series

[v2,2/9] platform/x86/intel/ifs: Refactor image loading code

Message ID 20230922232606.1928026-3-jithu.joseph@intel.com (mailing list archive)
State Changes Requested, archived
Headers show
Series IFS support for GNR and SRF | expand

Commit Message

Joseph, Jithu Sept. 22, 2023, 11:25 p.m. UTC
IFS image loading flow is slightly different for newer IFS generations.

In preparation for adding support for newer IFS generations, refactor
portions of existing image loading code for reuse.

Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
Reviewed-by: Tony Luck <tony.luck@intel.com>
Tested-by: Pengfei Xu <pengfei.xu@intel.com>
---
 drivers/platform/x86/intel/ifs/load.c | 31 ++++++++++++++++-----------
 1 file changed, 19 insertions(+), 12 deletions(-)

Comments

Ilpo Järvinen Sept. 25, 2023, 3:20 p.m. UTC | #1
On Fri, 22 Sep 2023, Jithu Joseph wrote:

> IFS image loading flow is slightly different for newer IFS generations.
> 
> In preparation for adding support for newer IFS generations, refactor
> portions of existing image loading code for reuse.
> 
> Signed-off-by: Jithu Joseph <jithu.joseph@intel.com>
> Reviewed-by: Tony Luck <tony.luck@intel.com>
> Tested-by: Pengfei Xu <pengfei.xu@intel.com>
> ---
>  drivers/platform/x86/intel/ifs/load.c | 31 ++++++++++++++++-----------
>  1 file changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c
> index cefd0d886cfd..851c97cc6a6b 100644
> --- a/drivers/platform/x86/intel/ifs/load.c
> +++ b/drivers/platform/x86/intel/ifs/load.c
> @@ -80,6 +80,23 @@ static struct metadata_header *find_meta_data(void *ucode, unsigned int meta_typ
>  	return NULL;
>  }
>  
> +static void hashcopy_err_message(struct device *dev, u32 err_code)
> +{
> +	if (err_code >= ARRAY_SIZE(scan_hash_status))
> +		dev_err(dev, "invalid error code 0x%x for hash copy\n", err_code);
> +	else
> +		dev_err(dev, "Hash copy error : %s\n", scan_hash_status[err_code]);
> +}
> +
> +static void auth_err_message(struct device *dev, u32 err_code)
> +{
> +	if (err_code >= ARRAY_SIZE(scan_authentication_status))
> +		dev_err(dev, "invalid error code 0x%x for authentication\n", err_code);
> +	else
> +		dev_err(dev, "Chunk authentication error : %s\n",
> +			scan_authentication_status[err_code]);
> +}
> +
>  /*
>   * To copy scan hashes and authenticate test chunks, the initiating cpu must point
>   * to the EDX:EAX to the test image in linear address.
> @@ -109,11 +126,7 @@ static void copy_hashes_authenticate_chunks(struct work_struct *work)
>  
>  	if (!hashes_status.valid) {
>  		ifsd->loading_error = true;
> -		if (err_code >= ARRAY_SIZE(scan_hash_status)) {
> -			dev_err(dev, "invalid error code 0x%x for hash copy\n", err_code);
> -			goto done;
> -		}
> -		dev_err(dev, "Hash copy error : %s", scan_hash_status[err_code]);
> +		hashcopy_err_message(dev, err_code);
>  		goto done;
>  	}
>  
> @@ -133,13 +146,7 @@ static void copy_hashes_authenticate_chunks(struct work_struct *work)
>  
>  		if (err_code) {
>  			ifsd->loading_error = true;
> -			if (err_code >= ARRAY_SIZE(scan_authentication_status)) {
> -				dev_err(dev,
> -					"invalid error code 0x%x for authentication\n", err_code);
> -				goto done;
> -			}
> -			dev_err(dev, "Chunk authentication error %s\n",
> -				scan_authentication_status[err_code]);
> +			auth_err_message(dev, err_code);
>  			goto done;
>  		}
>  	}
> 

Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
diff mbox series

Patch

diff --git a/drivers/platform/x86/intel/ifs/load.c b/drivers/platform/x86/intel/ifs/load.c
index cefd0d886cfd..851c97cc6a6b 100644
--- a/drivers/platform/x86/intel/ifs/load.c
+++ b/drivers/platform/x86/intel/ifs/load.c
@@ -80,6 +80,23 @@  static struct metadata_header *find_meta_data(void *ucode, unsigned int meta_typ
 	return NULL;
 }
 
+static void hashcopy_err_message(struct device *dev, u32 err_code)
+{
+	if (err_code >= ARRAY_SIZE(scan_hash_status))
+		dev_err(dev, "invalid error code 0x%x for hash copy\n", err_code);
+	else
+		dev_err(dev, "Hash copy error : %s\n", scan_hash_status[err_code]);
+}
+
+static void auth_err_message(struct device *dev, u32 err_code)
+{
+	if (err_code >= ARRAY_SIZE(scan_authentication_status))
+		dev_err(dev, "invalid error code 0x%x for authentication\n", err_code);
+	else
+		dev_err(dev, "Chunk authentication error : %s\n",
+			scan_authentication_status[err_code]);
+}
+
 /*
  * To copy scan hashes and authenticate test chunks, the initiating cpu must point
  * to the EDX:EAX to the test image in linear address.
@@ -109,11 +126,7 @@  static void copy_hashes_authenticate_chunks(struct work_struct *work)
 
 	if (!hashes_status.valid) {
 		ifsd->loading_error = true;
-		if (err_code >= ARRAY_SIZE(scan_hash_status)) {
-			dev_err(dev, "invalid error code 0x%x for hash copy\n", err_code);
-			goto done;
-		}
-		dev_err(dev, "Hash copy error : %s", scan_hash_status[err_code]);
+		hashcopy_err_message(dev, err_code);
 		goto done;
 	}
 
@@ -133,13 +146,7 @@  static void copy_hashes_authenticate_chunks(struct work_struct *work)
 
 		if (err_code) {
 			ifsd->loading_error = true;
-			if (err_code >= ARRAY_SIZE(scan_authentication_status)) {
-				dev_err(dev,
-					"invalid error code 0x%x for authentication\n", err_code);
-				goto done;
-			}
-			dev_err(dev, "Chunk authentication error %s\n",
-				scan_authentication_status[err_code]);
+			auth_err_message(dev, err_code);
 			goto done;
 		}
 	}