Hi,

On 06-03-17 11:02, Michel Dänzer wrote:
From: Michel Dänzer <[email protected]>

Preparation for the following change.

Assign pAMDGPUEnt->fd = -1 instead of 0 when we're not using the file
descriptor anymore.

Signed-off-by: Michel Dänzer <[email protected]>

Thank you for picking my original patch for this up, I still had
it on my to-do list but it got buried under other to-do list
items.

Both patches look good to me:

Reviewed-by: Hans de Goede <[email protected]>

Regards,

Hans



---
 src/amdgpu_kms.c   |  7 +------
 src/amdgpu_probe.c | 10 ++++++++++
 src/amdgpu_probe.h |  2 ++
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c
index 31c2e86f2..92bf5fadf 100644
--- a/src/amdgpu_kms.c
+++ b/src/amdgpu_kms.c
@@ -132,12 +132,7 @@ static void AMDGPUFreeRec(ScrnInfoPtr pScrn)
                pAMDGPUEnt->fd_ref--;
                if (!pAMDGPUEnt->fd_ref) {
                        amdgpu_device_deinitialize(pAMDGPUEnt->pDev);
-#ifdef XF86_PDEV_SERVER_FD
-                       if (!(pAMDGPUEnt->platform_dev &&
-                             pAMDGPUEnt->platform_dev->flags & 
XF86_PDEV_SERVER_FD))
-#endif
-                               drmClose(pAMDGPUEnt->fd);
-                       pAMDGPUEnt->fd = 0;
+                       amdgpu_kernel_close_fd(pAMDGPUEnt);
                }
        }

diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c
index 94da7f623..fc93ac6a2 100644
--- a/src/amdgpu_probe.c
+++ b/src/amdgpu_probe.c
@@ -134,6 +134,16 @@ static int amdgpu_kernel_open_fd(ScrnInfoPtr pScrn, char 
*busid,
        return fd;
 }

+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
+               drmClose(pAMDGPUEnt->fd);
+       pAMDGPUEnt->fd = -1;
+}
+
 static Bool amdgpu_open_drm_master(ScrnInfoPtr pScrn, AMDGPUEntPtr pAMDGPUEnt,
                                   char *busid)
 {
diff --git a/src/amdgpu_probe.h b/src/amdgpu_probe.h
index 0f43233c3..9e4a9a451 100644
--- a/src/amdgpu_probe.h
+++ b/src/amdgpu_probe.h
@@ -71,6 +71,8 @@ typedef struct {
        char *render_node;
 } AMDGPUEntRec, *AMDGPUEntPtr;

+extern void amdgpu_kernel_close_fd(AMDGPUEntPtr pAMDGPUEnt);
+
 extern const OptionInfoRec *AMDGPUOptionsWeak(void);

 extern Bool AMDGPUPreInit_KMS(ScrnInfoPtr, int);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reply via email to