mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-08-28 10:47:32 +00:00
drm/xe: Add sysfs entry for tile
We have recently introduced tile for each gpu, so lets add sysfs entry per tile for userspace to provide required information specific to tile. V5: - define ktype as const V4: - Reorder headers - Aravind V3: - Make API to return void and add drm_warn - Aravind V2: - Add logs in failure path Reviewed-by: Aravind Iddamsetty <aravind.iddamsetty@intel.com> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
This commit is contained in:
parent
5572a00468
commit
e5a845fd8f
@ -103,6 +103,7 @@ xe-y += xe_bb.o \
|
||||
xe_step.o \
|
||||
xe_sync.o \
|
||||
xe_tile.o \
|
||||
xe_tile_sysfs.o \
|
||||
xe_trace.o \
|
||||
xe_ttm_sys_mgr.o \
|
||||
xe_ttm_stolen_mgr.o \
|
||||
|
@ -144,6 +144,9 @@ struct xe_tile {
|
||||
|
||||
/** @migrate: Migration helper for vram blits and clearing */
|
||||
struct xe_migrate *migrate;
|
||||
|
||||
/** @sysfs: sysfs' kobj used by xe_tile_sysfs */
|
||||
struct kobject *sysfs;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "xe_migrate.h"
|
||||
#include "xe_sa.h"
|
||||
#include "xe_tile.h"
|
||||
#include "xe_tile_sysfs.h"
|
||||
#include "xe_ttm_vram_mgr.h"
|
||||
|
||||
/**
|
||||
@ -142,6 +143,8 @@ int xe_tile_init_noalloc(struct xe_tile *tile)
|
||||
if (IS_ERR(tile->mem.kernel_bb_pool))
|
||||
err = PTR_ERR(tile->mem.kernel_bb_pool);
|
||||
|
||||
xe_tile_sysfs_init(tile);
|
||||
|
||||
err_mem_access:
|
||||
xe_device_mem_access_put(tile_to_xe(tile));
|
||||
return err;
|
||||
|
@ -6,6 +6,8 @@
|
||||
#ifndef _XE_TILE_H_
|
||||
#define _XE_TILE_H_
|
||||
|
||||
#include "xe_device_types.h"
|
||||
|
||||
struct xe_tile;
|
||||
|
||||
int xe_tile_alloc(struct xe_tile *tile);
|
||||
|
59
drivers/gpu/drm/xe/xe_tile_sysfs.c
Normal file
59
drivers/gpu/drm/xe/xe_tile_sysfs.c
Normal file
@ -0,0 +1,59 @@
|
||||
// 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);
|
||||
return;
|
||||
}
|
||||
}
|
19
drivers/gpu/drm/xe/xe_tile_sysfs.h
Normal file
19
drivers/gpu/drm/xe/xe_tile_sysfs.h
Normal file
@ -0,0 +1,19 @@
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
/*
|
||||
* Copyright © 2023 Intel Corporation
|
||||
*/
|
||||
|
||||
#ifndef _XE_TILE_SYSFS_H_
|
||||
#define _XE_TILE_SYSFS_H_
|
||||
|
||||
#include "xe_tile_sysfs_types.h"
|
||||
|
||||
void xe_tile_sysfs_init(struct xe_tile *tile);
|
||||
|
||||
static inline struct xe_tile *
|
||||
kobj_to_tile(struct kobject *kobj)
|
||||
{
|
||||
return container_of(kobj, struct kobj_tile, base)->tile;
|
||||
}
|
||||
|
||||
#endif /* _XE_TILE_SYSFS_H_ */
|
27
drivers/gpu/drm/xe/xe_tile_sysfs_types.h
Normal file
27
drivers/gpu/drm/xe/xe_tile_sysfs_types.h
Normal file
@ -0,0 +1,27 @@
|
||||
/* SPDX-License-Identifier: MIT */
|
||||
/*
|
||||
* Copyright © 2023 Intel Corporation
|
||||
*/
|
||||
|
||||
#ifndef _XE_TILE_SYSFS_TYPES_H_
|
||||
#define _XE_TILE_SYSFS_TYPES_H_
|
||||
|
||||
#include <linux/kobject.h>
|
||||
|
||||
struct xe_tile;
|
||||
|
||||
/**
|
||||
* struct kobj_tile - A tile's kobject struct that connects the kobject
|
||||
* and the TILE
|
||||
*
|
||||
* When dealing with multiple TILEs, this struct helps to understand which
|
||||
* TILE needs to be addressed on a given sysfs call.
|
||||
*/
|
||||
struct kobj_tile {
|
||||
/** @base: The actual kobject */
|
||||
struct kobject base;
|
||||
/** @tile: A pointer to the tile itself */
|
||||
struct xe_tile *tile;
|
||||
};
|
||||
|
||||
#endif /* _XE_TILE_SYSFS_TYPES_H_ */
|
Loading…
Reference in New Issue
Block a user