diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2011-10-10 06:23:25 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2011-10-10 10:46:28 -0400 |
commit | 8bf445cee3127de3779a395d08d1ada2ad70161e (patch) | |
tree | c4b3af764bb099d5f12f672061be6e98b8ec8b51 /drivers/gpu/drm/vmwgfx | |
parent | 005a83f1412f4405694d08e95836bbdd88ea0109 (diff) |
vmwgfx: Break out and comment vmw_execbuf_copy_fence_user
This function will be used also by the upcoming fence event code,
so break it out and add a comment about the functionality.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/vmwgfx')
-rw-r--r-- | drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | 100 |
1 files changed, 67 insertions, 33 deletions
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c index 8a22f9d4a610..f53b99d3c2e0 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c | |||
@@ -1037,6 +1037,71 @@ int vmw_execbuf_fence_commands(struct drm_file *file_priv, | |||
1037 | return 0; | 1037 | return 0; |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | /** | ||
1041 | * vmw_execbuf_copy_fence_user - copy fence object information to | ||
1042 | * user-space. | ||
1043 | * | ||
1044 | * @dev_priv: Pointer to a vmw_private struct. | ||
1045 | * @vmw_fp: Pointer to the struct vmw_fpriv representing the calling file. | ||
1046 | * @ret: Return value from fence object creation. | ||
1047 | * @user_fence_rep: User space address of a struct drm_vmw_fence_rep to | ||
1048 | * which the information should be copied. | ||
1049 | * @fence: Pointer to the fenc object. | ||
1050 | * @fence_handle: User-space fence handle. | ||
1051 | * | ||
1052 | * This function copies fence information to user-space. If copying fails, | ||
1053 | * The user-space struct drm_vmw_fence_rep::error member is hopefully | ||
1054 | * left untouched, and if it's preloaded with an -EFAULT by user-space, | ||
1055 | * the error will hopefully be detected. | ||
1056 | * Also if copying fails, user-space will be unable to signal the fence | ||
1057 | * object so we wait for it immediately, and then unreference the | ||
1058 | * user-space reference. | ||
1059 | */ | ||
1060 | static void | ||
1061 | vmw_execbuf_copy_fence_user(struct vmw_private *dev_priv, | ||
1062 | struct vmw_fpriv *vmw_fp, | ||
1063 | int ret, | ||
1064 | struct drm_vmw_fence_rep __user *user_fence_rep, | ||
1065 | struct vmw_fence_obj *fence, | ||
1066 | uint32_t fence_handle) | ||
1067 | { | ||
1068 | struct drm_vmw_fence_rep fence_rep; | ||
1069 | |||
1070 | if (user_fence_rep == NULL) | ||
1071 | return; | ||
1072 | |||
1073 | fence_rep.error = ret; | ||
1074 | if (ret == 0) { | ||
1075 | BUG_ON(fence == NULL); | ||
1076 | |||
1077 | fence_rep.handle = fence_handle; | ||
1078 | fence_rep.seqno = fence->seqno; | ||
1079 | vmw_update_seqno(dev_priv, &dev_priv->fifo); | ||
1080 | fence_rep.passed_seqno = dev_priv->last_read_seqno; | ||
1081 | } | ||
1082 | |||
1083 | /* | ||
1084 | * copy_to_user errors will be detected by user space not | ||
1085 | * seeing fence_rep::error filled in. Typically | ||
1086 | * user-space would have pre-set that member to -EFAULT. | ||
1087 | */ | ||
1088 | ret = copy_to_user(user_fence_rep, &fence_rep, | ||
1089 | sizeof(fence_rep)); | ||
1090 | |||
1091 | /* | ||
1092 | * User-space lost the fence object. We need to sync | ||
1093 | * and unreference the handle. | ||
1094 | */ | ||
1095 | if (unlikely(ret != 0) && (fence_rep.error == 0)) { | ||
1096 | ttm_ref_object_base_unref(vmw_fp->tfile, | ||
1097 | fence_handle, TTM_REF_USAGE); | ||
1098 | DRM_ERROR("Fence copy error. Syncing.\n"); | ||
1099 | (void) vmw_fence_obj_wait(fence, fence->signal_mask, | ||
1100 | false, false, | ||
1101 | VMW_FENCE_WAIT_TIMEOUT); | ||
1102 | } | ||
1103 | } | ||
1104 | |||
1040 | int vmw_execbuf_process(struct drm_file *file_priv, | 1105 | int vmw_execbuf_process(struct drm_file *file_priv, |
1041 | struct vmw_private *dev_priv, | 1106 | struct vmw_private *dev_priv, |
1042 | void __user *user_commands, | 1107 | void __user *user_commands, |
@@ -1046,7 +1111,6 @@ int vmw_execbuf_process(struct drm_file *file_priv, | |||
1046 | struct drm_vmw_fence_rep __user *user_fence_rep) | 1111 | struct drm_vmw_fence_rep __user *user_fence_rep) |
1047 | { | 1112 | { |
1048 | struct vmw_sw_context *sw_context = &dev_priv->ctx; | 1113 | struct vmw_sw_context *sw_context = &dev_priv->ctx; |
1049 | struct drm_vmw_fence_rep fence_rep; | ||
1050 | struct vmw_fence_obj *fence; | 1114 | struct vmw_fence_obj *fence; |
1051 | uint32_t handle; | 1115 | uint32_t handle; |
1052 | void *cmd; | 1116 | void *cmd; |
@@ -1140,38 +1204,8 @@ int vmw_execbuf_process(struct drm_file *file_priv, | |||
1140 | (void *) fence); | 1204 | (void *) fence); |
1141 | 1205 | ||
1142 | vmw_clear_validations(sw_context); | 1206 | vmw_clear_validations(sw_context); |
1143 | 1207 | vmw_execbuf_copy_fence_user(dev_priv, vmw_fpriv(file_priv), ret, | |
1144 | if (user_fence_rep) { | 1208 | user_fence_rep, fence, handle); |
1145 | fence_rep.error = ret; | ||
1146 | fence_rep.handle = handle; | ||
1147 | fence_rep.seqno = fence->seqno; | ||
1148 | vmw_update_seqno(dev_priv, &dev_priv->fifo); | ||
1149 | fence_rep.passed_seqno = dev_priv->last_read_seqno; | ||
1150 | |||
1151 | /* | ||
1152 | * copy_to_user errors will be detected by user space not | ||
1153 | * seeing fence_rep::error filled in. Typically | ||
1154 | * user-space would have pre-set that member to -EFAULT. | ||
1155 | */ | ||
1156 | ret = copy_to_user(user_fence_rep, &fence_rep, | ||
1157 | sizeof(fence_rep)); | ||
1158 | |||
1159 | /* | ||
1160 | * User-space lost the fence object. We need to sync | ||
1161 | * and unreference the handle. | ||
1162 | */ | ||
1163 | if (unlikely(ret != 0) && (fence_rep.error == 0)) { | ||
1164 | BUG_ON(fence == NULL); | ||
1165 | |||
1166 | ttm_ref_object_base_unref(vmw_fpriv(file_priv)->tfile, | ||
1167 | handle, TTM_REF_USAGE); | ||
1168 | DRM_ERROR("Fence copy error. Syncing.\n"); | ||
1169 | (void) vmw_fence_obj_wait(fence, | ||
1170 | fence->signal_mask, | ||
1171 | false, false, | ||
1172 | VMW_FENCE_WAIT_TIMEOUT); | ||
1173 | } | ||
1174 | } | ||
1175 | 1209 | ||
1176 | if (likely(fence != NULL)) | 1210 | if (likely(fence != NULL)) |
1177 | vmw_fence_obj_unreference(&fence); | 1211 | vmw_fence_obj_unreference(&fence); |