Lines Matching +full:lock +full:- +full:offset
2 * Copyright (c) 2013-2019, Intel Corporation
33 #include "intel-pt.h"
41 uint64_t offset, uint64_t size) in pt_mk_section() argument
51 return -pte_internal; in pt_mk_section()
55 return -pte_invalid; in pt_mk_section()
61 return -pte_nomem; in pt_mk_section()
69 /* Fail if the requested @offset lies beyond the end of @file. */ in pt_mk_section()
70 if (fsize <= offset) { in pt_mk_section()
71 errcode = -pte_invalid; in pt_mk_section()
76 fsize -= offset; in pt_mk_section()
82 errcode = -pte_nomem; in pt_mk_section()
88 section->filename = fname; in pt_mk_section()
89 section->status = status; in pt_mk_section()
90 section->offset = offset; in pt_mk_section()
91 section->size = size; in pt_mk_section()
92 section->ucount = 1; in pt_mk_section()
96 errcode = mtx_init(§ion->lock, mtx_plain); in pt_mk_section()
100 errcode = -pte_bad_lock; in pt_mk_section()
104 errcode = mtx_init(§ion->alock, mtx_plain); in pt_mk_section()
106 mtx_destroy(§ion->lock); in pt_mk_section()
109 errcode = -pte_bad_lock; in pt_mk_section()
129 return -pte_internal; in pt_section_lock()
135 errcode = mtx_lock(§ion->lock); in pt_section_lock()
137 return -pte_bad_lock; in pt_section_lock()
147 return -pte_internal; in pt_section_unlock()
153 errcode = mtx_unlock(§ion->lock); in pt_section_unlock()
155 return -pte_bad_lock; in pt_section_unlock()
169 mtx_destroy(§ion->alock); in pt_section_free()
170 mtx_destroy(§ion->lock); in pt_section_free()
174 free(section->filename); in pt_section_free()
175 free(section->status); in pt_section_free()
185 return -pte_internal; in pt_section_get()
191 ucount = section->ucount + 1; in pt_section_get()
194 return -pte_overflow; in pt_section_get()
197 section->ucount = ucount; in pt_section_get()
208 return -pte_internal; in pt_section_put()
214 mcount = section->mcount; in pt_section_put()
215 ucount = section->ucount; in pt_section_put()
217 section->ucount = ucount - 1; in pt_section_put()
226 return -pte_internal; in pt_section_put()
235 return -pte_internal; in pt_section_lock_attach()
241 errcode = mtx_lock(§ion->alock); in pt_section_lock_attach()
243 return -pte_bad_lock; in pt_section_lock_attach()
253 return -pte_internal; in pt_section_unlock_attach()
259 errcode = mtx_unlock(§ion->alock); in pt_section_unlock_attach()
261 return -pte_bad_lock; in pt_section_unlock_attach()
275 return -pte_internal; in pt_section_attach()
281 ucount = section->ucount; in pt_section_attach()
282 acount = section->acount; in pt_section_attach()
284 if (section->iscache || !ucount) in pt_section_attach()
287 section->iscache = iscache; in pt_section_attach()
288 section->acount = 1; in pt_section_attach()
296 return -pte_overflow; in pt_section_attach()
302 if (section->iscache != iscache) in pt_section_attach()
305 section->acount = acount; in pt_section_attach()
311 return -pte_internal; in pt_section_attach()
321 return -pte_internal; in pt_section_detach()
327 if (section->iscache != iscache) in pt_section_detach()
330 acount = section->acount; in pt_section_detach()
334 acount -= 1; in pt_section_detach()
335 ucount = section->ucount; in pt_section_detach()
339 section->acount = acount; in pt_section_detach()
341 section->iscache = NULL; in pt_section_detach()
347 return -pte_internal; in pt_section_detach()
355 return section->filename; in pt_section_filename()
363 return section->size; in pt_section_size()
372 return -pte_internal; in pt_section_bcache_memsize()
374 bcache = section->bcache; in pt_section_bcache_memsize()
381 (bcache->nentries * sizeof(struct pt_bcache_entry)); in pt_section_bcache_memsize()
394 return -pte_internal; in pt_section_memsize_locked()
396 memsize = section->memsize; in pt_section_memsize_locked()
398 if (section->mcount) in pt_section_memsize_locked()
399 return -pte_internal; in pt_section_memsize_locked()
440 return section->offset; in pt_section_offset()
452 return -pte_internal; in pt_section_alloc_bcache()
454 if (!section->mcount) in pt_section_alloc_bcache()
455 return -pte_internal; in pt_section_alloc_bcache()
461 return -pte_not_supported; in pt_section_alloc_bcache()
465 /* We need to take both the attach and the section lock in order to pair in pt_section_alloc_bcache()
471 * The attach lock needs to be taken first. in pt_section_alloc_bcache()
489 errcode = -pte_nomem; in pt_section_alloc_bcache()
499 section->bcache = bcache; in pt_section_alloc_bcache()
510 iscache = section->iscache; in pt_section_alloc_bcache()
536 return -pte_internal; in pt_section_on_map_lock()
542 iscache = section->iscache; in pt_section_on_map_lock()
548 * re-entered while we're still holding the attach lock. in pt_section_on_map_lock()
568 return -pte_internal; in pt_section_map_share()
574 mcount = section->mcount; in pt_section_map_share()
577 return -pte_internal; in pt_section_map_share()
583 return -pte_overflow; in pt_section_map_share()
586 section->mcount = mcount; in pt_section_map_share()
597 return -pte_internal; in pt_section_unmap()
603 mcount = section->mcount; in pt_section_unmap()
605 errcode = -pte_nomap; in pt_section_unmap()
609 section->mcount = mcount -= 1; in pt_section_unmap()
613 errcode = -pte_internal; in pt_section_unmap()
614 if (!section->unmap) in pt_section_unmap()
617 status = section->unmap(section); in pt_section_unmap()
619 pt_bcache_free(section->bcache); in pt_section_unmap()
620 section->bcache = NULL; in pt_section_unmap()
634 uint16_t size, uint64_t offset) in pt_section_read() argument
639 return -pte_internal; in pt_section_read()
641 if (!section->read) in pt_section_read()
642 return -pte_nomap; in pt_section_read()
644 limit = section->size; in pt_section_read()
645 if (limit <= offset) in pt_section_read()
646 return -pte_nomap; in pt_section_read()
649 space = limit - offset; in pt_section_read()
653 return section->read(section, buffer, size, offset); in pt_section_read()