[Mesa-stable] [PATCH v2] loader: use drmDeviceUseRevisionFile to prevent waking up the GPUs

Mauro Santos registo.mailling at gmail.com
Wed Nov 9 21:43:19 UTC 2016


On 09-11-2016 20:28, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov at collabora.com>
> 
> Currently the drmGetDevice[s] API parses the config sysfs file to
> retrieve the revision field.
> 
> That is required since there's no separate file (nor a libudev call
> afaict) that can be used. At the same time doing so causes the device to
> be awaken, so if an application creates/destroys a GL context multiple
> times they can observe noticeable delays. 2-3s in the case of
> firefox/thunderbird/chromium + radeon module.
> 
> There's a kernel patch on the PCI mailing list, but until then we can
> use drmDeviceUseRevisionFile() which will use separate sysfs files and
> default to 0 if the revision one is missing.
> 
> Since we don't care about the revision id, we can use that.
> 
> v2: Add second invocation deep within loader_get_user_preferred_fd()
> 
> Cc: "13.0" <mesa-stable at lists.freedesktop.org>
> Cc: Mauro Santos <registo.mailling at gmail.com>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98502
> Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
> ---
> Just because some platforms use loader_get_user_preferred_fd while
> others do not. That in itself happens prior to any other loader_get_*
> call
> ---
>  configure.ac        | 2 +-
>  src/loader/loader.c | 2 ++
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/configure.ac b/configure.ac
> index d215b63..f529f2cf 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -68,7 +68,7 @@ OPENCL_VERSION=1
>  AC_SUBST([OPENCL_VERSION])
>  
>  dnl Versions for external dependencies
> -LIBDRM_REQUIRED=2.4.66
> +LIBDRM_REQUIRED=2.4.72
>  LIBDRM_RADEON_REQUIRED=2.4.56
>  LIBDRM_AMDGPU_REQUIRED=2.4.63
>  LIBDRM_INTEL_REQUIRED=2.4.61
> diff --git a/src/loader/loader.c b/src/loader/loader.c
> index fe90307..a69d583 100644
> --- a/src/loader/loader.c
> +++ b/src/loader/loader.c
> @@ -145,6 +145,7 @@ static char *drm_get_id_path_tag_for_fd(int fd)
>     drmDevicePtr device;
>     char *tag;
>  
> +   drmDeviceUseRevisionFile();
>     if (drmGetDevice(fd, &device) != 0)
>         return NULL;
>  
> @@ -275,6 +276,7 @@ drm_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
>     drmDevicePtr device;
>     int ret;
>  
> +   drmDeviceUseRevisionFile();
>     if (drmGetDevice(fd, &device) == 0) {
>        if (device->bustype == DRM_BUS_PCI) {
>           *vendor_id = device->deviceinfo.pci->vendor_id;
> 

I've omitted the version hunk and as far as I can tell this one works
fine. I see no delays when starting glxgears/etc.

With a patched kernel drmdevice returns the correct revision, with an
unpatched kernel it returns 0 as expected.

-- 
Mauro Santos


More information about the mesa-stable mailing list