From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:40 +0000 (-0700) Subject: resolutionSet/resolutionKMS: Force load the vmwgfx kernel module X-Git-Tag: stable-10.2.0~205 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a61a342fd48b248fc794d639c6690e42a4ebc7fb;p=thirdparty%2Fopen-vm-tools.git resolutionSet/resolutionKMS: Force load the vmwgfx kernel module When testing for resolutionKMS system support, make sure the vmwgfx kernel module is loaded before trying to obtain an open file descriptor to it. Otherwise both the resolutionKMS- and resolutionSet tests might fail. --- diff --git a/open-vm-tools/services/plugins/resolutionSet/resolutionCommon.c b/open-vm-tools/services/plugins/resolutionSet/resolutionCommon.c index 38dccdac0..668924850 100644 --- a/open-vm-tools/services/plugins/resolutionSet/resolutionCommon.c +++ b/open-vm-tools/services/plugins/resolutionSet/resolutionCommon.c @@ -38,6 +38,7 @@ /* The DRM device we are looking for */ #define RESOLUTION_VENDOR "0x15ad" #define RESOLUTION_DEVICE "0x0405" +#define RESOLUTION_KERNELNAME "vmwgfx" /* Required DRM version for resolutionKMS */ #define RESOLUTION_DRM_MAJOR 2 @@ -84,11 +85,19 @@ resolutionOpenDRM(const char *node) // IN: Device node base name. struct udev_list_entry *devices, *devListEntry; struct udev_device *dev; int fd = -1; + int drmFd; const char *devNode = NULL; + /* Force load the kernel module. */ + drmFd = drmOpen(RESOLUTION_KERNELNAME, NULL); + if (drmFd >= 0) { + (void) drmDropMaster(drmFd); + } + udev = udev_new(); - if (!udev) - return -1; + if (!udev) { + goto outNoUdev; + } /* * Udev error return codes that are not caught immediately are @@ -148,6 +157,10 @@ skipCheck: udev_enumerate_unref(enumerate); udev_unref(udev); + if (drmFd >= 0) { + drmClose(drmFd); + } + return fd; outFound: @@ -155,6 +168,10 @@ skipCheck: outErr: udev_enumerate_unref(enumerate); udev_unref(udev); + outNoUdev: + if (drmFd >= 0) { + drmClose(drmFd); + } return -1; } diff --git a/open-vm-tools/services/plugins/resolutionSet/resolutionDL.c b/open-vm-tools/services/plugins/resolutionSet/resolutionDL.c index 5ec0abbf4..571ab39c6 100644 --- a/open-vm-tools/services/plugins/resolutionSet/resolutionDL.c +++ b/open-vm-tools/services/plugins/resolutionSet/resolutionDL.c @@ -66,6 +66,8 @@ static struct FuncToResolv udev1Table[] = { }; static struct FuncToResolv drm2Table[] = { + LIBDRM_RESOLV(Open), + LIBDRM_RESOLV(Close), LIBDRM_RESOLV(GetVersion), LIBDRM_RESOLV(FreeVersion), LIBDRM_RESOLV(DropMaster), diff --git a/open-vm-tools/services/plugins/resolutionSet/resolutionDL.h b/open-vm-tools/services/plugins/resolutionSet/resolutionDL.h index f0d8c6dde..c27166a02 100644 --- a/open-vm-tools/services/plugins/resolutionSet/resolutionDL.h +++ b/open-vm-tools/services/plugins/resolutionSet/resolutionDL.h @@ -144,6 +144,8 @@ struct drm_vmw_update_layout_arg { * However this struct is not subject to the license header of this file. */ struct Drm2Interface { + int (*Open)(const char *, const char *); + int (*Close)(int); drmVersionPtr (*GetVersion)(int fd); void (*FreeVersion)(drmVersionPtr); int (*DropMaster)(int fd); @@ -190,6 +192,10 @@ int resolutionDLOpen(void); #define udev_list_entry_foreach(_a, _b)\ udevi_list_entry_foreach(udevi, _a, _b) +#define drmOpen \ + drmi->Open +#define drmClose \ + drmi->Close #define drmGetVersion \ drmi->GetVersion #define drmFreeVersion \