18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright © 2016 Intel Corporation 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 58c2ecf20Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 68c2ecf20Sopenharmony_ci * to deal in the Software without restriction, including without limitation 78c2ecf20Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 88c2ecf20Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 98c2ecf20Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * The above copyright notice and this permission notice (including the next 128c2ecf20Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 138c2ecf20Sopenharmony_ci * Software. 148c2ecf20Sopenharmony_ci * 158c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 168c2ecf20Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 178c2ecf20Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 188c2ecf20Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 198c2ecf20Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 208c2ecf20Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 218c2ecf20Sopenharmony_ci * IN THE SOFTWARE. 228c2ecf20Sopenharmony_ci * 238c2ecf20Sopenharmony_ci */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#ifndef I915_TIMELINE_H 268c2ecf20Sopenharmony_ci#define I915_TIMELINE_H 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci#include <linux/lockdep.h> 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci#include "i915_active.h" 318c2ecf20Sopenharmony_ci#include "i915_syncmap.h" 328c2ecf20Sopenharmony_ci#include "intel_timeline_types.h" 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_cistruct intel_timeline * 358c2ecf20Sopenharmony_ci__intel_timeline_create(struct intel_gt *gt, 368c2ecf20Sopenharmony_ci struct i915_vma *global_hwsp, 378c2ecf20Sopenharmony_ci unsigned int offset); 388c2ecf20Sopenharmony_ci 398c2ecf20Sopenharmony_cistatic inline struct intel_timeline * 408c2ecf20Sopenharmony_ciintel_timeline_create(struct intel_gt *gt) 418c2ecf20Sopenharmony_ci{ 428c2ecf20Sopenharmony_ci return __intel_timeline_create(gt, NULL, 0); 438c2ecf20Sopenharmony_ci} 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_cistatic inline struct intel_timeline * 468c2ecf20Sopenharmony_ciintel_timeline_create_from_engine(struct intel_engine_cs *engine, 478c2ecf20Sopenharmony_ci unsigned int offset) 488c2ecf20Sopenharmony_ci{ 498c2ecf20Sopenharmony_ci return __intel_timeline_create(engine->gt, 508c2ecf20Sopenharmony_ci engine->status_page.vma, 518c2ecf20Sopenharmony_ci offset); 528c2ecf20Sopenharmony_ci} 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_cistatic inline struct intel_timeline * 558c2ecf20Sopenharmony_ciintel_timeline_get(struct intel_timeline *timeline) 568c2ecf20Sopenharmony_ci{ 578c2ecf20Sopenharmony_ci kref_get(&timeline->kref); 588c2ecf20Sopenharmony_ci return timeline; 598c2ecf20Sopenharmony_ci} 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_civoid __intel_timeline_free(struct kref *kref); 628c2ecf20Sopenharmony_cistatic inline void intel_timeline_put(struct intel_timeline *timeline) 638c2ecf20Sopenharmony_ci{ 648c2ecf20Sopenharmony_ci kref_put(&timeline->kref, __intel_timeline_free); 658c2ecf20Sopenharmony_ci} 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_cistatic inline int __intel_timeline_sync_set(struct intel_timeline *tl, 688c2ecf20Sopenharmony_ci u64 context, u32 seqno) 698c2ecf20Sopenharmony_ci{ 708c2ecf20Sopenharmony_ci return i915_syncmap_set(&tl->sync, context, seqno); 718c2ecf20Sopenharmony_ci} 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_cistatic inline int intel_timeline_sync_set(struct intel_timeline *tl, 748c2ecf20Sopenharmony_ci const struct dma_fence *fence) 758c2ecf20Sopenharmony_ci{ 768c2ecf20Sopenharmony_ci return __intel_timeline_sync_set(tl, fence->context, fence->seqno); 778c2ecf20Sopenharmony_ci} 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_cistatic inline bool __intel_timeline_sync_is_later(struct intel_timeline *tl, 808c2ecf20Sopenharmony_ci u64 context, u32 seqno) 818c2ecf20Sopenharmony_ci{ 828c2ecf20Sopenharmony_ci return i915_syncmap_is_later(&tl->sync, context, seqno); 838c2ecf20Sopenharmony_ci} 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_cistatic inline bool intel_timeline_sync_is_later(struct intel_timeline *tl, 868c2ecf20Sopenharmony_ci const struct dma_fence *fence) 878c2ecf20Sopenharmony_ci{ 888c2ecf20Sopenharmony_ci return __intel_timeline_sync_is_later(tl, fence->context, fence->seqno); 898c2ecf20Sopenharmony_ci} 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_civoid __intel_timeline_pin(struct intel_timeline *tl); 928c2ecf20Sopenharmony_ciint intel_timeline_pin(struct intel_timeline *tl, struct i915_gem_ww_ctx *ww); 938c2ecf20Sopenharmony_civoid intel_timeline_enter(struct intel_timeline *tl); 948c2ecf20Sopenharmony_ciint intel_timeline_get_seqno(struct intel_timeline *tl, 958c2ecf20Sopenharmony_ci struct i915_request *rq, 968c2ecf20Sopenharmony_ci u32 *seqno); 978c2ecf20Sopenharmony_civoid intel_timeline_exit(struct intel_timeline *tl); 988c2ecf20Sopenharmony_civoid intel_timeline_unpin(struct intel_timeline *tl); 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_civoid intel_timeline_reset_seqno(const struct intel_timeline *tl); 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ciint intel_timeline_read_hwsp(struct i915_request *from, 1038c2ecf20Sopenharmony_ci struct i915_request *until, 1048c2ecf20Sopenharmony_ci u32 *hwsp_offset); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_civoid intel_gt_init_timelines(struct intel_gt *gt); 1078c2ecf20Sopenharmony_civoid intel_gt_fini_timelines(struct intel_gt *gt); 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#endif 110