[PATCH xf86-video-amdgpu] Fix the X crash for pci_probe path

Jammy Zhou Jammy.Zhou at amd.com
Mon Oct 26 00:46:35 PDT 2015


For xf86CallDriverProbe, xf86platformProbeDev can usually pass, but it
may fail in some cases (i.e, multiple X servers) because of the error
"failed to set DRM interface version 1.4: Permission denied"

drmSetInterfaceVersion requires drm master, but when do the platform probe
for the second X server, the master may not be dropped by previous X server.
The platform probe fails in this case, and then the pci prove patch is used.

Change-Id: Ic4581e3e932157c09a535a198e80601d5f710688
Signed-off-by: Jammy Zhou <Jammy.Zhou at amd.com>
---
 src/amdgpu_probe.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/amdgpu_probe.c b/src/amdgpu_probe.c
index 481271b..c041401 100644
--- a/src/amdgpu_probe.c
+++ b/src/amdgpu_probe.c
@@ -183,6 +183,7 @@ static Bool amdgpu_open_drm_master(ScrnInfoPtr pScrn)
 		return FALSE;
 	}
 
+	info->drmmode.fd = pAMDGPUEnt->fd = info->dri2.drm_fd;
 	return TRUE;
 }
 
@@ -234,13 +235,23 @@ static Bool amdgpu_get_scrninfo(int entity_num, void *pci_dev)
 	if (!pPriv->ptr) {
 		uint32_t major_version;
 		uint32_t minor_version;
+		AMDGPUInfoPtr info;
 
 		pPriv->ptr = xnfcalloc(sizeof(AMDGPUEntRec), 1);
 		pAMDGPUEnt = pPriv->ptr;
+		if (!pPriv->ptr)
+			return FALSE;
+
+		pScrn->driverPrivate = xnfcalloc(sizeof(AMDGPUInfoRec), 1);
+		if (!pScrn->driverPrivate)
+			goto error_private;
 
-		if (amdgpu_open_drm_master(pScrn)) {
+		info = (AMDGPUInfoPtr)pScrn->driverPrivate;
+		info->pEnt = pEnt;
+		info->PciInfo = xf86GetPciInfoForEntity(info->pEnt->index);
+
+		if (!amdgpu_open_drm_master(pScrn))
 			goto error_fd;
-		}
 
 		pAMDGPUEnt->fd_ref = 1;
 
@@ -267,6 +278,9 @@ static Bool amdgpu_get_scrninfo(int entity_num, void *pci_dev)
 error_amdgpu:
 	drmClose(pAMDGPUEnt->fd);
 	pAMDGPUEnt->fd = 0;
+error_private:
+	free(pScrn->driverPrivate);
+	pScrn->driverPrivate = NULL;
 error_fd:
 	free(pPriv->ptr);
 	return FALSE;
-- 
1.9.1



More information about the xorg-driver-ati mailing list