Rev 6937 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 6937 | Rev 7144 | ||
---|---|---|---|
Line 140... | Line 140... | ||
140 | 140 | ||
141 | if (!ppgtt) |
141 | if (!ppgtt) |
Line 142... | Line 142... | ||
142 | return; |
142 | return; |
143 | 143 | ||
144 | list_for_each_entry_safe(vma, next, &ppgtt->base.inactive_list, |
144 | list_for_each_entry_safe(vma, next, &ppgtt->base.inactive_list, |
145 | mm_list) { |
145 | vm_link) { |
146 | if (WARN_ON(__i915_vma_unbind_no_wait(vma))) |
146 | if (WARN_ON(__i915_vma_unbind_no_wait(vma))) |
147 | break; |
147 | break; |
Line 319... | Line 319... | ||
319 | idr_remove(&file_priv->context_idr, ctx->user_handle); |
319 | idr_remove(&file_priv->context_idr, ctx->user_handle); |
320 | i915_gem_context_unreference(ctx); |
320 | i915_gem_context_unreference(ctx); |
321 | return ERR_PTR(ret); |
321 | return ERR_PTR(ret); |
322 | } |
322 | } |
Line -... | Line 323... | ||
- | 323 | ||
- | 324 | static void i915_gem_context_unpin(struct intel_context *ctx, |
|
- | 325 | struct intel_engine_cs *engine) |
|
- | 326 | { |
|
- | 327 | if (i915.enable_execlists) { |
|
- | 328 | intel_lr_context_unpin(ctx, engine); |
|
- | 329 | } else { |
|
- | 330 | if (engine->id == RCS && ctx->legacy_hw_ctx.rcs_state) |
|
- | 331 | i915_gem_object_ggtt_unpin(ctx->legacy_hw_ctx.rcs_state); |
|
- | 332 | i915_gem_context_unreference(ctx); |
|
- | 333 | } |
|
- | 334 | } |
|
323 | 335 | ||
324 | void i915_gem_context_reset(struct drm_device *dev) |
336 | void i915_gem_context_reset(struct drm_device *dev) |
325 | { |
337 | { |
326 | struct drm_i915_private *dev_priv = dev->dev_private; |
338 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 327... | Line 339... | ||
327 | int i; |
339 | int i; |
328 | 340 | ||
Line 329... | Line 341... | ||
329 | if (i915.enable_execlists) { |
341 | if (i915.enable_execlists) { |
330 | struct intel_context *ctx; |
342 | struct intel_context *ctx; |
331 | 343 | ||
Line 332... | Line -... | ||
332 | list_for_each_entry(ctx, &dev_priv->context_list, link) { |
- | |
333 | intel_lr_context_reset(dev, ctx); |
- | |
334 | } |
- | |
335 | 344 | list_for_each_entry(ctx, &dev_priv->context_list, link) |
|
336 | return; |
345 | intel_lr_context_reset(dev, ctx); |
337 | } |
- | |
Line 338... | Line 346... | ||
338 | 346 | } |
|
339 | for (i = 0; i < I915_NUM_RINGS; i++) { |
- | |
340 | struct intel_engine_cs *ring = &dev_priv->ring[i]; |
- | |
341 | struct intel_context *lctx = ring->last_context; |
- | |
342 | 347 | ||
343 | if (lctx) { |
348 | for (i = 0; i < I915_NUM_RINGS; i++) { |
344 | if (lctx->legacy_hw_ctx.rcs_state && i == RCS) |
349 | struct intel_engine_cs *ring = &dev_priv->ring[i]; |
- | 350 | ||
Line 345... | Line 351... | ||
345 | i915_gem_object_ggtt_unpin(lctx->legacy_hw_ctx.rcs_state); |
351 | if (ring->last_context) { |
346 | - | ||
347 | i915_gem_context_unreference(lctx); |
352 | i915_gem_context_unpin(ring->last_context, ring); |
348 | ring->last_context = NULL; |
- | |
349 | } |
353 | ring->last_context = NULL; |
Line 350... | Line 354... | ||
350 | 354 | } |
|
351 | /* Force the GPU state to be reinitialised on enabling */ |
355 | } |
352 | if (ring->default_context) |
356 | |
353 | ring->default_context->legacy_hw_ctx.initialized = false; |
357 | /* Force the GPU state to be reinitialised on enabling */ |
354 | } |
- | |
Line 355... | Line 358... | ||
355 | } |
358 | dev_priv->kernel_context->legacy_hw_ctx.initialized = false; |
356 | 359 | } |
|
357 | int i915_gem_context_init(struct drm_device *dev) |
360 | |
358 | { |
361 | int i915_gem_context_init(struct drm_device *dev) |
Line 359... | Line 362... | ||
359 | struct drm_i915_private *dev_priv = dev->dev_private; |
362 | { |
360 | struct intel_context *ctx; |
363 | struct drm_i915_private *dev_priv = dev->dev_private; |
361 | int i; |
364 | struct intel_context *ctx; |
Line 390... | Line 393... | ||
390 | DRM_ERROR("Failed to create default global context (error %ld)\n", |
393 | DRM_ERROR("Failed to create default global context (error %ld)\n", |
391 | PTR_ERR(ctx)); |
394 | PTR_ERR(ctx)); |
392 | return PTR_ERR(ctx); |
395 | return PTR_ERR(ctx); |
393 | } |
396 | } |
Line 394... | Line -... | ||
394 | - | ||
395 | for (i = 0; i < I915_NUM_RINGS; i++) { |
- | |
396 | struct intel_engine_cs *ring = &dev_priv->ring[i]; |
- | |
397 | - | ||
398 | /* NB: RCS will hold a ref for all rings */ |
397 | |
399 | ring->default_context = ctx; |
- | |
Line 400... | Line 398... | ||
400 | } |
398 | dev_priv->kernel_context = ctx; |
401 | 399 | ||
402 | DRM_DEBUG_DRIVER("%s context support initialized\n", |
400 | DRM_DEBUG_DRIVER("%s context support initialized\n", |
403 | i915.enable_execlists ? "LR" : |
401 | i915.enable_execlists ? "LR" : |
404 | dev_priv->hw_context_size ? "HW" : "fake"); |
402 | dev_priv->hw_context_size ? "HW" : "fake"); |
Line 405... | Line 403... | ||
405 | return 0; |
403 | return 0; |
406 | } |
404 | } |
407 | 405 | ||
408 | void i915_gem_context_fini(struct drm_device *dev) |
406 | void i915_gem_context_fini(struct drm_device *dev) |
409 | { |
407 | { |
Line 410... | Line 408... | ||
410 | struct drm_i915_private *dev_priv = dev->dev_private; |
408 | struct drm_i915_private *dev_priv = dev->dev_private; |
411 | struct intel_context *dctx = dev_priv->ring[RCS].default_context; |
409 | struct intel_context *dctx = dev_priv->kernel_context; |
412 | int i; |
410 | int i; |
Line 422... | Line 420... | ||
422 | * i915_gem_context_fini() will be called after gpu_idle() has switched |
420 | * i915_gem_context_fini() will be called after gpu_idle() has switched |
423 | * to default context. So we need to unreference the base object once |
421 | * to default context. So we need to unreference the base object once |
424 | * to offset the do_switch part, so that i915_gem_context_unreference() |
422 | * to offset the do_switch part, so that i915_gem_context_unreference() |
425 | * can then free the base object correctly. */ |
423 | * can then free the base object correctly. */ |
426 | WARN_ON(!dev_priv->ring[RCS].last_context); |
424 | WARN_ON(!dev_priv->ring[RCS].last_context); |
427 | if (dev_priv->ring[RCS].last_context == dctx) { |
- | |
428 | /* Fake switch to NULL context */ |
- | |
429 | WARN_ON(dctx->legacy_hw_ctx.rcs_state->active); |
- | |
430 | i915_gem_object_ggtt_unpin(dctx->legacy_hw_ctx.rcs_state); |
- | |
431 | i915_gem_context_unreference(dctx); |
- | |
432 | dev_priv->ring[RCS].last_context = NULL; |
- | |
433 | } |
- | |
Line 434... | Line 425... | ||
434 | 425 | ||
435 | i915_gem_object_ggtt_unpin(dctx->legacy_hw_ctx.rcs_state); |
426 | i915_gem_object_ggtt_unpin(dctx->legacy_hw_ctx.rcs_state); |
Line 436... | Line 427... | ||
436 | } |
427 | } |
437 | 428 | ||
Line 438... | Line 429... | ||
438 | for (i = 0; i < I915_NUM_RINGS; i++) { |
429 | for (i = I915_NUM_RINGS; --i >= 0;) { |
439 | struct intel_engine_cs *ring = &dev_priv->ring[i]; |
430 | struct intel_engine_cs *ring = &dev_priv->ring[i]; |
440 | - | ||
441 | if (ring->last_context) |
- | |
442 | i915_gem_context_unreference(ring->last_context); |
431 | |
443 | 432 | if (ring->last_context) { |
|
- | 433 | i915_gem_context_unpin(ring->last_context, ring); |
|
Line 444... | Line 434... | ||
444 | ring->default_context = NULL; |
434 | ring->last_context = NULL; |
- | 435 | } |
|
445 | ring->last_context = NULL; |
436 | } |
Line 446... | Line 437... | ||
446 | } |
437 | |
447 | 438 | i915_gem_context_unreference(dctx); |
|
448 | i915_gem_context_unreference(dctx); |
439 | dev_priv->kernel_context = NULL; |
Line 862... | Line 853... | ||
862 | int ret; |
853 | int ret; |
Line 863... | Line 854... | ||
863 | 854 | ||
864 | if (!contexts_enabled(dev)) |
855 | if (!contexts_enabled(dev)) |
Line -... | Line 856... | ||
- | 856 | return -ENODEV; |
|
- | 857 | ||
- | 858 | if (args->pad != 0) |
|
865 | return -ENODEV; |
859 | return -EINVAL; |
866 | 860 | ||
867 | ret = i915_mutex_lock_interruptible(dev); |
861 | ret = i915_mutex_lock_interruptible(dev); |
Line 868... | Line 862... | ||
868 | if (ret) |
862 | if (ret) |
Line 885... | Line 879... | ||
885 | struct drm_i915_gem_context_destroy *args = data; |
879 | struct drm_i915_gem_context_destroy *args = data; |
886 | struct drm_i915_file_private *file_priv = file->driver_priv; |
880 | struct drm_i915_file_private *file_priv = file->driver_priv; |
887 | struct intel_context *ctx; |
881 | struct intel_context *ctx; |
888 | int ret; |
882 | int ret; |
Line -... | Line 883... | ||
- | 883 | ||
- | 884 | if (args->pad != 0) |
|
- | 885 | return -EINVAL; |
|
889 | 886 | ||
890 | if (args->ctx_id == DEFAULT_CONTEXT_HANDLE) |
887 | if (args->ctx_id == DEFAULT_CONTEXT_HANDLE) |
Line 891... | Line 888... | ||
891 | return -ENOENT; |
888 | return -ENOENT; |
892 | 889 |