git: c9e22c749c0f - main - iommu: extract driver-independent ddb context and mapping reporting
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 13 Oct 2024 22:30:53 UTC
The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c9e22c749c0f3950b4526f630f6853ab104ab52f commit c9e22c749c0f3950b4526f630f6853ab104ab52f Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-10-12 20:18:05 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-10-13 22:30:26 +0000 iommu: extract driver-independent ddb context and mapping reporting Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/x86/iommu/intel_drv.c | 28 +++++----------------------- sys/x86/iommu/iommu_utils.c | 35 +++++++++++++++++++++++++++++++++++ sys/x86/iommu/x86_iommu.h | 2 ++ 3 files changed, 42 insertions(+), 23 deletions(-) diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index e973115df21b..ebc77879480b 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -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) diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c index fde3f150947b..259c87403b07 100644 --- a/sys/x86/iommu/iommu_utils.c +++ b/sys/x86/iommu/iommu_utils.c @@ -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 diff --git a/sys/x86/iommu/x86_iommu.h b/sys/x86/iommu/x86_iommu.h index 043935a3e0de..92ac993e7c9c 100644 --- a/sys/x86/iommu/x86_iommu.h +++ b/sys/x86/iommu/x86_iommu.h @@ -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