diff options
-rw-r--r-- | src/radeon_kms.c | 65 | ||||
-rw-r--r-- | src/radeon_probe.c | 5 | ||||
-rw-r--r-- | src/radeon_probe.h | 2 |
3 files changed, 60 insertions, 12 deletions
diff --git a/src/radeon_kms.c b/src/radeon_kms.c index c0f97624..f7f0a0d6 100644 --- a/src/radeon_kms.c +++ b/src/radeon_kms.c @@ -180,7 +180,11 @@ static void RADEONFreeRec(ScrnInfoPtr pScrn) pRADEONEnt = pPriv->ptr; pRADEONEnt->fd_ref--; if (!pRADEONEnt->fd_ref) { - drmClose(pRADEONEnt->fd); +#ifdef XF86_PDEV_SERVER_FD + if (!(pRADEONEnt->platform_dev && + pRADEONEnt->platform_dev->flags & XF86_PDEV_SERVER_FD)) +#endif + drmClose(pRADEONEnt->fd); pRADEONEnt->fd = 0; } } @@ -584,10 +588,20 @@ static Bool RADEONPreInitChipType_KMS(ScrnInfoPtr pScrn) static int radeon_get_drm_master_fd(ScrnInfoPtr pScrn) { RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); struct pci_device *dev = info->PciInfo; char *busid; int fd; +#if defined(ODEV_ATTRIB_FD) + if (pRADEONEnt->platform_dev) { + fd = xf86_get_platform_device_int_attrib(pRADEONEnt->platform_dev, + ODEV_ATTRIB_FD, -1); + if (fd != -1) + return fd; + } +#endif + #if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,9,99,901,0) XNFasprintf(&busid, "pci:%04x:%02x:%02x.%d", dev->domain, dev->bus, dev->dev, dev->func); @@ -1107,6 +1121,39 @@ static Bool RADEONSaveScreen_KMS(ScreenPtr pScreen, int mode) return TRUE; } +static Bool radeon_set_drm_master(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); + int err; + +#ifdef XF86_PDEV_SERVER_FD + if (pRADEONEnt->platform_dev && + (pRADEONEnt->platform_dev->flags & XF86_PDEV_SERVER_FD)) + return TRUE; +#endif + + err = drmSetMaster(info->dri2.drm_fd); + if (err) + ErrorF("Unable to retrieve master\n"); + + return err == 0; +} + +static void radeon_drop_drm_master(ScrnInfoPtr pScrn) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + RADEONEntPtr pRADEONEnt = RADEONEntPriv(pScrn); + +#ifdef XF86_PDEV_SERVER_FD + if (pRADEONEnt->platform_dev && + (pRADEONEnt->platform_dev->flags & XF86_PDEV_SERVER_FD)) + return; +#endif + + drmDropMaster(info->dri2.drm_fd); +} + /* Called at the end of each server generation. Restore the original * text mode, unmap video memory, and unwrap and call the saved * CloseScreen function. @@ -1133,7 +1180,7 @@ static Bool RADEONCloseScreen_KMS(CLOSE_SCREEN_ARGS_DECL) if (info->accel_state->use_vbos) radeon_vbo_free_lists(pScrn); - drmDropMaster(info->dri2.drm_fd); + radeon_drop_drm_master(pScrn); drmmode_fini(pScrn, &info->drmmode); if (info->dri2.enabled) @@ -1168,7 +1215,6 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) int subPixelOrder = SubPixelUnknown; char* s; void *front_ptr; - int ret; pScrn->fbOffset = 0; @@ -1179,11 +1225,9 @@ Bool RADEONScreenInit_KMS(SCREEN_INIT_ARGS_DECL) pScrn->defaultVisual)) return FALSE; miSetPixmapDepths (); - ret = drmSetMaster(info->dri2.drm_fd); - if (ret) { - ErrorF("Unable to retrieve master\n"); + if (!radeon_set_drm_master(pScrn)) return FALSE; - } + info->directRenderingEnabled = FALSE; if (info->r600_shadow_fb == FALSE) info->directRenderingEnabled = radeon_dri2_screen_init(pScreen); @@ -1396,15 +1440,12 @@ Bool RADEONEnterVT_KMS(VT_FUNC_ARGS_DECL) { SCRN_INFO_PTR(arg); RADEONInfoPtr info = RADEONPTR(pScrn); - int ret; xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG, "RADEONEnterVT_KMS\n"); + radeon_set_drm_master(pScrn); - ret = drmSetMaster(info->dri2.drm_fd); - if (ret) - ErrorF("Unable to retrieve master\n"); info->accel_state->XInited3D = FALSE; info->accel_state->engineMode = EXA_ENGINEMODE_UNKNOWN; @@ -1425,7 +1466,7 @@ void RADEONLeaveVT_KMS(VT_FUNC_ARGS_DECL) xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG, "RADEONLeaveVT_KMS\n"); - drmDropMaster(info->dri2.drm_fd); + radeon_drop_drm_master(pScrn); xf86RotateFreeShadow(pScrn); diff --git a/src/radeon_probe.c b/src/radeon_probe.c index 2d3c58e8..ad1e96ea 100644 --- a/src/radeon_probe.c +++ b/src/radeon_probe.c @@ -202,6 +202,10 @@ RADEONDriverFunc(ScrnInfoPtr scrn, xorgDriverFuncOp op, void *data) flag = (CARD32 *)data; (*flag) = 0; return TRUE; +#if XORG_VERSION_CURRENT > XORG_VERSION_NUMERIC(1,15,99,0,0) + case SUPPORTS_SERVER_FDS: + return TRUE; +#endif default: return FALSE; } @@ -272,6 +276,7 @@ radeon_platform_probe(DriverPtr pDriver, pRADEONEnt = pPriv->ptr; pRADEONEnt->HasSecondary = TRUE; } + pRADEONEnt->platform_dev = dev; } free(pEnt); diff --git a/src/radeon_probe.h b/src/radeon_probe.h index cea66956..4f5e6450 100644 --- a/src/radeon_probe.h +++ b/src/radeon_probe.h @@ -42,6 +42,7 @@ #include "randrstr.h" #include "xf86Crtc.h" +#include "xf86platformBus.h" #include "compat-api.h" #include "exa.h" @@ -136,6 +137,7 @@ typedef struct int fd_ref; unsigned long fd_wakeup_registered; /* server generation for which fd has been registered for wakeup handling */ int fd_wakeup_ref; + struct xf86_platform_device *platform_dev; } RADEONEntRec, *RADEONEntPtr; extern const OptionInfoRec *RADEONOptionsWeak(void); |