Add server managed fd support

This commit is contained in:
Hans de Goede 2014-05-13 09:10:26 +02:00
parent 40ff5983ee
commit 35472a4872
5 changed files with 288 additions and 25 deletions

View File

@ -0,0 +1,137 @@
From 957a38a715e3013d9ba7a41f1fb1255c4cbff5f9 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 6 May 2014 16:00:50 +0200
Subject: [PATCH xf86-video-vmware 1/2] Add support for XSERVER_PLATFORM_BUS
This is a preparation patch for adding support for server managed fds.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
src/vmware.c | 3 ---
src/vmware_bootstrap.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++---
vmwgfx/vmwgfx_driver.c | 4 ++--
3 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/src/vmware.c b/src/vmware.c
index 6b74e14..17434ab 100644
--- a/src/vmware.c
+++ b/src/vmware.c
@@ -310,9 +310,6 @@ VMWAREPreInit(ScrnInfoPtr pScrn, int flags)
pVMWARE->pvtSema = &pScrn->vtSema;
pVMWARE->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
- if (pVMWARE->pEnt->location.type != BUS_PCI) {
- return FALSE;
- }
pVMWARE->PciInfo = xf86GetPciInfoForEntity(pVMWARE->pEnt->index);
if (pVMWARE->PciInfo == NULL) {
return FALSE;
diff --git a/src/vmware_bootstrap.c b/src/vmware_bootstrap.c
index ed6c740..b30cf2b 100644
--- a/src/vmware_bootstrap.c
+++ b/src/vmware_bootstrap.c
@@ -50,6 +50,10 @@
#include <xf86_libc.h>
#endif
+#ifdef XSERVER_PLATFORM_BUS
+#include "xf86platformBus.h"
+#endif
+
#ifdef HaveDriverFuncs
#define VMWARE_DRIVER_FUNC HaveDriverFuncs
#else
@@ -247,9 +251,6 @@ VMwarePreinitStub(ScrnInfoPtr pScrn, int flags)
vmwlegacy_hookup(pScrn);
pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
- if (pEnt->location.type != BUS_PCI)
- return FALSE;
-
pciInfo = xf86GetPciInfoForEntity(pEnt->index);
if (pciInfo == NULL)
return FALSE;
@@ -407,6 +408,45 @@ VMWAREProbe(DriverPtr drv, int flags)
}
#endif
+#ifdef XSERVER_PLATFORM_BUS
+static Bool
+VMwarePlatformProbe(DriverPtr drv, int entity, int flags,
+ struct xf86_platform_device *dev, intptr_t match_data)
+{
+ ScrnInfoPtr pScrn;
+ int scrnFlag = 0;
+
+ if (!dev->pdev)
+ return FALSE;
+
+ if (flags & PLATFORM_PROBE_GPU_SCREEN)
+ scrnFlag = XF86_ALLOCATE_GPU_SCREEN;
+
+ pScrn = xf86AllocateScreen(drv, scrnFlag);
+ if (!pScrn)
+ return FALSE;
+
+ if (xf86IsEntitySharable(entity))
+ xf86SetEntityShared(entity);
+
+ xf86AddEntityToScreen(pScrn, entity);
+
+ pScrn->driverVersion = VMWARE_DRIVER_VERSION;
+ pScrn->driverName = VMWARE_DRIVER_NAME;
+ pScrn->name = VMWARE_NAME;
+ pScrn->Probe = NULL;
+#ifdef BUILD_VMWGFX
+ vmwgfx_hookup(pScrn);
+#else
+ vmwlegacy_hookup(pScrn);
+#endif
+ pScrn->driverPrivate = pScrn->PreInit;
+ pScrn->PreInit = VMwarePreinitStub;
+
+ return TRUE;
+}
+#endif
+
static void
VMWAREIdentify(int flags)
{
@@ -481,6 +521,14 @@ _X_EXPORT DriverRec vmware = {
#if XSERVER_LIBPCIACCESS
VMwareDeviceMatch,
VMwarePciProbe,
+#else
+ NULL,
+ NULL,
+#endif
+#ifdef XSERVER_PLATFORM_BUS
+ VMwarePlatformProbe,
+#else
+ NULL,
#endif
};
diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
index 2d38d2a..7e5dc4e 100644
--- a/vmwgfx/vmwgfx_driver.c
+++ b/vmwgfx/vmwgfx_driver.c
@@ -465,13 +465,13 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags)
pScrn->displayWidth = 640; /* default it */
- if (ms->pEnt->location.type != BUS_PCI) {
+ ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
+ if (!ms->PciInfo) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Incorrect bus for device.\n");
goto out_err_bus;
}
- ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index);
xf86SetPrimInitDone(pScrn->entityList[0]);
ms->hdriver = vmwgfx_hosted_detect();
--
1.9.0

View File

@ -0,0 +1,142 @@
From 9cc046e896d504d1725e03acd28ff169dfaa0ff8 Mon Sep 17 00:00:00 2001
From: Hans de Goede <hdegoede@redhat.com>
Date: Tue, 6 May 2014 16:33:21 +0200
Subject: [PATCH xf86-video-vmware 2/2] Add support for server managed fds
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
src/vmware_bootstrap.c | 5 +++++
vmwgfx/vmwgfx_driver.c | 31 +++++++++++++++++++++++++++----
vmwgfx/vmwgfx_driver.h | 2 ++
3 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/src/vmware_bootstrap.c b/src/vmware_bootstrap.c
index b30cf2b..1635876 100644
--- a/src/vmware_bootstrap.c
+++ b/src/vmware_bootstrap.c
@@ -30,6 +30,7 @@
#endif
#include "xf86.h"
+#include <xorgVersion.h>
#include "compiler.h"
#include "xf86Pci.h" /* pci */
#include "vm_device_version.h"
@@ -496,6 +497,10 @@ VMWareDriverFunc(ScrnInfoPtr pScrn,
pScrn->yDpi / 2) / pScrn->yDpi;
}
return TRUE;
+#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,15,99,902,0)
+ case SUPPORTS_SERVER_FDS:
+ return TRUE;
+#endif
default:
return FALSE;
}
diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
index 7e5dc4e..03103a8 100644
--- a/vmwgfx/vmwgfx_driver.c
+++ b/vmwgfx/vmwgfx_driver.c
@@ -54,6 +54,10 @@
#include <pciaccess.h>
+#ifdef XSERVER_PLATFORM_BUS
+#include "xf86platformBus.h"
+#endif
+
#include "vmwgfx_driver.h"
#include <saa.h>
@@ -243,6 +247,15 @@ static const xf86CrtcConfigFuncsRec crtc_config_funcs = {
.resize = drv_crtc_resize
};
+static Bool vmwgfx_use_server_fd(modesettingPtr ms)
+{
+#ifdef XF86_PDEV_SERVER_FD
+ return ms->platform_dev && (ms->platform_dev->flags & XF86_PDEV_SERVER_FD);
+#else
+ return FALSE;
+#endif
+}
+
static Bool
drv_init_drm(ScrnInfoPtr pScrn)
{
@@ -253,6 +266,12 @@ drv_init_drm(ScrnInfoPtr pScrn)
ms->fd = vmwgfx_hosted_drm_fd(ms->hdriver, ms->hosted, ms->PciInfo);
+#ifdef ODEV_ATTRIB_FD
+ if (ms->fd < 0 && vmwgfx_use_server_fd(ms))
+ ms->fd = xf86_get_platform_device_int_attrib(ms->platform_dev,
+ ODEV_ATTRIB_FD, -1);
+#endif
+
if (ms->fd < 0) {
char bus_id[64];
@@ -472,6 +491,9 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags)
goto out_err_bus;
}
+ if (pEnt->location.type == BUS_PLATFORM)
+ ms->platform_dev = pEnt->location.id.plat;
+
xf86SetPrimInitDone(pScrn->entityList[0]);
ms->hdriver = vmwgfx_hosted_detect();
@@ -605,7 +627,7 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags)
free(ms->Options);
out_depth:
out_drm_version:
- if (!vmwgfx_is_hosted(ms->hdriver))
+ if (!vmwgfx_is_hosted(ms->hdriver) && !vmwgfx_use_server_fd(ms))
close(ms->fd);
out_no_drm:
vmwgfx_hosted_destroy(ms->hdriver, ms->hosted);
@@ -783,8 +805,8 @@ drv_set_master(ScrnInfoPtr pScrn)
{
modesettingPtr ms = modesettingPTR(pScrn);
- if (!vmwgfx_is_hosted(ms->hdriver) && !ms->isMaster &&
- drmSetMaster(ms->fd) != 0) {
+ if (!vmwgfx_is_hosted(ms->hdriver) && !vmwgfx_use_server_fd(ms) &&
+ !ms->isMaster && drmSetMaster(ms->fd) != 0) {
if (errno == EINVAL) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"drmSetMaster failed: 2.6.29 or newer kernel required for "
@@ -1184,7 +1206,8 @@ drv_leave_vt(VT_FUNC_ARGS_DECL)
vmwgfx_saa_drop_master(pScrn->pScreen);
- if (!vmwgfx_is_hosted(ms->hdriver) && drmDropMaster(ms->fd))
+ if (!vmwgfx_is_hosted(ms->hdriver) && !vmwgfx_use_server_fd(ms) &&
+ drmDropMaster(ms->fd))
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
"drmDropMaster failed: %s\n", strerror(errno));
ms->isMaster = FALSE;
diff --git a/vmwgfx/vmwgfx_driver.h b/vmwgfx/vmwgfx_driver.h
index c044a81..31dfc0f 100644
--- a/vmwgfx/vmwgfx_driver.h
+++ b/vmwgfx/vmwgfx_driver.h
@@ -83,6 +83,7 @@ enum xorg_throttling_reason {
};
struct vmwgfx_hosted;
+struct xf86_platform_device;
typedef struct _modesettingRec
{
@@ -98,6 +99,7 @@ typedef struct _modesettingRec
int Chipset;
EntityInfoPtr pEnt;
struct pci_device *PciInfo;
+ struct xf86_platform_device *platform_dev;
/* Accel */
Bool accelerate_render;
--
1.9.0

View File

@ -1,11 +0,0 @@
diff -up xf86-video-vmware-11.0.3/src/vmware.c.jx xf86-video-vmware-11.0.3/src/vmware.c
--- xf86-video-vmware-11.0.3/src/vmware.c.jx 2012-03-12 10:45:59.000000000 -0400
+++ xf86-video-vmware-11.0.3/src/vmware.c 2012-03-12 10:50:01.600735012 -0400
@@ -1142,6 +1142,7 @@ VMWAREModeInit(ScrnInfoPtr pScrn, Displa
vgaHWUnlock(hwp);
if (!vgaHWInit(pScrn, mode))
return FALSE;
+ vgaHWSetStdFuncs(VGAHWPTR(pScrn));
pScrn->vtSema = TRUE;
vmwareReg->svga_reg_enable = 1;

View File

@ -1,13 +0,0 @@
From: Andrew Wilcox <AWilcox@Wilcox-Tech.com>
Bugzilla: https://bugzilla.redhat.com/782995
--- xf86-video-vmware-12.0.1/src/vmware.old 2012-03-08 11:13:16.000000000 -0500
+++ xf86-video-vmware-12.0.1/src/vmware.c 2012-03-16 18:20:25.406907242 -0400
@@ -354,6 +354,7 @@
* Save the current video state. Do it here before VMXGetVMwareSvgaId
* writes to any registers.
*/
+ vgaHWSetStdFuncs(VGAHWPTR(pScrn));
VMWARESave(pScrn);
id = VMXGetVMwareSvgaId(pVMWARE);

View File

@ -11,7 +11,7 @@
Summary: Xorg X11 vmware video driver
Name: xorg-x11-drv-vmware
Version: 13.0.2
Release: 1%{?gver}%{?dist}
Release: 2%{?gver}%{?dist}
URL: http://www.x.org
License: MIT
Group: User Interface/X Hardware Support
@ -22,6 +22,9 @@ Source0: %{tarball}-%{gitdate}.tar.bz2
Source0: ftp://ftp.x.org/pub/individual/driver/%{tarball}-%{version}.tar.bz2
%endif
Patch1: 0001-Add-support-for-XSERVER_PLATFORM_BUS.patch
Patch2: 0002-Add-support-for-server-managed-fds.patch
ExclusiveArch: %{ix86} x86_64 ia64
%if 0%{?gitdate}
@ -40,6 +43,8 @@ X.Org X11 vmware video driver.
%prep
%setup -q -n %{tarball}-%{?gitdate:%{gitdate}}%{!?gitdate:%{version}}
%patch1 -p1
%patch2 -p1
%build
%if 0%{?gitdate}
@ -60,6 +65,9 @@ find $RPM_BUILD_ROOT -regex ".*\.la$" | xargs rm -f --
%{_mandir}/man4/vmware.4*
%changelog
* Tue May 13 2014 Hans de Goede <hdegoede@redhat.com> - 13.0.2-2
- Add server managed fd support
* Mon Apr 28 2014 Hans de Goede <hdegoede@redhat.com> - 13.0.2-1
- vmware 13.0.2