drm/xe: Stop ignoring errors from xe_heci_gsc_init()
authorLucas De Marchi <lucas.demarchi@intel.com>
Sat, 22 Feb 2025 00:10:49 +0000 (16:10 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Tue, 25 Feb 2025 22:32:03 +0000 (14:32 -0800)
Do not ignore errors from xe_heci_gsc_init(). For example, it shouldn't
be fine to report successfully entering survivability mode when there's
no communication with gsc working. The driver should also not be
half-initialized in the normal case neither.

Cc: Riana Tauro <riana.tauro@intel.com>
Cc: Alexander Usyskin <alexander.usyskin@intel.com>
Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250222001051.3012936-10-lucas.demarchi@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_device.c
drivers/gpu/drm/xe/xe_heci_gsc.c
drivers/gpu/drm/xe/xe_heci_gsc.h
drivers/gpu/drm/xe/xe_survivability_mode.c

index ef269227b64b16526ee4c9171f31174c7b13507e..5ef8cffbc88f74234aa1c3cf2fb81882d71577f8 100644 (file)
@@ -851,7 +851,9 @@ int xe_device_probe(struct xe_device *xe)
                        return err;
        }
 
-       xe_heci_gsc_init(xe);
+       err = xe_heci_gsc_init(xe);
+       if (err)
+               return err;
 
        err = xe_oa_init(xe);
        if (err)
@@ -903,8 +905,6 @@ void xe_device_remove(struct xe_device *xe)
        xe_display_unregister(xe);
 
        drm_dev_unplug(&xe->drm);
-
-       xe_heci_gsc_fini(xe);
 }
 
 void xe_device_shutdown(struct xe_device *xe)
index 992ee47abcdb7963e685f93aa11f544c52df35b0..3ea325d3db99d7228ad21cb3671800e0c8414485 100644 (file)
@@ -89,12 +89,9 @@ static void heci_gsc_release_dev(struct device *dev)
        kfree(adev);
 }
 
-void xe_heci_gsc_fini(struct xe_device *xe)
+static void xe_heci_gsc_fini(void *arg)
 {
-       struct xe_heci_gsc *heci_gsc = &xe->heci_gsc;
-
-       if (!xe->info.has_heci_gscfi && !xe->info.has_heci_cscfi)
-               return;
+       struct xe_heci_gsc *heci_gsc = arg;
 
        if (heci_gsc->adev) {
                struct auxiliary_device *aux_dev = &heci_gsc->adev->aux_dev;
@@ -106,6 +103,7 @@ void xe_heci_gsc_fini(struct xe_device *xe)
 
        if (heci_gsc->irq >= 0)
                irq_free_desc(heci_gsc->irq);
+
        heci_gsc->irq = -1;
 }
 
@@ -172,14 +170,14 @@ static int heci_gsc_add_device(struct xe_device *xe, const struct heci_gsc_def *
        return ret;
 }
 
-void xe_heci_gsc_init(struct xe_device *xe)
+int xe_heci_gsc_init(struct xe_device *xe)
 {
        struct xe_heci_gsc *heci_gsc = &xe->heci_gsc;
        const struct heci_gsc_def *def;
        int ret;
 
        if (!xe->info.has_heci_gscfi && !xe->info.has_heci_cscfi)
-               return;
+               return 0;
 
        heci_gsc->irq = -1;
 
@@ -191,29 +189,24 @@ void xe_heci_gsc_init(struct xe_device *xe)
                def = &heci_gsc_def_dg2;
        } else if (xe->info.platform == XE_DG1) {
                def = &heci_gsc_def_dg1;
-       } else {
-               drm_warn_once(&xe->drm, "Unknown platform\n");
-               return;
        }
 
-       if (!def->name) {
-               drm_warn_once(&xe->drm, "HECI is not implemented!\n");
-               return;
+       if (!def || !def->name) {
+               drm_warn(&xe->drm, "HECI is not implemented!\n");
+               return 0;
        }
 
+       ret = devm_add_action_or_reset(xe->drm.dev, xe_heci_gsc_fini, heci_gsc);
+       if (ret)
+               return ret;
+
        if (!def->use_polling && !xe_survivability_mode_is_enabled(xe)) {
                ret = heci_gsc_irq_setup(xe);
                if (ret)
-                       goto fail;
+                       return ret;
        }
 
-       ret = heci_gsc_add_device(xe, def);
-       if (ret)
-               goto fail;
-
-       return;
-fail:
-       xe_heci_gsc_fini(xe);
+       return heci_gsc_add_device(xe, def);
 }
 
 void xe_heci_gsc_irq_handler(struct xe_device *xe, u32 iir)
index 48b3b18380453f845aca2d5b130d10bdb668de5f..745eb6783942de78c265f2c5bc407d5294279bb3 100644 (file)
@@ -33,8 +33,7 @@ struct xe_heci_gsc {
        int irq;
 };
 
-void xe_heci_gsc_init(struct xe_device *xe);
-void xe_heci_gsc_fini(struct xe_device *xe);
+int xe_heci_gsc_init(struct xe_device *xe);
 void xe_heci_gsc_irq_handler(struct xe_device *xe, u32 iir);
 void xe_heci_csc_irq_handler(struct xe_device *xe, u32 iir);
 
index 7ba02e085b5b1b53bf127bc3805b675d392e97eb..d939ce70e6fa82b414353045f3264eb895aab831 100644 (file)
@@ -134,7 +134,6 @@ static void xe_survivability_mode_fini(void *arg)
        struct device *dev = &pdev->dev;
 
        sysfs_remove_file(&dev->kobj, &dev_attr_survivability_mode.attr);
-       xe_heci_gsc_fini(xe);
 }
 
 static int enable_survivability_mode(struct pci_dev *pdev)
@@ -156,7 +155,9 @@ static int enable_survivability_mode(struct pci_dev *pdev)
        if (ret)
                return ret;
 
-       xe_heci_gsc_init(xe);
+       ret = xe_heci_gsc_init(xe);
+       if (ret)
+               return ret;
 
        xe_vsec_init(xe);