Commit 9c3f72a3 authored by Himal Prasad Ghimiray's avatar Himal Prasad Ghimiray Committed by Lucas De Marchi

drm/xe/gt: Abort driver load for sysfs creation failure

Instead of allowing the driver to load with incomplete sysfs entries in
case of sysfs creation failure, we should terminate the driver loading.
This change ensures that the status of all gt associated sysfs entries
creation is relayed to xe_gt_init, leading to a driver load abort if any
sysfs creation failures occur.

-v2
use err_force_wake label instead of new. (Lucas)
Avoid unnecessary warn/error messages. (Lucas)

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: default avatarHimal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Reviewed-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240412181211.1155732-6-himal.prasad.ghimiray@intel.comSigned-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
parent 6e40f142
...@@ -366,7 +366,9 @@ static int gt_fw_domain_init(struct xe_gt *gt) ...@@ -366,7 +366,9 @@ static int gt_fw_domain_init(struct xe_gt *gt)
xe_lmtt_init(&gt_to_tile(gt)->sriov.pf.lmtt); xe_lmtt_init(&gt_to_tile(gt)->sriov.pf.lmtt);
} }
xe_gt_idle_sysfs_init(&gt->gtidle); err = xe_gt_idle_sysfs_init(&gt->gtidle);
if (err)
goto err_force_wake;
/* Enable per hw engine IRQs */ /* Enable per hw engine IRQs */
xe_irq_enable_hwe(gt); xe_irq_enable_hwe(gt);
...@@ -380,9 +382,7 @@ static int gt_fw_domain_init(struct xe_gt *gt) ...@@ -380,9 +382,7 @@ static int gt_fw_domain_init(struct xe_gt *gt)
err = xe_hw_engine_class_sysfs_init(gt); err = xe_hw_engine_class_sysfs_init(gt);
if (err) if (err)
drm_warn(&gt_to_xe(gt)->drm, goto err_force_wake;
"failed to register engines sysfs directory, err: %d\n",
err);
/* Initialize CCS mode sysfs after early initialization of HW engines */ /* Initialize CCS mode sysfs after early initialization of HW engines */
err = xe_gt_ccs_mode_sysfs_init(gt); err = xe_gt_ccs_mode_sysfs_init(gt);
...@@ -546,13 +546,17 @@ int xe_gt_init(struct xe_gt *gt) ...@@ -546,13 +546,17 @@ int xe_gt_init(struct xe_gt *gt)
xe_mocs_init_early(gt); xe_mocs_init_early(gt);
xe_gt_sysfs_init(gt); err = xe_gt_sysfs_init(gt);
if (err)
return err;
err = gt_fw_domain_init(gt); err = gt_fw_domain_init(gt);
if (err) if (err)
return err; return err;
xe_gt_freq_init(gt); err = xe_gt_freq_init(gt);
if (err)
return err;
xe_force_wake_init_engines(gt, gt_to_fw(gt)); xe_force_wake_init_engines(gt, gt_to_fw(gt));
......
...@@ -222,33 +222,28 @@ static void freq_fini(struct drm_device *drm, void *arg) ...@@ -222,33 +222,28 @@ static void freq_fini(struct drm_device *drm, void *arg)
* @gt: Xe GT object * @gt: Xe GT object
* *
* It needs to be initialized after GT Sysfs and GuC PC components are ready. * It needs to be initialized after GT Sysfs and GuC PC components are ready.
*
* Returns: Returns error value for failure and 0 for success.
*/ */
void xe_gt_freq_init(struct xe_gt *gt) int xe_gt_freq_init(struct xe_gt *gt)
{ {
struct xe_device *xe = gt_to_xe(gt); struct xe_device *xe = gt_to_xe(gt);
int err; int err;
if (xe->info.skip_guc_pc) if (xe->info.skip_guc_pc)
return; return 0;
gt->freq = kobject_create_and_add("freq0", gt->sysfs); gt->freq = kobject_create_and_add("freq0", gt->sysfs);
if (!gt->freq) { if (!gt->freq)
drm_warn(&xe->drm, "failed to add freq0 directory to %s\n", return -ENOMEM;
kobject_name(gt->sysfs));
return;
}
err = drmm_add_action_or_reset(&xe->drm, freq_fini, gt->freq); err = drmm_add_action_or_reset(&xe->drm, freq_fini, gt->freq);
if (err) { if (err)
drm_warn(&xe->drm, "%s: drmm_add_action_or_reset failed, err: %d\n", return err;
__func__, err);
return;
}
err = sysfs_create_files(gt->freq, freq_attrs); err = sysfs_create_files(gt->freq, freq_attrs);
if (err) if (err)
drm_warn(&xe->drm, "failed to add freq attrs to %s, err: %d\n", return err;
kobject_name(gt->freq), err);
xe_gt_throttle_sysfs_init(gt); return xe_gt_throttle_sysfs_init(gt);
} }
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
struct xe_gt; struct xe_gt;
void xe_gt_freq_init(struct xe_gt *gt); int xe_gt_freq_init(struct xe_gt *gt);
#endif #endif
...@@ -152,7 +152,7 @@ static void gt_idle_sysfs_fini(struct drm_device *drm, void *arg) ...@@ -152,7 +152,7 @@ static void gt_idle_sysfs_fini(struct drm_device *drm, void *arg)
kobject_put(kobj); kobject_put(kobj);
} }
void xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle) int xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle)
{ {
struct xe_gt *gt = gtidle_to_gt(gtidle); struct xe_gt *gt = gtidle_to_gt(gtidle);
struct xe_device *xe = gt_to_xe(gt); struct xe_device *xe = gt_to_xe(gt);
...@@ -160,10 +160,8 @@ void xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle) ...@@ -160,10 +160,8 @@ void xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle)
int err; int err;
kobj = kobject_create_and_add("gtidle", gt->sysfs); kobj = kobject_create_and_add("gtidle", gt->sysfs);
if (!kobj) { if (!kobj)
drm_warn(&xe->drm, "%s failed, err: %d\n", __func__, -ENOMEM); return -ENOMEM;
return;
}
if (xe_gt_is_media_type(gt)) { if (xe_gt_is_media_type(gt)) {
snprintf(gtidle->name, sizeof(gtidle->name), "gt%d-mc", gt->info.id); snprintf(gtidle->name, sizeof(gtidle->name), "gt%d-mc", gt->info.id);
...@@ -180,14 +178,10 @@ void xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle) ...@@ -180,14 +178,10 @@ void xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle)
err = sysfs_create_files(kobj, gt_idle_attrs); err = sysfs_create_files(kobj, gt_idle_attrs);
if (err) { if (err) {
kobject_put(kobj); kobject_put(kobj);
drm_warn(&xe->drm, "failed to register gtidle sysfs, err: %d\n", err); return err;
return;
} }
err = drmm_add_action_or_reset(&xe->drm, gt_idle_sysfs_fini, kobj); return drmm_add_action_or_reset(&xe->drm, gt_idle_sysfs_fini, kobj);
if (err)
drm_warn(&xe->drm, "%s: drmm_add_action_or_reset failed, err: %d\n",
__func__, err);
} }
void xe_gt_idle_enable_c6(struct xe_gt *gt) void xe_gt_idle_enable_c6(struct xe_gt *gt)
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
struct xe_gt; struct xe_gt;
void xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle); int xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle);
void xe_gt_idle_enable_c6(struct xe_gt *gt); void xe_gt_idle_enable_c6(struct xe_gt *gt);
void xe_gt_idle_disable_c6(struct xe_gt *gt); void xe_gt_idle_disable_c6(struct xe_gt *gt);
......
...@@ -29,7 +29,7 @@ static void gt_sysfs_fini(struct drm_device *drm, void *arg) ...@@ -29,7 +29,7 @@ static void gt_sysfs_fini(struct drm_device *drm, void *arg)
kobject_put(gt->sysfs); kobject_put(gt->sysfs);
} }
void xe_gt_sysfs_init(struct xe_gt *gt) int xe_gt_sysfs_init(struct xe_gt *gt)
{ {
struct xe_tile *tile = gt_to_tile(gt); struct xe_tile *tile = gt_to_tile(gt);
struct xe_device *xe = gt_to_xe(gt); struct xe_device *xe = gt_to_xe(gt);
...@@ -38,24 +38,18 @@ void xe_gt_sysfs_init(struct xe_gt *gt) ...@@ -38,24 +38,18 @@ void xe_gt_sysfs_init(struct xe_gt *gt)
kg = kzalloc(sizeof(*kg), GFP_KERNEL); kg = kzalloc(sizeof(*kg), GFP_KERNEL);
if (!kg) if (!kg)
return; return -ENOMEM;
kobject_init(&kg->base, &xe_gt_sysfs_kobj_type); kobject_init(&kg->base, &xe_gt_sysfs_kobj_type);
kg->gt = gt; kg->gt = gt;
err = kobject_add(&kg->base, tile->sysfs, "gt%d", gt->info.id); err = kobject_add(&kg->base, tile->sysfs, "gt%d", gt->info.id);
if (err) { if (err) {
drm_warn(&xe->drm, "failed to add GT sysfs directory, err: %d\n", err);
kobject_put(&kg->base); kobject_put(&kg->base);
return; return err;
} }
gt->sysfs = &kg->base; gt->sysfs = &kg->base;
err = drmm_add_action_or_reset(&xe->drm, gt_sysfs_fini, gt); return drmm_add_action_or_reset(&xe->drm, gt_sysfs_fini, gt);
if (err) {
drm_warn(&xe->drm, "%s: drmm_add_action_or_reset failed, err: %d\n",
__func__, err);
return;
}
} }
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "xe_gt_sysfs_types.h" #include "xe_gt_sysfs_types.h"
void xe_gt_sysfs_init(struct xe_gt *gt); int xe_gt_sysfs_init(struct xe_gt *gt);
static inline struct xe_gt * static inline struct xe_gt *
kobj_to_gt(struct kobject *kobj) kobj_to_gt(struct kobject *kobj)
......
...@@ -236,19 +236,14 @@ static void gt_throttle_sysfs_fini(struct drm_device *drm, void *arg) ...@@ -236,19 +236,14 @@ static void gt_throttle_sysfs_fini(struct drm_device *drm, void *arg)
sysfs_remove_group(gt->freq, &throttle_group_attrs); sysfs_remove_group(gt->freq, &throttle_group_attrs);
} }
void xe_gt_throttle_sysfs_init(struct xe_gt *gt) int xe_gt_throttle_sysfs_init(struct xe_gt *gt)
{ {
struct xe_device *xe = gt_to_xe(gt); struct xe_device *xe = gt_to_xe(gt);
int err; int err;
err = sysfs_create_group(gt->freq, &throttle_group_attrs); err = sysfs_create_group(gt->freq, &throttle_group_attrs);
if (err) {
drm_warn(&xe->drm, "failed to register throttle sysfs, err: %d\n", err);
return;
}
err = drmm_add_action_or_reset(&xe->drm, gt_throttle_sysfs_fini, gt);
if (err) if (err)
drm_warn(&xe->drm, "%s: drmm_add_action_or_reset failed, err: %d\n", return err;
__func__, err);
return drmm_add_action_or_reset(&xe->drm, gt_throttle_sysfs_fini, gt);
} }
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
struct xe_gt; struct xe_gt;
void xe_gt_throttle_sysfs_init(struct xe_gt *gt); int xe_gt_throttle_sysfs_init(struct xe_gt *gt);
#endif /* _XE_GT_THROTTLE_SYSFS_H_ */ #endif /* _XE_GT_THROTTLE_SYSFS_H_ */
...@@ -690,12 +690,8 @@ int xe_hw_engine_class_sysfs_init(struct xe_gt *gt) ...@@ -690,12 +690,8 @@ int xe_hw_engine_class_sysfs_init(struct xe_gt *gt)
keclass->eclass = hwe->eclass; keclass->eclass = hwe->eclass;
err = xe_add_hw_engine_class_defaults(xe, &keclass->base); err = xe_add_hw_engine_class_defaults(xe, &keclass->base);
if (err) { if (err)
drm_warn(&xe->drm,
"Add .defaults to engines failed!, err: %d\n",
err);
goto err_object; goto err_object;
}
err = sysfs_create_files(&keclass->base, files); err = sysfs_create_files(&keclass->base, files);
if (err) if (err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment