@@ -435,15 +435,11 @@ static int proxy_channel_alloc(struct xe_gsc *gsc)
435435 return 0 ;
436436}
437437
438- static void xe_gsc_proxy_remove ( void * arg )
438+ static void xe_gsc_proxy_stop ( struct xe_gsc * gsc )
439439{
440- struct xe_gsc * gsc = arg ;
441440 struct xe_gt * gt = gsc_to_gt (gsc );
442441 struct xe_device * xe = gt_to_xe (gt );
443442
444- if (!gsc -> proxy .component_added )
445- return ;
446-
447443 /* disable HECI2 IRQs */
448444 scoped_guard (xe_pm_runtime , xe ) {
449445 CLASS (xe_force_wake , fw_ref )(gt_to_fw (gt ), XE_FW_GSC );
@@ -455,6 +451,30 @@ static void xe_gsc_proxy_remove(void *arg)
455451 }
456452
457453 xe_gsc_wait_for_worker_completion (gsc );
454+ gsc -> proxy .started = false;
455+ }
456+
457+ static void xe_gsc_proxy_remove (void * arg )
458+ {
459+ struct xe_gsc * gsc = arg ;
460+ struct xe_gt * gt = gsc_to_gt (gsc );
461+ struct xe_device * xe = gt_to_xe (gt );
462+
463+ if (!gsc -> proxy .component_added )
464+ return ;
465+
466+ /*
467+ * GSC proxy start is an async process that can be ongoing during
468+ * Xe module load/unload. Using devm managed action to register
469+ * xe_gsc_proxy_stop could cause issues if Xe module unload has
470+ * already started when the action is registered, potentially leading
471+ * to the cleanup being called at the wrong time. Therefore, instead
472+ * of registering a separate devm action to undo what is done in
473+ * proxy start, we call it from here, but only if the start has
474+ * completed successfully (tracked with the 'started' flag).
475+ */
476+ if (gsc -> proxy .started )
477+ xe_gsc_proxy_stop (gsc );
458478
459479 component_del (xe -> drm .dev , & xe_gsc_proxy_component_ops );
460480 gsc -> proxy .component_added = false;
@@ -510,6 +530,7 @@ int xe_gsc_proxy_init(struct xe_gsc *gsc)
510530 */
511531int xe_gsc_proxy_start (struct xe_gsc * gsc )
512532{
533+ struct xe_gt * gt = gsc_to_gt (gsc );
513534 int err ;
514535
515536 /* enable the proxy interrupt in the GSC shim layer */
@@ -521,12 +542,18 @@ int xe_gsc_proxy_start(struct xe_gsc *gsc)
521542 */
522543 err = xe_gsc_proxy_request_handler (gsc );
523544 if (err )
524- return err ;
545+ goto err_irq_disable ;
525546
526547 if (!xe_gsc_proxy_init_done (gsc )) {
527- xe_gt_err (gsc_to_gt (gsc ), "GSC FW reports proxy init not completed\n" );
528- return - EIO ;
548+ xe_gt_err (gt , "GSC FW reports proxy init not completed\n" );
549+ err = - EIO ;
550+ goto err_irq_disable ;
529551 }
530552
553+ gsc -> proxy .started = true;
531554 return 0 ;
555+
556+ err_irq_disable :
557+ gsc_proxy_irq_toggle (gsc , false);
558+ return err ;
532559}
0 commit comments