2023-06-28 11:08:35 +05:30
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/*
|
|
|
|
* Copyright © 2023 Intel Corporation
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kobject.h>
|
|
|
|
#include <linux/sysfs.h>
|
|
|
|
#include <drm/drm_managed.h>
|
|
|
|
|
2024-02-22 11:39:28 -05:00
|
|
|
#include "xe_pm.h"
|
2023-06-28 11:08:35 +05:30
|
|
|
#include "xe_tile.h"
|
|
|
|
#include "xe_tile_sysfs.h"
|
2024-01-09 16:34:18 +05:30
|
|
|
#include "xe_vram_freq.h"
|
2023-06-28 11:08:35 +05:30
|
|
|
|
|
|
|
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,
|
|
|
|
};
|
|
|
|
|
2024-05-22 11:21:45 +01:00
|
|
|
static void tile_sysfs_fini(void *arg)
|
2023-06-28 11:08:35 +05:30
|
|
|
{
|
|
|
|
struct xe_tile *tile = arg;
|
|
|
|
|
|
|
|
kobject_put(tile->sysfs);
|
|
|
|
}
|
|
|
|
|
2024-04-12 23:42:10 +05:30
|
|
|
int xe_tile_sysfs_init(struct xe_tile *tile)
|
2023-06-28 11:08:35 +05:30
|
|
|
{
|
|
|
|
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)
|
2024-04-12 23:42:10 +05:30
|
|
|
return -ENOMEM;
|
2023-06-28 11:08:35 +05:30
|
|
|
|
|
|
|
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);
|
2024-04-12 23:42:10 +05:30
|
|
|
return err;
|
2023-06-28 11:08:35 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
tile->sysfs = &kt->base;
|
|
|
|
|
2024-04-12 23:42:10 +05:30
|
|
|
err = xe_vram_freq_sysfs_init(tile);
|
2023-12-11 19:20:58 -05:00
|
|
|
if (err)
|
2024-04-12 23:42:10 +05:30
|
|
|
return err;
|
|
|
|
|
2024-05-22 11:21:45 +01:00
|
|
|
return devm_add_action_or_reset(xe->drm.dev, tile_sysfs_fini, tile);
|
2023-06-28 11:08:35 +05:30
|
|
|
}
|