Files
linux/drivers/gpu/drm/xe/xe_tile_sysfs.c
Sujaritha Sundaresan 4ae3aeab32 drm/xe: Add vram frequency sysfs attributes
Add vram frequency sysfs attributes under the below hierarchy;

/device/tile#/memory/freq0
			|-max_freq
			|-min_freq

v2: Drop "vram" from attribute names (Rodrigo)

v3: Add documentation for new sysfs (Riana)
    Drop prefix from XEHP_PCODE_FREQUENCY_CONFIG (Riana)

v4: Create sysfs under tile#/freq0 after removal of
    physical_memsize attrbute

v5: Revert back to creating sysfs under tile#/memory/freq0
    Remove definition of GT_FREQUENCY_MULTIPLIER (Rodrigo)

v6: Rename attributes to max/min_freq (Anshuman)
    Fix review comments (Rodrigo)

v7: Make documentation more verbose
    Move sysfs to separate file (Anshuman)

v8: Fix platform specific conditions and add kernel doc (Anshuman)
    Fix typos and remove redundant headers (Riana)

v9: Fix typo (Riana)
    Change function name to include "sysfs" (Lucas)

Signed-off-by: Sujaritha Sundaresan <sujaritha.sundaresan@intel.com>
Reviewed-by: Anshuman Gupta <anshuman.gupta@intel.com>
Link: https://lore.kernel.org/r/20240109110418.2065101-1-sujaritha.sundaresan@intel.com
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
2024-01-09 17:47:24 -05:00

61 lines
1.3 KiB
C

// 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"
#include "xe_vram_freq.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;
xe_vram_freq_sysfs_init(tile);
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);
}