From: Emil Velikov <emil.velikov@xxxxxxxxxxxxx> Rename the variable to reflect what it is. Plus move it out of the dri2 section - it's used in dri2 and dri3. Signed-off-by: Emil Velikov <emil.velikov at collabora.com> --- src/amdgpu_dri2.c | 8 +------- src/amdgpu_dri2.h | 1 - src/amdgpu_dri3.c | 3 +-- src/amdgpu_kms.c | 1 + src/amdgpu_probe.c | 5 +++++ src/amdgpu_probe.h | 1 + 6 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/amdgpu_dri2.c b/src/amdgpu_dri2.c index 62964ab..082520a 100644 --- a/src/amdgpu_dri2.c +++ b/src/amdgpu_dri2.c @@ -1282,11 +1282,9 @@ Bool amdgpu_dri2_screen_init(ScreenPtr pScreen) if (!info->dri2.available) return FALSE; - info->dri2.device_name = drmGetDeviceNameFromFd(pAMDGPUEnt->fd); - dri2_info.driverName = SI_DRIVER_NAME; dri2_info.fd = pAMDGPUEnt->fd; - dri2_info.deviceName = info->dri2.device_name; + dri2_info.deviceName = pAMDGPUEnt->master_node; if (info->drmmode.count_crtcs > 2) { uint64_t cap_value; @@ -1340,15 +1338,11 @@ Bool amdgpu_dri2_screen_init(ScreenPtr pScreen) void amdgpu_dri2_close_screen(ScreenPtr pScreen) { - ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); - AMDGPUInfoPtr info = AMDGPUPTR(pScrn); - if (--DRI2InfoCnt == 0) DeleteCallback(&ClientStateCallback, amdgpu_dri2_client_state_changed, 0); DRI2CloseScreen(pScreen); - drmFree(info->dri2.device_name); } #endif /* DRI2 */ diff --git a/src/amdgpu_dri2.h b/src/amdgpu_dri2.h index a345e6b..a9411b2 100644 --- a/src/amdgpu_dri2.h +++ b/src/amdgpu_dri2.h @@ -32,7 +32,6 @@ struct amdgpu_dri2 { Bool available; Bool enabled; - char *device_name; }; #ifdef DRI2 diff --git a/src/amdgpu_dri3.c b/src/amdgpu_dri3.c index 87e3d85..2c06b74 100644 --- a/src/amdgpu_dri3.c +++ b/src/amdgpu_dri3.c @@ -44,11 +44,10 @@ static int open_master_node(ScreenPtr screen, int *out) { ScrnInfoPtr scrn = xf86ScreenToScrn(screen); AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn); - AMDGPUInfoPtr info = AMDGPUPTR(scrn); drm_magic_t magic; int fd; - fd = open(info->dri2.device_name, O_RDWR | O_CLOEXEC); + fd = open(pAMDGPUEnt->master_node, O_RDWR | O_CLOEXEC); if (fd < 0) return BadAlloc; diff --git a/src/amdgpu_kms.c b/src/amdgpu_kms.c index c70cfe5..d27f71d 100644 --- a/src/amdgpu_kms.c +++ b/src/amdgpu_kms.c @@ -147,6 +147,7 @@ static void AMDGPUFreeRec(ScrnInfoPtr pScrn) pAMDGPUEnt->fd_ref--; if (!pAMDGPUEnt->fd_ref) { amdgpu_device_deinitialize(pAMDGPUEnt->pDev); + free(pAMDGPUEnt->master_node); amdgpu_kernel_close_fd(pAMDGPUEnt); free(pPriv->ptr); pPriv->ptr = NULL; diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c index 4959bd6..e9afe42 100644 --- a/src/amdgpu_probe.c +++ b/src/amdgpu_probe.c @@ -178,6 +178,10 @@ static Bool amdgpu_device_setup(ScrnInfoPtr pScrn, if (pAMDGPUEnt->fd < 0) return FALSE; + pAMDGPUEnt->master_node = drmGetDeviceNameFromFd2(pAMDGPUEnt->fd); + if (pAMDGPUEnt->master_node) + goto error_amdgpu; + if (amdgpu_device_initialize(pAMDGPUEnt->fd, &major_version, &minor_version, @@ -190,6 +194,7 @@ static Bool amdgpu_device_setup(ScrnInfoPtr pScrn, return TRUE; error_amdgpu: + free(pAMDGPUEnt->master_node); amdgpu_kernel_close_fd(pAMDGPUEnt); return FALSE; } diff --git a/src/amdgpu_probe.h b/src/amdgpu_probe.h index 5f61aab..94f204f 100644 --- a/src/amdgpu_probe.h +++ b/src/amdgpu_probe.h @@ -62,6 +62,7 @@ typedef struct { int fd; /* for sharing across zaphod heads */ int fd_ref; + char *master_node; unsigned long fd_wakeup_registered; /* server generation for which fd has been registered for wakeup handling */ int fd_wakeup_ref; unsigned int assigned_crtcs; -- 2.16.0