From: Rafael Antognolli Date: Thu, 14 May 2020 18:44:29 +0000 (-0700) Subject: intel: Store the aperture size in devinfo. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bb3545a6ee419c4802ac4153eb690a93dc2f339d;p=mesa.git intel: Store the aperture size in devinfo. We will later use the devinfo from iris_bufmgr, where we don't have access to the screen pointer. And since we are moving it, we can reuse it in Anv and i965. v2: return error code and check for it on Anv (Lionel). v3: Remove anv_gem_get_aperture() from anv_private.h and stubs (Lionel). Reviewed-by: Lionel Landwerlin Part-of: --- diff --git a/src/gallium/drivers/iris/iris_screen.c b/src/gallium/drivers/iris/iris_screen.c index 94ee60eb016..cd5d9b72951 100644 --- a/src/gallium/drivers/iris/iris_screen.c +++ b/src/gallium/drivers/iris/iris_screen.c @@ -90,14 +90,6 @@ iris_get_name(struct pipe_screen *pscreen) return buf; } -static uint64_t -get_aperture_size(int fd) -{ - struct drm_i915_gem_get_aperture aperture = {}; - gen_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture); - return aperture.aper_size; -} - static int iris_get_param(struct pipe_screen *pscreen, enum pipe_cap param) { @@ -283,7 +275,7 @@ iris_get_param(struct pipe_screen *pscreen, enum pipe_cap param) * flushing, etc. That's the big cliff apps will care about. */ const unsigned gpu_mappable_megabytes = - (screen->aperture_bytes * 3 / 4) / (1024 * 1024); + (devinfo->aperture_bytes * 3 / 4) / (1024 * 1024); const long system_memory_pages = sysconf(_SC_PHYS_PAGES); const long system_page_size = sysconf(_SC_PAGE_SIZE); @@ -718,8 +710,6 @@ iris_screen_create(int fd, const struct pipe_screen_config *config) screen->fd = iris_bufmgr_get_fd(screen->bufmgr); - screen->aperture_bytes = get_aperture_size(fd); - if (getenv("INTEL_NO_HW") != NULL) screen->no_hw = true; diff --git a/src/intel/dev/gen_device_info.c b/src/intel/dev/gen_device_info.c index c23a0e9cd19..83061211287 100644 --- a/src/intel/dev/gen_device_info.c +++ b/src/intel/dev/gen_device_info.c @@ -1396,6 +1396,18 @@ query_topology(struct gen_device_info *devinfo, int fd) } +int +gen_get_aperture_size(int fd, uint64_t *size) +{ + struct drm_i915_gem_get_aperture aperture = { 0 }; + + int ret = gen_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture); + if (ret == 0 && size) + *size = aperture.aper_size; + + return ret; +} + bool gen_get_device_info_from_fd(int fd, struct gen_device_info *devinfo) { @@ -1463,5 +1475,7 @@ gen_get_device_info_from_fd(int fd, struct gen_device_info *devinfo) getparam_topology(devinfo, fd); } + gen_get_aperture_size(fd, &devinfo->aperture_bytes); + return true; } diff --git a/src/intel/dev/gen_device_info.h b/src/intel/dev/gen_device_info.h index d465d5ffd2e..1456dd16dab 100644 --- a/src/intel/dev/gen_device_info.h +++ b/src/intel/dev/gen_device_info.h @@ -252,6 +252,8 @@ struct gen_device_info */ uint64_t timestamp_frequency; + uint64_t aperture_bytes; + /** * ID to put into the .aub files. */ @@ -293,6 +295,7 @@ gen_device_info_timebase_scale(const struct gen_device_info *devinfo, bool gen_get_device_info_from_fd(int fh, struct gen_device_info *devinfo); bool gen_get_device_info_from_pci_id(int pci_id, struct gen_device_info *devinfo); +int gen_get_aperture_size(int fd, uint64_t *size); #ifdef __cplusplus } diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c index ba0b14ac714..71fc427aa92 100644 --- a/src/intel/vulkan/anv_device.c +++ b/src/intel/vulkan/anv_device.c @@ -136,7 +136,7 @@ anv_physical_device_init_heaps(struct anv_physical_device *device, int fd) anv_perf_warn(NULL, NULL, "Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m"); - if (anv_gem_get_aperture(fd, &device->gtt_size) == -1) { + if (gen_get_aperture_size(fd, &device->gtt_size) == -1) { return vk_errorfi(device->instance, NULL, VK_ERROR_INITIALIZATION_FAILED, "failed to get aperture size: %m"); diff --git a/src/intel/vulkan/anv_gem.c b/src/intel/vulkan/anv_gem.c index bea6a6803c4..30774292b15 100644 --- a/src/intel/vulkan/anv_gem.c +++ b/src/intel/vulkan/anv_gem.c @@ -389,20 +389,6 @@ anv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value) return 0; } -int -anv_gem_get_aperture(int fd, uint64_t *size) -{ - struct drm_i915_gem_get_aperture aperture = { 0 }; - - int ret = gen_ioctl(fd, DRM_IOCTL_I915_GEM_GET_APERTURE, &aperture); - if (ret == -1) - return -1; - - *size = aperture.aper_available_size; - - return 0; -} - int anv_gem_gpu_get_reset_stats(struct anv_device *device, uint32_t *active, uint32_t *pending) diff --git a/src/intel/vulkan/anv_gem_stubs.c b/src/intel/vulkan/anv_gem_stubs.c index c4d1c87b75a..aca54e64152 100644 --- a/src/intel/vulkan/anv_gem_stubs.c +++ b/src/intel/vulkan/anv_gem_stubs.c @@ -159,12 +159,6 @@ anv_gem_has_context_priority(int fd) unreachable("Unused"); } -int -anv_gem_get_aperture(int fd, uint64_t *size) -{ - unreachable("Unused"); -} - int anv_gem_gpu_get_reset_stats(struct anv_device *device, uint32_t *active, uint32_t *pending) diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h index 5e3724534c3..28c2aa5633a 100644 --- a/src/intel/vulkan/anv_private.h +++ b/src/intel/vulkan/anv_private.h @@ -1530,7 +1530,6 @@ int anv_gem_get_context_param(int fd, int context, uint32_t param, int anv_gem_get_param(int fd, uint32_t param); int anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle); bool anv_gem_get_bit6_swizzle(int fd, uint32_t tiling); -int anv_gem_get_aperture(int fd, uint64_t *size); int anv_gem_gpu_get_reset_stats(struct anv_device *device, uint32_t *active, uint32_t *pending); int anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle); diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index f2fbe70cada..8f5e4102cb6 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -1505,17 +1505,6 @@ static const __DRIimageExtension intelImageExtension = { .queryDmaBufFormatModifierAttribs = intel_query_format_modifier_attribs, }; -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; -} - static int brw_query_renderer_integer(__DRIscreen *dri_screen, int param, unsigned int *value) @@ -2610,7 +2599,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen) screen->max_gtt_map_object_size = gtt_size / 4; } - screen->aperture_threshold = get_aperture_size(screen->fd) * 3 / 4; + screen->aperture_threshold = devinfo->aperture_bytes * 3 / 4; screen->hw_has_swizzling = intel_detect_swizzling(screen); screen->hw_has_timestamp = intel_detect_timestamp(screen);