diff options
| author | Thomas Hellstrom <thellstrom@vmware.com> | 2014-06-09 06:39:22 -0400 |
|---|---|---|
| committer | Thomas Hellstrom <thellstrom@vmware.com> | 2014-07-04 06:12:09 -0400 |
| commit | 18e4a4669c5023eb1157f2a3f1bf6ca2b8535572 (patch) | |
| tree | 3d3e32d5eee38490a1660f8dfc4f62c7b8e3fd01 | |
| parent | bc1dfff04a5d4064ba0db1fab13f84ab4f333d2b (diff) | |
drm/vmwgfx: Fix compat shader namespace
Contrary to the host-backed shader interface that has a per-context
name-space for shaders, the compat shader namespace was per client
(or rather, per file). Fix this so that the compat shader namespace is per
context, and at the same time, make command buffer managed context resource
management generic.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/Makefile | 3 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | 341 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_context.c | 38 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_drv.c | 7 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_drv.h | 74 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 227 | ||||
| -rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_shader.c | 396 |
7 files changed, 673 insertions, 413 deletions
diff --git a/drivers/gpu/drm/vmwgfx/Makefile b/drivers/gpu/drm/vmwgfx/Makefile index 458cdf6d81e8..ce0ab951f507 100644 --- a/drivers/gpu/drm/vmwgfx/Makefile +++ b/drivers/gpu/drm/vmwgfx/Makefile | |||
| @@ -6,6 +6,7 @@ vmwgfx-y := vmwgfx_execbuf.o vmwgfx_gmr.o vmwgfx_kms.o vmwgfx_drv.o \ | |||
| 6 | vmwgfx_fifo.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \ | 6 | vmwgfx_fifo.o vmwgfx_irq.o vmwgfx_ldu.o vmwgfx_ttm_glue.o \ |
| 7 | vmwgfx_overlay.o vmwgfx_marker.o vmwgfx_gmrid_manager.o \ | 7 | vmwgfx_overlay.o vmwgfx_marker.o vmwgfx_gmrid_manager.o \ |
| 8 | vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \ | 8 | vmwgfx_fence.o vmwgfx_dmabuf.o vmwgfx_scrn.o vmwgfx_context.o \ |
| 9 | vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o vmwgfx_shader.o | 9 | vmwgfx_surface.o vmwgfx_prime.o vmwgfx_mob.o vmwgfx_shader.o \ |
| 10 | vmwgfx_cmdbuf_res.o \ | ||
| 10 | 11 | ||
| 11 | obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o | 12 | obj-$(CONFIG_DRM_VMWGFX) := vmwgfx.o |
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c new file mode 100644 index 000000000000..bfeb4b1f2acf --- /dev/null +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cmdbuf_res.c | |||
| @@ -0,0 +1,341 @@ | |||
| 1 | /************************************************************************** | ||
| 2 | * | ||
| 3 | * Copyright © 2014 VMware, Inc., Palo Alto, CA., USA | ||
| 4 | * All Rights Reserved. | ||
| 5 | * | ||
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
| 7 | * copy of this software and associated documentation files (the | ||
| 8 | * "Software"), to deal in the Software without restriction, including | ||
| 9 | * without limitation the rights to use, copy, modify, merge, publish, | ||
| 10 | * distribute, sub license, and/or sell copies of the Software, and to | ||
| 11 | * permit persons to whom the Software is furnished to do so, subject to | ||
| 12 | * the following conditions: | ||
| 13 | * | ||
| 14 | * The above copyright notice and this permission notice (including the | ||
| 15 | * next paragraph) shall be included in all copies or substantial portions | ||
| 16 | * of the Software. | ||
| 17 | * | ||
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 20 | * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | ||
| 21 | * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, | ||
| 22 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 23 | * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 24 | * USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 25 | * | ||
| 26 | **************************************************************************/ | ||
| 27 | |||
| 28 | #include "vmwgfx_drv.h" | ||
| 29 | |||
| 30 | #define VMW_CMDBUF_RES_MAN_HT_ORDER 12 | ||
| 31 | |||
| 32 | enum vmw_cmdbuf_res_state { | ||
| 33 | VMW_CMDBUF_RES_COMMITED, | ||
| 34 | VMW_CMDBUF_RES_ADD, | ||
| 35 | VMW_CMDBUF_RES_DEL | ||
| 36 | }; | ||
| 37 | |||
| 38 | /** | ||
| 39 | * struct vmw_cmdbuf_res - Command buffer managed resource entry. | ||
| 40 | * | ||
| 41 | * @res: Refcounted pointer to a struct vmw_resource. | ||
| 42 | * @hash: Hash entry for the manager hash table. | ||
| 43 | * @head: List head used either by the staging list or the manager list | ||
| 44 | * of commited resources. | ||
| 45 | * @state: Staging state of this resource entry. | ||
| 46 | * @man: Pointer to a resource manager for this entry. | ||
| 47 | */ | ||
| 48 | struct vmw_cmdbuf_res { | ||
| 49 | struct vmw_resource *res; | ||
| 50 | struct drm_hash_item hash; | ||
| 51 | struct list_head head; | ||
| 52 | enum vmw_cmdbuf_res_state state; | ||
| 53 | struct vmw_cmdbuf_res_manager *man; | ||
| 54 | }; | ||
| 55 | |||
| 56 | /** | ||
| 57 | * struct vmw_cmdbuf_res_manager - Command buffer resource manager. | ||
| 58 | * | ||
| 59 | * @resources: Hash table containing staged and commited command buffer | ||
| 60 | * resources | ||
| 61 | * @list: List of commited command buffer resources. | ||
| 62 | * @dev_priv: Pointer to a device private structure. | ||
| 63 | * | ||
| 64 | * @resources and @list are protected by the cmdbuf mutex for now. | ||
| 65 | */ | ||
| 66 | struct vmw_cmdbuf_res_manager { | ||
| 67 | struct drm_open_hash resources; | ||
| 68 | struct list_head list; | ||
| 69 | struct vmw_private *dev_priv; | ||
| 70 | }; | ||
| 71 | |||
| 72 | |||
| 73 | /** | ||
| 74 | * vmw_cmdbuf_res_lookup - Look up a command buffer resource | ||
| 75 | * | ||
| 76 | * @man: Pointer to the command buffer resource manager | ||
| 77 | * @resource_type: The resource type, that combined with the user key | ||
| 78 | * identifies the resource. | ||
| 79 | * @user_key: The user key. | ||
| 80 | * | ||
| 81 | * Returns a valid refcounted struct vmw_resource pointer on success, | ||
| 82 | * an error pointer on failure. | ||
| 83 | */ | ||
| 84 | struct vmw_resource * | ||
| 85 | vmw_cmdbuf_res_lookup(struct vmw_cmdbuf_res_manager *man, | ||
| 86 | enum vmw_cmdbuf_res_type res_type, | ||
| 87 | u32 user_key) | ||
| 88 | { | ||
| 89 | struct drm_hash_item *hash; | ||
| 90 | int ret; | ||
| 91 | unsigned long key = user_key | (res_type << 24); | ||
| 92 | |||
| 93 | ret = drm_ht_find_item(&man->resources, key, &hash); | ||
| 94 | if (unlikely(ret != 0)) | ||
| 95 | return ERR_PTR(ret); | ||
| 96 | |||
| 97 | return vmw_resource_reference | ||
| 98 | (drm_hash_entry(hash, struct vmw_cmdbuf_res, hash)->res); | ||
| 99 | } | ||
| 100 | |||
| 101 | /** | ||
| 102 | * vmw_cmdbuf_res_free - Free a command buffer resource. | ||
| 103 | * | ||
| 104 | * @man: Pointer to the command buffer resource manager | ||
| 105 | * @entry: Pointer to a struct vmw_cmdbuf_res. | ||
| 106 | * | ||
| 107 | * Frees a struct vmw_cmdbuf_res entry and drops its reference to the | ||
| 108 | * struct vmw_resource. | ||
| 109 | */ | ||
| 110 | static void vmw_cmdbuf_res_free(struct vmw_cmdbuf_res_manager *man, | ||
| 111 | struct vmw_cmdbuf_res *entry) | ||
| 112 | { | ||
| 113 | list_del(&entry->head); | ||
| 114 | WARN_ON(drm_ht_remove_item(&man->resources, &entry->hash)); | ||
| 115 | vmw_resource_unreference(&entry->res); | ||
| 116 | kfree(entry); | ||
| 117 | } | ||
| 118 | |||
| 119 | /** | ||
| 120 | * vmw_cmdbuf_res_commit - Commit a list of command buffer resource actions | ||
| 121 | * | ||
| 122 | * @list: Caller's list of command buffer resource actions. | ||
| 123 | * | ||
| 124 | * This function commits a list of command buffer resource | ||
| 125 | * additions or removals. | ||
| 126 | * It is typically called when the execbuf ioctl call triggering these | ||
| 127 | * actions has commited the fifo contents to the device. | ||
| 128 | */ | ||
| 129 | void vmw_cmdbuf_res_commit(struct list_head *list) | ||
| 130 | { | ||
| 131 | struct vmw_cmdbuf_res *entry, *next; | ||
| 132 | |||
| 133 | list_for_each_entry_safe(entry, next, list, head) { | ||
| 134 | list_del(&entry->head); | ||
| 135 | switch (entry->state) { | ||
| 136 | case VMW_CMDBUF_RES_ADD: | ||
| 137 | entry->state = VMW_CMDBUF_RES_COMMITED; | ||
| 138 | list_add_tail(&entry->head, &entry->man->list); | ||
| 139 | break; | ||
| 140 | case VMW_CMDBUF_RES_DEL: | ||
| 141 | vmw_resource_unreference(&entry->res); | ||
| 142 | kfree(entry); | ||
| 143 | break; | ||
| 144 | default: | ||
| 145 | BUG(); | ||
| 146 | break; | ||
| 147 | } | ||
| 148 | } | ||
| 149 | } | ||
| 150 | |||
| 151 | /** | ||
| 152 | * vmw_cmdbuf_res_revert - Revert a list of command buffer resource actions | ||
| 153 | * | ||
| 154 | * @man: Pointer to the command buffer resource manager | ||
| 155 | * @list: Caller's list of command buffer resource action | ||
| 156 | * | ||
| 157 | * This function reverts a list of command buffer resource | ||
| 158 | * additions or removals. | ||
| 159 | * It is typically called when the execbuf ioctl call triggering these | ||
| 160 | * actions failed for some reason, and the command stream was never | ||
| 161 | * submitted. | ||
| 162 | */ | ||
