Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm: split locking and pinning BO's

Split up locking and pinning buffers in the submit path. This is needed
because we'll want to insert fencing in between the two steps.

This makes things end up looking more similar to etnaviv submit code
(which was originally modelled on the msm code but has already added
'struct fence' support).

Signed-off-by: Rob Clark <robdclark@gmail.com>

Rob Clark 340faef2 7d12a279

+40 -31
+1 -1
drivers/gpu/drm/msm/msm_gem.h
··· 100 100 struct list_head bo_list; 101 101 struct ww_acquire_ctx ticket; 102 102 uint32_t fence; 103 - bool valid; 103 + bool valid; /* true if no cmdstream patching needed */ 104 104 unsigned int nr_cmds; 105 105 unsigned int nr_bos; 106 106 struct {
+39 -30
drivers/gpu/drm/msm/msm_gem_submit.c
··· 24 24 */ 25 25 26 26 /* make sure these don't conflict w/ MSM_SUBMIT_BO_x */ 27 - #define BO_VALID 0x8000 27 + #define BO_VALID 0x8000 /* is current addr in cmdstream correct/valid? */ 28 28 #define BO_LOCKED 0x4000 29 29 #define BO_PINNED 0x2000 30 30 ··· 136 136 } 137 137 138 138 /* This is where we make sure all the bo's are reserved and pin'd: */ 139 - static int submit_validate_objects(struct msm_gem_submit *submit) 139 + static int submit_lock_objects(struct msm_gem_submit *submit) 140 140 { 141 141 int contended, slow_locked = -1, i, ret = 0; 142 142 143 143 retry: 144 - submit->valid = true; 145 - 146 144 for (i = 0; i < submit->nr_bos; i++) { 147 145 struct msm_gem_object *msm_obj = submit->bos[i].obj; 148 - uint32_t iova; 149 146 150 147 if (slow_locked == i) 151 148 slow_locked = -1; ··· 155 158 if (ret) 156 159 goto fail; 157 160 submit->bos[i].flags |= BO_LOCKED; 158 - } 159 - 160 - 161 - /* if locking succeeded, pin bo: */ 162 - ret = msm_gem_get_iova_locked(&msm_obj->base, 163 - submit->gpu->id, &iova); 164 - 165 - /* this would break the logic in the fail path.. there is no 166 - * reason for this to happen, but just to be on the safe side 167 - * let's notice if this starts happening in the future: 168 - */ 169 - WARN_ON(ret == -EDEADLK); 170 - 171 - if (ret) 172 - goto fail; 173 - 174 - submit->bos[i].flags |= BO_PINNED; 175 - 176 - if (iova == submit->bos[i].iova) { 177 - submit->bos[i].flags |= BO_VALID; 178 - } else { 179 - submit->bos[i].iova = iova; 180 - submit->bos[i].flags &= ~BO_VALID; 181 - submit->valid = false; 182 161 } 183 162 } 184 163 ··· 178 205 submit->bos[contended].flags |= BO_LOCKED; 179 206 slow_locked = contended; 180 207 goto retry; 208 + } 209 + } 210 + 211 + return ret; 212 + } 213 + 214 + static int submit_pin_objects(struct msm_gem_submit *submit) 215 + { 216 + int i, ret = 0; 217 + 218 + submit->valid = true; 219 + 220 + for (i = 0; i < submit->nr_bos; i++) { 221 + struct msm_gem_object *msm_obj = submit->bos[i].obj; 222 + uint32_t iova; 223 + 224 + /* if locking succeeded, pin bo: */ 225 + ret = msm_gem_get_iova_locked(&msm_obj->base, 226 + submit->gpu->id, &iova); 227 + 228 + if (ret) 229 + break; 230 + 231 + submit->bos[i].flags |= BO_PINNED; 232 + 233 + if (iova == submit->bos[i].iova) { 234 + submit->bos[i].flags |= BO_VALID; 235 + } else { 236 + submit->bos[i].iova = iova; 237 + /* iova changed, so address in cmdstream is not valid: */ 238 + submit->bos[i].flags &= ~BO_VALID; 239 + submit->valid = false; 181 240 } 182 241 } 183 242 ··· 354 349 if (ret) 355 350 goto out; 356 351 357 - ret = submit_validate_objects(submit); 352 + ret = submit_lock_objects(submit); 353 + if (ret) 354 + goto out; 355 + 356 + ret = submit_pin_objects(submit); 358 357 if (ret) 359 358 goto out; 360 359