[Mesa-dev] [PATCH] i965: Fix GLX_MESA_query_renderer video memory on 32-bit.

Emil Velikov emil.l.velikov at gmail.com
Fri Mar 31 12:49:20 UTC 2017


Hi Ken,

On 31 March 2017 at 00:28, Kenneth Graunke <kenneth at whitecape.org> wrote:
> On modern systems with 4GB apertures, the size in bytes is 4294967296,
> or (1ull << 32).  The kernel gives us the aperture size as a __u64,
> which works out great.
>
> Unfortunately, libdrm "helpfully" returns the data as a size_t, which
> on 32-bit systems means it truncates the aperture size to 0 bytes.
> We've happily reported this value as 0 MB of video memory via
> GLX_MESA_query_renderer since it was originally exposed.
>
> This patch bypasses libdrm and calls the ioctl ourselves so we can
> use a proper uint64_t, avoiding the 32-bit integer overflow.  We now
> report a proper video memory size on 32-bit systems.
> ---
>  src/mesa/drivers/dri/i965/intel_screen.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
> index 811a9c5a867..f94e8a77c10 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -950,6 +950,17 @@ static const __DRIimageExtension intelImageExtension = {
>      .createImageWithModifiers           = intel_create_image_with_modifiers,
>  };
>
> +static uint64_t
> +get_aperture_size(int fd)
> +{
> +   struct drm_i915_gem_get_aperture aperture;
> +
> +   if (drmIoctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture) != 0)
> +      return 0;
> +
> +   return aperture.aper_size;
> +}
> +
Can we also use this for i915 + i915g ?

At the moment a simple glxinfo invocation wakes up all the pci devices
on the system. Props to libpciaccess, which is used by libdrm_intel.

I've fixed that in both the kernel and libpciaccess, but latter hasn't
seen any release yet. Will check over the weekend if I have access do
a release myself.

Thanks
Emil


More information about the mesa-dev mailing list