@@ -177,6 +177,50 @@ err:
}
EXPORT_SYMBOL(drm_open);
+int drm_flush(struct file *filp, fl_owner_t id)
+{
+ struct drm_file *file_priv = filp->private_data;
+ struct drm_device *dev = file_priv->minor->dev;
+
+ if (atomic_long_read(&filp->f_count) != 1 || !file_priv->is_master)
+ return 0;
+
+ mutex_lock(&dev->struct_mutex);
+
+ if (file_priv->is_master) {
+ struct drm_master *master = file_priv->master;
+ struct drm_file *temp;
+ list_for_each_entry(temp, &dev->filelist, lhead) {
+ if ((temp->master == file_priv->master) &&
+ (temp != file_priv))
+ temp->authenticated = 0;
+ }
+
+ /**
+ * Since the master is disappearing, so is the
+ * possibility to lock.
+ */
+
+ if (master->lock.hw_lock) {
+ if (dev->sigdata.lock == master->lock.hw_lock)
+ dev->sigdata.lock = NULL;
+ master->lock.hw_lock = NULL;
+ master->lock.file_priv = NULL;
+ wake_up_interruptible_all(&master->lock.lock_queue);
+ }
+
+ if (file_priv->minor->master == file_priv->master) {
+ /* drop the reference held my the minor */
+ if (dev->driver->master_drop)
+ dev->driver->master_drop(dev, file_priv, true);
+ drm_master_put(&file_priv->minor->master);
+ }
+ }
+ mutex_unlock(&dev->struct_mutex);
+ return 0;
+}
+EXPORT_SYMBOL(drm_flush);
+
/**
* File \c open operation.
*
@@ -1018,6 +1018,7 @@ static const struct vm_operations_struct i915_gem_vm_ops = {
static const struct file_operations i915_driver_fops = {
.owner = THIS_MODULE,
.open = drm_open,
+ .flush = drm_flush,
.release = drm_release,
.unlocked_ioctl = drm_ioctl,
.mmap = drm_gem_mmap,
@@ -361,6 +361,7 @@ radeon_pci_resume(struct pci_dev *pdev)
static const struct file_operations radeon_driver_kms_fops = {
.owner = THIS_MODULE,
.open = drm_open,
+ .flush = drm_flush,
.release = drm_release,
.unlocked_ioctl = drm_ioctl,
.mmap = radeon_mmap,
@@ -1320,6 +1320,8 @@ extern int drm_stub_open(struct inode *inode, struct file *filp);
extern int drm_fasync(int fd, struct file *filp, int on);
extern ssize_t drm_read(struct file *filp, char __user *buffer,
size_t count, loff_t *offset);
+
+extern int drm_flush(struct file *filp, fl_owner_t id);
extern int drm_release(struct inode *inode, struct file *filp);
/* Mapping support (drm_vm.h) */