Skip to contentSkip to conversation

intel_device: Don't close the fd on probe failure if it is server managed

PATCH In review Hans de Goede 2 participants 4 messages Mar 18, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 intel_device: Don't close the fd on probe failure if it is server managed

I hit this corner case when testing a single X server spanning both intel gfx + an usb display link adapter driven by xf86-video-modesetting.

In this scenario the intel driver gets its platformProbe method called first, and if it then closes the server managed fd, the xf86-video-modesetting gets EBADFD errors.

---
 src/intel_device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/intel_device.c +2 -1
index c0e1582..2d31ec8 100644
@@ -339,7 +339,8 @@ int intel_open_device(int entity_num,
 	return fd;
 
 err_close:
-	close(fd);
+	if (master_count == 0) /* Don't close server-fds */
+		close(fd);
 err_path:
 	free(local_path);
 	return -1;
Signature · 1 line
1.9.0
#1 lore raw

PATCH 2/2 uxa: Add support for server managed fds

I've just noticed that my previous patch-set for server managed fds misses out on adding server managed fds support to uxa, because uxa does its own /dev/dri/... device node management.

This commit switches uxa over to using intel_device.c device node management. This is a nice cleanup and as an added bonus adds server managed fd support.

---
 src/intel_device.c     | 14 --------------
 src/intel_driver.h     |  2 --
 src/uxa/intel_driver.c | 44 +++-----------------------------------------
 3 files changed, 3 insertions(+), 57 deletions(-)
src/intel_device.c +0 -14
index 2d31ec8..11118c2 100644
@@ -442,20 +442,6 @@ int intel_put_master(ScrnInfoPtr scrn)
 	return ret;
 }
 
-void __intel_uxa_release_device(ScrnInfoPtr scrn)
-{
-	struct intel_device *dev = intel_device(scrn);
-	if (dev && dev->open_count == 0) {
-		intel_set_device(scrn, NULL);
-
-		drmClose(dev->fd);
-		if (dev->render_node != dev->master_node)
-			free(dev->render_node);
-		free(dev->master_node);
-		free(dev);
-	}
-}
-
 void intel_put_device(ScrnInfoPtr scrn)
 {
 	struct intel_device *dev = intel_device(scrn);
src/intel_driver.h +0 -2
index b2cb1b9..182a30e 100644
@@ -132,8 +132,6 @@ int intel_get_master(ScrnInfoPtr scrn);
 int intel_put_master(ScrnInfoPtr scrn);
 void intel_put_device(ScrnInfoPtr scrn);
 
-void __intel_uxa_release_device(ScrnInfoPtr scrn);
-
 #define hosted() (0)
 
 #endif /* INTEL_DRIVER_H */
src/uxa/intel_driver.c +3 -41

78 lines not on this page · raw message

Signature · 1 line
1.9.0
#2 lore raw

Re: [PATCH 2/2] uxa: Add support for server managed fds

Quoted 6 lines · Hans de Goede

I've just noticed that my previous patch-set for server managed fds misses out on adding server managed fds support to uxa, because uxa does its own /dev/dri/... device node management.

This commit switches uxa over to using intel_device.c device node management. This is a nice cleanup and as an added bonus adds server managed fd support.

I thought this was going to be uglier... Let me double check if I was just imagining the extra complexity.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
#3 lore raw

Re: [PATCH 2/2] uxa: Add support for server managed fds

Quoted 10 lines · Chris Wilson
Quoted 6 lines · Hans de Goede

I've just noticed that my previous patch-set for server managed fds misses out on adding server managed fds support to uxa, because uxa does its own /dev/dri/... device node management.

This commit switches uxa over to using intel_device.c device node management. This is a nice cleanup and as an added bonus adds server managed fd support.

I thought this was going to be uglier... Let me double check if I was just imagining the extra complexity.

No it was that easy, and we could remove a few more lines as well.

Thanks for the patches, pushed.
-Chris

Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre