Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+21 -18
+3 -1
drivers/gpu/drm/xe/xe_device.c
··· 895 895 896 896 xe_debugfs_register(xe); 897 897 898 - xe_hwmon_register(xe); 898 + err = xe_hwmon_register(xe); 899 + if (err) 900 + goto err_unregister_display; 899 901 900 902 for_each_gt(gt, xe, id) 901 903 xe_gt_sanitize_freq(gt);
+16 -15
drivers/gpu/drm/xe/xe_hwmon.c
··· 839 839 }; 840 840 841 841 static void 842 - xe_hwmon_get_preregistration_info(struct xe_device *xe) 842 + xe_hwmon_get_preregistration_info(struct xe_hwmon *hwmon) 843 843 { 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); 846 845 long energy; 847 846 u64 val_sku_unit = 0; 848 847 int channel; ··· 875 876 mutex_destroy(&hwmon->hwmon_lock); 876 877 } 877 878 878 - void xe_hwmon_register(struct xe_device *xe) 879 + int xe_hwmon_register(struct xe_device *xe) 879 880 { 880 881 struct device *dev = xe->drm.dev; 881 882 struct xe_hwmon *hwmon; 883 + int ret; 882 884 883 885 /* hwmon is available only for dGfx */ 884 886 if (!IS_DGFX(xe)) 885 - return; 887 + return 0; 886 888 887 889 /* hwmon is not available on VFs */ 888 890 if (IS_SRIOV_VF(xe)) 889 - return; 891 + return 0; 890 892 891 893 hwmon = devm_kzalloc(dev, sizeof(*hwmon), GFP_KERNEL); 892 894 if (!hwmon) 893 - return; 894 - 895 - xe->hwmon = hwmon; 895 + return -ENOMEM; 896 896 897 897 mutex_init(&hwmon->hwmon_lock); 898 - if (devm_add_action_or_reset(dev, xe_hwmon_mutex_destroy, hwmon)) 899 - return; 898 + ret = devm_add_action_or_reset(dev, xe_hwmon_mutex_destroy, hwmon); 899 + if (ret) 900 + return ret; 900 901 901 902 /* There's only one instance of hwmon per device */ 902 903 hwmon->xe = xe; 904 + xe->hwmon = hwmon; 903 905 904 - xe_hwmon_get_preregistration_info(xe); 906 + xe_hwmon_get_preregistration_info(hwmon); 905 907 906 908 drm_dbg(&xe->drm, "Register xe hwmon interface\n"); 907 909 ··· 910 910 hwmon->hwmon_dev = devm_hwmon_device_register_with_info(dev, "xe", hwmon, 911 911 &hwmon_chip_info, 912 912 hwmon_groups); 913 - 914 913 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); 916 915 xe->hwmon = NULL; 917 - return; 916 + return PTR_ERR(hwmon->hwmon_dev); 918 917 } 918 + 919 + return 0; 919 920 } 920 921
+2 -2
drivers/gpu/drm/xe/xe_hwmon.h
··· 11 11 struct xe_device; 12 12 13 13 #if IS_REACHABLE(CONFIG_HWMON) 14 - void xe_hwmon_register(struct xe_device *xe); 14 + int xe_hwmon_register(struct xe_device *xe); 15 15 #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; }; 17 17 #endif 18 18 19 19 #endif /* _XE_HWMON_H_ */