mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
accel/ivpu: Add fdinfo support for memory statistics
Implement DRM fdinfo interface to expose memory usage statistics for NPU device file descriptors. Exclude unpinned and imported buffers from resident memory calculations to provide accurate memory usage reporting. Reviewed-by: Jeff Hugo <jeff.hugo@oss.qualcomm.com> Signed-off-by: Karol Wachowski <karol.wachowski@linux.intel.com> Link: https://patch.msgid.link/20251106101052.1050348-2-karol.wachowski@linux.intel.com
This commit is contained in:
@@ -455,6 +455,9 @@ int ivpu_shutdown(struct ivpu_device *vdev)
|
||||
static const struct file_operations ivpu_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
DRM_ACCEL_FOPS,
|
||||
#if CONFIG_PROC_FS
|
||||
.show_fdinfo = drm_show_fdinfo,
|
||||
#endif
|
||||
};
|
||||
|
||||
static const struct drm_driver driver = {
|
||||
@@ -469,6 +472,9 @@ static const struct drm_driver driver = {
|
||||
.ioctls = ivpu_drm_ioctls,
|
||||
.num_ioctls = ARRAY_SIZE(ivpu_drm_ioctls),
|
||||
.fops = &ivpu_fops,
|
||||
#if CONFIG_PROC_FS
|
||||
.show_fdinfo = drm_show_memory_stats,
|
||||
#endif
|
||||
|
||||
.name = DRIVER_NAME,
|
||||
.desc = DRIVER_DESC,
|
||||
|
||||
@@ -333,6 +333,17 @@ static void ivpu_gem_bo_free(struct drm_gem_object *obj)
|
||||
drm_gem_shmem_free(&bo->base);
|
||||
}
|
||||
|
||||
static enum drm_gem_object_status ivpu_gem_status(struct drm_gem_object *obj)
|
||||
{
|
||||
struct ivpu_bo *bo = to_ivpu_bo(obj);
|
||||
enum drm_gem_object_status status = 0;
|
||||
|
||||
if (ivpu_bo_is_resident(bo))
|
||||
status |= DRM_GEM_OBJECT_RESIDENT;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static const struct drm_gem_object_funcs ivpu_gem_funcs = {
|
||||
.free = ivpu_gem_bo_free,
|
||||
.open = ivpu_gem_bo_open,
|
||||
@@ -343,6 +354,7 @@ static const struct drm_gem_object_funcs ivpu_gem_funcs = {
|
||||
.vmap = drm_gem_shmem_object_vmap,
|
||||
.vunmap = drm_gem_shmem_object_vunmap,
|
||||
.mmap = drm_gem_shmem_object_mmap,
|
||||
.status = ivpu_gem_status,
|
||||
.vm_ops = &drm_gem_shmem_vm_ops,
|
||||
};
|
||||
|
||||
|
||||
@@ -82,6 +82,11 @@ static inline bool ivpu_bo_is_read_only(struct ivpu_bo *bo)
|
||||
return bo->flags & DRM_IVPU_BO_READ_ONLY;
|
||||
}
|
||||
|
||||
static inline bool ivpu_bo_is_resident(struct ivpu_bo *bo)
|
||||
{
|
||||
return !!bo->base.pages;
|
||||
}
|
||||
|
||||
static inline void *ivpu_to_cpu_addr(struct ivpu_bo *bo, u32 vpu_addr)
|
||||
{
|
||||
if (vpu_addr < bo->vpu_addr)
|
||||
|
||||
Reference in New Issue
Block a user