Lines Matching defs:tcs

31 #include <soc/qcom/tcs.h>
102 * specified in the device tree by "qcom,tcs-offset" and used to
105 * specified by the device tree as "qcom,tcs-config".
264 struct tcs_group *tcs = &drv->tcs[type];
267 if (bitmap_empty(tcs->slots, MAX_TCS_SLOTS))
270 for (m = tcs->offset; m < tcs->offset + tcs->num_tcs; m++)
273 bitmap_zero(tcs->slots, MAX_TCS_SLOTS);
304 struct tcs_group *tcs;
327 tcs = &drv->tcs[type];
328 if (msg->state == RPMH_ACTIVE_ONLY_STATE && !tcs->num_tcs)
329 tcs = &drv->tcs[WAKE_TCS];
331 return tcs;
353 struct tcs_group *tcs;
357 tcs = &drv->tcs[i];
358 if (tcs->mask & BIT(tcs_id))
359 return tcs->req[tcs_id - tcs->offset];
456 * If wake tcs was re-purposed for sending active
460 if (!drv->tcs[ACTIVE_TCS].num_tcs)
473 if (!drv->tcs[ACTIVE_TCS].num_tcs)
529 * @tcs: A pointer to the tcs_group used for ACTIVE_ONLY transfers.
546 static int check_for_req_inflight(struct rsc_drv *drv, struct tcs_group *tcs,
552 int i = tcs->offset;
554 for_each_set_bit_from(i, drv->tcs_in_use, tcs->offset + tcs->num_tcs) {
570 * find_free_tcs() - Find free tcs in the given tcs_group; only for active.
571 * @tcs: A pointer to the active-only tcs_group (or the wake tcs_group if
576 * Return: The first tcs that's free or -EBUSY if all in use.
578 static int find_free_tcs(struct tcs_group *tcs)
580 const struct rsc_drv *drv = tcs->drv;
582 unsigned long max = tcs->offset + tcs->num_tcs;
584 i = find_next_zero_bit(drv->tcs_in_use, max, tcs->offset);
592 * claim_tcs_for_req() - Claim a tcs in the given tcs_group; only for active.
594 * @tcs: The tcs_group used for ACTIVE_ONLY transfers.
597 * Claims a tcs in the given tcs_group while making sure that no existing cmd
603 * Return: The id of the claimed tcs or -EBUSY if a matching msg is in flight
606 static int claim_tcs_for_req(struct rsc_drv *drv, struct tcs_group *tcs,
615 ret = check_for_req_inflight(drv, tcs, msg);
619 return find_free_tcs(tcs);
646 struct tcs_group *tcs;
650 tcs = get_tcs_for_msg(drv, msg);
651 if (IS_ERR(tcs))
652 return PTR_ERR(tcs);
656 /* Wait forever for a free tcs. It better be there eventually! */
658 (tcs_id = claim_tcs_for_req(drv, tcs, msg)) >= 0,
661 tcs->req[tcs_id - tcs->offset] = msg;
663 if (msg->state == RPMH_ACTIVE_ONLY_STATE && tcs->type != ACTIVE_TCS) {
666 * repurposed TCS to avoid triggering them. tcs->slots will be
690 * @tcs: The tcs group to search.
699 * tcs->slots for.
703 static int find_slots(struct tcs_group *tcs, const struct tcs_request *msg,
711 slot = bitmap_find_next_zero_area(tcs->slots, MAX_TCS_SLOTS,
713 if (slot >= tcs->num_tcs * tcs->ncpt)
715 i += tcs->ncpt;
718 bitmap_set(tcs->slots, slot, msg->num_cmds);
720 offset = slot / tcs->ncpt;
721 *tcs_id = offset + tcs->offset;
722 *cmd_id = slot % tcs->ncpt;
742 struct tcs_group *tcs;
746 tcs = get_tcs_for_msg(drv, msg);
747 if (IS_ERR(tcs))
748 return PTR_ERR(tcs);
751 ret = find_slots(tcs, msg, &tcs_id, &cmd_id);
776 const struct tcs_group *tcs = &drv->tcs[ACTIVE_TCS];
785 if (!tcs->num_tcs)
786 tcs = &drv->tcs[WAKE_TCS];
788 max = tcs->offset + tcs->num_tcs;
789 set = find_next_bit(drv->tcs_in_use, max, tcs->offset);
807 if (!drv->tcs[CONTROL_TCS].num_tcs || !drv->genpd_nb.notifier_call)
970 struct tcs_group *tcs;
972 ret = of_property_read_u32(dn, "qcom,tcs-offset", &offset);
986 n = of_property_count_u32_elems(dn, "qcom,tcs-config");
991 ret = of_property_read_u32_index(dn, "qcom,tcs-config",
998 ret = of_property_read_u32_index(dn, "qcom,tcs-config",
1007 tcs = &drv->tcs[tcs_cfg[i].type];
1008 if (tcs->drv)
1010 tcs->drv = drv;
1011 tcs->type = tcs_cfg[i].type;
1012 tcs->num_tcs = tcs_cfg[i].n;
1013 tcs->ncpt = ncpt;
1015 if (!tcs->num_tcs || tcs->type == CONTROL_TCS)
1018 if (st + tcs->num_tcs > max_tcs ||
1019 st + tcs->num_tcs >= BITS_PER_BYTE * sizeof(tcs->mask))
1022 tcs->mask = ((1 << tcs->num_tcs) - 1) << st;
1023 tcs->offset = st;
1024 st += tcs->num_tcs;
1119 writel_relaxed(drv->tcs[ACTIVE_TCS].mask,