Skip to content

Commit d6dab90

Browse files
hghimiralucasdemarchi
authored andcommitted
drm/xe: Remove sysfs only once on action add failure
The drmm_add_action_or_reset function automatically invokes the action (sysfs removal) in the event of a failure; therefore, there's no necessity to call it within the return check. Modify the return type of xe_gt_ccs_mode_sysfs_init to int, allowing the caller to pass errors up the call chain. Should sysfs creation or drmm_add_action_or_reset fail, error propagation will prompt a driver load abort. -v2 Edit commit message (Nikula/Lucas) use err_force_wake label instead of new. (Lucas) Avoid unnecessary warn/error messages. (Lucas) Fixes: f3bc5bb ("drm/xe: Allow userspace to configure CCS mode") Cc: Lucas De Marchi <[email protected]> Cc: Jani Nikula <[email protected]> Cc: Rodrigo Vivi <[email protected]> Cc: Niranjana Vishwanathapura <[email protected]> Reviewed-by: Lucas De Marchi <[email protected]> Signed-off-by: Himal Prasad Ghimiray <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Lucas De Marchi <[email protected]> (cherry picked from commit a99641e) Signed-off-by: Lucas De Marchi <[email protected]>
1 parent ed30a4a commit d6dab90

File tree

3 files changed

+11
-14
lines changed

3 files changed

+11
-14
lines changed

drivers/gpu/drm/xe/xe_gt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,9 @@ static int gt_fw_domain_init(struct xe_gt *gt)
378378
err);
379379

380380
/* Initialize CCS mode sysfs after early initialization of HW engines */
381-
xe_gt_ccs_mode_sysfs_init(gt);
381+
err = xe_gt_ccs_mode_sysfs_init(gt);
382+
if (err)
383+
goto err_force_wake;
382384

383385
/*
384386
* Stash hardware-reported version. Since this register does not exist

drivers/gpu/drm/xe/xe_gt_ccs_mode.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -167,25 +167,20 @@ static void xe_gt_ccs_mode_sysfs_fini(struct drm_device *drm, void *arg)
167167
* and it is expected that there are no open drm clients while doing so.
168168
* The number of available compute slices is exposed to user through a per-gt
169169
* 'num_cslices' sysfs interface.
170+
*
171+
* Returns: Returns error value for failure and 0 for success.
170172
*/
171-
void xe_gt_ccs_mode_sysfs_init(struct xe_gt *gt)
173+
int xe_gt_ccs_mode_sysfs_init(struct xe_gt *gt)
172174
{
173175
struct xe_device *xe = gt_to_xe(gt);
174176
int err;
175177

176178
if (!xe_gt_ccs_mode_enabled(gt))
177-
return;
179+
return 0;
178180

179181
err = sysfs_create_files(gt->sysfs, gt_ccs_mode_attrs);
180-
if (err) {
181-
drm_warn(&xe->drm, "Sysfs creation for ccs_mode failed err: %d\n", err);
182-
return;
183-
}
182+
if (err)
183+
return err;
184184

185-
err = drmm_add_action_or_reset(&xe->drm, xe_gt_ccs_mode_sysfs_fini, gt);
186-
if (err) {
187-
sysfs_remove_files(gt->sysfs, gt_ccs_mode_attrs);
188-
drm_warn(&xe->drm, "%s: drmm_add_action_or_reset failed, err: %d\n",
189-
__func__, err);
190-
}
185+
return drmm_add_action_or_reset(&xe->drm, xe_gt_ccs_mode_sysfs_fini, gt);
191186
}

drivers/gpu/drm/xe/xe_gt_ccs_mode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
#include "xe_platform_types.h"
1313

1414
void xe_gt_apply_ccs_mode(struct xe_gt *gt);
15-
void xe_gt_ccs_mode_sysfs_init(struct xe_gt *gt);
15+
int xe_gt_ccs_mode_sysfs_init(struct xe_gt *gt);
1616

1717
static inline bool xe_gt_ccs_mode_enabled(const struct xe_gt *gt)
1818
{

0 commit comments

Comments
 (0)