drm/i915: add a context parameter to {en, dis}able zero address mapping
Export a new context parameter that can be set/queried through the
context_{get,set}param ioctls. This parameter is passed as a context
flag and decides whether or not a GPU address mapping is allowed to
be made at address zero. The default is to allow such mappings.
Signed-off-by: David Weinehall <david.weinehall@intel.com>
Acked-by: "Zou, Nanhai" <nanhai.zou@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
committed by
Daniel Vetter
parent
4373f0f24e
commit
b1b38278e1
@@ -805,11 +805,15 @@ struct i915_ctx_hang_stats {
|
|||||||
|
|
||||||
/* This must match up with the value previously used for execbuf2.rsvd1. */
|
/* This must match up with the value previously used for execbuf2.rsvd1. */
|
||||||
#define DEFAULT_CONTEXT_HANDLE 0
|
#define DEFAULT_CONTEXT_HANDLE 0
|
||||||
|
|
||||||
|
#define CONTEXT_NO_ZEROMAP (1<<0)
|
||||||
/**
|
/**
|
||||||
* struct intel_context - as the name implies, represents a context.
|
* struct intel_context - as the name implies, represents a context.
|
||||||
* @ref: reference count.
|
* @ref: reference count.
|
||||||
* @user_handle: userspace tracking identity for this context.
|
* @user_handle: userspace tracking identity for this context.
|
||||||
* @remap_slice: l3 row remapping information.
|
* @remap_slice: l3 row remapping information.
|
||||||
|
* @flags: context specific flags:
|
||||||
|
* CONTEXT_NO_ZEROMAP: do not allow mapping things to page 0.
|
||||||
* @file_priv: filp associated with this context (NULL for global default
|
* @file_priv: filp associated with this context (NULL for global default
|
||||||
* context).
|
* context).
|
||||||
* @hang_stats: information about the role of this context in possible GPU
|
* @hang_stats: information about the role of this context in possible GPU
|
||||||
@@ -826,6 +830,7 @@ struct intel_context {
|
|||||||
struct kref ref;
|
struct kref ref;
|
||||||
int user_handle;
|
int user_handle;
|
||||||
uint8_t remap_slice;
|
uint8_t remap_slice;
|
||||||
|
int flags;
|
||||||
struct drm_i915_file_private *file_priv;
|
struct drm_i915_file_private *file_priv;
|
||||||
struct i915_ctx_hang_stats hang_stats;
|
struct i915_ctx_hang_stats hang_stats;
|
||||||
struct i915_hw_ppgtt *ppgtt;
|
struct i915_hw_ppgtt *ppgtt;
|
||||||
|
|||||||
@@ -900,6 +900,9 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data,
|
|||||||
case I915_CONTEXT_PARAM_BAN_PERIOD:
|
case I915_CONTEXT_PARAM_BAN_PERIOD:
|
||||||
args->value = ctx->hang_stats.ban_period_seconds;
|
args->value = ctx->hang_stats.ban_period_seconds;
|
||||||
break;
|
break;
|
||||||
|
case I915_CONTEXT_PARAM_NO_ZEROMAP:
|
||||||
|
args->value = ctx->flags & CONTEXT_NO_ZEROMAP;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
@@ -937,6 +940,14 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,
|
|||||||
else
|
else
|
||||||
ctx->hang_stats.ban_period_seconds = args->value;
|
ctx->hang_stats.ban_period_seconds = args->value;
|
||||||
break;
|
break;
|
||||||
|
case I915_CONTEXT_PARAM_NO_ZEROMAP:
|
||||||
|
if (args->size) {
|
||||||
|
ret = -EINVAL;
|
||||||
|
} else {
|
||||||
|
ctx->flags &= ~CONTEXT_NO_ZEROMAP;
|
||||||
|
ctx->flags |= args->value ? CONTEXT_NO_ZEROMAP : 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -676,6 +676,7 @@ eb_vma_misplaced(struct i915_vma *vma)
|
|||||||
static int
|
static int
|
||||||
i915_gem_execbuffer_reserve(struct intel_engine_cs *ring,
|
i915_gem_execbuffer_reserve(struct intel_engine_cs *ring,
|
||||||
struct list_head *vmas,
|
struct list_head *vmas,
|
||||||
|
struct intel_context *ctx,
|
||||||
bool *need_relocs)
|
bool *need_relocs)
|
||||||
{
|
{
|
||||||
struct drm_i915_gem_object *obj;
|
struct drm_i915_gem_object *obj;
|
||||||
@@ -698,6 +699,9 @@ i915_gem_execbuffer_reserve(struct intel_engine_cs *ring,
|
|||||||
obj = vma->obj;
|
obj = vma->obj;
|
||||||
entry = vma->exec_entry;
|
entry = vma->exec_entry;
|
||||||
|
|
||||||
|
if (ctx->flags & CONTEXT_NO_ZEROMAP)
|
||||||
|
entry->flags |= __EXEC_OBJECT_NEEDS_BIAS;
|
||||||
|
|
||||||
if (!has_fenced_gpu_access)
|
if (!has_fenced_gpu_access)
|
||||||
entry->flags &= ~EXEC_OBJECT_NEEDS_FENCE;
|
entry->flags &= ~EXEC_OBJECT_NEEDS_FENCE;
|
||||||
need_fence =
|
need_fence =
|
||||||
@@ -775,7 +779,8 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
|
|||||||
struct drm_file *file,
|
struct drm_file *file,
|
||||||
struct intel_engine_cs *ring,
|
struct intel_engine_cs *ring,
|
||||||
struct eb_vmas *eb,
|
struct eb_vmas *eb,
|
||||||
struct drm_i915_gem_exec_object2 *exec)
|
struct drm_i915_gem_exec_object2 *exec,
|
||||||
|
struct intel_context *ctx)
|
||||||
{
|
{
|
||||||
struct drm_i915_gem_relocation_entry *reloc;
|
struct drm_i915_gem_relocation_entry *reloc;
|
||||||
struct i915_address_space *vm;
|
struct i915_address_space *vm;
|
||||||
@@ -861,7 +866,7 @@ i915_gem_execbuffer_relocate_slow(struct drm_device *dev,
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
need_relocs = (args->flags & I915_EXEC_NO_RELOC) == 0;
|
need_relocs = (args->flags & I915_EXEC_NO_RELOC) == 0;
|
||||||
ret = i915_gem_execbuffer_reserve(ring, &eb->vmas, &need_relocs);
|
ret = i915_gem_execbuffer_reserve(ring, &eb->vmas, ctx, &need_relocs);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
@@ -1519,7 +1524,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
|
|||||||
|
|
||||||
/* Move the objects en-masse into the GTT, evicting if necessary. */
|
/* Move the objects en-masse into the GTT, evicting if necessary. */
|
||||||
need_relocs = (args->flags & I915_EXEC_NO_RELOC) == 0;
|
need_relocs = (args->flags & I915_EXEC_NO_RELOC) == 0;
|
||||||
ret = i915_gem_execbuffer_reserve(ring, &eb->vmas, &need_relocs);
|
ret = i915_gem_execbuffer_reserve(ring, &eb->vmas, ctx, &need_relocs);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
@@ -1529,7 +1534,7 @@ i915_gem_do_execbuffer(struct drm_device *dev, void *data,
|
|||||||
if (ret) {
|
if (ret) {
|
||||||
if (ret == -EFAULT) {
|
if (ret == -EFAULT) {
|
||||||
ret = i915_gem_execbuffer_relocate_slow(dev, args, file, ring,
|
ret = i915_gem_execbuffer_relocate_slow(dev, args, file, ring,
|
||||||
eb, exec);
|
eb, exec, ctx);
|
||||||
BUG_ON(!mutex_is_locked(&dev->struct_mutex));
|
BUG_ON(!mutex_is_locked(&dev->struct_mutex));
|
||||||
}
|
}
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|||||||
@@ -1106,6 +1106,7 @@ struct drm_i915_gem_context_param {
|
|||||||
__u32 size;
|
__u32 size;
|
||||||
__u64 param;
|
__u64 param;
|
||||||
#define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
|
#define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
|
||||||
|
#define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
|
||||||
__u64 value;
|
__u64 value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user