Lines Matching defs:topa

551  * struct topa - ToPA metadata
558 struct topa {
572 ((PAGE_SIZE - sizeof(struct topa)) / sizeof(struct topa_entry))
577 * @topa: metadata
581 struct topa topa;
584 static inline struct topa_page *topa_to_page(struct topa *topa)
586 return container_of(topa, struct topa_page, topa);
594 static inline phys_addr_t topa_pfn(struct topa *topa)
596 return PFN_DOWN(virt_to_phys(topa_to_page(topa)));
641 static struct topa *topa_alloc(int cpu, gfp_t gfp)
652 tp->topa.last = 0;
659 TOPA_ENTRY(&tp->topa, 1)->base = page_to_phys(p) >> TOPA_SHIFT;
660 TOPA_ENTRY(&tp->topa, 1)->end = 1;
663 return &tp->topa;
668 * @topa: Table to deallocate.
670 static void topa_free(struct topa *topa)
672 free_page((unsigned long)topa);
678 * @topa: New topa table to be inserted.
681 * accordingly; otherwise, add a END=1 link entry to @topa to the current
682 * "last" table and adjust the last table pointer to @topa.
684 static void topa_insert_table(struct pt_buffer *buf, struct topa *topa)
686 struct topa *last = buf->last;
688 list_add_tail(&topa->list, &buf->tables);
691 buf->first = buf->last = buf->cur = topa;
695 topa->offset = last->offset + last->size;
696 buf->last = topa;
703 TOPA_ENTRY(last, -1)->base = topa_pfn(topa);
709 * @topa: ToPA table.
711 static bool topa_table_full(struct topa *topa)
715 return !!topa->last;
717 return topa->last == TENTS_PER_PAGE - 1;
732 struct topa *topa = buf->last;
740 if (topa_table_full(topa)) {
741 topa = topa_alloc(cpu, gfp);
742 if (!topa)
745 topa_insert_table(buf, topa);
748 if (topa->z_count == topa->last - 1) {
749 if (order == TOPA_ENTRY(topa, topa->last - 1)->size)
750 topa->z_count++;
753 TOPA_ENTRY(topa, -1)->base = page_to_phys(p) >> TOPA_SHIFT;
754 TOPA_ENTRY(topa, -1)->size = order;
757 TOPA_ENTRY(topa, -1)->intr = 1;
758 TOPA_ENTRY(topa, -1)->stop = 1;
761 topa->last++;
762 topa->size += sizes(order);
775 struct topa *topa;
777 list_for_each_entry(topa, &buf->tables, list) {
778 struct topa_page *tp = topa_to_page(topa);
782 topa->offset, topa->size);
796 if (!i && topa->z_count)
797 i += topa->z_count;
817 buf->cur = list_entry(buf->cur->list.next, struct topa,
947 buf->cur = &tp->topa;
962 struct topa *topa;
975 list_for_each_entry(topa, &buf->tables, list) {
976 if (topa->offset + topa->size > pg << PAGE_SHIFT)
992 if (WARN_ON_ONCE(topa->last == -1))
995 tp = topa_to_page(topa);
996 cur_pg = PFN_DOWN(topa->offset);
997 if (topa->z_count) {
998 z_pg = TOPA_ENTRY_PAGES(topa, 0) * (topa->z_count + 1);
999 start_idx = topa->z_count + 1;
1007 idx = (pg - cur_pg) / TOPA_ENTRY_PAGES(topa, 0);
1014 for (idx = start_idx, cur_pg += z_pg; idx < topa->last; idx++) {
1015 if (cur_pg + TOPA_ENTRY_PAGES(topa, idx) > pg)
1018 cur_pg += TOPA_ENTRY_PAGES(topa, idx);
1034 struct topa *topa;
1040 topa = &tp->topa;
1041 if (topa == buf->first)
1042 topa = buf->last;
1044 topa = list_prev_entry(topa, list);
1046 tp = topa_to_page(topa);
1048 return &tp->table[topa->last - 1];
1160 buf->cur = &cur_tp->topa;
1177 struct topa *topa, *iter;
1182 list_for_each_entry_safe(topa, iter, &buf->tables, list) {
1187 topa_free(topa);
1200 struct topa *topa;
1203 topa = topa_alloc(cpu, gfp);
1204 if (!topa)
1207 topa_insert_table(buf, topa);
1267 * pt_buffer_setup_aux() - set up topa tables for a PT buffer
1743 BUILD_BUG_ON(sizeof(struct topa) > PAGE_SIZE);