drm_WARN_ON(drm, vc4_hvs_debugfs_init(minor));
+ if (vc4->is_vc5) {
+ drm_WARN_ON(drm, vc5_bo_debugfs_init(minor));
+ }
+
if (vc4->v3d) {
drm_WARN_ON(drm, vc4_bo_debugfs_init(minor));
drm_WARN_ON(drm, vc4_v3d_debugfs_init(minor));
return 0;
}
+struct vc5_gem_info_data {
+ struct drm_file *filp;
+ struct seq_file *m;
+};
+
+static int vc5_gem_one_info(int id, void *ptr, void *data)
+{
+
+ struct drm_gem_object *obj = (struct drm_gem_object *)ptr;
+ struct vc5_gem_info_data *gem_info_data = data;
+ struct vc4_file *vc4file = gem_info_data->filp->driver_priv;
+ struct drm_vc5_file_private *file_priv = &vc4file->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",
+ file_priv->pid,
+ file_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 vc5_debugfs_gem_info(struct seq_file *m, void *data)
+{
+ struct drm_info_node *node = (struct drm_info_node *)m->private;
+ struct drm_minor *minor = node->minor;
+ struct drm_device *drm_dev = minor->dev;
+ struct vc5_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, vc5_gem_one_info,
+ &gem_info_data);
+ spin_unlock(&filp->table_lock);
+ }
+ mutex_unlock(&drm_dev->struct_mutex);
+
+ return 0;
+}
+
int vc4_debugfs_add_file(struct drm_minor *minor,
const char *name,
int (*show)(struct seq_file*, void*),
return 0;
}
+static void vc5_gem_register_pid(struct drm_file *file_priv)
+{
+ struct vc4_file *vc4file = file_priv->driver_priv;
+ struct drm_vc5_file_private *driver_priv = &vc4file->priv;
+
+ if (!driver_priv->pid && !driver_priv->tgid) {
+ driver_priv->pid = task_pid_nr(current);
+ driver_priv->tgid = task_tgid_nr(current);
+ } else {
+ if (driver_priv->pid != task_pid_nr(current))
+ DRM_DEBUG_KMS("wrong pid: %ld, %ld\n",
+ (unsigned long)driver_priv->pid,
+ (unsigned long)task_pid_nr(current));
+ if (driver_priv->tgid != task_tgid_nr(current))
+ DRM_DEBUG_KMS("wrong tgid: %ld, %ld\n",
+ (unsigned long)driver_priv->tgid,
+ (unsigned long)task_tgid_nr(current));
+ }
+}
+
+int vc5_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;
+
+ vc5_gem_register_pid(file_priv);
+
+ return ret;
+}
+
static int vc4_dumb_create(struct drm_file *file_priv,
struct drm_device *dev,
struct drm_mode_create_dumb *args)
if (ret)
return ret;
- return drm_gem_cma_dumb_create_internal(file_priv, dev, args);
+ ret = drm_gem_cma_dumb_create_internal(file_priv, dev, args);
+ if (!ret)
+ vc5_gem_register_pid(file_priv);
+
+ return ret;
}
static int vc4_get_param_ioctl(struct drm_device *dev, void *data,
kfree(vc4file);
}
+static int vc5_open(struct drm_device *dev, struct drm_file *file)
+{
+ struct vc4_dev *vc4 = to_vc4_dev(dev);
+ struct vc4_file *vc4file;
+
+ vc4file = kzalloc(sizeof(*vc4file), GFP_KERNEL);
+ if (!vc4file)
+ return -ENOMEM;
+ vc4file->dev = vc4;
+
+ file->driver_priv = vc4file;
+ return 0;
+}
+
+static void vc5_close(struct drm_device *dev, struct drm_file *file)
+{
+ struct vc4_file *vc4file = file->driver_priv;
+
+ kfree(vc4file);
+}
+
DEFINE_DRM_GEM_FOPS(vc4_drm_fops);
static const struct drm_ioctl_desc vc4_drm_ioctls[] = {
DRIVER_ATOMIC |
DRIVER_GEM),
+ .open = vc5_open,
+ .postclose = vc5_close,
#if defined(CONFIG_DEBUG_FS)
.debugfs_init = vc4_debugfs_init,
#endif
DRM_GEM_CMA_DRIVER_OPS_WITH_DUMB_CREATE(vc4_dumb_create),
+ .prime_fd_to_handle = vc5_drm_gem_prime_fd_to_handle,
.fops = &vc4_drm_fops,
.name = DRIVER_NAME,
"raspberrypi,rpi-firmware-kms-2711"));
}
+int vc5_bo_debugfs_init(struct drm_minor *minor)
+{
+ struct drm_device *drm = minor->dev;
+ struct vc4_dev *vc4 = to_vc4_dev(drm);
+ int ret;
+
+ if (!vc4->is_vc5)
+ return -ENODEV;
+
+ ret = vc4_debugfs_add_file(minor, "gem_info",
+ vc5_debugfs_gem_info, NULL);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
static int vc4_drm_bind(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
bool bin_bo_used;
};
+struct drm_vc5_file_private {
+ pid_t pid;
+ pid_t tgid;
+};
+
/* Per-open file private data. Any driver-specific resource that has to be
* released when the DRM file is closed should be placed here.
*/
} perfmon;
bool bin_bo_used;
+ struct drm_vc5_file_private priv;
};
static inline struct vc4_exec_info *
void vc4_bo_add_to_purgeable_pool(struct vc4_bo *bo);
void vc4_bo_remove_from_purgeable_pool(struct vc4_bo *bo);
int vc4_bo_debugfs_init(struct drm_minor *minor);
+int vc5_bo_debugfs_init(struct drm_minor *minor);
/* vc4_crtc.c */
extern struct platform_driver vc4_crtc_driver;
struct vc4_validated_shader_info *
vc4_validate_shader(struct drm_gem_cma_object *shader_obj);
+int vc5_debugfs_gem_info(struct seq_file *m, void *data);
+
/* vc4_perfmon.c */
void vc4_perfmon_get(struct vc4_perfmon *perfmon);
void vc4_perfmon_put(struct vc4_perfmon *perfmon);