Skip to content

Commit

Permalink
drm/xe: Stop ignoring errors from xe_heci_gsc_init()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Lucas De Marchi committed Feb 25, 2025
1 parent d40f275 commit 292b1a8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 28 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/xe/xe_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
35 changes: 14 additions & 21 deletions drivers/gpu/drm/xe/xe_heci_gsc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down Expand Up @@ -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;

Expand All @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions drivers/gpu/drm/xe/xe_heci_gsc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 3 additions & 2 deletions drivers/gpu/drm/xe/xe_survivability_mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);

Expand Down

0 comments on commit 292b1a8

Please sign in to comment.