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:f3bc5bb4d5
("drm/xe: Allow userspace to configure CCS mode") Cc: Lucas De Marchi <lucas.demarchi@intel.com> Cc: Jani Nikula <jani.nikula@intel.com> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> Cc: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20240412181211.1155732-3-himal.prasad.ghimiray@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> (cherry picked from commita99641e387
) Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
This commit is contained in:
parent
ed30a4a51b
commit
d6dab9017b
|
@ -378,7 +378,9 @@ static int gt_fw_domain_init(struct xe_gt *gt)
|
||||||
err);
|
err);
|
||||||
|
|
||||||
/* Initialize CCS mode sysfs after early initialization of HW engines */
|
/* Initialize CCS mode sysfs after early initialization of HW engines */
|
||||||
xe_gt_ccs_mode_sysfs_init(gt);
|
err = xe_gt_ccs_mode_sysfs_init(gt);
|
||||||
|
if (err)
|
||||||
|
goto err_force_wake;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Stash hardware-reported version. Since this register does not exist
|
* Stash hardware-reported version. Since this register does not exist
|
||||||
|
|
|
@ -167,25 +167,20 @@ static void xe_gt_ccs_mode_sysfs_fini(struct drm_device *drm, void *arg)
|
||||||
* and it is expected that there are no open drm clients while doing so.
|
* and it is expected that there are no open drm clients while doing so.
|
||||||
* The number of available compute slices is exposed to user through a per-gt
|
* The number of available compute slices is exposed to user through a per-gt
|
||||||
* 'num_cslices' sysfs interface.
|
* 'num_cslices' sysfs interface.
|
||||||
|
*
|
||||||
|
* Returns: Returns error value for failure and 0 for success.
|
||||||
*/
|
*/
|
||||||
void xe_gt_ccs_mode_sysfs_init(struct xe_gt *gt)
|
int xe_gt_ccs_mode_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;
|
||||||
|
|
||||||
if (!xe_gt_ccs_mode_enabled(gt))
|
if (!xe_gt_ccs_mode_enabled(gt))
|
||||||
return;
|
return 0;
|
||||||
|
|
||||||
err = sysfs_create_files(gt->sysfs, gt_ccs_mode_attrs);
|
err = sysfs_create_files(gt->sysfs, gt_ccs_mode_attrs);
|
||||||
if (err) {
|
if (err)
|
||||||
drm_warn(&xe->drm, "Sysfs creation for ccs_mode failed err: %d\n", err);
|
return err;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = drmm_add_action_or_reset(&xe->drm, xe_gt_ccs_mode_sysfs_fini, gt);
|
return drmm_add_action_or_reset(&xe->drm, xe_gt_ccs_mode_sysfs_fini, gt);
|
||||||
if (err) {
|
|
||||||
sysfs_remove_files(gt->sysfs, gt_ccs_mode_attrs);
|
|
||||||
drm_warn(&xe->drm, "%s: drmm_add_action_or_reset failed, err: %d\n",
|
|
||||||
__func__, err);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "xe_platform_types.h"
|
#include "xe_platform_types.h"
|
||||||
|
|
||||||
void xe_gt_apply_ccs_mode(struct xe_gt *gt);
|
void xe_gt_apply_ccs_mode(struct xe_gt *gt);
|
||||||
void xe_gt_ccs_mode_sysfs_init(struct xe_gt *gt);
|
int xe_gt_ccs_mode_sysfs_init(struct xe_gt *gt);
|
||||||
|
|
||||||
static inline bool xe_gt_ccs_mode_enabled(const struct xe_gt *gt)
|
static inline bool xe_gt_ccs_mode_enabled(const struct xe_gt *gt)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue