Lines Matching full:file

36 #include <linux/file.h>
70 * DOC: file operations
72 * Drivers must define the file operations structure that forms the DRM
85 * userspace through the file descriptor. They are used to send vblank event and
95 * No other file operations are supported by the DRM userspace API. Overall the
120 * drm_file_alloc - allocate file context
123 * This allocates a new DRM file context. It is not linked into any context and
134 struct drm_file *file; in drm_file_alloc() local
137 file = kzalloc(sizeof(*file), GFP_KERNEL); in drm_file_alloc()
138 if (!file) in drm_file_alloc()
142 file->client_id = atomic64_inc_return(&ident); in drm_file_alloc()
143 rcu_assign_pointer(file->pid, get_pid(task_tgid(current))); in drm_file_alloc()
144 file->minor = minor; in drm_file_alloc()
147 file->authenticated = capable(CAP_SYS_ADMIN); in drm_file_alloc()
149 INIT_LIST_HEAD(&file->lhead); in drm_file_alloc()
150 INIT_LIST_HEAD(&file->fbs); in drm_file_alloc()
151 mutex_init(&file->fbs_lock); in drm_file_alloc()
152 INIT_LIST_HEAD(&file->blobs); in drm_file_alloc()
153 INIT_LIST_HEAD(&file->pending_event_list); in drm_file_alloc()
154 INIT_LIST_HEAD(&file->event_list); in drm_file_alloc()
155 init_waitqueue_head(&file->event_wait); in drm_file_alloc()
156 file->event_space = 4096; /* set aside 4k for event buffer */ in drm_file_alloc()
158 spin_lock_init(&file->master_lookup_lock); in drm_file_alloc()
159 mutex_init(&file->event_read_lock); in drm_file_alloc()
162 drm_gem_open(dev, file); in drm_file_alloc()
165 drm_syncobj_open(file); in drm_file_alloc()
167 drm_prime_init_file_private(&file->prime); in drm_file_alloc()
170 ret = dev->driver->open(dev, file); in drm_file_alloc()
175 return file; in drm_file_alloc()
178 drm_prime_destroy_file_private(&file->prime); in drm_file_alloc()
180 drm_syncobj_release(file); in drm_file_alloc()
182 drm_gem_release(dev, file); in drm_file_alloc()
183 put_pid(rcu_access_pointer(file->pid)); in drm_file_alloc()
184 kfree(file); in drm_file_alloc()
214 * drm_file_free - free file context
215 * @file: context to free, or NULL
217 * This destroys and deallocates a DRM file context previously allocated via
223 void drm_file_free(struct drm_file *file) in drm_file_free() argument
227 if (!file) in drm_file_free()
230 dev = file->minor->dev; in drm_file_free()
234 (long)old_encode_dev(file->minor->kdev->devt), in drm_file_free()
237 drm_events_release(file); in drm_file_free()
240 drm_fb_release(file); in drm_file_free()
241 drm_property_destroy_user_blobs(dev, file); in drm_file_free()
245 drm_syncobj_release(file); in drm_file_free()
248 drm_gem_release(dev, file); in drm_file_free()
250 if (drm_is_primary_client(file)) in drm_file_free()
251 drm_master_release(file); in drm_file_free()
254 dev->driver->postclose(dev, file); in drm_file_free()
256 drm_prime_destroy_file_private(&file->prime); in drm_file_free()
258 WARN_ON(!list_empty(&file->event_list)); in drm_file_free()
260 put_pid(rcu_access_pointer(file->pid)); in drm_file_free()
261 kfree(file); in drm_file_free()
264 static void drm_close_helper(struct file *filp) in drm_close_helper()
292 * \param filp file pointer.
296 * Creates and initializes a drm_file structure for the file private data in \p
299 int drm_open_helper(struct file *filp, struct drm_minor *minor) in drm_open_helper()
341 * drm_open - open method for DRM file
343 * @filp: file pointer.
346 * It looks up the correct DRM device and instantiates all the per-file
352 int drm_open(struct inode *inode, struct file *filp) in drm_open()
398 * drm_release - release method for DRM file
400 * @filp: file pointer.
403 * method. It frees any resources associated with the open file. If this
404 * is the last open file for the DRM device, it also restores the active
410 int drm_release(struct inode *inode, struct file *filp) in drm_release()
468 * drm_release_noglobal - release method for DRM file
470 * @filp: file pointer.
473 * method. It frees any resources associated with the open file prior to taking
474 * the drm_global_mutex. If this is the last open file for the DRM device, it
480 int drm_release_noglobal(struct inode *inode, struct file *filp) in drm_release_noglobal()
500 * drm_read - read method for DRM file
501 * @filp: file pointer
523 ssize_t drm_read(struct file *filp, char __user *buffer, in drm_read()
593 * drm_poll - poll method for DRM file
594 * @filp: file pointer
605 * Mask of POLL flags indicating the current status of the file.
607 __poll_t drm_poll(struct file *filp, struct poll_table_struct *wait) in drm_poll()
624 * @file_priv: DRM file private data
665 * @file_priv: DRM file private data
761 * drm_send_event_timestamp_locked - send DRM event to file descriptor
768 * to its associated userspace DRM file. Callers must already hold
772 * corresponding DRM file is closed. Drivers need not worry about whether the
773 * DRM file for this event still exists and can call this function upon
784 * drm_send_event_locked - send DRM event to file descriptor
789 * to its associated userspace DRM file. Callers must already hold
793 * corresponding DRM file is closed. Drivers need not worry about whether the
794 * DRM file for this event still exists and can call this function upon
804 * drm_send_event - send DRM event to file descriptor
809 * to its associated userspace DRM file. This function acquires
814 * corresponding DRM file is closed. Drivers need not worry about whether the
815 * DRM file for this event still exists and can call this function upon
871 * @file: the DRM file
874 * file.
876 void drm_show_memory_stats(struct drm_printer *p, struct drm_file *file) in drm_show_memory_stats() argument
883 spin_lock(&file->table_lock); in drm_show_memory_stats()
884 idr_for_each_entry (&file->object_idr, obj, id) { in drm_show_memory_stats()
920 spin_unlock(&file->table_lock); in drm_show_memory_stats()
927 * drm_show_fdinfo - helper for drm file fops
929 * @f: the device file instance
936 void drm_show_fdinfo(struct seq_file *m, struct file *f) in drm_show_fdinfo()
938 struct drm_file *file = f->private_data; in drm_show_fdinfo() local
939 struct drm_device *dev = file->minor->dev; in drm_show_fdinfo()
943 drm_printf(&p, "drm-client-id:\t%llu\n", file->client_id); in drm_show_fdinfo()
954 dev->driver->show_fdinfo(&p, file); in drm_show_fdinfo()
959 * mock_drm_getfile - Create a new struct file for the drm device
961 * @flags: file creation mode (O_RDWR etc)
963 * This create a new struct file that wraps a DRM file context around a
965 * invoking userspace. The struct file may be operated on using its f_op
970 * Pointer to newly created struct file, ERR_PTR on failure.
972 struct file *mock_drm_getfile(struct drm_minor *minor, unsigned int flags) in mock_drm_getfile()
976 struct file *file; in mock_drm_getfile() local
982 file = anon_inode_getfile("drm", dev->driver->fops, priv, flags); in mock_drm_getfile()
983 if (IS_ERR(file)) { in mock_drm_getfile()
985 return file; in mock_drm_getfile()
989 file->f_mapping = dev->anon_inode->i_mapping; in mock_drm_getfile()
992 priv->filp = file; in mock_drm_getfile()
994 return file; in mock_drm_getfile()