aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoger He <Hongbo.He@amd.com>2017-12-08 02:09:50 -0500
committerAlex Deucher <alexander.deucher@amd.com>2017-12-27 11:38:54 -0500
commit279c01f6ef626d59b93383d183fb69173d3f7ac7 (patch)
tree5874a26a7c74a50a483fbf18df1d9a2aadbc3026
parenta6c26af8a4348a0ba2eb146b08f4d4d908cd9222 (diff)
drm/ttm: use an operation ctx for ttm_mem_global_alloc
forward the operation context to ttm_mem_global_alloc as well, and the ultimate goal is swapout enablement for reserved BOs Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Roger He <Hongbo.He@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c2
-rw-r--r--drivers/gpu/drm/ttm/ttm_memory.c15
-rw-r--r--drivers/gpu/drm/ttm/ttm_object.c13
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_binding.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c13
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_context.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_fence.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_shader.c18
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_so.c6
-rw-r--r--drivers/gpu/drm/vmwgfx/vmwgfx_surface.c12
-rw-r--r--include/drm/ttm/ttm_memory.h3
13 files changed, 87 insertions, 25 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index f2cfa93cbba5..4424bf2db8ad 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1135,7 +1135,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
1135 struct ttm_mem_global *mem_glob = bdev->glob->mem_glob; 1135 struct ttm_mem_global *mem_glob = bdev->glob->mem_glob;
1136 bool locked; 1136 bool locked;
1137 1137
1138 ret = ttm_mem_global_alloc(mem_glob, acc_size, false, false); 1138 ret = ttm_mem_global_alloc(mem_glob, acc_size, ctx);
1139 if (ret) { 1139 if (ret) {
1140 pr_err("Out of kernel memory\n"); 1140 pr_err("Out of kernel memory\n");
1141 if (destroy) 1141 if (destroy)
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 9130bdfb26ad..525d3b601790 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -508,7 +508,7 @@ out_unlock:
508static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob, 508static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob,
509 struct ttm_mem_zone *single_zone, 509 struct ttm_mem_zone *single_zone,
510 uint64_t memory, 510 uint64_t memory,
511 bool no_wait, bool interruptible) 511 struct ttm_operation_ctx *ctx)
512{ 512{
513 int count = TTM_MEMORY_ALLOC_RETRIES; 513 int count = TTM_MEMORY_ALLOC_RETRIES;
514 514
@@ -516,7 +516,7 @@ static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob,
516 single_zone, 516 single_zone,
517 memory, true) 517 memory, true)
518 != 0)) { 518 != 0)) {
519 if (no_wait) 519 if (ctx->no_wait_gpu)
520 return -ENOMEM; 520 return -ENOMEM;
521 if (unlikely(count-- == 0)) 521 if (unlikely(count-- == 0))
522 return -ENOMEM; 522 return -ENOMEM;
@@ -527,15 +527,14 @@ static int ttm_mem_global_alloc_zone(struct ttm_mem_global *glob,
527} 527}
528 528
529int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, 529int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory,
530 bool no_wait, bool interruptible) 530 struct ttm_operation_ctx *ctx)
531{ 531{
532 /** 532 /**
533 * Normal allocations of kernel memory are registered in 533 * Normal allocations of kernel memory are registered in
534 * all zones. 534 * all zones.
535 */ 535 */
536 536
537 return ttm_mem_global_alloc_zone(glob, NULL, memory, no_wait, 537 return ttm_mem_global_alloc_zone(glob, NULL, memory, ctx);
538 interruptible);
539} 538}
540EXPORT_SYMBOL(ttm_mem_global_alloc); 539EXPORT_SYMBOL(ttm_mem_global_alloc);
541 540
@@ -544,6 +543,10 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global *glob,
544{ 543{
545 544
546 struct ttm_mem_zone *zone = NULL; 545 struct ttm_mem_zone *zone = NULL;
546 struct ttm_operation_ctx ctx = {
547 .interruptible = false,
548 .no_wait_gpu = false
549 };
547 550
548 /** 551 /**
549 * Page allocations may be registed in a single zone 552 * Page allocations may be registed in a single zone
@@ -557,7 +560,7 @@ int ttm_mem_global_alloc_page(struct ttm_mem_global *glob,
557 if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL) 560 if (glob->zone_dma32 && page_to_pfn(page) > 0x00100000UL)
558 zone = glob->zone_kernel; 561 zone = glob->zone_kernel;
559#endif 562#endif
560 return ttm_mem_global_alloc_zone(glob, zone, size, false, false); 563 return ttm_mem_global_alloc_zone(glob, zone, size, &ctx);
561} 564}
562 565
563void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page, 566void ttm_mem_global_free_page(struct ttm_mem_global *glob, struct page *page,
diff --git a/drivers/gpu/drm/ttm/ttm_object.c b/drivers/gpu/drm/ttm/ttm_object.c
index 26a7ad0f4789..1aa2baa83959 100644
--- a/drivers/gpu/drm/ttm/ttm_object.c
+++ b/drivers/gpu/drm/ttm/ttm_object.c
@@ -325,6 +325,10 @@ int ttm_ref_object_add(struct ttm_object_file *tfile,
325 struct ttm_ref_object *ref; 325 struct ttm_ref_object *ref;
326 struct drm_hash_item *hash; 326 struct drm_hash_item *hash;
327 struct ttm_mem_global *mem_glob = tfile->tdev->mem_glob; 327 struct ttm_mem_global *mem_glob = tfile->tdev->mem_glob;
328 struct ttm_operation_ctx ctx = {
329 .interruptible = false,
330 .no_wait_gpu = false
331 };
328 int ret = -EINVAL; 332 int ret = -EINVAL;
329 333
330 if (base->tfile != tfile && !base->shareable) 334 if (base->tfile != tfile && !base->shareable)
@@ -350,7 +354,7 @@ int ttm_ref_object_add(struct ttm_object_file *tfile,
350 return -EPERM; 354 return -EPERM;
351 355
352 ret = ttm_mem_global_alloc(mem_glob, sizeof(*ref), 356 ret = ttm_mem_global_alloc(mem_glob, sizeof(*ref),
353 false, false); 357 &ctx);
354 if (unlikely(ret != 0)) 358 if (unlikely(ret != 0))
355 return ret; 359 return ret;
356 ref = kmalloc(sizeof(*ref), GFP_KERNEL); 360 ref = kmalloc(sizeof(*ref), GFP_KERNEL);
@@ -686,7 +690,10 @@ int ttm_prime_handle_to_fd(struct ttm_object_file *tfile,
686 dma_buf = prime->dma_buf; 690 dma_buf = prime->dma_buf;
687 if (!dma_buf || !get_dma_buf_unless_doomed(dma_buf)) { 691 if (!dma_buf || !get_dma_buf_unless_doomed(dma_buf)) {
688 DEFINE_DMA_BUF_EXPORT_INFO(exp_info); 692 DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
689 693 struct ttm_operation_ctx ctx = {
694 .interruptible = true,
695 .no_wait_gpu = false
696 };
690 exp_info.ops = &tdev->ops; 697 exp_info.ops = &tdev->ops;
691 exp_info.size = prime->size; 698 exp_info.size = prime->size;
692 exp_info.flags = flags; 699 exp_info.flags = flags;
@@ -696,7 +703,7 @@ int ttm_prime_handle_to_fd(struct ttm_object_file *tfile,
696 * Need to create a new dma_buf, with memory accounting. 703 * Need to create a new dma_buf, with memory accounting.
697 */ 704 */
698 ret = ttm_mem_global_alloc(tdev->mem_glob, tdev->dma_buf_size, 705 ret = ttm_mem_global_alloc(tdev->mem_glob, tdev->dma_buf_size,
699 false, true); 706 &ctx);
700 if (unlikely(ret != 0)) { 707 if (unlikely(ret != 0)) {
701 mutex_unlock(&prime->mutex); 708 mutex_unlock(&prime->mutex);
702 goto out_unref; 709 goto out_unref;
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
index 9c42e96da510..55d32ae43aa4 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
@@ -1202,10 +1202,14 @@ struct vmw_ctx_binding_state *
1202vmw_binding_state_alloc(struct vmw_private *dev_priv) 1202vmw_binding_state_alloc(struct vmw_private *dev_priv)
1203{ 1203{
1204 struct vmw_ctx_binding_state *cbs; 1204 struct vmw_ctx_binding_state *cbs;
1205 struct ttm_operation_ctx ctx = {
1206 .interruptible = false,
1207 .no_wait_gpu = false
1208 };
1205 int ret; 1209 int ret;
1206 1210
1207 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), sizeof(*cbs), 1211 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), sizeof(*cbs),
1208 false, false); 1212 &ctx);
1209 if (ret) 1213 if (ret)
1210 return ERR_PTR(ret); 1214 return ERR_PTR(ret);
1211 1215
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
index 828dd5994854..cb386eb234ac 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
@@ -394,6 +394,10 @@ static int vmw_ttm_map_dma(struct vmw_ttm_tt *vmw_tt)
394 struct vmw_private *dev_priv = vmw_tt->dev_priv; 394 struct vmw_private *dev_priv = vmw_tt->dev_priv;
395 struct ttm_mem_global *glob = vmw_mem_glob(dev_priv); 395 struct ttm_mem_global *glob = vmw_mem_glob(dev_priv);
396 struct vmw_sg_table *vsgt = &vmw_tt->vsgt; 396 struct vmw_sg_table *vsgt = &vmw_tt->vsgt;
397 struct ttm_operation_ctx ctx = {
398 .interruptible = true,
399 .no_wait_gpu = false
400 };
397 struct vmw_piter iter; 401 struct vmw_piter iter;
398 dma_addr_t old; 402 dma_addr_t old;
399 int ret = 0; 403 int ret = 0;
@@ -417,8 +421,7 @@ static int vmw_ttm_map_dma(struct vmw_ttm_tt *vmw_tt)
417 sgt_size = ttm_round_pot(sizeof(struct sg_table)); 421 sgt_size = ttm_round_pot(sizeof(struct sg_table));
418 } 422 }
419 vmw_tt->sg_alloc_size = sgt_size + sgl_size * vsgt->num_pages; 423 vmw_tt->sg_alloc_size = sgt_size + sgl_size * vsgt->num_pages;
420 ret = ttm_mem_global_alloc(glob, vmw_tt->sg_alloc_size, false, 424 ret = ttm_mem_global_alloc(glob, vmw_tt->sg_alloc_size, &ctx);
421 true);
422 if (unlikely(ret != 0)) 425 if (unlikely(ret != 0))
423 return ret; 426 return ret;
424 427
@@ -638,6 +641,10 @@ static int vmw_ttm_populate(struct ttm_tt *ttm)
638 container_of(ttm, struct vmw_ttm_tt, dma_ttm.ttm); 641 container_of(ttm, struct vmw_ttm_tt, dma_ttm.ttm);
639 struct vmw_private *dev_priv = vmw_tt->dev_priv; 642 struct vmw_private *dev_priv = vmw_tt->dev_priv;
640 struct ttm_mem_global *glob = vmw_mem_glob(dev_priv); 643 struct ttm_mem_global *glob = vmw_mem_glob(dev_priv);
644 struct ttm_operation_ctx ctx = {
645 .interruptible = true,
646 .no_wait_gpu = false
647 };
641 int ret; 648 int ret;
642 649
643 if (ttm->state != tt_unpopulated) 650 if (ttm->state != tt_unpopulated)
@@ -646,7 +653,7 @@ static int vmw_ttm_populate(struct ttm_tt *ttm)
646 if (dev_priv->map_mode == vmw_dma_alloc_coherent) { 653 if (dev_priv->map_mode == vmw_dma_alloc_coherent) {
647 size_t size = 654 size_t size =
648 ttm_round_pot(ttm->num_pages * sizeof(dma_addr_t)); 655 ttm_round_pot(ttm->num_pages * sizeof(dma_addr_t));
649 ret = ttm_mem_global_alloc(glob, size, false, true); 656 ret = ttm_mem_global_alloc(glob, size, &ctx);
650 if (unlikely(ret != 0)) 657 if (unlikely(ret != 0))
651 return ret; 658 return ret;
652 659
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
index 4212b3e673bc..3767ac335aca 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_context.c
@@ -746,6 +746,10 @@ static int vmw_context_define(struct drm_device *dev, void *data,
746 struct vmw_resource *tmp; 746 struct vmw_resource *tmp;
747 struct drm_vmw_context_arg *arg = (struct drm_vmw_context_arg *)data; 747 struct drm_vmw_context_arg *arg = (struct drm_vmw_context_arg *)data;
748 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 748 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
749 struct ttm_operation_ctx ttm_opt_ctx = {
750 .interruptible = true,
751 .no_wait_gpu = false
752 };
749 int ret; 753 int ret;
750 754
751 if (!dev_priv->has_dx && dx) { 755 if (!dev_priv->has_dx && dx) {
@@ -768,7 +772,7 @@ static int vmw_context_define(struct drm_device *dev, void *data,
768 772
769 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), 773 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv),
770 vmw_user_context_size, 774 vmw_user_context_size,
771 false, true); 775 &ttm_opt_ctx);
772 if (unlikely(ret != 0)) { 776 if (unlikely(ret != 0)) {
773 if (ret != -ERESTARTSYS) 777 if (ret != -ERESTARTSYS)
774 DRM_ERROR("Out of graphics memory for context" 778 DRM_ERROR("Out of graphics memory for context"
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c
index 92df0b08c194..cbf54ea7b4c0 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cotable.c
@@ -573,6 +573,10 @@ struct vmw_resource *vmw_cotable_alloc(struct vmw_private *dev_priv,
573 u32 type) 573 u32 type)
574{ 574{
575 struct vmw_cotable *vcotbl; 575 struct vmw_cotable *vcotbl;
576 struct ttm_operation_ctx ttm_opt_ctx = {
577 .interruptible = true,
578 .no_wait_gpu = false
579 };
576 int ret; 580 int ret;
577 u32 num_entries; 581 u32 num_entries;
578 582
@@ -580,7 +584,7 @@ struct vmw_resource *vmw_cotable_alloc(struct vmw_private *dev_priv,
580 cotable_acc_size = ttm_round_pot(sizeof(struct vmw_cotable)); 584 cotable_acc_size = ttm_round_pot(sizeof(struct vmw_cotable));
581 585
582 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), 586 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv),
583 cotable_acc_size, false, true); 587 cotable_acc_size, &ttm_opt_ctx);
584 if (unlikely(ret)) 588 if (unlikely(ret))
585 return ERR_PTR(ret); 589 return ERR_PTR(ret);
586 590
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
index d6b1c509ae01..6c5c75cf5e6c 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fence.c
@@ -588,6 +588,10 @@ int vmw_user_fence_create(struct drm_file *file_priv,
588 struct vmw_user_fence *ufence; 588 struct vmw_user_fence *ufence;
589 struct vmw_fence_obj *tmp; 589 struct vmw_fence_obj *tmp;
590 struct ttm_mem_global *mem_glob = vmw_mem_glob(fman->dev_priv); 590 struct ttm_mem_global *mem_glob = vmw_mem_glob(fman->dev_priv);
591 struct ttm_operation_ctx ctx = {
592 .interruptible = false,
593 .no_wait_gpu = false
594 };
591 int ret; 595 int ret;
592 596
593 /* 597 /*
@@ -596,7 +600,7 @@ int vmw_user_fence_create(struct drm_file *file_priv,
596 */ 600 */
597 601
598 ret = ttm_mem_global_alloc(mem_glob, fman->user_fence_size, 602 ret = ttm_mem_global_alloc(mem_glob, fman->user_fence_size,
599 false, false); 603 &ctx);
600 if (unlikely(ret != 0)) 604 if (unlikely(ret != 0))
601 return ret; 605 return ret;
602 606
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
index 004e18b8832c..73b8e9a16368 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_shader.c
@@ -607,6 +607,10 @@ int vmw_dx_shader_add(struct vmw_cmdbuf_res_manager *man,
607 struct vmw_dx_shader *shader; 607 struct vmw_dx_shader *shader;
608 struct vmw_resource *res; 608 struct vmw_resource *res;
609 struct vmw_private *dev_priv = ctx->dev_priv; 609 struct vmw_private *dev_priv = ctx->dev_priv;
610 struct ttm_operation_ctx ttm_opt_ctx = {
611 .interruptible = true,
612 .no_wait_gpu = false
613 };
610 int ret; 614 int ret;
611 615
612 if (!vmw_shader_dx_size) 616 if (!vmw_shader_dx_size)
@@ -616,7 +620,7 @@ int vmw_dx_shader_add(struct vmw_cmdbuf_res_manager *man,
616 return -EINVAL; 620 return -EINVAL;
617 621
618 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), vmw_shader_dx_size, 622 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), vmw_shader_dx_size,
619 false, true); 623 &ttm_opt_ctx);
620 if (ret) { 624 if (ret) {
621 if (ret != -ERESTARTSYS) 625 if (ret != -ERESTARTSYS)
622 DRM_ERROR("Out of graphics memory for shader " 626 DRM_ERROR("Out of graphics memory for shader "
@@ -730,6 +734,10 @@ static int vmw_user_shader_alloc(struct vmw_private *dev_priv,
730{ 734{
731 struct vmw_user_shader *ushader; 735 struct vmw_user_shader *ushader;
732 struct vmw_resource *res, *tmp; 736 struct vmw_resource *res, *tmp;
737 struct ttm_operation_ctx ctx = {
738 .interruptible = true,
739 .no_wait_gpu = false
740 };
733 int ret; 741 int ret;
734 742
735 /* 743 /*
@@ -742,7 +750,7 @@ static int vmw_user_shader_alloc(struct vmw_private *dev_priv,
742 750
743 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), 751 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv),
744 vmw_user_shader_size, 752 vmw_user_shader_size,
745 false, true); 753 &ctx);
746 if (unlikely(ret != 0)) { 754 if (unlikely(ret != 0)) {
747 if (ret != -ERESTARTSYS) 755 if (ret != -ERESTARTSYS)
748 DRM_ERROR("Out of graphics memory for shader " 756 DRM_ERROR("Out of graphics memory for shader "
@@ -800,6 +808,10 @@ static struct vmw_resource *vmw_shader_alloc(struct vmw_private *dev_priv,
800{ 808{
801 struct vmw_shader *shader; 809 struct vmw_shader *shader;
802 struct vmw_resource *res; 810 struct vmw_resource *res;
811 struct ttm_operation_ctx ctx = {
812 .interruptible = true,
813 .no_wait_gpu = false
814 };
803 int ret; 815 int ret;
804 816
805 /* 817 /*
@@ -812,7 +824,7 @@ static struct vmw_resource *vmw_shader_alloc(struct vmw_private *dev_priv,
812 824
813 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), 825 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv),
814 vmw_shader_size, 826 vmw_shader_size,
815 false, true); 827 &ctx);
816 if (unlikely(ret != 0)) { 828 if (unlikely(ret != 0)) {
817 if (ret != -ERESTARTSYS) 829 if (ret != -ERESTARTSYS)
818 DRM_ERROR("Out of graphics memory for shader " 830 DRM_ERROR("Out of graphics memory for shader "
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c
index 051d3b39b0ea..a0cb310665cc 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_simple_resource.c
@@ -149,6 +149,10 @@ vmw_simple_resource_create_ioctl(struct drm_device *dev, void *data,
149 struct vmw_resource *res; 149 struct vmw_resource *res;
150 struct vmw_resource *tmp; 150 struct vmw_resource *tmp;
151 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 151 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
152 struct ttm_operation_ctx ctx = {
153 .interruptible = true,
154 .no_wait_gpu = false
155 };
152 size_t alloc_size; 156 size_t alloc_size;
153 size_t account_size; 157 size_t account_size;
154 int ret; 158 int ret;
@@ -162,7 +166,7 @@ vmw_simple_resource_create_ioctl(struct drm_device *dev, void *data,
162 return ret; 166 return ret;
163 167
164 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), account_size, 168 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), account_size,
165 false, true); 169 &ctx);
166 ttm_read_unlock(&dev_priv->reservation_sem); 170 ttm_read_unlock(&dev_priv->reservation_sem);
167 if (ret) { 171 if (ret) {
168 if (ret != -ERESTARTSYS) 172 if (ret != -ERESTARTSYS)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
index 5a73eebd0f35..d3573c37c436 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_so.c
@@ -329,6 +329,10 @@ int vmw_view_add(struct vmw_cmdbuf_res_manager *man,
329 struct vmw_private *dev_priv = ctx->dev_priv; 329 struct vmw_private *dev_priv = ctx->dev_priv;
330 struct vmw_resource *res; 330 struct vmw_resource *res;
331 struct vmw_view *view; 331 struct vmw_view *view;
332 struct ttm_operation_ctx ttm_opt_ctx = {
333 .interruptible = true,
334 .no_wait_gpu = false
335 };
332 size_t size; 336 size_t size;
333 int ret; 337 int ret;
334 338
@@ -345,7 +349,7 @@ int vmw_view_add(struct vmw_cmdbuf_res_manager *man,
345 349
346 size = offsetof(struct vmw_view, cmd) + cmd_size; 350 size = offsetof(struct vmw_view, cmd) + cmd_size;
347 351
348 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), size, false, true); 352 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), size, &ttm_opt_ctx);
349 if (ret) { 353 if (ret) {
350 if (ret != -ERESTARTSYS) 354 if (ret != -ERESTARTSYS)
351 DRM_ERROR("Out of graphics memory for view" 355 DRM_ERROR("Out of graphics memory for view"
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 6ac094ee8983..db1bb166845e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -700,6 +700,10 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
700 struct drm_vmw_surface_create_req *req = &arg->req; 700 struct drm_vmw_surface_create_req *req = &arg->req;
701 struct drm_vmw_surface_arg *rep = &arg->rep; 701 struct drm_vmw_surface_arg *rep = &arg->rep;
702 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; 702 struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile;
703 struct ttm_operation_ctx ctx = {
704 .interruptible = true,
705 .no_wait_gpu = false
706 };
703 int ret; 707 int ret;
704 int i, j; 708 int i, j;
705 uint32_t cur_bo_offset; 709 uint32_t cur_bo_offset;
@@ -741,7 +745,7 @@ int vmw_surface_define_ioctl(struct drm_device *dev, void *data,
741 return ret; 745 return ret;
742 746
743 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), 747 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv),
744 size, false, true); 748 size, &ctx);
745 if (unlikely(ret != 0)) { 749 if (unlikely(ret != 0)) {
746 if (ret != -ERESTARTSYS) 750 if (ret != -ERESTARTSYS)
747 DRM_ERROR("Out of graphics memory for surface" 751 DRM_ERROR("Out of graphics memory for surface"
@@ -1479,6 +1483,10 @@ int vmw_surface_gb_priv_define(struct drm_device *dev,
1479{ 1483{
1480 struct vmw_private *dev_priv = vmw_priv(dev); 1484 struct vmw_private *dev_priv = vmw_priv(dev);
1481 struct vmw_user_surface *user_srf; 1485 struct vmw_user_surface *user_srf;
1486 struct ttm_operation_ctx ctx = {
1487 .interruptible = true,
1488 .no_wait_gpu = false
1489 };
1482 struct vmw_surface *srf; 1490 struct vmw_surface *srf;
1483 int ret; 1491 int ret;
1484 u32 num_layers; 1492 u32 num_layers;
@@ -1525,7 +1533,7 @@ int vmw_surface_gb_priv_define(struct drm_device *dev,
1525 return ret; 1533 return ret;
1526 1534
1527 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv), 1535 ret = ttm_mem_global_alloc(vmw_mem_glob(dev_priv),
1528 user_accounting_size, false, true); 1536 user_accounting_size, &ctx);
1529 if (unlikely(ret != 0)) { 1537 if (unlikely(ret != 0)) {
1530 if (ret != -ERESTARTSYS) 1538 if (ret != -ERESTARTSYS)
1531 DRM_ERROR("Out of graphics memory for surface" 1539 DRM_ERROR("Out of graphics memory for surface"
diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
index 85f3ad6f1348..755c107817da 100644
--- a/include/drm/ttm/ttm_memory.h
+++ b/include/drm/ttm/ttm_memory.h
@@ -35,6 +35,7 @@
35#include <linux/errno.h> 35#include <linux/errno.h>
36#include <linux/kobject.h> 36#include <linux/kobject.h>
37#include <linux/mm.h> 37#include <linux/mm.h>
38#include "ttm_bo_api.h"
38 39
39/** 40/**
40 * struct ttm_mem_global - Global memory accounting structure. 41 * struct ttm_mem_global - Global memory accounting structure.
@@ -79,7 +80,7 @@ struct ttm_mem_global {
79extern int ttm_mem_global_init(struct ttm_mem_global *glob); 80extern int ttm_mem_global_init(struct ttm_mem_global *glob);
80extern void ttm_mem_global_release(struct ttm_mem_global *glob); 81extern void ttm_mem_global_release(struct ttm_mem_global *glob);
81extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory, 82extern int ttm_mem_global_alloc(struct ttm_mem_global *glob, uint64_t memory,
82 bool no_wait, bool interruptible); 83 struct ttm_operation_ctx *ctx);
83extern void ttm_mem_global_free(struct ttm_mem_global *glob, 84extern void ttm_mem_global_free(struct ttm_mem_global *glob,
84 uint64_t amount); 85 uint64_t amount);
85extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob, 86extern int ttm_mem_global_alloc_page(struct ttm_mem_global *glob,