[PATCH xf86-video-amdgpu 18/19] Keep track of who owns the fd in AMDGPUEnt

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Emil Velikov <emil.velikov@xxxxxxxxxxxxx>

Currently we're having xf86_platform_device pointer embedded, alongside
a bunch of ifdef compiler guards.

Swap that with a simple is_server_fd bool ;-)

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 src/amdgpu_kms.c   | 10 ++--------
 src/amdgpu_probe.c | 15 +++++++--------
 src/amdgpu_probe.h |  2 +-
 3 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index d27f71d..d625f56 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -1611,11 +1611,8 @@ static Bool amdgpu_set_drm_master(ScrnInfoPtr pScrn)
 	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 	int err;
 
-#ifdef XF86_PDEV_SERVER_FD
-	if (pAMDGPUEnt->platform_dev &&
-	    (pAMDGPUEnt->platform_dev->flags & XF86_PDEV_SERVER_FD))
+	if (pAMDGPUEnt->is_server_fd)
 		return TRUE;
-#endif
 
 	err = drmSetMaster(pAMDGPUEnt->fd);
 	if (err)
@@ -1628,11 +1625,8 @@ static void amdgpu_drop_drm_master(ScrnInfoPtr pScrn)
 {
 	AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(pScrn);
 
-#ifdef XF86_PDEV_SERVER_FD
-	if (pAMDGPUEnt->platform_dev &&
-	    (pAMDGPUEnt->platform_dev->flags & XF86_PDEV_SERVER_FD))
+	if (pAMDGPUEnt->is_server_fd)
 		return;
-#endif
 
 	drmDropMaster(pAMDGPUEnt->fd);
 }
diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c
index e9afe42..5d4890b 100644
--- a/src/amdgpu_probe.c
+++ b/src/amdgpu_probe.c
@@ -87,7 +87,8 @@ static Bool amdgpu_device_matches(const drmDevicePtr device,
 
 static int amdgpu_kernel_open_fd(ScrnInfoPtr pScrn,
 				 struct pci_device *pci_dev,
-				 struct xf86_platform_device *platform_dev)
+				 struct xf86_platform_device *platform_dev,
+				 AMDGPUEntPtr pAMDGPUEnt)
 {
 	drmDevicePtr *devices;
 	struct pci_device *dev;
@@ -98,8 +99,10 @@ static int amdgpu_kernel_open_fd(ScrnInfoPtr pScrn,
 #ifdef ODEV_ATTRIB_FD
 		fd = xf86_get_platform_device_int_attrib(platform_dev,
 							 ODEV_ATTRIB_FD, -1);
-		if (fd != -1)
+		if (fd != -1) {
+			pAMDGPUEnt->is_server_fd = TRUE;
 			return fd;
+		}
 #endif
 
 #ifdef ODEV_ATTRIB_PATH
@@ -157,10 +160,7 @@ static int amdgpu_kernel_open_fd(ScrnInfoPtr pScrn,
 
 void amdgpu_kernel_close_fd(AMDGPUEntPtr pAMDGPUEnt)
 {
-#ifdef XF86_PDEV_SERVER_FD
-	if (!(pAMDGPUEnt->platform_dev &&
-	      pAMDGPUEnt->platform_dev->flags & XF86_PDEV_SERVER_FD))
-#endif
+	if (!pAMDGPUEnt->is_server_fd)
 		close(pAMDGPUEnt->fd);
 	pAMDGPUEnt->fd = -1;
 }
@@ -173,8 +173,7 @@ static Bool amdgpu_device_setup(ScrnInfoPtr pScrn,
 	uint32_t major_version;
 	uint32_t minor_version;
 
-	pAMDGPUEnt->platform_dev = platform_dev;
-	pAMDGPUEnt->fd = amdgpu_kernel_open_fd(pScrn, pci_dev, platform_dev);
+	pAMDGPUEnt->fd = amdgpu_kernel_open_fd(pScrn, pci_dev, platform_dev, pAMDGPUEnt);
 	if (pAMDGPUEnt->fd < 0)
 		return FALSE;
 
diff --git a/src/amdgpu_probe.h b/src/amdgpu_probe.h
index 94f204f..81fe4a1 100644
--- a/src/amdgpu_probe.h
+++ b/src/amdgpu_probe.h
@@ -65,10 +65,10 @@ typedef struct {
 	char *master_node;
 	unsigned long fd_wakeup_registered;	/* server generation for which fd has been registered for wakeup handling */
 	int fd_wakeup_ref;
+	Bool is_server_fd;
 	unsigned int assigned_crtcs;
 	ScrnInfoPtr primary_scrn;
 	ScrnInfoPtr secondary_scrn;
-	struct xf86_platform_device *platform_dev;
 	char *render_node;
 } AMDGPUEntRec, *AMDGPUEntPtr;
 
-- 
2.16.0



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux