Lines Matching refs:ei
91 struct hte_ts_info ei[]; member
120 static void hte_ts_dbgfs_init(const char *name, struct hte_ts_info *ei) in hte_ts_dbgfs_init() argument
122 if (!ei->gdev->dbg_root || !name) in hte_ts_dbgfs_init()
125 ei->ts_dbg_root = debugfs_create_dir(name, ei->gdev->dbg_root); in hte_ts_dbgfs_init()
127 debugfs_create_atomic_t("dropped_timestamps", 0444, ei->ts_dbg_root, in hte_ts_dbgfs_init()
128 &ei->dropped_ts); in hte_ts_dbgfs_init()
137 static void hte_ts_dbgfs_init(const char *name, struct hte_ts_info *ei) in hte_ts_dbgfs_init() argument
157 struct hte_ts_info *ei; in hte_ts_put() local
162 ei = desc->hte_data; in hte_ts_put()
164 if (!ei || !ei->gdev) in hte_ts_put()
167 gdev = ei->gdev; in hte_ts_put()
169 mutex_lock(&ei->req_mlock); in hte_ts_put()
171 if (unlikely(!test_bit(HTE_TS_REQ, &ei->flags) && in hte_ts_put()
172 !test_bit(HTE_TS_REGISTERED, &ei->flags))) { in hte_ts_put()
179 if (unlikely(!test_bit(HTE_TS_REQ, &ei->flags) && in hte_ts_put()
180 test_bit(HTE_TS_REGISTERED, &ei->flags))) { in hte_ts_put()
187 if (test_bit(HTE_TS_REQ, &ei->flags) && in hte_ts_put()
188 !test_bit(HTE_TS_REGISTERED, &ei->flags)) { in hte_ts_put()
189 clear_bit(HTE_TS_REQ, &ei->flags); in hte_ts_put()
195 ret = gdev->chip->ops->release(gdev->chip, desc, ei->xlated_id); in hte_ts_put()
202 kfree(ei->line_name); in hte_ts_put()
203 if (ei->free_attr_name) in hte_ts_put()
206 debugfs_remove_recursive(ei->ts_dbg_root); in hte_ts_put()
208 spin_lock_irqsave(&ei->slock, flag); in hte_ts_put()
210 if (test_bit(HTE_TS_QUEUE_WK, &ei->flags)) { in hte_ts_put()
211 spin_unlock_irqrestore(&ei->slock, flag); in hte_ts_put()
212 flush_work(&ei->cb_work); in hte_ts_put()
213 spin_lock_irqsave(&ei->slock, flag); in hte_ts_put()
217 atomic_set(&ei->dropped_ts, 0); in hte_ts_put()
219 ei->seq = 1; in hte_ts_put()
220 ei->flags = 0; in hte_ts_put()
223 spin_unlock_irqrestore(&ei->slock, flag); in hte_ts_put()
225 ei->cb = NULL; in hte_ts_put()
226 ei->tcb = NULL; in hte_ts_put()
227 ei->cl_data = NULL; in hte_ts_put()
232 mutex_unlock(&ei->req_mlock); in hte_ts_put()
243 struct hte_ts_info *ei; in hte_ts_dis_en_common() local
250 ei = desc->hte_data; in hte_ts_dis_en_common()
252 if (!ei || !ei->gdev) in hte_ts_dis_en_common()
255 gdev = ei->gdev; in hte_ts_dis_en_common()
258 mutex_lock(&ei->req_mlock); in hte_ts_dis_en_common()
260 if (!test_bit(HTE_TS_REGISTERED, &ei->flags)) { in hte_ts_dis_en_common()
266 spin_lock_irqsave(&ei->slock, flag); in hte_ts_dis_en_common()
269 if (!test_bit(HTE_TS_DISABLE, &ei->flags)) { in hte_ts_dis_en_common()
274 spin_unlock_irqrestore(&ei->slock, flag); in hte_ts_dis_en_common()
275 ret = gdev->chip->ops->enable(gdev->chip, ei->xlated_id); in hte_ts_dis_en_common()
282 spin_lock_irqsave(&ei->slock, flag); in hte_ts_dis_en_common()
283 clear_bit(HTE_TS_DISABLE, &ei->flags); in hte_ts_dis_en_common()
285 if (test_bit(HTE_TS_DISABLE, &ei->flags)) { in hte_ts_dis_en_common()
290 spin_unlock_irqrestore(&ei->slock, flag); in hte_ts_dis_en_common()
291 ret = gdev->chip->ops->disable(gdev->chip, ei->xlated_id); in hte_ts_dis_en_common()
298 spin_lock_irqsave(&ei->slock, flag); in hte_ts_dis_en_common()
299 set_bit(HTE_TS_DISABLE, &ei->flags); in hte_ts_dis_en_common()
303 spin_unlock_irqrestore(&ei->slock, flag); in hte_ts_dis_en_common()
305 mutex_unlock(&ei->req_mlock); in hte_ts_dis_en_common()
342 struct hte_ts_info *ei = container_of(w, struct hte_ts_info, cb_work); in hte_do_cb_work() local
344 if (unlikely(!ei->tcb)) in hte_do_cb_work()
347 ei->tcb(ei->cl_data); in hte_do_cb_work()
349 spin_lock_irqsave(&ei->slock, flag); in hte_do_cb_work()
350 clear_bit(HTE_TS_QUEUE_WK, &ei->flags); in hte_do_cb_work()
351 spin_unlock_irqrestore(&ei->slock, flag); in hte_do_cb_work()
359 struct hte_ts_info *ei = desc->hte_data; in __hte_req_ts() local
361 gdev = ei->gdev; in __hte_req_ts()
366 mutex_lock(&ei->req_mlock); in __hte_req_ts()
368 if (test_bit(HTE_TS_REGISTERED, &ei->flags) || in __hte_req_ts()
369 !test_bit(HTE_TS_REQ, &ei->flags)) { in __hte_req_ts()
376 ei->cb = cb; in __hte_req_ts()
377 ei->tcb = tcb; in __hte_req_ts()
379 INIT_WORK(&ei->cb_work, hte_do_cb_work); in __hte_req_ts()
381 ret = gdev->chip->ops->request(gdev->chip, desc, ei->xlated_id); in __hte_req_ts()
387 ei->cl_data = data; in __hte_req_ts()
388 ei->seq = 1; in __hte_req_ts()
392 ei->line_name = NULL; in __hte_req_ts()
394 ei->line_name = kzalloc(HTE_TS_NAME_LEN, GFP_KERNEL); in __hte_req_ts()
395 if (ei->line_name) in __hte_req_ts()
396 scnprintf(ei->line_name, HTE_TS_NAME_LEN, "ts_%u", in __hte_req_ts()
401 ei->line_name : desc->attr.name, ei); in __hte_req_ts()
402 set_bit(HTE_TS_REGISTERED, &ei->flags); in __hte_req_ts()
405 desc->attr.line_id, ei->xlated_id); in __hte_req_ts()
410 mutex_unlock(&ei->req_mlock); in __hte_req_ts()
415 static int hte_bind_ts_info_locked(struct hte_ts_info *ei, in hte_bind_ts_info_locked() argument
420 mutex_lock(&ei->req_mlock); in hte_bind_ts_info_locked()
422 if (test_bit(HTE_TS_REQ, &ei->flags)) { in hte_bind_ts_info_locked()
423 dev_dbg(ei->gdev->chip->dev, "id:%u is already requested\n", in hte_bind_ts_info_locked()
429 set_bit(HTE_TS_REQ, &ei->flags); in hte_bind_ts_info_locked()
430 desc->hte_data = ei; in hte_bind_ts_info_locked()
431 ei->xlated_id = x_id; in hte_bind_ts_info_locked()
434 mutex_unlock(&ei->req_mlock); in hte_bind_ts_info_locked()
570 struct hte_ts_info *ei; in hte_ts_get() local
619 ei = &gdev->ei[xlated_id]; in hte_ts_get()
621 ret = hte_bind_ts_info_locked(ei, desc, xlated_id); in hte_ts_get()
625 ei->free_attr_name = free_name; in hte_ts_get()
660 struct hte_ts_info *ei; in hte_request_ts_ns() local
665 ei = desc->hte_data; in hte_request_ts_ns()
666 if (!ei || !ei->gdev) in hte_request_ts_ns()
671 dev_err(ei->gdev->chip->dev, in hte_request_ts_ns()
772 struct hte_ts_info *ei; in hte_get_clk_src_info() local
779 ei = desc->hte_data; in hte_get_clk_src_info()
780 if (!ei->gdev || !ei->gdev->chip) in hte_get_clk_src_info()
783 chip = ei->gdev->chip; in hte_get_clk_src_info()
808 struct hte_ts_info *ei; in hte_push_ts_ns() local
817 ei = &chip->gdev->ei[xlated_id]; in hte_push_ts_ns()
819 spin_lock_irqsave(&ei->slock, flag); in hte_push_ts_ns()
822 data->seq = ei->seq++; in hte_push_ts_ns()
824 if (!test_bit(HTE_TS_REGISTERED, &ei->flags) || in hte_push_ts_ns()
825 test_bit(HTE_TS_DISABLE, &ei->flags)) { in hte_push_ts_ns()
827 atomic_inc(&ei->dropped_ts); in hte_push_ts_ns()
832 ret = ei->cb(data, ei->cl_data); in hte_push_ts_ns()
833 if (ret == HTE_RUN_SECOND_CB && ei->tcb) { in hte_push_ts_ns()
834 queue_work(system_unbound_wq, &ei->cb_work); in hte_push_ts_ns()
835 set_bit(HTE_TS_QUEUE_WK, &ei->flags); in hte_push_ts_ns()
839 spin_unlock_irqrestore(&ei->slock, flag); in hte_push_ts_ns()
858 gdev = kzalloc(struct_size(gdev, ei, chip->nlines), GFP_KERNEL); in hte_register_chip()
868 gdev->ei[i].gdev = gdev; in hte_register_chip()
869 mutex_init(&gdev->ei[i].req_mlock); in hte_register_chip()
870 spin_lock_init(&gdev->ei[i].slock); in hte_register_chip()