}
static VkResult
-anv_compute_heap_size(int fd, uint64_t *heap_size)
+anv_compute_heap_size(int fd, uint64_t gtt_size, uint64_t *heap_size)
{
- uint64_t gtt_size;
- if (anv_gem_get_context_param(fd, 0, I915_CONTEXT_PARAM_GTT_SIZE,
- >t_size) == -1) {
- /* If, for whatever reason, we can't actually get the GTT size from the
- * kernel (too old?) fall back to the aperture size.
- */
- anv_perf_warn(NULL, NULL,
- "Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");
-
- if (anv_gem_get_aperture(fd, >t_size) == -1) {
- return vk_errorf(NULL, NULL, VK_ERROR_INITIALIZATION_FAILED,
- "failed to get aperture size: %m");
- }
- }
-
/* Query the total ram from the system */
struct sysinfo info;
sysinfo(&info);
static VkResult
anv_physical_device_init_heaps(struct anv_physical_device *device, int fd)
{
- /* The kernel query only tells us whether or not the kernel supports the
- * EXEC_OBJECT_SUPPORTS_48B_ADDRESS flag and not whether or not the
- * hardware has actual 48bit address support.
- */
- device->supports_48bit_addresses =
- (device->info.gen >= 8) && anv_gem_supports_48b_addresses(fd);
+ uint64_t gtt_size;
+ if (anv_gem_get_context_param(fd, 0, I915_CONTEXT_PARAM_GTT_SIZE,
+ >t_size) == -1) {
+ /* If, for whatever reason, we can't actually get the GTT size from the
+ * kernel (too old?) fall back to the aperture size.
+ */
+ anv_perf_warn(NULL, NULL,
+ "Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");
+
+ if (anv_gem_get_aperture(fd, >t_size) == -1) {
+ return vk_errorf(NULL, NULL, VK_ERROR_INITIALIZATION_FAILED,
+ "failed to get aperture size: %m");
+ }
+ }
+
+ device->supports_48bit_addresses = (device->info.gen >= 8) &&
+ gtt_size > (4ULL << 30 /* GiB */);
uint64_t heap_size = 0;
- VkResult result = anv_compute_heap_size(fd, &heap_size);
+ VkResult result = anv_compute_heap_size(fd, gtt_size, &heap_size);
if (result != VK_SUCCESS)
return result;
return 0;
}
-bool
-anv_gem_supports_48b_addresses(int fd)
-{
- struct drm_i915_gem_exec_object2 obj = {
- .flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS,
- };
-
- struct drm_i915_gem_execbuffer2 execbuf = {
- .buffers_ptr = (uintptr_t)&obj,
- .buffer_count = 1,
- .rsvd1 = 0xffffffu,
- };
-
- int ret = anv_ioctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
-
- return ret == -1 && errno == ENOENT;
-}
-
int
anv_gem_gpu_get_reset_stats(struct anv_device *device,
uint32_t *active, uint32_t *pending)
unreachable("Unused");
}
-bool
-anv_gem_supports_48b_addresses(int fd)
-{
- unreachable("Unused");
-}
-
int
anv_gem_gpu_get_reset_stats(struct anv_device *device,
uint32_t *active, uint32_t *pending)
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);
-bool anv_gem_supports_48b_addresses(int fd);
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);
return v;
}
-static bool
-gem_supports_48b_addresses(int fd)
+static int
+gem_context_getparam(int fd, uint32_t context, uint64_t param, uint64_t *value)
{
- struct drm_i915_gem_exec_object2 obj = {
- .flags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS,
+ struct drm_i915_gem_context_param gp = {
+ .ctx_id = context,
+ .param = param,
};
- struct drm_i915_gem_execbuffer2 execbuf = {
- .buffers_ptr = (uintptr_t)&obj,
- .buffer_count = 1,
- .rsvd1 = 0xffffffu,
- };
+ if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &gp))
+ return -1;
- int ret = drmIoctl(fd, DRM_IOCTL_I915_GEM_EXECBUFFER2, &execbuf);
+ *value = gp.value;
- return ret == -1 && errno == ENOENT;
+ return 0;
}
/**
return NULL;
}
+ uint64_t gtt_size;
+ if (gem_context_getparam(fd, 0, I915_CONTEXT_PARAM_GTT_SIZE, >t_size))
+ gtt_size = 0;
+
bufmgr->has_llc = devinfo->has_llc;
bufmgr->has_mmap_wc = gem_param(fd, I915_PARAM_MMAP_VERSION) > 0;
- bufmgr->supports_48b_addresses =
- devinfo->gen >= 8 && gem_supports_48b_addresses(fd);
+ bufmgr->supports_48b_addresses = devinfo->gen >= 8 &&
+ gtt_size > (4ULL << 30 /* GiB */);
init_cache_buckets(bufmgr);