drm/i915: relax context alignment
With the introduction of contexts per fd in the future, one can easily envision more contexts being used. We do not have an easy remedy to reduce the space requirements of the contexts, we can make things slightly better by using less stringent alignments on later hardware. Ville: Since I can almost predict you'll point this out. I can no longer find the docs which specify the 64k requirement on certain gen6 SKUs. If you'd like to change that too, be my guest. CC: Ville Syrjälä <ville.syrjala@linux.intel.com> Signed-off-by: Ben Widawsky <ben@bwidawsk.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
parent
e422b888eb
commit
b731d33d05
1 changed files with 19 additions and 7 deletions
|
@ -93,12 +93,21 @@
|
||||||
* I've seen in a spec to date, and that was a workaround for a non-shipping
|
* I've seen in a spec to date, and that was a workaround for a non-shipping
|
||||||
* part. It should be safe to decrease this, but it's more future proof as is.
|
* part. It should be safe to decrease this, but it's more future proof as is.
|
||||||
*/
|
*/
|
||||||
#define CONTEXT_ALIGN (64<<10)
|
#define GEN6_CONTEXT_ALIGN (64<<10)
|
||||||
|
#define GEN7_CONTEXT_ALIGN 4096
|
||||||
|
|
||||||
static struct i915_hw_context *
|
static struct i915_hw_context *
|
||||||
i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id);
|
i915_gem_context_get(struct drm_i915_file_private *file_priv, u32 id);
|
||||||
static int do_switch(struct i915_hw_context *to);
|
static int do_switch(struct i915_hw_context *to);
|
||||||
|
|
||||||
|
static size_t get_context_alignment(struct drm_device *dev)
|
||||||
|
{
|
||||||
|
if (IS_GEN6(dev))
|
||||||
|
return GEN6_CONTEXT_ALIGN;
|
||||||
|
|
||||||
|
return GEN7_CONTEXT_ALIGN;
|
||||||
|
}
|
||||||
|
|
||||||
static int get_context_size(struct drm_device *dev)
|
static int get_context_size(struct drm_device *dev)
|
||||||
{
|
{
|
||||||
struct drm_i915_private *dev_priv = dev->dev_private;
|
struct drm_i915_private *dev_priv = dev->dev_private;
|
||||||
|
@ -206,14 +215,15 @@ static inline bool is_default_context(struct i915_hw_context *ctx)
|
||||||
* context state of the GPU for applications that don't utilize HW contexts, as
|
* context state of the GPU for applications that don't utilize HW contexts, as
|
||||||
* well as an idle case.
|
* well as an idle case.
|
||||||
*/
|
*/
|
||||||
static int create_default_context(struct drm_i915_private *dev_priv)
|
static int create_default_context(struct drm_device *dev)
|
||||||
{
|
{
|
||||||
|
struct drm_i915_private *dev_priv = dev->dev_private;
|
||||||
struct i915_hw_context *ctx;
|
struct i915_hw_context *ctx;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
BUG_ON(!mutex_is_locked(&dev_priv->dev->struct_mutex));
|
BUG_ON(!mutex_is_locked(&dev->struct_mutex));
|
||||||
|
|
||||||
ctx = create_hw_context(dev_priv->dev, NULL);
|
ctx = create_hw_context(dev, NULL);
|
||||||
if (IS_ERR(ctx))
|
if (IS_ERR(ctx))
|
||||||
return PTR_ERR(ctx);
|
return PTR_ERR(ctx);
|
||||||
|
|
||||||
|
@ -223,7 +233,8 @@ static int create_default_context(struct drm_i915_private *dev_priv)
|
||||||
* may not be available. To avoid this we always pin the
|
* may not be available. To avoid this we always pin the
|
||||||
* default context.
|
* default context.
|
||||||
*/
|
*/
|
||||||
ret = i915_gem_obj_ggtt_pin(ctx->obj, CONTEXT_ALIGN, false, false);
|
ret = i915_gem_obj_ggtt_pin(ctx->obj, get_context_alignment(dev),
|
||||||
|
false, false);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DRM_DEBUG_DRIVER("Couldn't pin %d\n", ret);
|
DRM_DEBUG_DRIVER("Couldn't pin %d\n", ret);
|
||||||
goto err_destroy;
|
goto err_destroy;
|
||||||
|
@ -266,7 +277,7 @@ int i915_gem_context_init(struct drm_device *dev)
|
||||||
return -E2BIG;
|
return -E2BIG;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = create_default_context(dev_priv);
|
ret = create_default_context(dev);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
DRM_DEBUG_DRIVER("Disabling HW Contexts; create failed %d\n",
|
DRM_DEBUG_DRIVER("Disabling HW Contexts; create failed %d\n",
|
||||||
ret);
|
ret);
|
||||||
|
@ -433,7 +444,8 @@ static int do_switch(struct i915_hw_context *to)
|
||||||
if (from == to && !to->remap_slice)
|
if (from == to && !to->remap_slice)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ret = i915_gem_obj_ggtt_pin(to->obj, CONTEXT_ALIGN, false, false);
|
ret = i915_gem_obj_ggtt_pin(to->obj, get_context_alignment(ring->dev),
|
||||||
|
false, false);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue