diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2016-10-10 13:44:00 -0400 |
---|---|---|
committer | Sinclair Yeh <syeh@vmware.com> | 2016-10-10 14:15:02 -0400 |
commit | e7a45284ba1abcea591f7c01b05227b6698b596c (patch) | |
tree | 5bb4f977a949f3362ab4ef3b5b5a32f9a99b4454 | |
parent | 1f982e4e390b31d6c44fb8bf03e3462ab33b8244 (diff) |
drm/vmwgfx: Allow resource relocations on byte boundaries
So far, resource allocations have only been allowed on 4-byte boundaries.
As commands get packed tighter, allow them on byte boundaries.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Signed-off-by: Sinclair Yeh <syeh@vmware.com>
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 41 |
1 files changed, 26 insertions, 15 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 0243acc8845f..b915f621187f 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | |||
@@ -39,7 +39,7 @@ | |||
39 | * | 39 | * |
40 | * @head: List head for the software context's relocation list. | 40 | * @head: List head for the software context's relocation list. |
41 | * @res: Non-ref-counted pointer to the resource. | 41 | * @res: Non-ref-counted pointer to the resource. |
42 | * @offset: Offset of 4 byte entries into the command buffer where the | 42 | * @offset: Offset of single byte entries into the command buffer where the |
43 | * id that needs fixup is located. | 43 | * id that needs fixup is located. |
44 | */ | 44 | */ |
45 | struct vmw_resource_relocation { | 45 | struct vmw_resource_relocation { |
@@ -109,7 +109,18 @@ static int vmw_bo_to_validate_list(struct vmw_sw_context *sw_context, | |||
109 | struct vmw_dma_buffer *vbo, | 109 | struct vmw_dma_buffer *vbo, |
110 | bool validate_as_mob, | 110 | bool validate_as_mob, |
111 | uint32_t *p_val_node); | 111 | uint32_t *p_val_node); |
112 | 112 | /** | |
113 | * vmw_ptr_diff - Compute the offset from a to b in bytes | ||
114 | * | ||
115 | * @a: A starting pointer. | ||
116 | * @b: A pointer offset in the same address space. | ||
117 | * | ||
118 | * Returns: The offset in bytes between the two pointers. | ||
119 | */ | ||
120 | static size_t vmw_ptr_diff(void *a, void *b) | ||
121 | { | ||
122 | return (unsigned long) b - (unsigned long) a; | ||
123 | } | ||
113 | 124 | ||
114 | /** | 125 | /** |
115 | * vmw_resources_unreserve - unreserve resources previously reserved for | 126 | * vmw_resources_unreserve - unreserve resources previously reserved for |
@@ -409,7 +420,7 @@ static int vmw_resource_context_res_add(struct vmw_private *dev_priv, | |||
409 | * @list: Pointer to head of relocation list. | 420 | * @list: Pointer to head of relocation list. |
410 | * @res: The resource. | 421 | * @res: The resource. |
411 | * @offset: Offset into the command buffer currently being parsed where the | 422 | * @offset: Offset into the command buffer currently being parsed where the |
412 | * id that needs fixup is located. Granularity is 4 bytes. | 423 | * id that needs fixup is located. Granularity is one byte. |
413 | */ | 424 | */ |
414 | static int vmw_resource_relocation_add(struct list_head *list, | 425 | static int vmw_resource_relocation_add(struct list_head *list, |
415 | const struct vmw_resource *res, | 426 | const struct vmw_resource *res, |
@@ -460,10 +471,11 @@ static void vmw_resource_relocations_apply(uint32_t *cb, | |||
460 | struct vmw_resource_relocation *rel; | 471 | struct vmw_resource_relocation *rel; |
461 | 472 | ||
462 | list_for_each_entry(rel, list, head) { | 473 | list_for_each_entry(rel, list, head) { |
474 | u32 *addr = (u32 *)((unsigned long) cb + rel->offset); | ||
463 | if (likely(rel->res != NULL)) | 475 | if (likely(rel->res != NULL)) |
464 | cb[rel->offset] = rel->res->id; | 476 | *addr = rel->res->id; |
465 | else | 477 | else |
466 | cb[rel->offset] = SVGA_3D_CMD_NOP; | 478 | *addr = SVGA_3D_CMD_NOP; |
467 | } | 479 | } |
468 | } | 480 | } |
469 | 481 | ||
@@ -655,7 +667,8 @@ static int vmw_cmd_res_reloc_add(struct vmw_private *dev_priv, | |||
655 | *p_val = NULL; | 667 | *p_val = NULL; |
656 | ret = vmw_resource_relocation_add(&sw_context->res_relocations, | 668 | ret = vmw_resource_relocation_add(&sw_context->res_relocations, |
657 | res, | 669 | res, |
658 | id_loc - sw_context->buf_start); | 670 | vmw_ptr_diff(sw_context->buf_start, |
671 | id_loc)); | ||
659 | if (unlikely(ret != 0)) | 672 | if (unlikely(ret != 0)) |
660 | return ret; | 673 | return ret; |
661 | 674 | ||
@@ -721,7 +734,7 @@ vmw_cmd_res_check(struct vmw_private *dev_priv, | |||
721 | 734 | ||
722 | return vmw_resource_relocation_add | 735 | return vmw_resource_relocation_add |
723 | (&sw_context->res_relocations, res, | 736 | (&sw_context->res_relocations, res, |
724 | id_loc - sw_context->buf_start); | 737 | vmw_ptr_diff(sw_context->buf_start, id_loc)); |
725 | } | 738 | } |
726 | 739 | ||
727 | ret = vmw_user_resource_lookup_handle(dev_priv, | 740 | ret = vmw_user_resource_lookup_handle(dev_priv, |
@@ -2143,10 +2156,9 @@ static int vmw_cmd_shader_define(struct vmw_private *dev_priv, | |||
2143 | return ret; | 2156 | return ret; |
2144 | 2157 | ||
2145 | return vmw_resource_relocation_add(&sw_context->res_relocations, | 2158 | return vmw_resource_relocation_add(&sw_context->res_relocations, |
2146 | NULL, &cmd->header.id - | 2159 | NULL, |
2147 | sw_context->buf_start); | 2160 | vmw_ptr_diff(sw_context->buf_start, |
2148 | 2161 | &cmd->header.id)); | |
2149 | return 0; | ||
2150 | } | 2162 | } |
2151 | 2163 | ||
2152 | /** | 2164 | /** |
@@ -2188,10 +2200,9 @@ static int vmw_cmd_shader_destroy(struct vmw_private *dev_priv, | |||
2188 | return ret; | 2200 | return ret; |
2189 | 2201 | ||
2190 | return vmw_resource_relocation_add(&sw_context->res_relocations, | 2202 | return vmw_resource_relocation_add(&sw_context->res_relocations, |
2191 | NULL, &cmd->header.id - | 2203 | NULL, |
2192 | sw_context->buf_start); | 2204 | vmw_ptr_diff(sw_context->buf_start, |
2193 | 2205 | &cmd->header.id)); | |
2194 | return 0; | ||
2195 | } | 2206 | } |
2196 | 2207 | ||
2197 | /** | 2208 | /** |