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 <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5043>
This commit is contained in:

committed by
Marge Bot

parent
a887ad7c84
commit
bb3545a6ee
@@ -90,14 +90,6 @@ iris_get_name(struct pipe_screen *pscreen)
|
|||||||
return buf;
|
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
|
static int
|
||||||
iris_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
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.
|
* flushing, etc. That's the big cliff apps will care about.
|
||||||
*/
|
*/
|
||||||
const unsigned gpu_mappable_megabytes =
|
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_memory_pages = sysconf(_SC_PHYS_PAGES);
|
||||||
const long system_page_size = sysconf(_SC_PAGE_SIZE);
|
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->fd = iris_bufmgr_get_fd(screen->bufmgr);
|
||||||
|
|
||||||
screen->aperture_bytes = get_aperture_size(fd);
|
|
||||||
|
|
||||||
if (getenv("INTEL_NO_HW") != NULL)
|
if (getenv("INTEL_NO_HW") != NULL)
|
||||||
screen->no_hw = true;
|
screen->no_hw = true;
|
||||||
|
|
||||||
|
@@ -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
|
bool
|
||||||
gen_get_device_info_from_fd(int fd, struct gen_device_info *devinfo)
|
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);
|
getparam_topology(devinfo, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gen_get_aperture_size(fd, &devinfo->aperture_bytes);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -252,6 +252,8 @@ struct gen_device_info
|
|||||||
*/
|
*/
|
||||||
uint64_t timestamp_frequency;
|
uint64_t timestamp_frequency;
|
||||||
|
|
||||||
|
uint64_t aperture_bytes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID to put into the .aub files.
|
* 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_fd(int fh, struct gen_device_info *devinfo);
|
||||||
bool gen_get_device_info_from_pci_id(int pci_id,
|
bool gen_get_device_info_from_pci_id(int pci_id,
|
||||||
struct gen_device_info *devinfo);
|
struct gen_device_info *devinfo);
|
||||||
|
int gen_get_aperture_size(int fd, uint64_t *size);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -136,7 +136,7 @@ anv_physical_device_init_heaps(struct anv_physical_device *device, int fd)
|
|||||||
anv_perf_warn(NULL, NULL,
|
anv_perf_warn(NULL, NULL,
|
||||||
"Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");
|
"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,
|
return vk_errorfi(device->instance, NULL,
|
||||||
VK_ERROR_INITIALIZATION_FAILED,
|
VK_ERROR_INITIALIZATION_FAILED,
|
||||||
"failed to get aperture size: %m");
|
"failed to get aperture size: %m");
|
||||||
|
@@ -389,20 +389,6 @@ anv_gem_get_context_param(int fd, int context, uint32_t param, uint64_t *value)
|
|||||||
return 0;
|
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
|
int
|
||||||
anv_gem_gpu_get_reset_stats(struct anv_device *device,
|
anv_gem_gpu_get_reset_stats(struct anv_device *device,
|
||||||
uint32_t *active, uint32_t *pending)
|
uint32_t *active, uint32_t *pending)
|
||||||
|
@@ -159,12 +159,6 @@ anv_gem_has_context_priority(int fd)
|
|||||||
unreachable("Unused");
|
unreachable("Unused");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
anv_gem_get_aperture(int fd, uint64_t *size)
|
|
||||||
{
|
|
||||||
unreachable("Unused");
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
anv_gem_gpu_get_reset_stats(struct anv_device *device,
|
anv_gem_gpu_get_reset_stats(struct anv_device *device,
|
||||||
uint32_t *active, uint32_t *pending)
|
uint32_t *active, uint32_t *pending)
|
||||||
|
@@ -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_param(int fd, uint32_t param);
|
||||||
int anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle);
|
int anv_gem_get_tiling(struct anv_device *device, uint32_t gem_handle);
|
||||||
bool anv_gem_get_bit6_swizzle(int fd, uint32_t tiling);
|
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,
|
int anv_gem_gpu_get_reset_stats(struct anv_device *device,
|
||||||
uint32_t *active, uint32_t *pending);
|
uint32_t *active, uint32_t *pending);
|
||||||
int anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle);
|
int anv_gem_handle_to_fd(struct anv_device *device, uint32_t gem_handle);
|
||||||
|
@@ -1505,17 +1505,6 @@ static const __DRIimageExtension intelImageExtension = {
|
|||||||
.queryDmaBufFormatModifierAttribs = intel_query_format_modifier_attribs,
|
.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
|
static int
|
||||||
brw_query_renderer_integer(__DRIscreen *dri_screen,
|
brw_query_renderer_integer(__DRIscreen *dri_screen,
|
||||||
int param, unsigned int *value)
|
int param, unsigned int *value)
|
||||||
@@ -2610,7 +2599,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen)
|
|||||||
screen->max_gtt_map_object_size = gtt_size / 4;
|
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_swizzling = intel_detect_swizzling(screen);
|
||||||
screen->hw_has_timestamp = intel_detect_timestamp(screen);
|
screen->hw_has_timestamp = intel_detect_timestamp(screen);
|
||||||
|
Reference in New Issue
Block a user