diff options
author | Oscar Mateo <oscar.mateo@intel.com> | 2014-07-03 11:27:58 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-07-08 06:30:31 -0400 |
commit | aa0c13daada955ca86dff0b99428929841bfdbc6 (patch) | |
tree | 82159303e3446a68e61f3432247754e4425ad918 /drivers/gpu/drm/i915/i915_gem_context.c | |
parent | 95fa2eeecfe82788b47366abf7c3a773cc187663 (diff) |
drm/i915: Extract context backing object allocation
This is preparatory work for Execlists: we plan to use it later to
allocate our own context objects (since Logical Ring Contexts do
not have the same kind of backing objects).
No functional changes.
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_context.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_context.c | 54 |
1 files changed, 35 insertions, 19 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 06561213cf29..e664e869181f 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
@@ -198,6 +198,36 @@ void i915_gem_context_free(struct kref *ctx_ref) | |||
198 | kfree(ctx); | 198 | kfree(ctx); |
199 | } | 199 | } |
200 | 200 | ||
201 | static struct drm_i915_gem_object * | ||
202 | i915_gem_alloc_context_obj(struct drm_device *dev, size_t size) | ||
203 | { | ||
204 | struct drm_i915_gem_object *obj; | ||
205 | int ret; | ||
206 | |||
207 | obj = i915_gem_alloc_object(dev, size); | ||
208 | if (obj == NULL) | ||
209 | return ERR_PTR(-ENOMEM); | ||
210 | |||
211 | /* | ||
212 | * Try to make the context utilize L3 as well as LLC. | ||
213 | * | ||
214 | * On VLV we don't have L3 controls in the PTEs so we | ||
215 | * shouldn't touch the cache level, especially as that | ||
216 | * would make the object snooped which might have a | ||
217 | * negative performance impact. | ||
218 | */ | ||
219 | if (INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev)) { | ||
220 | ret = i915_gem_object_set_cache_level(obj, I915_CACHE_L3_LLC); | ||
221 | /* Failure shouldn't ever happen this early */ | ||
222 | if (WARN_ON(ret)) { | ||
223 | drm_gem_object_unreference(&obj->base); | ||
224 | return ERR_PTR(ret); | ||
225 | } | ||
226 | } | ||
227 | |||
228 | return obj; | ||
229 | } | ||
230 | |||
201 | static struct i915_hw_ppgtt * | 231 | static struct i915_hw_ppgtt * |
202 | create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx) | 232 | create_vm_for_ctx(struct drm_device *dev, struct intel_context *ctx) |
203 | { | 233 | { |
@@ -234,27 +264,13 @@ __create_hw_context(struct drm_device *dev, | |||
234 | list_add_tail(&ctx->link, &dev_priv->context_list); | 264 | list_add_tail(&ctx->link, &dev_priv->context_list); |
235 | 265 | ||
236 | if (dev_priv->hw_context_size) { | 266 | if (dev_priv->hw_context_size) { |
237 | ctx->obj = i915_gem_alloc_object(dev, dev_priv->hw_context_size); | 267 | struct drm_i915_gem_object *obj = |
238 | if (ctx->obj == NULL) { | 268 | i915_gem_alloc_context_obj(dev, dev_priv->hw_context_size); |
239 | ret = -ENOMEM; | 269 | if (IS_ERR(obj)) { |
270 | ret = PTR_ERR(obj); | ||
240 | goto err_out; | 271 | goto err_out; |
241 | } | 272 | } |
242 | 273 | ctx->obj = obj; | |
243 | /* | ||
244 | * Try to make the context utilize L3 as well as LLC. | ||
245 | * | ||
246 | * On VLV we don't have L3 controls in the PTEs so we | ||
247 | * shouldn't touch the cache level, especially as that | ||
248 | * would make the object snooped which might have a | ||
249 | * negative performance impact. | ||
250 | */ | ||
251 | if (INTEL_INFO(dev)->gen >= 7 && !IS_VALLEYVIEW(dev)) { | ||
252 | ret = i915_gem_object_set_cache_level(ctx->obj, | ||
253 | I915_CACHE_L3_LLC); | ||
254 | /* Failure shouldn't ever happen this early */ | ||
255 | if (WARN_ON(ret)) | ||
256 | goto err_out; | ||
257 | } | ||
258 | } | 274 | } |
259 | 275 | ||
260 | /* Default context will never have a file_priv */ | 276 | /* Default context will never have a file_priv */ |