1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-18 02:19:39 +00:00

iommu: extract driver-independent ddb context and mapping reporting

Sponsored by:	Advanced Micro Devices (AMD)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2024-10-12 23:18:05 +03:00
parent e9d948cfe0
commit c9e22c749c
3 changed files with 42 additions and 23 deletions

View File

@ -1057,8 +1057,6 @@ static void
dmar_print_domain(struct dmar_domain *domain, bool show_mappings)
{
struct iommu_domain *iodom;
struct iommu_map_entry *entry;
struct iommu_ctx *ctx;
iodom = DOM2IODOM(domain);
@ -1068,27 +1066,11 @@ dmar_print_domain(struct dmar_domain *domain, bool show_mappings)
domain, domain->domain, domain->mgaw, domain->agaw, domain->pglvl,
(uintmax_t)domain->iodom.end, domain->refs, domain->ctx_cnt,
domain->iodom.flags, domain->pgtbl_obj, domain->iodom.entries_cnt);
if (!LIST_EMPTY(&iodom->contexts)) {
db_printf(" Contexts:\n");
LIST_FOREACH(ctx, &iodom->contexts, link)
iommu_db_print_ctx(ctx);
}
if (!show_mappings)
return;
db_printf(" mapped:\n");
RB_FOREACH(entry, iommu_gas_entries_tree, &iodom->rb_root) {
iommu_db_print_domain_entry(entry);
if (db_pager_quit)
break;
}
if (db_pager_quit)
return;
db_printf(" unloading:\n");
TAILQ_FOREACH(entry, &domain->iodom.unload_entries, dmamap_link) {
iommu_db_print_domain_entry(entry);
if (db_pager_quit)
break;
}
iommu_db_domain_print_contexts(iodom);
if (show_mappings)
iommu_db_domain_print_mappings(iodom);
}
DB_SHOW_COMMAND_FLAGS(dmar_domain, db_dmar_print_domain, CS_OWN)

View File

@ -796,4 +796,39 @@ iommu_db_print_ctx(struct iommu_ctx *ctx)
pci_get_function(ctx->tag->owner), ctx->refs,
ctx->flags, ctx->loads, ctx->unloads);
}
void
iommu_db_domain_print_contexts(struct iommu_domain *iodom)
{
struct iommu_ctx *ctx;
if (LIST_EMPTY(&iodom->contexts))
return;
db_printf(" Contexts:\n");
LIST_FOREACH(ctx, &iodom->contexts, link)
iommu_db_print_ctx(ctx);
}
void
iommu_db_domain_print_mappings(struct iommu_domain *iodom)
{
struct iommu_map_entry *entry;
db_printf(" mapped:\n");
RB_FOREACH(entry, iommu_gas_entries_tree, &iodom->rb_root) {
iommu_db_print_domain_entry(entry);
if (db_pager_quit)
break;
}
if (db_pager_quit)
return;
db_printf(" unloading:\n");
TAILQ_FOREACH(entry, &iodom->unload_entries, dmamap_link) {
iommu_db_print_domain_entry(entry);
if (db_pager_quit)
break;
}
}
#endif

View File

@ -196,5 +196,7 @@ iommu_gaddr_t pglvl_page_size(int total_pglvl, int lvl);
void iommu_db_print_domain_entry(const struct iommu_map_entry *entry);
void iommu_db_print_ctx(struct iommu_ctx *ctx);
void iommu_db_domain_print_contexts(struct iommu_domain *iodom);
void iommu_db_domain_print_mappings(struct iommu_domain *iodom);
#endif