[PATCH v4 6/7] drm/xe/tile: Abort driver load for sysfs creation failure
Lucas De Marchi
lucas.demarchi at intel.com
Thu Apr 18 14:57:58 UTC 2024
On Fri, Apr 12, 2024 at 11:42:10PM GMT, Himal Prasad Ghimiray wrote:
>Ensure that the status of all tile associated sysfs entries creation is
>relayed to xe_tile_init_noalloc, leading to a driver load abort if any
>sysfs creation failures occur.
>
>-v2
>Avoid unnecessary warn/error messages. (Lucas)
>
>Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
>Cc: Lucas De Marchi <lucas.demarchi at intel.com>
>Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray at intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi at intel.com>
thanks
Lucas De Marchi
>---
> drivers/gpu/drm/xe/xe_tile.c | 2 +-
> drivers/gpu/drm/xe/xe_tile_sysfs.c | 16 +++++++---------
> drivers/gpu/drm/xe/xe_tile_sysfs.h | 2 +-
> drivers/gpu/drm/xe/xe_vram_freq.c | 20 ++++++++------------
> drivers/gpu/drm/xe/xe_vram_freq.h | 2 +-
> 5 files changed, 18 insertions(+), 24 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_tile.c b/drivers/gpu/drm/xe/xe_tile.c
>index 0650b2fa75ef..409cf55aa8a1 100644
>--- a/drivers/gpu/drm/xe/xe_tile.c
>+++ b/drivers/gpu/drm/xe/xe_tile.c
>@@ -173,7 +173,7 @@ int xe_tile_init_noalloc(struct xe_tile *tile)
> }
> xe_wa_apply_tile_workarounds(tile);
>
>- xe_tile_sysfs_init(tile);
>+ err = xe_tile_sysfs_init(tile);
>
> err_mem_access:
> xe_device_mem_access_put(tile_to_xe(tile));
>diff --git a/drivers/gpu/drm/xe/xe_tile_sysfs.c b/drivers/gpu/drm/xe/xe_tile_sysfs.c
>index 237a0761d3ad..e1bfe0e4257d 100644
>--- a/drivers/gpu/drm/xe/xe_tile_sysfs.c
>+++ b/drivers/gpu/drm/xe/xe_tile_sysfs.c
>@@ -29,7 +29,7 @@ static void tile_sysfs_fini(struct drm_device *drm, void *arg)
> kobject_put(tile->sysfs);
> }
>
>-void xe_tile_sysfs_init(struct xe_tile *tile)
>+int xe_tile_sysfs_init(struct xe_tile *tile)
> {
> struct xe_device *xe = tile_to_xe(tile);
> struct device *dev = xe->drm.dev;
>@@ -38,7 +38,7 @@ void xe_tile_sysfs_init(struct xe_tile *tile)
>
> kt = kzalloc(sizeof(*kt), GFP_KERNEL);
> if (!kt)
>- return;
>+ return -ENOMEM;
>
> kobject_init(&kt->base, &xe_tile_sysfs_kobj_type);
> kt->tile = tile;
>@@ -46,16 +46,14 @@ void xe_tile_sysfs_init(struct xe_tile *tile)
> err = kobject_add(&kt->base, &dev->kobj, "tile%d", tile->id);
> if (err) {
> kobject_put(&kt->base);
>- drm_warn(&xe->drm, "failed to register TILE sysfs directory, err: %d\n", err);
>- return;
>+ return err;
> }
>
> tile->sysfs = &kt->base;
>
>- xe_vram_freq_sysfs_init(tile);
>-
>- err = drmm_add_action_or_reset(&xe->drm, tile_sysfs_fini, tile);
>+ err = xe_vram_freq_sysfs_init(tile);
> 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, tile_sysfs_fini, tile);
> }
>diff --git a/drivers/gpu/drm/xe/xe_tile_sysfs.h b/drivers/gpu/drm/xe/xe_tile_sysfs.h
>index e4f065039eba..54a2ba8ba533 100644
>--- a/drivers/gpu/drm/xe/xe_tile_sysfs.h
>+++ b/drivers/gpu/drm/xe/xe_tile_sysfs.h
>@@ -8,7 +8,7 @@
>
> #include "xe_tile_sysfs_types.h"
>
>-void xe_tile_sysfs_init(struct xe_tile *tile);
>+int xe_tile_sysfs_init(struct xe_tile *tile);
>
> static inline struct xe_tile *
> kobj_to_tile(struct kobject *kobj)
>diff --git a/drivers/gpu/drm/xe/xe_vram_freq.c b/drivers/gpu/drm/xe/xe_vram_freq.c
>index c5f6b5a5d117..3e21ddc6e60c 100644
>--- a/drivers/gpu/drm/xe/xe_vram_freq.c
>+++ b/drivers/gpu/drm/xe/xe_vram_freq.c
>@@ -100,31 +100,27 @@ static void vram_freq_sysfs_fini(struct drm_device *drm, void *arg)
> * @tile: Xe Tile object
> *
> * It needs to be initialized after the main tile component is ready
>+ *
>+ * Returns: 0 on success, negative error code on error.
> */
>-void xe_vram_freq_sysfs_init(struct xe_tile *tile)
>+int xe_vram_freq_sysfs_init(struct xe_tile *tile)
> {
> struct xe_device *xe = tile_to_xe(tile);
> struct kobject *kobj;
> int err;
>
> if (xe->info.platform != XE_PVC)
>- return;
>+ return 0;
>
> kobj = kobject_create_and_add("memory", tile->sysfs);
>- if (!kobj) {
>- drm_warn(&xe->drm, "failed to add memory directory, err: %d\n", -ENOMEM);
>- return;
>- }
>+ if (!kobj)
>+ return -ENOMEM;
>
> err = sysfs_create_group(kobj, &freq_group_attrs);
> if (err) {
> kobject_put(kobj);
>- drm_warn(&xe->drm, "failed to register vram freq sysfs, err: %d\n", err);
>- return;
>+ return err;
> }
>
>- err = drmm_add_action_or_reset(&xe->drm, vram_freq_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, vram_freq_sysfs_fini, kobj);
> }
>diff --git a/drivers/gpu/drm/xe/xe_vram_freq.h b/drivers/gpu/drm/xe/xe_vram_freq.h
>index cbe8c12fbd64..bf726bc5881f 100644
>--- a/drivers/gpu/drm/xe/xe_vram_freq.h
>+++ b/drivers/gpu/drm/xe/xe_vram_freq.h
>@@ -8,6 +8,6 @@
>
> struct xe_tile;
>
>-void xe_vram_freq_sysfs_init(struct xe_tile *tile);
>+int xe_vram_freq_sysfs_init(struct xe_tile *tile);
>
> #endif /* _XE_VRAM_FREQ_H_ */
>--
>2.25.1
>
More information about the Intel-xe
mailing list