mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 09:28:07 +02:00
intel: Add and use intel_gem_get_context_param()
Again sharing the same function across all Intel drivers. There is still two additional DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM calls, one in intel/dev and other in perf. The first one can't call intel_gem_get_context_param() because of the build order of libs and the second one because it sets the size parameter. Will revisit those calls in future but this is already an improvement. v2: - using intel_gem_get_context_param() for the recently added query for I915_CONTEXT_PARAM_PROTECTED_CONTENT Signed-off-by: José Roberto de Souza <jose.souza@intel.com> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18974>
This commit is contained in:
parent
39486661e9
commit
fd14fcb9f9
4 changed files with 33 additions and 25 deletions
|
|
@ -1547,12 +1547,10 @@ crocus_create_hw_context(struct crocus_bufmgr *bufmgr)
|
|||
static int
|
||||
crocus_hw_context_get_priority(struct crocus_bufmgr *bufmgr, uint32_t ctx_id)
|
||||
{
|
||||
struct drm_i915_gem_context_param p = {
|
||||
.ctx_id = ctx_id,
|
||||
.param = I915_CONTEXT_PARAM_PRIORITY,
|
||||
};
|
||||
drmIoctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p);
|
||||
return p.value; /* on error, return 0 i.e. default priority */
|
||||
uint64_t priority = 0;
|
||||
intel_gem_get_context_param(bufmgr->fd, ctx_id,
|
||||
I915_CONTEXT_PARAM_PRIORITY, &priority);
|
||||
return priority; /* on error, return 0 i.e. default priority */
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
|||
|
|
@ -2229,12 +2229,10 @@ iris_create_hw_context(struct iris_bufmgr *bufmgr, bool protected)
|
|||
int
|
||||
iris_kernel_context_get_priority(struct iris_bufmgr *bufmgr, uint32_t ctx_id)
|
||||
{
|
||||
struct drm_i915_gem_context_param p = {
|
||||
.ctx_id = ctx_id,
|
||||
.param = I915_CONTEXT_PARAM_PRIORITY,
|
||||
};
|
||||
intel_ioctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p);
|
||||
return p.value; /* on error, return 0 i.e. default priority */
|
||||
uint64_t priority = 0;
|
||||
intel_gem_get_context_param(bufmgr->fd, ctx_id,
|
||||
I915_CONTEXT_PARAM_PRIORITY, &priority);
|
||||
return priority; /* on error, return 0 i.e. default priority */
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -2253,12 +2251,11 @@ iris_hw_context_set_priority(struct iris_bufmgr *bufmgr,
|
|||
static bool
|
||||
iris_hw_context_get_protected(struct iris_bufmgr *bufmgr, uint32_t ctx_id)
|
||||
{
|
||||
struct drm_i915_gem_context_param p = {
|
||||
.ctx_id = ctx_id,
|
||||
.param = I915_CONTEXT_PARAM_PROTECTED_CONTENT,
|
||||
};
|
||||
drmIoctl(bufmgr->fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &p);
|
||||
return p.value; /* on error, return 0 i.e. default priority */
|
||||
uint64_t protected_content = 0;
|
||||
intel_gem_get_context_param(bufmgr->fd, ctx_id,
|
||||
I915_CONTEXT_PARAM_PROTECTED_CONTENT,
|
||||
&protected_content);
|
||||
return protected_content;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
|
|
@ -2373,17 +2370,13 @@ iris_bufmgr_get_meminfo(struct iris_bufmgr *bufmgr,
|
|||
static void
|
||||
iris_bufmgr_init_global_vm(int fd, struct iris_bufmgr *bufmgr)
|
||||
{
|
||||
struct drm_i915_gem_context_param gcp = {
|
||||
.ctx_id = 0,
|
||||
.param = I915_CONTEXT_PARAM_VM,
|
||||
};
|
||||
|
||||
if (intel_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &gcp)) {
|
||||
uint64_t value;
|
||||
if (!intel_gem_get_context_param(fd, 0, I915_CONTEXT_PARAM_VM, &value)) {
|
||||
bufmgr->use_global_vm = false;
|
||||
bufmgr->global_vm_id = 0;
|
||||
} else {
|
||||
bufmgr->use_global_vm = true;
|
||||
bufmgr->global_vm_id = gcp.value;
|
||||
bufmgr->global_vm_id = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,20 @@ intel_gem_set_context_param(int fd, uint32_t context, uint32_t param,
|
|||
return intel_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &p) == 0;
|
||||
}
|
||||
|
||||
bool
|
||||
intel_gem_get_context_param(int fd, uint32_t context, uint32_t param,
|
||||
uint64_t *value)
|
||||
{
|
||||
struct drm_i915_gem_context_param gp = {
|
||||
.ctx_id = context,
|
||||
.param = param,
|
||||
};
|
||||
if (intel_ioctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &gp))
|
||||
return false;
|
||||
*value = gp.value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool intel_gem_read_render_timestamp(int fd, uint64_t *value)
|
||||
{
|
||||
struct drm_i915_reg_read reg_read = {
|
||||
|
|
|
|||
|
|
@ -169,6 +169,9 @@ intel_gem_create_context_engines(int fd,
|
|||
bool
|
||||
intel_gem_set_context_param(int fd, uint32_t context, uint32_t param,
|
||||
uint64_t value);
|
||||
bool
|
||||
intel_gem_get_context_param(int fd, uint32_t context, uint32_t param,
|
||||
uint64_t *value);
|
||||
|
||||
bool intel_gem_read_render_timestamp(int fd, uint64_t *value);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue