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)
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 */
xe_irq_enable_hwe(gt);
......@@ -380,9 +382,7 @@ static int gt_fw_domain_init(struct xe_gt *gt)
err = xe_hw_engine_class_sysfs_init(gt);
if (err)
drm_warn(&gt_to_xe(gt)->drm,
"failed to register engines sysfs directory, err: %d\n",
err);
goto err_force_wake;
/* Initialize CCS mode sysfs after early initialization of HW engines */
err = xe_gt_ccs_mode_sysfs_init(gt);
......@@ -546,13 +546,17 @@ int xe_gt_init(struct xe_gt *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);
if (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));
......
......@@ -222,33 +222,28 @@ static void freq_fini(struct drm_device *drm, void *arg)
* @gt: Xe GT object
*
* 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);
int err;
if (xe->info.skip_guc_pc)
return;
return 0;
gt->freq = kobject_create_and_add("freq0", gt->sysfs);
if (!gt->freq) {
drm_warn(&xe->drm, "failed to add freq0 directory to %s\n",
kobject_name(gt->sysfs));
return;
}
if (!gt->freq)
return -ENOMEM;
err = drmm_add_action_or_reset(&xe->drm, freq_fini, gt->freq);
if (err) {
drm_warn(&xe->drm, "%s: drmm_add_action_or_reset failed, err: %d\n",
__func__, err);
return;
}
if (err)
return err;
err = sysfs_create_files(gt->freq, freq_attrs);
if (err)
drm_warn(&xe->drm, "failed to add freq attrs to %s, err: %d\n",
kobject_name(gt->freq), err);
return err;
xe_gt_throttle_sysfs_init(gt);
return xe_gt_throttle_sysfs_init(gt);
}
......@@ -8,6 +8,6 @@
struct xe_gt;
void xe_gt_freq_init(struct xe_gt *gt);
int xe_gt_freq_init(struct xe_gt *gt);
#endif
......@@ -152,7 +152,7 @@ static void gt_idle_sysfs_fini(struct drm_device *drm, void *arg)
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_device *xe = gt_to_xe(gt);
......@@ -160,10 +160,8 @@ void xe_gt_idle_sysfs_init(struct xe_gt_idle *gtidle)
int err;
kobj = kobject_create_and_add("gtidle", gt->sysfs);
if (!kobj) {
drm_warn(&xe->drm, "%s failed, err: %d\n", __func__, -ENOMEM);
return;
}
if (!kobj)
return -ENOMEM;
if (xe_gt_is_media_type(gt)) {
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)
err = sysfs_create_files(kobj, gt_idle_attrs);
if (err) {
kobject_put(kobj);
drm_warn(&xe->drm, "failed to register gtidle sysfs, err: %d\n", err);
return;
return err;
}
err = 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);
return drmm_add_action_or_reset(&xe->drm, gt_idle_sysfs_fini, kobj);
}
void xe_gt_idle_enable_c6(struct xe_gt *gt)
......
......@@ -10,7 +10,7 @@
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_disable_c6(struct xe_gt *gt);
......
......@@ -29,7 +29,7 @@ static void gt_sysfs_fini(struct drm_device *drm, void *arg)
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_device *xe = gt_to_xe(gt);
......@@ -38,24 +38,18 @@ void xe_gt_sysfs_init(struct xe_gt *gt)
kg = kzalloc(sizeof(*kg), GFP_KERNEL);
if (!kg)
return;
return -ENOMEM;
kobject_init(&kg->base, &xe_gt_sysfs_kobj_type);
kg->gt = gt;
err = kobject_add(&kg->base, tile->sysfs, "gt%d", gt->info.id);
if (err) {
drm_warn(&xe->drm, "failed to add GT sysfs directory, err: %d\n", err);
kobject_put(&kg->base);
return;
return err;
}
gt->sysfs = &kg->base;
err = 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;
}
return drmm_add_action_or_reset(&xe->drm, gt_sysfs_fini, gt);
}
......@@ -8,7 +8,7 @@
#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 *
kobj_to_gt(struct kobject *kobj)
......
......@@ -236,19 +236,14 @@ static void gt_throttle_sysfs_fini(struct drm_device *drm, void *arg)
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);
int err;
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)
drm_warn(&xe->drm, "%s: drmm_add_action_or_reset failed, err: %d\n",
__func__, err);
return err;
return drmm_add_action_or_reset(&xe->drm, gt_throttle_sysfs_fini, gt);
}
......@@ -10,7 +10,7 @@
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_ */
......@@ -690,12 +690,8 @@ int xe_hw_engine_class_sysfs_init(struct xe_gt *gt)
keclass->eclass = hwe->eclass;
err = xe_add_hw_engine_class_defaults(xe, &keclass->base);
if (err) {
drm_warn(&xe->drm,
"Add .defaults to engines failed!, err: %d\n",
err);
if (err)
goto err_object;
}
err = sysfs_create_files(&keclass->base, files);
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