Skip to content

Commit 7bd4ae4

Browse files
committed
gpu: drm: adp: Refuse X* as client in open()
This is hack which might or might not be removed after the Xorg's modesetting driver is fixed to ignore non-desktop devices. Signed-off-by: Janne Grunau <j@jannau.net>
1 parent b7cf9ba commit 7bd4ae4

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

drivers/gpu/drm/adp/adp_drv.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22

3+
#include <linux/anon_inodes.h>
34
#include <linux/dma-mapping.h>
45
#include <linux/io.h>
56
#include <linux/iopoll.h>
7+
#include <linux/file.h>
68
#include <linux/of.h>
79
#include <linux/platform_device.h>
10+
#include <linux/types.h>
11+
12+
#include <asm/current.h>
13+
814
#include <drm/drm_atomic.h>
915
#include <drm/drm_atomic_helper.h>
1016
#include <drm/drm_damage_helper.h>
@@ -13,6 +19,7 @@
1319
#include <drm/drm_edid.h>
1420
#include <drm/drm_fb_dma_helper.h>
1521
#include <drm/drm_fbdev_generic.h>
22+
#include <drm/drm_file.h>
1623
#include <drm/drm_framebuffer.h>
1724
#include <drm/drm_gem_atomic_helper.h>
1825
#include <drm/drm_gem_dma_helper.h>
@@ -73,7 +80,33 @@
7380
#define GEN_RD_CMD_BUSY BIT(6)
7481
#define CMD_PKT_STATUS_TIMEOUT_US 20000
7582

76-
DEFINE_DRM_GEM_DMA_FOPS(adp_fops);
83+
static int adp_open(struct inode *inode, struct file *filp)
84+
{
85+
/*
86+
* The modesetting driver does not check the non-desktop connector
87+
* property and keeps the device open and locked. If the touchbar daemon
88+
* opens the device first modesetting breaks the whole X session.
89+
* Simply refuse to open the device for X11 server processes as
90+
* workaround.
91+
*/
92+
if (current->comm[0] == 'X')
93+
return -EBUSY;
94+
95+
return drm_open(inode, filp);
96+
}
97+
98+
static const struct file_operations adp_fops = {
99+
.owner = THIS_MODULE,
100+
.open = adp_open,
101+
.release = drm_release,
102+
.unlocked_ioctl = drm_ioctl,
103+
.compat_ioctl = drm_compat_ioctl,
104+
.poll = drm_poll,
105+
.read = drm_read,
106+
.llseek = noop_llseek,
107+
.mmap = drm_gem_mmap,
108+
DRM_GEM_DMA_UNMAPPED_AREA_FOPS
109+
};
77110

78111
static int adp_drm_gem_dumb_create(struct drm_file *file_priv,
79112
struct drm_device *drm,

0 commit comments

Comments
 (0)