aboutsummaryrefslogtreecommitdiff
path: root/xorg-server/hw/xfree86/os-support/linux/lnx_platform.c
diff options
context:
space:
mode:
Diffstat (limited to 'xorg-server/hw/xfree86/os-support/linux/lnx_platform.c')
-rw-r--r--xorg-server/hw/xfree86/os-support/linux/lnx_platform.c62
1 files changed, 51 insertions, 11 deletions
diff --git a/xorg-server/hw/xfree86/os-support/linux/lnx_platform.c b/xorg-server/hw/xfree86/os-support/linux/lnx_platform.c
index 76f5583dd..1865b31b9 100644
--- a/xorg-server/hw/xfree86/os-support/linux/lnx_platform.c
+++ b/xorg-server/hw/xfree86/os-support/linux/lnx_platform.c
@@ -7,6 +7,8 @@
#include <xf86drm.h>
#include <fcntl.h>
#include <unistd.h>
+#include <errno.h>
+#include <string.h>
/* Linux platform device support */
#include "xf86_OSproc.h"
@@ -18,11 +20,12 @@
#include "hotplug.h"
static Bool
-get_drm_info(struct OdevAttributes *attribs, char *path)
+get_drm_info(struct OdevAttributes *attribs, char *path, int delayed_index)
{
drmSetVersion sv;
char *buf;
int fd;
+ int err = 0;
fd = open(path, O_RDWR, O_CLOEXEC);
if (fd == -1)
@@ -32,19 +35,26 @@ get_drm_info(struct OdevAttributes *attribs, char *path)
sv.drm_di_minor = 4;
sv.drm_dd_major = -1; /* Don't care */
sv.drm_dd_minor = -1; /* Don't care */
- if (drmSetInterfaceVersion(fd, &sv)) {
- ErrorF("setversion 1.4 failed\n");
- return FALSE;
+
+ err = drmSetInterfaceVersion(fd, &sv);
+ if (err) {
+ ErrorF("setversion 1.4 failed: %s\n", strerror(-err));
+ goto out;
}
- xf86_add_platform_device(attribs);
+ /* for a delayed probe we've already added the device */
+ if (delayed_index == -1) {
+ xf86_add_platform_device(attribs);
+ delayed_index = xf86_num_platform_devices - 1;
+ }
buf = drmGetBusid(fd);
- xf86_add_platform_device_attrib(xf86_num_platform_devices - 1,
+ xf86_add_platform_device_attrib(delayed_index,
ODEV_ATTRIB_BUSID, buf);
drmFreeBusid(buf);
+out:
close(fd);
- return TRUE;
+ return (err == 0);
}
Bool
@@ -89,6 +99,23 @@ xf86PlatformDeviceCheckBusID(struct xf86_platform_device *device, const char *bu
}
void
+xf86PlatformReprobeDevice(int index, struct OdevAttributes *attribs)
+{
+ Bool ret;
+ char *dpath;
+ dpath = xf86_get_platform_attrib(index, ODEV_ATTRIB_PATH);
+
+ ret = get_drm_info(attribs, dpath, index);
+ if (ret == FALSE) {
+ xf86_remove_platform_device(index);
+ return;
+ }
+ ret = xf86platformAddDevice(index);
+ if (ret == -1)
+ xf86_remove_platform_device(index);
+}
+
+void
xf86PlatformDeviceProbe(struct OdevAttributes *attribs)
{
struct OdevAttribute *attrib;
@@ -116,10 +143,17 @@ xf86PlatformDeviceProbe(struct OdevAttributes *attribs)
if (i != xf86_num_platform_devices)
goto out_free;
- LogMessage(X_INFO, "config/udev: Adding drm device (%s)\n",
- path);
+ LogMessage(X_INFO, "xfree86: Adding drm device (%s)\n", path);
- ret = get_drm_info(attribs, path);
+ if (!xf86VTOwner()) {
+ /* if we don't currently own the VT then don't probe the device,
+ just mark it as unowned for later use */
+ attribs->unowned = TRUE;
+ xf86_add_platform_device(attribs);
+ return;
+ }
+
+ ret = get_drm_info(attribs, path, -1);
if (ret == FALSE)
goto out_free;
@@ -138,6 +172,9 @@ void NewGPUDeviceRequest(struct OdevAttributes *attribs)
if (old_num == xf86_num_platform_devices)
return;
+ if (xf86_get_platform_device_unowned(xf86_num_platform_devices - 1) == TRUE)
+ return;
+
ret = xf86platformAddDevice(xf86_num_platform_devices-1);
if (ret == -1)
xf86_remove_platform_device(xf86_num_platform_devices-1);
@@ -171,7 +208,10 @@ void DeleteGPUDeviceRequest(struct OdevAttributes *attribs)
ErrorF("xf86: remove device %d %s\n", index, syspath);
- xf86platformRemoveDevice(index);
+ if (xf86_get_platform_device_unowned(index) == TRUE)
+ xf86_remove_platform_device(index);
+ else
+ xf86platformRemoveDevice(index);
out:
config_odev_free_attribute_list(attribs);
}