Skip to content

Commit 62fbc75

Browse files
committed
drm/xe/hwmon: Stop ignoring errors on probe
Not registering hwmon because it's not available (SRIOV_VF and DGFX) is different from failing the initialization. Handle the errors appropriately. Cc: Badal Nilawar <badal.nilawar@intel.com> Cc: Karthik Poosa <karthik.poosa@intel.com> Reviewed-by: Raag Jadav <raag.jadav@intel.com> Reviewed-by: Badal Nilawar <badal.nilawar@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250213192909.996148-13-lucas.demarchi@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
1 parent 6b55061 commit 62fbc75

File tree

3 files changed

+21
-18
lines changed

3 files changed

+21
-18
lines changed

drivers/gpu/drm/xe/xe_device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,9 @@ int xe_device_probe(struct xe_device *xe)
895895

896896
xe_debugfs_register(xe);
897897

898-
xe_hwmon_register(xe);
898+
err = xe_hwmon_register(xe);
899+
if (err)
900+
goto err_unregister_display;
899901

900902
for_each_gt(gt, xe, id)
901903
xe_gt_sanitize_freq(gt);

drivers/gpu/drm/xe/xe_hwmon.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -839,10 +839,9 @@ static const struct hwmon_chip_info hwmon_chip_info = {
839839
};
840840

841841
static void
842-
xe_hwmon_get_preregistration_info(struct xe_device *xe)
842+
xe_hwmon_get_preregistration_info(struct xe_hwmon *hwmon)
843843
{
844-
struct xe_mmio *mmio = xe_root_tile_mmio(xe);
845-
struct xe_hwmon *hwmon = xe->hwmon;
844+
struct xe_mmio *mmio = xe_root_tile_mmio(hwmon->xe);
846845
long energy;
847846
u64 val_sku_unit = 0;
848847
int channel;
@@ -876,45 +875,47 @@ static void xe_hwmon_mutex_destroy(void *arg)
876875
mutex_destroy(&hwmon->hwmon_lock);
877876
}
878877

879-
void xe_hwmon_register(struct xe_device *xe)
878+
int xe_hwmon_register(struct xe_device *xe)
880879
{
881880
struct device *dev = xe->drm.dev;
882881
struct xe_hwmon *hwmon;
882+
int ret;
883883

884884
/* hwmon is available only for dGfx */
885885
if (!IS_DGFX(xe))
886-
return;
886+
return 0;
887887

888888
/* hwmon is not available on VFs */
889889
if (IS_SRIOV_VF(xe))
890-
return;
890+
return 0;
891891

892892
hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL);
893893
if (!hwmon)
894-
return;
895-
896-
xe->hwmon = hwmon;
894+
return -ENOMEM;
897895

898896
mutex_init(&hwmon->hwmon_lock);
899-
if (devm_add_action_or_reset(dev, xe_hwmon_mutex_destroy, hwmon))
900-
return;
897+
ret = devm_add_action_or_reset(dev, xe_hwmon_mutex_destroy, hwmon);
898+
if (ret)
899+
return ret;
901900

902901
/* There's only one instance of hwmon per device */
903902
hwmon->xe = xe;
903+
xe->hwmon = hwmon;
904904

905-
xe_hwmon_get_preregistration_info(xe);
905+
xe_hwmon_get_preregistration_info(hwmon);
906906

907907
drm_dbg(&xe->drm, "Register xe hwmon interface\n");
908908

909909
/* hwmon_dev points to device hwmon<i> */
910910
hwmon->hwmon_dev = devm_hwmon_device_register_with_info(dev, "xe", hwmon,
911911
&hwmon_chip_info,
912912
hwmon_groups);
913-
914913
if (IS_ERR(hwmon->hwmon_dev)) {
915-
drm_warn(&xe->drm, "Failed to register xe hwmon (%pe)\n", hwmon->hwmon_dev);
914+
drm_err(&xe->drm, "Failed to register xe hwmon (%pe)\n", hwmon->hwmon_dev);
916915
xe->hwmon = NULL;
917-
return;
916+
return PTR_ERR(hwmon->hwmon_dev);
918917
}
918+
919+
return 0;
919920
}
920921

drivers/gpu/drm/xe/xe_hwmon.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
struct xe_device;
1212

1313
#if IS_REACHABLE(CONFIG_HWMON)
14-
void xe_hwmon_register(struct xe_device *xe);
14+
int xe_hwmon_register(struct xe_device *xe);
1515
#else
16-
static inline void xe_hwmon_register(struct xe_device *xe) { };
16+
static inline int xe_hwmon_register(struct xe_device *xe) { return 0; };
1717
#endif
1818

1919
#endif /* _XE_HWMON_H_ */

0 commit comments

Comments
 (0)