summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/xe/xe_drm_client.c
diff options
context:
space:
mode:
authorTejas Upadhyay <tejas.upadhyay@intel.com>2023-09-21 14:41:34 +0300
committerRodrigo Vivi <rodrigo.vivi@intel.com>2023-12-21 19:41:15 +0300
commitb27970f3e11c616c7a5121537502f6e21a460881 (patch)
tree15d1ae8a28707974d2e63315f3232726e01bda14 /drivers/gpu/drm/xe/xe_drm_client.c
parent85c6ad1aa263a852d51d980575e7c1c305f1697e (diff)
downloadlinux-b27970f3e11c616c7a5121537502f6e21a460881.tar.xz
drm/xe: Add tracking support for bos per client
In order to show per client memory consumption, we need tracking support APIs to add at every bo consumption and removal. Adding APIs here to add tracking calls at places wherever it is applicable. V5: - Rebase V4: - remove client bo before vm_put - spin_lock_irqsave not required - Auld V3: - update .h to return xe_drm_client_remove_bo void - protect xe_drm_client_remove_bo under CONFIG_PROC_FS check - Himal - Fixed Checkpatch error - CI V2: - make xe_drm_client_remove_bo return void - Himal Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Diffstat (limited to 'drivers/gpu/drm/xe/xe_drm_client.c')
-rw-r--r--drivers/gpu/drm/xe/xe_drm_client.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/drivers/gpu/drm/xe/xe_drm_client.c b/drivers/gpu/drm/xe/xe_drm_client.c
index 98c8a0cf2f56..b5ac9bc1f685 100644
--- a/drivers/gpu/drm/xe/xe_drm_client.c
+++ b/drivers/gpu/drm/xe/xe_drm_client.c
@@ -8,8 +8,10 @@
#include <linux/slab.h>
#include <linux/types.h>
+#include "xe_bo_types.h"
#include "xe_device_types.h"
#include "xe_drm_client.h"
+#include "xe_trace.h"
/**
* xe_drm_client_alloc() - Allocate drm client
@@ -31,6 +33,10 @@ struct xe_drm_client *xe_drm_client_alloc(void)
kref_init(&client->kref);
+#ifdef CONFIG_PROC_FS
+ spin_lock_init(&client->bos_lock);
+ INIT_LIST_HEAD(&client->bos_list);
+#endif
return client;
}
@@ -53,6 +59,48 @@ void __xe_drm_client_free(struct kref *kref)
#ifdef CONFIG_PROC_FS
/**
+ * xe_drm_client_add_bo() - Add BO for tracking client mem usage
+ * @client: The drm client ptr
+ * @bo: The xe BO ptr
+ *
+ * Add all BO created by individual drm client by calling this function.
+ * This helps in tracking client memory usage.
+ *
+ * Return: void
+ */
+void xe_drm_client_add_bo(struct xe_drm_client *client,
+ struct xe_bo *bo)
+{
+ XE_WARN_ON(bo->client);
+ XE_WARN_ON(!list_empty(&bo->client_link));
+
+ spin_lock(&client->bos_lock);
+ bo->client = xe_drm_client_get(client);
+ list_add_tail_rcu(&bo->client_link, &client->bos_list);
+ spin_unlock(&client->bos_lock);
+}
+
+/**
+ * xe_drm_client_remove_bo() - Remove BO for tracking client mem usage
+ * @bo: The xe BO ptr
+ *
+ * Remove all BO removed by individual drm client by calling this function.
+ * This helps in tracking client memory usage.
+ *
+ * Return: void
+ */
+void xe_drm_client_remove_bo(struct xe_bo *bo)
+{
+ struct xe_drm_client *client = bo->client;
+
+ spin_lock(&client->bos_lock);
+ list_del_rcu(&bo->client_link);
+ spin_unlock(&client->bos_lock);
+
+ xe_drm_client_put(client);
+}
+
+/**
* xe_drm_client_fdinfo() - Callback for fdinfo interface
* @p: The drm_printer ptr
* @file: The drm_file ptr