Lines Matching defs:topa
567 * struct topa - ToPA metadata
574 struct topa {
588 ((PAGE_SIZE - sizeof(struct topa)) / sizeof(struct topa_entry))
593 * @topa: metadata
597 struct topa topa;
600 static inline struct topa_page *topa_to_page(struct topa *topa)
602 return container_of(topa, struct topa_page, topa);
610 static inline phys_addr_t topa_pfn(struct topa *topa)
612 return PFN_DOWN(virt_to_phys(topa_to_page(topa)));
657 static struct topa *topa_alloc(int cpu, gfp_t gfp)
668 tp->topa.last = 0;
675 TOPA_ENTRY(&tp->topa, 1)->base = page_to_phys(p) >> TOPA_SHIFT;
676 TOPA_ENTRY(&tp->topa, 1)->end = 1;
679 return &tp->topa;
684 * @topa: Table to deallocate.
686 static void topa_free(struct topa *topa)
688 free_page((unsigned long)topa);
694 * @topa: New topa table to be inserted.
697 * accordingly; otherwise, add a END=1 link entry to @topa to the current
698 * "last" table and adjust the last table pointer to @topa.
700 static void topa_insert_table(struct pt_buffer *buf, struct topa *topa)
702 struct topa *last = buf->last;
704 list_add_tail(&topa->list, &buf->tables);
707 buf->first = buf->last = buf->cur = topa;
711 topa->offset = last->offset + last->size;
712 buf->last = topa;
719 TOPA_ENTRY(last, -1)->base = topa_pfn(topa);
725 * @topa: ToPA table.
727 static bool topa_table_full(struct topa *topa)
731 return !!topa->last;
733 return topa->last == TENTS_PER_PAGE - 1;
748 struct topa *topa = buf->last;
756 if (topa_table_full(topa)) {
757 topa = topa_alloc(cpu, gfp);
758 if (!topa)
761 topa_insert_table(buf, topa);
764 if (topa->z_count == topa->last - 1) {
765 if (order == TOPA_ENTRY(topa, topa->last - 1)->size)
766 topa->z_count++;
769 TOPA_ENTRY(topa, -1)->base = page_to_phys(p) >> TOPA_SHIFT;
770 TOPA_ENTRY(topa, -1)->size = order;
773 TOPA_ENTRY(topa, -1)->intr = 1;
774 TOPA_ENTRY(topa, -1)->stop = 1;
777 topa->last++;
778 topa->size += sizes(order);
791 struct topa *topa;
793 list_for_each_entry(topa, &buf->tables, list) {
794 struct topa_page *tp = topa_to_page(topa);
798 topa->offset, topa->size);
812 if (!i && topa->z_count)
813 i += topa->z_count;
833 buf->cur = list_entry(buf->cur->list.next, struct topa,
963 buf->cur = &tp->topa;
978 struct topa *topa;
991 list_for_each_entry(topa, &buf->tables, list) {
992 if (topa->offset + topa->size > pg << PAGE_SHIFT)
1008 if (WARN_ON_ONCE(topa->last == -1))
1011 tp = topa_to_page(topa);
1012 cur_pg = PFN_DOWN(topa->offset);
1013 if (topa->z_count) {
1014 z_pg = TOPA_ENTRY_PAGES(topa, 0) * (topa->z_count + 1);
1015 start_idx = topa->z_count + 1;
1023 idx = (pg - cur_pg) / TOPA_ENTRY_PAGES(topa, 0);
1030 for (idx = start_idx, cur_pg += z_pg; idx < topa->last; idx++) {
1031 if (cur_pg + TOPA_ENTRY_PAGES(topa, idx) > pg)
1034 cur_pg += TOPA_ENTRY_PAGES(topa, idx);
1050 struct topa *topa;
1056 topa = &tp->topa;
1057 if (topa == buf->first)
1058 topa = buf->last;
1060 topa = list_prev_entry(topa, list);
1062 tp = topa_to_page(topa);
1064 return &tp->table[topa->last - 1];
1176 buf->cur = &cur_tp->topa;
1193 struct topa *topa, *iter;
1198 list_for_each_entry_safe(topa, iter, &buf->tables, list) {
1203 topa_free(topa);
1216 struct topa *topa;
1219 topa = topa_alloc(cpu, gfp);
1220 if (!topa)
1223 topa_insert_table(buf, topa);
1283 * pt_buffer_setup_aux() - set up topa tables for a PT buffer
1759 BUILD_BUG_ON(sizeof(struct topa) > PAGE_SIZE);