Lines Matching refs:tcs
32 #include <soc/qcom/tcs.h>
103 * specified in the device tree by "qcom,tcs-offset" and used to
106 * specified by the device tree as "qcom,tcs-config".
265 struct tcs_group *tcs = &drv->tcs[type];
268 if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS))
271 for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++)
274 bitmap_zero(tcs->slots, MAX_TCS_SLOTS);
305 struct tcs_group *tcs;
328 tcs = &drv->tcs[type];
329 if (msg->state == RPMH_ACTIVE_ONLY_STATE && !tcs->num_tcs)
330 tcs = &drv->tcs[WAKE_TCS];
332 return tcs;
354 struct tcs_group *tcs;
358 tcs = &drv->tcs[i];
359 if (tcs->mask & BIT(tcs_id))
360 return tcs->req[tcs_id - tcs->offset];
457 * If wake tcs was re-purposed for sending active
461 if (!drv->tcs[ACTIVE_TCS].num_tcs)
474 if (!drv->tcs[ACTIVE_TCS].num_tcs)
530 * @tcs: A pointer to the tcs_group used for ACTIVE_ONLY transfers.
547 static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs,
553 int i = tcs->offset;
555 for_each_set_bit_from(i, drv->tcs_in_use, tcs->offset + tcs->num_tcs) {
571 * find_free_tcs() - Find free tcs in the given tcs_group; only for active.
572 * @tcs: A pointer to the active-only tcs_group (or the wake tcs_group if
577 * Return: The first tcs that's free or -EBUSY if all in use.
579 static int find_free_tcs(struct tcs_group *tcs)
581 const struct rsc_drv *drv = tcs->drv;
583 unsigned long max = tcs->offset + tcs->num_tcs;
585 i = find_next_zero_bit(drv->tcs_in_use, max, tcs->offset);
593 * claim_tcs_for_req() - Claim a tcs in the given tcs_group; only for active.
595 * @tcs: The tcs_group used for ACTIVE_ONLY transfers.
598 * Claims a tcs in the given tcs_group while making sure that no existing cmd
604 * Return: The id of the claimed tcs or -EBUSY if a matching msg is in flight
607 static int claim_tcs_for_req(struct rsc_drv *drv, struct tcs_group *tcs,
616 ret = check_for_req_inflight(drv, tcs, msg);
620 return find_free_tcs(tcs);
647 struct tcs_group *tcs;
652 tcs = get_tcs_for_msg(drv, msg);
653 if (IS_ERR(tcs))
654 return PTR_ERR(tcs);
658 /* Wait forever for a free tcs. It better be there eventually! */
660 (tcs_id = claim_tcs_for_req(drv, tcs, msg)) >= 0,
663 tcs->req[tcs_id - tcs->offset] = msg;
665 if (msg->state == RPMH_ACTIVE_ONLY_STATE && tcs->type != ACTIVE_TCS) {
668 * repurposed TCS to avoid triggering them. tcs->slots will be
692 * @tcs: The tcs group to search.
701 * tcs->slots for.
705 static int find_slots(struct tcs_group *tcs, const struct tcs_request *msg,
713 slot = bitmap_find_next_zero_area(tcs->slots, MAX_TCS_SLOTS,
715 if (slot >= tcs->num_tcs * tcs->ncpt)
717 i += tcs->ncpt;
720 bitmap_set(tcs->slots, slot, msg->num_cmds);
722 offset = slot / tcs->ncpt;
723 *tcs_id = offset + tcs->offset;
724 *cmd_id = slot % tcs->ncpt;
744 struct tcs_group *tcs;
748 tcs = get_tcs_for_msg(drv, msg);
749 if (IS_ERR(tcs))
750 return PTR_ERR(tcs);
753 ret = find_slots(tcs, msg, &tcs_id, &cmd_id);
778 const struct tcs_group *tcs = &drv->tcs[ACTIVE_TCS];
787 if (!tcs->num_tcs)
788 tcs = &drv->tcs[WAKE_TCS];
790 max = tcs->offset + tcs->num_tcs;
791 set = find_next_bit(drv->tcs_in_use, max, tcs->offset);
809 if (!drv->tcs[CONTROL_TCS].num_tcs || !drv->genpd_nb.notifier_call)
972 struct tcs_group *tcs;
974 ret = of_property_read_u32(dn, "qcom,tcs-offset", &offset);
988 n = of_property_count_u32_elems(dn, "qcom,tcs-config");
993 ret = of_property_read_u32_index(dn, "qcom,tcs-config",
1000 ret = of_property_read_u32_index(dn, "qcom,tcs-config",
1009 tcs = &drv->tcs[tcs_cfg[i].type];
1010 if (tcs->drv)
1012 tcs->drv = drv;
1013 tcs->type = tcs_cfg[i].type;
1014 tcs->num_tcs = tcs_cfg[i].n;
1015 tcs->ncpt = ncpt;
1017 if (!tcs->num_tcs || tcs->type == CONTROL_TCS)
1020 if (st + tcs->num_tcs > max_tcs ||
1021 st + tcs->num_tcs >= BITS_PER_BYTE * sizeof(tcs->mask))
1024 tcs->mask = ((1 << tcs->num_tcs) - 1) << st;
1025 tcs->offset = st;
1026 st += tcs->num_tcs;
1118 writel_relaxed(drv->tcs[ACTIVE_TCS].mask,