Rev 4569 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4569 | Rev 5078 | ||
---|---|---|---|
Line 120... | Line 120... | ||
120 | list_del_init(&res->lru_head); |
120 | list_del_init(&res->lru_head); |
121 | write_unlock(&dev_priv->resource_lock); |
121 | write_unlock(&dev_priv->resource_lock); |
122 | if (res->backup) { |
122 | if (res->backup) { |
123 | struct ttm_buffer_object *bo = &res->backup->base; |
123 | struct ttm_buffer_object *bo = &res->backup->base; |
Line 124... | Line 124... | ||
124 | 124 | ||
125 | ttm_bo_reserve(bo, false, false, false, 0); |
125 | ttm_bo_reserve(bo, false, false, false, NULL); |
126 | if (!list_empty(&res->mob_head) && |
126 | if (!list_empty(&res->mob_head) && |
127 | res->func->unbind != NULL) { |
127 | res->func->unbind != NULL) { |
Line 128... | Line 128... | ||
128 | struct ttm_validate_buffer val_buf; |
128 | struct ttm_validate_buffer val_buf; |
Line 134... | Line 134... | ||
134 | list_del_init(&res->mob_head); |
134 | list_del_init(&res->mob_head); |
135 | ttm_bo_unreserve(bo); |
135 | ttm_bo_unreserve(bo); |
136 | vmw_dmabuf_unreference(&res->backup); |
136 | vmw_dmabuf_unreference(&res->backup); |
137 | } |
137 | } |
Line 138... | Line 138... | ||
138 | 138 | ||
139 | if (likely(res->hw_destroy != NULL)) |
139 | if (likely(res->hw_destroy != NULL)) { |
- | 140 | res->hw_destroy(res); |
|
- | 141 | mutex_lock(&dev_priv->binding_mutex); |
|
- | 142 | vmw_context_binding_res_list_kill(&res->binding_head); |
|
- | 143 | mutex_unlock(&dev_priv->binding_mutex); |
|
Line 140... | Line 144... | ||
140 | res->hw_destroy(res); |
144 | } |
141 | 145 | ||
142 | id = res->id; |
146 | id = res->id; |
143 | if (res->res_free != NULL) |
147 | if (res->res_free != NULL) |
Line 416... | Line 420... | ||
416 | memset(vmw_bo, 0, sizeof(*vmw_bo)); |
420 | memset(vmw_bo, 0, sizeof(*vmw_bo)); |
Line 417... | Line 421... | ||
417 | 421 | ||
Line 418... | Line 422... | ||
418 | INIT_LIST_HEAD(&vmw_bo->res_list); |
422 | INIT_LIST_HEAD(&vmw_bo->res_list); |
419 | - | ||
420 | ret = ttm_bo_init(bdev, &vmw_bo->base, size, |
423 | |
421 | (user) ? ttm_bo_type_device : |
424 | ret = ttm_bo_init(bdev, &vmw_bo->base, size, |
422 | ttm_bo_type_kernel, placement, |
425 | ttm_bo_type_device, placement, |
423 | 0, interruptible, |
426 | 0, interruptible, |
424 | NULL, acc_size, NULL, bo_free); |
427 | NULL, acc_size, NULL, bo_free); |
Line 530... | Line 533... | ||
530 | 533 | ||
531 | if (unlikely(bo->destroy != vmw_user_dmabuf_destroy)) |
534 | if (unlikely(bo->destroy != vmw_user_dmabuf_destroy)) |
Line 532... | Line 535... | ||
532 | return -EPERM; |
535 | return -EPERM; |
- | 536 | ||
533 | 537 | vmw_user_bo = vmw_user_dma_buffer(bo); |
|
- | 538 | ||
- | 539 | /* Check that the caller has opened the object. */ |
|
- | 540 | if (likely(ttm_ref_object_exists(tfile, &vmw_user_bo->prime.base))) |
|
534 | vmw_user_bo = vmw_user_dma_buffer(bo); |
541 | return 0; |
- | 542 | ||
535 | return (vmw_user_bo->prime.base.tfile == tfile || |
543 | DRM_ERROR("Could not grant buffer access.\n"); |
Line 536... | Line 544... | ||
536 | vmw_user_bo->prime.base.shareable) ? 0 : -EPERM; |
544 | return -EPERM; |
537 | } |
545 | } |
538 | 546 | ||
Line 551... | Line 559... | ||
551 | struct ttm_object_file *tfile, |
559 | struct ttm_object_file *tfile, |
552 | uint32_t flags) |
560 | uint32_t flags) |
553 | { |
561 | { |
554 | struct ttm_buffer_object *bo = &user_bo->dma.base; |
562 | struct ttm_buffer_object *bo = &user_bo->dma.base; |
555 | bool existed; |
563 | bool existed; |
556 | int ret=0; |
564 | int ret; |
Line 557... | Line 565... | ||
557 | 565 | ||
558 | if (flags & drm_vmw_synccpu_allow_cs) { |
566 | if (flags & drm_vmw_synccpu_allow_cs) { |
Line 559... | Line 567... | ||
559 | struct ttm_bo_device *bdev = bo->bdev; |
567 | struct ttm_bo_device *bdev = bo->bdev; |
Line 669... | Line 677... | ||
669 | (union drm_vmw_alloc_dmabuf_arg *)data; |
677 | (union drm_vmw_alloc_dmabuf_arg *)data; |
670 | struct drm_vmw_alloc_dmabuf_req *req = &arg->req; |
678 | struct drm_vmw_alloc_dmabuf_req *req = &arg->req; |
671 | struct drm_vmw_dmabuf_rep *rep = &arg->rep; |
679 | struct drm_vmw_dmabuf_rep *rep = &arg->rep; |
672 | struct vmw_dma_buffer *dma_buf; |
680 | struct vmw_dma_buffer *dma_buf; |
673 | uint32_t handle; |
681 | uint32_t handle; |
674 | struct vmw_master *vmaster = vmw_master(file_priv->master); |
- | |
675 | int ret; |
682 | int ret; |
Line 676... | Line 683... | ||
676 | 683 | ||
677 | ret = ttm_read_lock(&vmaster->lock, true); |
684 | ret = ttm_read_lock(&dev_priv->reservation_sem, true); |
678 | if (unlikely(ret != 0)) |
685 | if (unlikely(ret != 0)) |
Line 679... | Line 686... | ||
679 | return ret; |
686 | return ret; |
680 | 687 | ||
Line 689... | Line 696... | ||
689 | rep->cur_gmr_offset = 0; |
696 | rep->cur_gmr_offset = 0; |
Line 690... | Line 697... | ||
690 | 697 | ||
Line 691... | Line 698... | ||
691 | vmw_dmabuf_unreference(&dma_buf); |
698 | vmw_dmabuf_unreference(&dma_buf); |
692 | 699 | ||
Line 693... | Line 700... | ||
693 | out_no_dmabuf: |
700 | out_no_dmabuf: |
694 | ttm_read_unlock(&vmaster->lock); |
701 | ttm_read_unlock(&dev_priv->reservation_sem); |
Line 695... | Line 702... | ||
695 | 702 | ||
Line 804... | Line 811... | ||
804 | { |
811 | { |
805 | struct vmw_user_stream *stream = |
812 | struct vmw_user_stream *stream = |
806 | container_of(res, struct vmw_user_stream, stream.res); |
813 | container_of(res, struct vmw_user_stream, stream.res); |
807 | struct vmw_private *dev_priv = res->dev_priv; |
814 | struct vmw_private *dev_priv = res->dev_priv; |
Line 808... | Line 815... | ||
808 | 815 | ||
809 | // ttm_base_object_kfree(stream, base); |
816 | ttm_base_object_kfree(stream, base); |
810 | ttm_mem_global_free(vmw_mem_glob(dev_priv), |
817 | ttm_mem_global_free(vmw_mem_glob(dev_priv), |
811 | vmw_user_stream_size); |
818 | vmw_user_stream_size); |
Line 812... | Line 819... | ||
812 | } |
819 | } |
Line 868... | Line 875... | ||
868 | struct vmw_user_stream *stream; |
875 | struct vmw_user_stream *stream; |
869 | struct vmw_resource *res; |
876 | struct vmw_resource *res; |
870 | struct vmw_resource *tmp; |
877 | struct vmw_resource *tmp; |
871 | struct drm_vmw_stream_arg *arg = (struct drm_vmw_stream_arg *)data; |
878 | struct drm_vmw_stream_arg *arg = (struct drm_vmw_stream_arg *)data; |
872 | struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; |
879 | struct ttm_object_file *tfile = vmw_fpriv(file_priv)->tfile; |
873 | struct vmw_master *vmaster = vmw_master(file_priv->master); |
- | |
874 | int ret; |
880 | int ret; |
Line 875... | Line 881... | ||
875 | 881 | ||
876 | /* |
882 | /* |
877 | * Approximate idr memory usage with 128 bytes. It will be limited |
883 | * Approximate idr memory usage with 128 bytes. It will be limited |
878 | * by maximum number_of streams anyway? |
884 | * by maximum number_of streams anyway? |
Line 879... | Line 885... | ||
879 | */ |
885 | */ |
880 | 886 | ||
Line 881... | Line 887... | ||
881 | if (unlikely(vmw_user_stream_size == 0)) |
887 | if (unlikely(vmw_user_stream_size == 0)) |
882 | vmw_user_stream_size = ttm_round_pot(sizeof(*stream)) + 128; |
888 | vmw_user_stream_size = ttm_round_pot(sizeof(*stream)) + 128; |
883 | 889 | ||
Line 884... | Line 890... | ||
884 | ret = ttm_read_lock(&vmaster->lock, true); |
890 | ret = ttm_read_lock(&dev_priv->reservation_sem, true); |
885 | if (unlikely(ret != 0)) |
891 | if (unlikely(ret != 0)) |
Line 927... | Line 933... | ||
927 | 933 | ||
928 | arg->stream_id = res->id; |
934 | arg->stream_id = res->id; |
929 | out_err: |
935 | out_err: |
930 | vmw_resource_unreference(&res); |
936 | vmw_resource_unreference(&res); |
931 | out_unlock: |
937 | out_unlock: |
932 | ttm_read_unlock(&vmaster->lock); |
938 | ttm_read_unlock(&dev_priv->reservation_sem); |
933 | return ret; |
939 | return ret; |
934 | } |
940 | } |
Line 935... | Line 941... | ||
935 | #endif |
941 | #endif |
Line 977... | Line 983... | ||
977 | int ret; |
983 | int ret; |
Line 978... | Line 984... | ||
978 | 984 | ||
979 | args->pitch = args->width * ((args->bpp + 7) / 8); |
985 | args->pitch = args->width * ((args->bpp + 7) / 8); |
Line 980... | Line 986... | ||
980 | args->size = args->pitch * args->height; |
986 | args->size = args->pitch * args->height; |
981 | 987 | ||
982 | ret = ttm_read_lock(&vmaster->lock, true); |
988 | ret = ttm_read_lock(&dev_priv->reservation_sem, true); |
Line 983... | Line 989... | ||
983 | if (unlikely(ret != 0)) |
989 | if (unlikely(ret != 0)) |
984 | return ret; |
990 | return ret; |
Line 989... | Line 995... | ||
989 | if (unlikely(ret != 0)) |
995 | if (unlikely(ret != 0)) |
990 | goto out_no_dmabuf; |
996 | goto out_no_dmabuf; |
Line 991... | Line 997... | ||
991 | 997 | ||
992 | vmw_dmabuf_unreference(&dma_buf); |
998 | vmw_dmabuf_unreference(&dma_buf); |
993 | out_no_dmabuf: |
999 | out_no_dmabuf: |
994 | ttm_read_unlock(&vmaster->lock); |
1000 | ttm_read_unlock(&dev_priv->reservation_sem); |
995 | return ret; |
1001 | return ret; |
996 | } |
1002 | } |
Line 997... | Line 1003... | ||
997 | #endif |
1003 | #endif |