Skip to content

Commit 0bda379

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 f1c6fd0 commit 0bda379

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,17 +1,24 @@
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>
1117
#include <drm/drm_device.h>
1218
#include <drm/drm_drv.h>
1319
#include <drm/drm_edid.h>
1420
#include <drm/drm_fb_dma_helper.h>
21+
#include <drm/drm_file.h>
1522
#include <drm/drm_framebuffer.h>
1623
#include <drm/drm_gem_atomic_helper.h>
1724
#include <drm/drm_gem_dma_helper.h>
@@ -72,7 +79,33 @@
7279
#define GEN_RD_CMD_BUSY BIT(6)
7380
#define CMD_PKT_STATUS_TIMEOUT_US 20000
7481

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

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

0 commit comments

Comments
 (0)