Lines Matching refs:tcs
102 return &drv->tcs[type]; in get_tcs_of_type()
108 struct tcs_group *tcs; in tcs_invalidate() local
110 tcs = get_tcs_of_type(drv, type); in tcs_invalidate()
112 spin_lock(&tcs->lock); in tcs_invalidate()
113 if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS)) { in tcs_invalidate()
114 spin_unlock(&tcs->lock); in tcs_invalidate()
118 for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++) { in tcs_invalidate()
120 spin_unlock(&tcs->lock); in tcs_invalidate()
125 bitmap_zero(tcs->slots, MAX_TCS_SLOTS); in tcs_invalidate()
126 spin_unlock(&tcs->lock); in tcs_invalidate()
151 struct tcs_group *tcs; in get_tcs_for_msg() local
175 tcs = get_tcs_of_type(drv, type); in get_tcs_for_msg()
176 if (msg->state == RPMH_ACTIVE_ONLY_STATE && !tcs->num_tcs) { in get_tcs_for_msg()
177 tcs = get_tcs_of_type(drv, WAKE_TCS); in get_tcs_for_msg()
178 if (tcs->num_tcs) { in get_tcs_for_msg()
185 return tcs; in get_tcs_for_msg()
191 struct tcs_group *tcs; in get_req_from_tcs() local
195 tcs = &drv->tcs[i]; in get_req_from_tcs()
196 if (tcs->mask & BIT(tcs_id)) in get_req_from_tcs()
197 return tcs->req[tcs_id - tcs->offset]; in get_req_from_tcs()
308 static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs, in check_for_req_inflight() argument
314 int tcs_id = tcs->offset; in check_for_req_inflight()
316 for (i = 0; i < tcs->num_tcs; i++, tcs_id++) { in check_for_req_inflight()
334 static int find_free_tcs(struct tcs_group *tcs) in find_free_tcs() argument
338 for (i = 0; i < tcs->num_tcs; i++) { in find_free_tcs()
339 if (tcs_is_free(tcs->drv, tcs->offset + i)) in find_free_tcs()
340 return tcs->offset + i; in find_free_tcs()
348 struct tcs_group *tcs; in tcs_write() local
353 tcs = get_tcs_for_msg(drv, msg); in tcs_write()
354 if (IS_ERR(tcs)) in tcs_write()
355 return PTR_ERR(tcs); in tcs_write()
357 spin_lock_irqsave(&tcs->lock, flags); in tcs_write()
363 ret = check_for_req_inflight(drv, tcs, msg); in tcs_write()
369 tcs_id = find_free_tcs(tcs); in tcs_write()
376 tcs->req[tcs_id - tcs->offset] = msg; in tcs_write()
384 spin_unlock_irqrestore(&tcs->lock, flags); in tcs_write()
420 static int find_match(const struct tcs_group *tcs, const struct tcs_cmd *cmd, in find_match() argument
426 for_each_set_bit(i, tcs->slots, MAX_TCS_SLOTS) { in find_match()
427 if (tcs->cmd_cache[i] != cmd[0].addr) in find_match()
429 if (i + len >= tcs->num_tcs * tcs->ncpt) in find_match()
432 if (tcs->cmd_cache[i + j] != cmd[j].addr) in find_match()
445 static int find_slots(struct tcs_group *tcs, const struct tcs_request *msg, in find_slots() argument
452 slot = find_match(tcs, msg->cmds, msg->num_cmds); in find_slots()
458 slot = bitmap_find_next_zero_area(tcs->slots, MAX_TCS_SLOTS, in find_slots()
460 if (slot == tcs->num_tcs * tcs->ncpt) in find_slots()
462 i += tcs->ncpt; in find_slots()
466 bitmap_set(tcs->slots, slot, msg->num_cmds); in find_slots()
469 tcs->cmd_cache[slot + i] = msg->cmds[i].addr; in find_slots()
471 offset = slot / tcs->ncpt; in find_slots()
472 *tcs_id = offset + tcs->offset; in find_slots()
473 *cmd_id = slot % tcs->ncpt; in find_slots()
480 struct tcs_group *tcs; in tcs_ctrl_write() local
485 tcs = get_tcs_for_msg(drv, msg); in tcs_ctrl_write()
486 if (IS_ERR(tcs)) in tcs_ctrl_write()
487 return PTR_ERR(tcs); in tcs_ctrl_write()
489 spin_lock_irqsave(&tcs->lock, flags); in tcs_ctrl_write()
491 ret = find_slots(tcs, msg, &tcs_id, &cmd_id); in tcs_ctrl_write()
494 spin_unlock_irqrestore(&tcs->lock, flags); in tcs_ctrl_write()
532 struct tcs_group *tcs; in rpmh_probe_tcs_config() local
578 tcs = &drv->tcs[tcs_cfg[i].type]; in rpmh_probe_tcs_config()
579 if (tcs->drv) in rpmh_probe_tcs_config()
581 tcs->drv = drv; in rpmh_probe_tcs_config()
582 tcs->type = tcs_cfg[i].type; in rpmh_probe_tcs_config()
583 tcs->num_tcs = tcs_cfg[i].n; in rpmh_probe_tcs_config()
584 tcs->ncpt = ncpt; in rpmh_probe_tcs_config()
585 spin_lock_init(&tcs->lock); in rpmh_probe_tcs_config()
587 if (!tcs->num_tcs || tcs->type == CONTROL_TCS) in rpmh_probe_tcs_config()
590 if (st + tcs->num_tcs > max_tcs || in rpmh_probe_tcs_config()
591 st + tcs->num_tcs >= BITS_PER_BYTE * sizeof(tcs->mask)) in rpmh_probe_tcs_config()
594 tcs->mask = ((1 << tcs->num_tcs) - 1) << st; in rpmh_probe_tcs_config()
595 tcs->offset = st; in rpmh_probe_tcs_config()
596 st += tcs->num_tcs; in rpmh_probe_tcs_config()
602 if (tcs->type == ACTIVE_TCS) in rpmh_probe_tcs_config()
605 tcs->cmd_cache = devm_kcalloc(&pdev->dev, in rpmh_probe_tcs_config()
606 tcs->num_tcs * ncpt, sizeof(u32), in rpmh_probe_tcs_config()
608 if (!tcs->cmd_cache) in rpmh_probe_tcs_config()
665 write_tcs_reg(drv, RSC_DRV_IRQ_ENABLE, 0, drv->tcs[ACTIVE_TCS].mask); in rpmh_rsc_probe()