1111#include "intel_huc_print.h"
1212#include "i915_drv.h"
1313#include "i915_reg.h"
14+ #include "pxp/intel_pxp_cmd_interface_43.h"
1415
1516#include <linux/device/bus.h>
1617#include <linux/mei_aux.h>
@@ -371,20 +372,36 @@ static int check_huc_loading_mode(struct intel_huc *huc)
371372
372373int intel_huc_init (struct intel_huc * huc )
373374{
375+ struct intel_gt * gt = huc_to_gt (huc );
374376 int err ;
375377
376378 err = check_huc_loading_mode (huc );
377379 if (err )
378380 goto out ;
379381
382+ if (HAS_ENGINE (gt , GSC0 )) {
383+ struct i915_vma * vma ;
384+
385+ vma = intel_guc_allocate_vma (& gt -> uc .guc , PXP43_HUC_AUTH_INOUT_SIZE * 2 );
386+ if (IS_ERR (vma )) {
387+ huc_info (huc , "Failed to allocate heci pkt\n" );
388+ goto out ;
389+ }
390+
391+ huc -> heci_pkt = vma ;
392+ }
393+
380394 err = intel_uc_fw_init (& huc -> fw );
381395 if (err )
382- goto out ;
396+ goto out_pkt ;
383397
384398 intel_uc_fw_change_status (& huc -> fw , INTEL_UC_FIRMWARE_LOADABLE );
385399
386400 return 0 ;
387401
402+ out_pkt :
403+ if (huc -> heci_pkt )
404+ i915_vma_unpin_and_release (& huc -> heci_pkt , 0 );
388405out :
389406 intel_uc_fw_change_status (& huc -> fw , INTEL_UC_FIRMWARE_INIT_FAIL );
390407 huc_info (huc , "initialization failed %pe\n" , ERR_PTR (err ));
@@ -399,6 +416,9 @@ void intel_huc_fini(struct intel_huc *huc)
399416 */
400417 delayed_huc_load_fini (huc );
401418
419+ if (huc -> heci_pkt )
420+ i915_vma_unpin_and_release (& huc -> heci_pkt , 0 );
421+
402422 if (intel_uc_fw_is_loadable (& huc -> fw ))
403423 intel_uc_fw_fini (& huc -> fw );
404424}
@@ -454,14 +474,15 @@ int intel_huc_wait_for_auth_complete(struct intel_huc *huc,
454474/**
455475 * intel_huc_auth() - Authenticate HuC uCode
456476 * @huc: intel_huc structure
477+ * @type: authentication type (via GuC or via GSC)
457478 *
458479 * Called after HuC and GuC firmware loading during intel_uc_init_hw().
459480 *
460481 * This function invokes the GuC action to authenticate the HuC firmware,
461482 * passing the offset of the RSA signature to intel_guc_auth_huc(). It then
462483 * waits for up to 50ms for firmware verification ACK.
463484 */
464- int intel_huc_auth (struct intel_huc * huc )
485+ int intel_huc_auth (struct intel_huc * huc , enum intel_huc_authentication_type type )
465486{
466487 struct intel_gt * gt = huc_to_gt (huc );
467488 struct intel_guc * guc = & gt -> uc .guc ;
@@ -470,31 +491,41 @@ int intel_huc_auth(struct intel_huc *huc)
470491 if (!intel_uc_fw_is_loaded (& huc -> fw ))
471492 return - ENOEXEC ;
472493
473- /* GSC will do the auth */
494+ /* GSC will do the auth with the load */
474495 if (intel_huc_is_loaded_by_gsc (huc ))
475496 return - ENODEV ;
476497
498+ if (intel_huc_is_authenticated (huc , type ))
499+ return - EEXIST ;
500+
477501 ret = i915_inject_probe_error (gt -> i915 , - ENXIO );
478502 if (ret )
479503 goto fail ;
480504
481- GEM_BUG_ON (intel_uc_fw_is_running (& huc -> fw ));
482-
483- ret = intel_guc_auth_huc (guc , intel_guc_ggtt_offset (guc , huc -> fw .rsa_data ));
484- if (ret ) {
485- huc_err (huc , "authentication by GuC failed %pe\n" , ERR_PTR (ret ));
486- goto fail ;
505+ switch (type ) {
506+ case INTEL_HUC_AUTH_BY_GUC :
507+ ret = intel_guc_auth_huc (guc , intel_guc_ggtt_offset (guc , huc -> fw .rsa_data ));
508+ break ;
509+ case INTEL_HUC_AUTH_BY_GSC :
510+ ret = intel_huc_fw_auth_via_gsccs (huc );
511+ break ;
512+ default :
513+ MISSING_CASE (type );
514+ ret = - EINVAL ;
487515 }
516+ if (ret )
517+ goto fail ;
488518
489519 /* Check authentication status, it should be done by now */
490- ret = intel_huc_wait_for_auth_complete (huc , INTEL_HUC_AUTH_BY_GUC );
520+ ret = intel_huc_wait_for_auth_complete (huc , type );
491521 if (ret )
492522 goto fail ;
493523
494524 return 0 ;
495525
496526fail :
497- huc_probe_error (huc , "authentication failed %pe\n" , ERR_PTR (ret ));
527+ huc_probe_error (huc , "%s authentication failed %pe\n" ,
528+ auth_mode_string (huc , type ), ERR_PTR (ret ));
498529 return ret ;
499530}
500531
0 commit comments