diff options
author | Sami Kiminki <skiminki@nvidia.com> | 2017-11-13 07:32:29 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-11-15 16:26:06 -0500 |
commit | 1f28b429a2fb73a260e0c9fe112dbbc6981ef4b4 (patch) | |
tree | 1f408ffccb9b6e45f65119d75d144b34592940b6 | |
parent | 23396c58db7e9d9c974bb3334a159aad960afc3e (diff) |
gpu: nvgpu: Always do full buffer compbits allocs
Remove parameter 'lines' from gk20a_alloc_or_get_comptags() and
nvgpu_ctag_buffer_info. We're always doing full buffer allocs
anyways. This simplifies the code a bit.
Bug 1902982
Change-Id: Iacfc9cdba8cb75b31a7d44b175660252e09d605d
Signed-off-by: Sami Kiminki <skiminki@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1597131
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/comptags.c | 18 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/vm.c | 18 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/comptags.h | 1 |
3 files changed, 17 insertions, 20 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/comptags.c b/drivers/gpu/nvgpu/common/linux/comptags.c index 4a96e07b..7d095793 100644 --- a/drivers/gpu/nvgpu/common/linux/comptags.c +++ b/drivers/gpu/nvgpu/common/linux/comptags.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include <nvgpu/linux/vm.h> | 21 | #include <nvgpu/linux/vm.h> |
22 | 22 | ||
23 | #include "gk20a/gk20a.h" | ||
23 | #include "dmabuf.h" | 24 | #include "dmabuf.h" |
24 | 25 | ||
25 | void gk20a_get_comptags(struct nvgpu_os_buffer *buf, | 26 | void gk20a_get_comptags(struct nvgpu_os_buffer *buf, |
@@ -42,26 +43,33 @@ void gk20a_get_comptags(struct nvgpu_os_buffer *buf, | |||
42 | int gk20a_alloc_or_get_comptags(struct gk20a *g, | 43 | int gk20a_alloc_or_get_comptags(struct gk20a *g, |
43 | struct nvgpu_os_buffer *buf, | 44 | struct nvgpu_os_buffer *buf, |
44 | struct gk20a_comptag_allocator *allocator, | 45 | struct gk20a_comptag_allocator *allocator, |
45 | u32 lines, | ||
46 | struct gk20a_comptags *comptags) | 46 | struct gk20a_comptags *comptags) |
47 | { | 47 | { |
48 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, | 48 | struct gk20a_dmabuf_priv *priv = dma_buf_get_drvdata(buf->dmabuf, |
49 | buf->dev); | 49 | buf->dev); |
50 | u32 offset; | 50 | u32 offset; |
51 | int err; | 51 | int err; |
52 | unsigned int ctag_granularity; | ||
53 | u32 lines; | ||
52 | 54 | ||
53 | if (!priv) | 55 | if (!priv) |
54 | return -ENOSYS; | 56 | return -ENOSYS; |
55 | 57 | ||
56 | if (!lines) | ||
57 | return -EINVAL; | ||
58 | |||
59 | if (priv->comptags.allocated) { | 58 | if (priv->comptags.allocated) { |
60 | /* already allocated */ | 59 | /* |
60 | * already allocated | ||
61 | */ | ||
61 | *comptags = priv->comptags; | 62 | *comptags = priv->comptags; |
62 | return 0; | 63 | return 0; |
63 | } | 64 | } |
64 | 65 | ||
66 | ctag_granularity = g->ops.fb.compression_page_size(g); | ||
67 | lines = DIV_ROUND_UP_ULL(buf->dmabuf->size, ctag_granularity); | ||
68 | |||
69 | /* 0-sized buffer? Shouldn't occur, but let's check anyways. */ | ||
70 | if (lines < 1) | ||
71 | return -EINVAL; | ||
72 | |||
65 | /* store the allocator so we can use it when we free the ctags */ | 73 | /* store the allocator so we can use it when we free the ctags */ |
66 | priv->comptag_allocator = allocator; | 74 | priv->comptag_allocator = allocator; |
67 | err = gk20a_comptaglines_alloc(allocator, &offset, lines); | 75 | err = gk20a_comptaglines_alloc(allocator, &offset, lines); |
diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index 7a451956..c3f6b79d 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c | |||
@@ -774,7 +774,8 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, | |||
774 | 774 | ||
775 | binfo.flags = flags; | 775 | binfo.flags = flags; |
776 | binfo.size = nvgpu_os_buf_get_size(os_buf); | 776 | binfo.size = nvgpu_os_buf_get_size(os_buf); |
777 | binfo.compr_kind = compr_kind; | 777 | binfo.compr_kind = (vm->enable_ctag && compr_kind != NV_KIND_INVALID ? |
778 | compr_kind : NV_KIND_INVALID); | ||
778 | binfo.incompr_kind = incompr_kind; | 779 | binfo.incompr_kind = incompr_kind; |
779 | 780 | ||
780 | if (compr_kind != NV_KIND_INVALID) | 781 | if (compr_kind != NV_KIND_INVALID) |
@@ -847,13 +848,7 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, | |||
847 | goto clean_up; | 848 | goto clean_up; |
848 | } | 849 | } |
849 | 850 | ||
850 | /* | 851 | if (binfo.compr_kind != NV_KIND_INVALID) { |
851 | * bar1 and pmu VMs don't need ctags. | ||
852 | */ | ||
853 | if (!vm->enable_ctag) | ||
854 | binfo.ctag_lines = 0; | ||
855 | |||
856 | if (binfo.ctag_lines) { | ||
857 | struct gk20a_comptags comptags = { 0 }; | 852 | struct gk20a_comptags comptags = { 0 }; |
858 | 853 | ||
859 | /* | 854 | /* |
@@ -861,7 +856,7 @@ struct nvgpu_mapped_buf *nvgpu_vm_map(struct vm_gk20a *vm, | |||
861 | */ | 856 | */ |
862 | err = gk20a_alloc_or_get_comptags(g, os_buf, | 857 | err = gk20a_alloc_or_get_comptags(g, os_buf, |
863 | &g->gr.comp_tags, | 858 | &g->gr.comp_tags, |
864 | binfo.ctag_lines, &comptags); | 859 | &comptags); |
865 | if (err) { | 860 | if (err) { |
866 | /* | 861 | /* |
867 | * This is an irrecoverable failure and we need to | 862 | * This is an irrecoverable failure and we need to |
@@ -1116,7 +1111,6 @@ static int nvgpu_vm_compute_compression(struct vm_gk20a *vm, | |||
1116 | { | 1111 | { |
1117 | bool kind_compressible = (binfo->compr_kind != NV_KIND_INVALID); | 1112 | bool kind_compressible = (binfo->compr_kind != NV_KIND_INVALID); |
1118 | struct gk20a *g = gk20a_from_vm(vm); | 1113 | struct gk20a *g = gk20a_from_vm(vm); |
1119 | int ctag_granularity = g->ops.fb.compression_page_size(g); | ||
1120 | 1114 | ||
1121 | if (kind_compressible && | 1115 | if (kind_compressible && |
1122 | vm->gmmu_page_sizes[binfo->pgsz_idx] < | 1116 | vm->gmmu_page_sizes[binfo->pgsz_idx] < |
@@ -1138,9 +1132,5 @@ static int nvgpu_vm_compute_compression(struct vm_gk20a *vm, | |||
1138 | } | 1132 | } |
1139 | } | 1133 | } |
1140 | 1134 | ||
1141 | if (kind_compressible) | ||
1142 | binfo->ctag_lines = DIV_ROUND_UP_ULL(binfo->size, | ||
1143 | ctag_granularity); | ||
1144 | |||
1145 | return 0; | 1135 | return 0; |
1146 | } | 1136 | } |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/comptags.h b/drivers/gpu/nvgpu/include/nvgpu/comptags.h index 41a918b5..99e2d657 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/comptags.h +++ b/drivers/gpu/nvgpu/include/nvgpu/comptags.h | |||
@@ -71,7 +71,6 @@ void gk20a_comptaglines_free(struct gk20a_comptag_allocator *allocator, | |||
71 | int gk20a_alloc_or_get_comptags(struct gk20a *g, | 71 | int gk20a_alloc_or_get_comptags(struct gk20a *g, |
72 | struct nvgpu_os_buffer *buf, | 72 | struct nvgpu_os_buffer *buf, |
73 | struct gk20a_comptag_allocator *allocator, | 73 | struct gk20a_comptag_allocator *allocator, |
74 | u32 lines, | ||
75 | struct gk20a_comptags *comptags); | 74 | struct gk20a_comptags *comptags); |
76 | void gk20a_get_comptags(struct nvgpu_os_buffer *buf, | 75 | void gk20a_get_comptags(struct nvgpu_os_buffer *buf, |
77 | struct gk20a_comptags *comptags); | 76 | struct gk20a_comptags *comptags); |