summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/xe/xe_tile_sysfs.c
diff options
context:
space:
mode:
authorAndrew Morton <akpm@linux-foundation.org>2024-01-17 23:58:28 +0300
committerAndrew Morton <akpm@linux-foundation.org>2024-01-17 23:58:28 +0300
commitfe33c0fbed75dd464747c0faaedf94c7d8eb4101 (patch)
tree057a9d98ca492c55708baedcc59bf2ea3e2511c7 /drivers/gpu/drm/xe/xe_tile_sysfs.c
parent5d4747a6cc8e78ce74742d557fc9b7697fcacc95 (diff)
parent052d534373b7ed33712a63d5e17b2b6cdbce84fd (diff)
downloadlinux-fe33c0fbed75dd464747c0faaedf94c7d8eb4101.tar.xz
Merge branch 'master' into mm-hotfixes-stable
Diffstat (limited to 'drivers/gpu/drm/xe/xe_tile_sysfs.c')
-rw-r--r--drivers/gpu/drm/xe/xe_tile_sysfs.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/drivers/gpu/drm/xe/xe_tile_sysfs.c b/drivers/gpu/drm/xe/xe_tile_sysfs.c
new file mode 100644
index 000000000000..0f8d3e7fce46
--- /dev/null
+++ b/drivers/gpu/drm/xe/xe_tile_sysfs.c
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: MIT
+/*
+ * Copyright © 2023 Intel Corporation
+ */
+
+#include <linux/kobject.h>
+#include <linux/sysfs.h>
+#include <drm/drm_managed.h>
+
+#include "xe_tile.h"
+#include "xe_tile_sysfs.h"
+
+static void xe_tile_sysfs_kobj_release(struct kobject *kobj)
+{
+ kfree(kobj);
+}
+
+static const struct kobj_type xe_tile_sysfs_kobj_type = {
+ .release = xe_tile_sysfs_kobj_release,
+ .sysfs_ops = &kobj_sysfs_ops,
+};
+
+static void tile_sysfs_fini(struct drm_device *drm, void *arg)
+{
+ struct xe_tile *tile = arg;
+
+ kobject_put(tile->sysfs);
+}
+
+void xe_tile_sysfs_init(struct xe_tile *tile)
+{
+ struct xe_device *xe = tile_to_xe(tile);
+ struct device *dev = xe->drm.dev;
+ struct kobj_tile *kt;
+ int err;
+
+ kt = kzalloc(sizeof(*kt), GFP_KERNEL);
+ if (!kt)
+ return;
+
+ kobject_init(&kt->base, &xe_tile_sysfs_kobj_type);
+ kt->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;
+ }
+
+ tile->sysfs = &kt->base;
+
+ err = drmm_add_action_or_reset(&xe->drm, tile_sysfs_fini, tile);
+ if (err)
+ drm_warn(&xe->drm, "%s: drmm_add_action_or_reset failed, err: %d\n",
+ __func__, err);
+}