Lines Matching refs:client
83 static inline bool is_high_priority(struct i915_guc_client* client) in is_high_priority() argument
85 return client->priority <= GUC_CLIENT_PRIORITY_HIGH; in is_high_priority()
88 static int __reserve_doorbell(struct i915_guc_client *client) in __reserve_doorbell() argument
94 GEM_BUG_ON(client->doorbell_id != GUC_DOORBELL_INVALID); in __reserve_doorbell()
103 if (is_high_priority(client)) { in __reserve_doorbell()
108 id = find_next_zero_bit(client->guc->doorbell_bitmap, end, offset); in __reserve_doorbell()
112 __set_bit(id, client->guc->doorbell_bitmap); in __reserve_doorbell()
113 client->doorbell_id = id; in __reserve_doorbell()
115 client->stage_id, yesno(is_high_priority(client)), in __reserve_doorbell()
120 static void __unreserve_doorbell(struct i915_guc_client *client) in __unreserve_doorbell() argument
122 GEM_BUG_ON(client->doorbell_id == GUC_DOORBELL_INVALID); in __unreserve_doorbell()
124 __clear_bit(client->doorbell_id, client->guc->doorbell_bitmap); in __unreserve_doorbell()
125 client->doorbell_id = GUC_DOORBELL_INVALID; in __unreserve_doorbell()
152 static struct guc_stage_desc *__get_stage_desc(struct i915_guc_client *client) in __get_stage_desc() argument
154 struct guc_stage_desc *base = client->guc->stage_desc_pool_vaddr; in __get_stage_desc()
156 return &base[client->stage_id]; in __get_stage_desc()
166 static void __update_doorbell_desc(struct i915_guc_client *client, u16 new_id) in __update_doorbell_desc() argument
171 desc = __get_stage_desc(client); in __update_doorbell_desc()
175 static struct guc_doorbell_info *__get_doorbell(struct i915_guc_client *client) in __get_doorbell() argument
177 return client->vaddr + client->doorbell_offset; in __get_doorbell()
180 static bool has_doorbell(struct i915_guc_client *client) in has_doorbell() argument
182 if (client->doorbell_id == GUC_DOORBELL_INVALID) in has_doorbell()
185 return test_bit(client->doorbell_id, client->guc->doorbell_bitmap); in has_doorbell()
188 static int __create_doorbell(struct i915_guc_client *client) in __create_doorbell() argument
193 doorbell = __get_doorbell(client); in __create_doorbell()
195 doorbell->cookie = client->doorbell_cookie; in __create_doorbell()
197 err = __guc_allocate_doorbell(client->guc, client->stage_id); in __create_doorbell()
205 static int __destroy_doorbell(struct i915_guc_client *client) in __destroy_doorbell() argument
207 struct drm_i915_private *dev_priv = guc_to_i915(client->guc); in __destroy_doorbell()
209 u16 db_id = client->doorbell_id; in __destroy_doorbell()
213 doorbell = __get_doorbell(client); in __destroy_doorbell()
223 return __guc_deallocate_doorbell(client->guc, client->stage_id); in __destroy_doorbell()
226 static int create_doorbell(struct i915_guc_client *client) in create_doorbell() argument
230 ret = __reserve_doorbell(client); in create_doorbell()
234 __update_doorbell_desc(client, client->doorbell_id); in create_doorbell()
236 ret = __create_doorbell(client); in create_doorbell()
243 __update_doorbell_desc(client, GUC_DOORBELL_INVALID); in create_doorbell()
244 __unreserve_doorbell(client); in create_doorbell()
248 static int destroy_doorbell(struct i915_guc_client *client) in destroy_doorbell() argument
252 GEM_BUG_ON(!has_doorbell(client)); in destroy_doorbell()
257 err = __destroy_doorbell(client); in destroy_doorbell()
261 __update_doorbell_desc(client, GUC_DOORBELL_INVALID); in destroy_doorbell()
263 __unreserve_doorbell(client); in destroy_doorbell()
284 __get_process_desc(struct i915_guc_client *client) in __get_process_desc() argument
286 return client->vaddr + client->proc_desc_offset; in __get_process_desc()
293 struct i915_guc_client *client) in guc_proc_desc_init() argument
297 desc = memset(__get_process_desc(client), 0, sizeof(*desc)); in guc_proc_desc_init()
308 desc->stage_id = client->stage_id; in guc_proc_desc_init()
309 desc->wq_size_bytes = client->wq_size; in guc_proc_desc_init()
311 desc->priority = client->priority; in guc_proc_desc_init()
322 struct i915_guc_client *client) in guc_stage_desc_init() argument
326 struct i915_gem_context *ctx = client->owner; in guc_stage_desc_init()
331 desc = __get_stage_desc(client); in guc_stage_desc_init()
335 desc->stage_id = client->stage_id; in guc_stage_desc_init()
336 desc->priority = client->priority; in guc_stage_desc_init()
337 desc->db_id = client->doorbell_id; in guc_stage_desc_init()
339 for_each_engine_masked(engine, dev_priv, client->engines, tmp) { in guc_stage_desc_init()
369 lrc->context_id = (client->stage_id << GUC_ELC_CTXID_OFFSET) | in guc_stage_desc_init()
381 client->engines, desc->engines_used); in guc_stage_desc_init()
388 gfx_addr = guc_ggtt_offset(client->vma); in guc_stage_desc_init()
389 desc->db_trigger_phy = sg_dma_address(client->vma->pages->sgl) + in guc_stage_desc_init()
390 client->doorbell_offset; in guc_stage_desc_init()
391 desc->db_trigger_cpu = (uintptr_t)__get_doorbell(client); in guc_stage_desc_init()
392 desc->db_trigger_uk = gfx_addr + client->doorbell_offset; in guc_stage_desc_init()
393 desc->process_desc = gfx_addr + client->proc_desc_offset; in guc_stage_desc_init()
394 desc->wq_addr = gfx_addr + client->wq_offset; in guc_stage_desc_init()
395 desc->wq_size = client->wq_size; in guc_stage_desc_init()
397 desc->desc_private = (uintptr_t)client; in guc_stage_desc_init()
401 struct i915_guc_client *client) in guc_stage_desc_fini() argument
405 desc = __get_stage_desc(client); in guc_stage_desc_fini()
428 struct i915_guc_client *client = request->i915->guc.execbuf_client; in i915_guc_wq_reserve() local
429 struct guc_process_desc *desc = __get_process_desc(client); in i915_guc_wq_reserve()
433 spin_lock_irq(&client->wq_lock); in i915_guc_wq_reserve()
434 freespace = CIRC_SPACE(client->wq_tail, desc->head, client->wq_size); in i915_guc_wq_reserve()
435 freespace -= client->wq_rsvd; in i915_guc_wq_reserve()
437 client->wq_rsvd += wqi_size; in i915_guc_wq_reserve()
440 client->no_wq_space++; in i915_guc_wq_reserve()
443 spin_unlock_irq(&client->wq_lock); in i915_guc_wq_reserve()
448 static void guc_client_update_wq_rsvd(struct i915_guc_client *client, int size) in guc_client_update_wq_rsvd() argument
452 spin_lock_irqsave(&client->wq_lock, flags); in guc_client_update_wq_rsvd()
453 client->wq_rsvd += size; in guc_client_update_wq_rsvd()
454 spin_unlock_irqrestore(&client->wq_lock, flags); in guc_client_update_wq_rsvd()
460 struct i915_guc_client *client = request->i915->guc.execbuf_client; in i915_guc_wq_unreserve() local
462 GEM_BUG_ON(READ_ONCE(client->wq_rsvd) < wqi_size); in i915_guc_wq_unreserve()
463 guc_client_update_wq_rsvd(client, -wqi_size); in i915_guc_wq_unreserve()
467 static void guc_wq_item_append(struct i915_guc_client *client, in guc_wq_item_append() argument
474 struct guc_process_desc *desc = __get_process_desc(client); in guc_wq_item_append()
479 freespace = CIRC_SPACE(client->wq_tail, desc->head, client->wq_size); in guc_wq_item_append()
494 GEM_BUG_ON(client->wq_rsvd < wqi_size); in guc_wq_item_append()
497 wq_off = client->wq_tail; in guc_wq_item_append()
499 client->wq_tail += wqi_size; in guc_wq_item_append()
500 client->wq_tail &= client->wq_size - 1; in guc_wq_item_append()
501 client->wq_rsvd -= wqi_size; in guc_wq_item_append()
504 wqi = client->vaddr + wq_off + GUC_DB_SIZE; in guc_wq_item_append()
519 static void guc_reset_wq(struct i915_guc_client *client) in guc_reset_wq() argument
521 struct guc_process_desc *desc = __get_process_desc(client); in guc_reset_wq()
526 client->wq_tail = 0; in guc_reset_wq()
529 static int guc_ring_doorbell(struct i915_guc_client *client) in guc_ring_doorbell() argument
531 struct guc_process_desc *desc = __get_process_desc(client); in guc_ring_doorbell()
537 desc->tail = client->wq_tail; in guc_ring_doorbell()
541 db_cmp.cookie = client->doorbell_cookie; in guc_ring_doorbell()
545 db_exc.cookie = client->doorbell_cookie + 1; in guc_ring_doorbell()
550 db = (union guc_doorbell_qw *)__get_doorbell(client); in guc_ring_doorbell()
560 client->doorbell_cookie = db_exc.cookie; in guc_ring_doorbell()
603 struct i915_guc_client *client = guc->execbuf_client; in __i915_guc_submit() local
611 spin_lock_irqsave(&client->wq_lock, flags); in __i915_guc_submit()
613 guc_wq_item_append(client, rq); in __i915_guc_submit()
614 b_ret = guc_ring_doorbell(client); in __i915_guc_submit()
616 client->submissions[engine_id] += 1; in __i915_guc_submit()
618 spin_unlock_irqrestore(&client->wq_lock, flags); in __i915_guc_submit()
812 static int __reset_doorbell(struct i915_guc_client* client, u16 db_id) in __reset_doorbell() argument
816 __update_doorbell_desc(client, db_id); in __reset_doorbell()
817 err = __create_doorbell(client); in __reset_doorbell()
819 err = __destroy_doorbell(client); in __reset_doorbell()
833 struct i915_guc_client *client = guc->execbuf_client; in guc_init_doorbell_hw() local
843 if (has_doorbell(client)) { in guc_init_doorbell_hw()
845 destroy_doorbell(client); in guc_init_doorbell_hw()
849 ret = __reset_doorbell(client, db_id); in guc_init_doorbell_hw()
854 ret = __reserve_doorbell(client); in guc_init_doorbell_hw()
860 __update_doorbell_desc(client, client->doorbell_id); in guc_init_doorbell_hw()
867 ret = __create_doorbell(client); in guc_init_doorbell_hw()
870 client->stage_id, ret); in guc_init_doorbell_hw()
901 struct i915_guc_client *client; in guc_client_alloc() local
907 client = kzalloc(sizeof(*client), GFP_KERNEL); in guc_client_alloc()
908 if (!client) in guc_client_alloc()
911 client->guc = guc; in guc_client_alloc()
912 client->owner = ctx; in guc_client_alloc()
913 client->engines = engines; in guc_client_alloc()
914 client->priority = priority; in guc_client_alloc()
915 client->doorbell_id = GUC_DOORBELL_INVALID; in guc_client_alloc()
916 client->wq_offset = GUC_DB_SIZE; in guc_client_alloc()
917 client->wq_size = GUC_WQ_SIZE; in guc_client_alloc()
918 spin_lock_init(&client->wq_lock); in guc_client_alloc()
925 client->stage_id = ret; in guc_client_alloc()
935 client->vma = vma; in guc_client_alloc()
942 client->vaddr = vaddr; in guc_client_alloc()
944 client->doorbell_offset = __select_cacheline(guc); in guc_client_alloc()
951 if (client->doorbell_offset >= (GUC_DB_SIZE / 2)) in guc_client_alloc()
952 client->proc_desc_offset = 0; in guc_client_alloc()
954 client->proc_desc_offset = (GUC_DB_SIZE / 2); in guc_client_alloc()
956 guc_proc_desc_init(guc, client); in guc_client_alloc()
957 guc_stage_desc_init(guc, client); in guc_client_alloc()
959 ret = create_doorbell(client); in guc_client_alloc()
964 priority, client, client->engines, client->stage_id); in guc_client_alloc()
966 client->doorbell_id, client->doorbell_offset); in guc_client_alloc()
968 return client; in guc_client_alloc()
971 i915_gem_object_unpin_map(client->vma->obj); in guc_client_alloc()
973 i915_vma_unpin_and_release(&client->vma); in guc_client_alloc()
975 ida_simple_remove(&guc->stage_ids, client->stage_id); in guc_client_alloc()
977 kfree(client); in guc_client_alloc()
981 static void guc_client_free(struct i915_guc_client *client) in guc_client_free() argument
991 destroy_doorbell(client); in guc_client_free()
992 guc_stage_desc_fini(client->guc, client); in guc_client_free()
993 i915_gem_object_unpin_map(client->vma->obj); in guc_client_free()
994 i915_vma_unpin_and_release(&client->vma); in guc_client_free()
995 ida_simple_remove(&client->guc->stage_ids, client->stage_id); in guc_client_free()
996 kfree(client); in guc_client_free()
1219 struct i915_guc_client *client = guc->execbuf_client; in i915_guc_submission_enable() local
1224 if (!client) { in i915_guc_submission_enable()
1225 client = guc_client_alloc(dev_priv, in i915_guc_submission_enable()
1229 if (IS_ERR(client)) { in i915_guc_submission_enable()
1231 return PTR_ERR(client); in i915_guc_submission_enable()
1234 guc->execbuf_client = client; in i915_guc_submission_enable()
1241 guc_reset_wq(client); in i915_guc_submission_enable()
1265 guc_client_update_wq_rsvd(client, wqi_size); in i915_guc_submission_enable()