xf86-video-intel: 2 commits - src/intel_device.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Mar 20 01:53:02 PDT 2014


 src/intel_device.c |   46 ++++++++++++++++++----------------------------
 1 file changed, 18 insertions(+), 28 deletions(-)

New commits:
commit 7cf0676ff868e7d8cdbfb264e5822250b1f59882
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Mar 20 08:51:05 2014 +0000

    intel: Do not close server fds
    
    If we are given an fd by the Xserver, then it is not our responsibility
    to close it during CloseScreen.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
    Cc: Hans de Goede <hdegoede at redhat.com>

diff --git a/src/intel_device.c b/src/intel_device.c
index adcd6c0..a55f62b 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -312,20 +312,18 @@ int intel_open_device(int entity_num,
 	if (dev == NULL)
 		goto err_close;
 
+	/* If hosted under a system compositor, just pretend to be master */
+	if (hosted())
+		master_count++;
+
 	dev->fd = fd;
-	dev->open_count = 0;
+	dev->open_count = master_count;
 	dev->master_count = master_count;
 	dev->master_node = path;
 	dev->render_node = find_render_node(fd);
 	if (dev->render_node == NULL)
 		dev->render_node = dev->master_node;
 
-	/* If hosted under a system compositor, just pretend to be master */
-	if (hosted()) {
-		dev->open_count++;
-		dev->master_count++;
-	}
-
 	xf86GetEntityPrivate(entity_num, intel_device_key)->ptr = dev;
 
 	return fd;
commit 9f4c121974abcec77e7f920e3258a337260200b3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Mar 20 08:48:40 2014 +0000

    intel: Refactor finding device path if unknown
    
    Since we already lookup the device path if we do not know it after
    opening the fd, we can remove the special case along the legacy PCI
    probe path.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel_device.c b/src/intel_device.c
index 11118c2..adcd6c0 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -143,11 +143,11 @@ static int __intel_check_device(int fd)
 	return ret;
 }
 
-static int __intel_open_device(const struct pci_device *pci, char **path)
+static int __intel_open_device(const struct pci_device *pci, const char *path)
 {
 	int fd;
 
-	if (*path == NULL) {
+	if (path == NULL) {
 		char id[20];
 		int ret;
 
@@ -168,23 +168,15 @@ static int __intel_open_device(const struct pci_device *pci, char **path)
 			(void)xf86LoadKernelModule("fbcon");
 		}
 
-		fd = drmOpen(NULL, id);
-		if (fd != -1) {
-			*path = drmGetDeviceNameFromFd(fd);
-			if (*path == NULL) {
-				close(fd);
-				fd = -1;
-			}
-		}
-		fd = fd_set_nonblock(fd);
+		fd = fd_set_nonblock(drmOpen(NULL, id));
 	} else {
 #ifdef O_CLOEXEC
-		fd = open(*path, O_RDWR | O_NONBLOCK | O_CLOEXEC);
+		fd = open(path, O_RDWR | O_NONBLOCK | O_CLOEXEC);
 #else
 		fd = -1;
 #endif
 		if (fd == -1)
-			fd = fd_set_cloexec(open(*path, O_RDWR | O_NONBLOCK));
+			fd = fd_set_cloexec(open(path, O_RDWR | O_NONBLOCK));
 	}
 
 	return fd;
@@ -283,7 +275,7 @@ int intel_open_device(int entity_num,
 		      struct xf86_platform_device *platform)
 {
 	struct intel_device *dev;
-	char *local_path;
+	char *path;
 	int fd, master_count;
 
 	if (intel_device_key == -1)
@@ -295,21 +287,21 @@ int intel_open_device(int entity_num,
 	if (dev)
 		return dev->fd;
 
-	local_path = get_path(platform);
+	path = get_path(platform);
 
 	master_count = 1; /* DRM_MASTER is managed by Xserver */
 	fd = get_fd(platform);
 	if (fd == -1) {
-		fd = __intel_open_device(pci, &local_path);
+		fd = __intel_open_device(pci, path);
 		if (fd == -1)
 			goto err_path;
 
 		master_count = 0;
 	}
 
-	if (local_path == NULL) {
-		local_path = find_master_node(fd);
-		if (local_path == NULL)
+	if (path == NULL) {
+		path = find_master_node(fd);
+		if (path == NULL)
 			goto err_close;
 	}
 
@@ -323,7 +315,7 @@ int intel_open_device(int entity_num,
 	dev->fd = fd;
 	dev->open_count = 0;
 	dev->master_count = master_count;
-	dev->master_node = local_path;
+	dev->master_node = path;
 	dev->render_node = find_render_node(fd);
 	if (dev->render_node == NULL)
 		dev->render_node = dev->master_node;
@@ -342,7 +334,7 @@ err_close:
 	if (master_count == 0) /* Don't close server-fds */
 		close(fd);
 err_path:
-	free(local_path);
+	free(path);
 	return -1;
 }
 


More information about the xorg-commit mailing list