return obj;
}
+static void v3d_gem_register_pid(struct drm_file *file)
+{
+ struct v3d_file_priv *v3d_priv = file->driver_priv;
+ struct drm_v3d_file_private *pid_priv;
+
+ if (!v3d_priv)
+ return;
+
+ pid_priv = &v3d_priv->priv;
+
+ if (!pid_priv->pid && !pid_priv->tgid) {
+ pid_priv->pid = task_pid_nr(current);
+ pid_priv->tgid = task_tgid_nr(current);
+ } else {
+ if (pid_priv->pid != task_pid_nr(current))
+ DRM_DEBUG_KMS("wrong pid: %ld, %ld\n",
+ (unsigned long)pid_priv->pid,
+ (unsigned long)task_pid_nr(current));
+ if (pid_priv->tgid != task_tgid_nr(current))
+ DRM_DEBUG_KMS("wrong tgid: %ld, %ld\n",
+ (unsigned long)pid_priv->tgid,
+ (unsigned long)task_tgid_nr(current));
+ }
+}
+
+int v3d_drm_gem_prime_fd_to_handle(struct drm_device *dev,
+ struct drm_file *file_priv, int prime_fd,
+ uint32_t *handle)
+{
+ int ret;
+
+ ret = drm_gem_prime_fd_to_handle(dev, file_priv, prime_fd, handle);
+ if (ret < 0)
+ return ret;
+
+ v3d_gem_register_pid(file_priv);
+
+ return ret;
+}
+
int v3d_create_bo_ioctl(struct drm_device *dev, void *data,
struct drm_file *file_priv)
{
args->offset = bo->node.start << V3D_MMU_PAGE_SHIFT;
ret = drm_gem_handle_create(file_priv, &bo->base.base, &args->handle);
+ if (!ret)
+ v3d_gem_register_pid(file_priv);
+
drm_gem_object_put(&bo->base.base);
return ret;
return 0;
}
+struct v3d_gem_info_data {
+ struct drm_file *filp;
+ struct seq_file *m;
+};
+
+static int v3d_gem_one_info(int id, void *ptr, void *data)
+{
+ struct drm_gem_object *obj = (struct drm_gem_object *)ptr;
+ struct v3d_gem_info_data *gem_info_data = data;
+ struct v3d_file_priv *v3d_priv = gem_info_data->filp->driver_priv;
+ struct drm_v3d_file_private *pid_priv = &v3d_priv->priv;
+
+ if (!obj) {
+ DRM_ERROR("failed to get drm_gem_object\n");
+ return -EFAULT;
+ }
+
+ drm_gem_object_get(obj);
+
+ seq_printf(gem_info_data->m,
+ "%5d\t%5d\t%4d\t%4d\t\t%4d\t0x%08zx\t0x%x\t%4d\t%4d\t\t"
+ "%4d\t\t0x%p\t%6d\n",
+ pid_priv->pid,
+ pid_priv->tgid,
+ id,
+ kref_read(&obj->refcount) - 1,
+ obj->handle_count,
+ obj->size,
+ 0,
+ 0,
+ obj->dma_buf ? 1 : 0,
+ obj->import_attach ? 1 : 0,
+ obj,
+ obj->name);
+
+ drm_gem_object_put(obj);
+
+ return 0;
+}
+
+int v3d_debugfs_gem_info(struct seq_file *m, void *data)
+{
+ struct drm_debugfs_entry *entry = m->private;
+ struct drm_device *drm_dev = entry->dev;
+ struct v3d_gem_info_data gem_info_data;
+ struct drm_file *filp;
+
+ gem_info_data.m = m;
+
+ seq_puts(gem_info_data.m,
+ "pid\ttgid\thandle\trefcount\thcount\tsize\t\tflags\t"
+ "pfnmap\texport_to_fd\timport_from_fd\tobj_addr\t\t"
+ "name\n");
+
+ mutex_lock(&drm_dev->struct_mutex);
+ list_for_each_entry(filp, &drm_dev->filelist, lhead) {
+ gem_info_data.filp = filp;
+
+ spin_lock(&filp->table_lock);
+ idr_for_each(&filp->object_idr, v3d_gem_one_info,
+ &gem_info_data);
+ spin_unlock(&filp->table_lock);
+ }
+ mutex_unlock(&drm_dev->struct_mutex);
+
+ return 0;
+}
+
static const struct drm_debugfs_info v3d_debugfs_list[] = {
{"v3d_ident", v3d_v3d_debugfs_ident, 0},
{"v3d_regs", v3d_v3d_debugfs_regs, 0},
{"measure_clock", v3d_measure_clock, 0},
{"bo_stats", v3d_debugfs_bo_stats, 0},
{"gpu_usage", v3d_debugfs_gpu_usage, 0},
+ {"gpu_gem_info", v3d_debugfs_gem_info, 0},
{"gpu_pid_usage", v3d_debugfs_gpu_pid_usage, 0},
};
#define v3d_to_pdev(v3d) to_platform_device((v3d)->drm.dev)
+struct drm_v3d_file_private {
+ pid_t pid;
+ pid_t tgid;
+};
+
/* The per-fd struct, which tracks the MMU mappings. */
struct v3d_file_priv {
struct v3d_dev *v3d;
} perfmon;
struct drm_sched_entity sched_entity[V3D_MAX_QUEUES];
+ struct drm_v3d_file_private priv;
};
struct v3d_bo {
struct drm_gem_object *v3d_prime_import_sg_table(struct drm_device *dev,
struct dma_buf_attachment *attach,
struct sg_table *sgt);
+int v3d_drm_gem_prime_fd_to_handle(struct drm_device *dev,
+ struct drm_file *file_priv, int prime_fd,
+ uint32_t *handle);
/* v3d_debugfs.c */
void v3d_debugfs_init(struct drm_minor *minor);