@@ -37,6 +37,7 @@
#include <uapi/drm/drm.h>
#include <drm/drm_prime.h>
+#include <drm/drm_print.h>
struct dma_fence;
struct drm_file;
@@ -446,6 +447,43 @@ static inline bool drm_is_accel_client(const struct drm_file *file_priv)
return file_priv->minor->type == DRM_MINOR_ACCEL;
}
+static __maybe_unused struct task_struct *drm_task_lock(struct drm_file *file_priv)
+{
+ struct task_struct *task;
+ struct pid *pid;
+
+ mutex_lock(&file_priv->client_name_lock);
+ rcu_read_lock();
+ pid = rcu_dereference(file_priv->pid);
+ task = pid_task(pid, PIDTYPE_TGID);
+ return task;
+}
+
+static __maybe_unused void drm_task_unlock(struct drm_file *file_priv)
+{
+ rcu_read_unlock();
+ mutex_unlock(&file_priv->client_name_lock);
+}
+/**
+ * drm_file_err - Fill info string with process name and pid
+ * @file_priv: context of interest for process name and pid
+ * @fmt: prinf() like format string
+ *
+ * This update the user provided buffer with process
+ * name and pid information for @file_priv
+ */
+#define drm_file_err(file_priv, fmt, ...) \
+ do { \
+ struct task_struct *task; \
+ struct drm_device *dev = file_priv->minor->dev; \
+ \
+ task = drm_task_lock(file_priv); \
+ drm_err(dev, "comm: %s pid: %d client: %s " fmt, \
+ task ? task->comm : "", task ? task->pid : 0, \
+ file_priv->client_name ?: "Unset", ##__VA_ARGS__); \
+ drm_task_unlock(file_priv); \
+ } while (0)
+
void drm_file_update_pid(struct drm_file *);
struct drm_minor *drm_minor_acquire(struct xarray *minors_xa, unsigned int minor_id);
Add a drm helper macro which append the process information for the drm_file over drm_err. Signed-off-by: Sunil Khatri <sunil.khatri@amd.com> --- include/drm/drm_file.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)