From nobody Sun Oct 13 22:30:53 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XRZnp35ZKz5Yg58; Sun, 13 Oct 2024 22:30:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XRZnp0R4nz4q1f; Sun, 13 Oct 2024 22:30:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728858654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xGGVyIjszI+PP3enzfnm/vA7UcCC88W6Qs2Ht1v6kak=; b=H+D4liFflo0f7gWcRnMfUleRGXGF/QWnGZy6TvaLKhjZw0v3Wnx8bd3KdTX+bydKwHMmDV vxj8qTWwO+2txHUMrtDZw3ZA+HINANNUHlQ/bdcCgLaavkBawL6VaqK+OqoaGm7JG8moEn Ye535SPAofhOqh6JGgKRwS8pDY2vtzxcK6dTCG4Gu5Yv11k+5aNjMLuxTpsBGjfRI1Ghek ikqTdkiRB6CJGC4qpiNTANGe9sbRdfGIsWiWLvhqGB7VfSnNscLelpUFm2m2a6OAReg3NN VpVvdUaNj6oJa1bzo7RpPH0fgMeY2WYbboB6rX52Emd+ZwMSQN/z2foyjc7dvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728858654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=xGGVyIjszI+PP3enzfnm/vA7UcCC88W6Qs2Ht1v6kak=; b=WHyxxoXBYJr6aVPaRZYC+TvqUfQdaMRJSIIkKM+eEJUFRhgXzruxRtLBwl6eXbbEHxKSaE z2oAB60U8OiMvGZ8aWuYI67IyebjDeOq2VdqsXvjKfaAnP9WeOWWMcr3qVZ+X/Z5UcJYq9 UDkY9URYT0WeWj1z5+yqQJqXdVKa2SAaVeK4Oi4Lfs3IpqhtcFsFVH6CGaf4WhrHJ7CWTE PqWcVD1/CZ/pCpLn8+V5XDXT0rXk59iqPK5JRHLNcp2QU9dBhainaNY9+ARnEWFD0WgLHQ GHt67LJi7ZH2kZMxcsf6Q46SpaGcAkO+TnjYMogml/TCxcPnK9mxPBtIt/ihjA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728858654; a=rsa-sha256; cv=none; b=h5rAggK/otIw6jV1GvtAIQ5f2gwqkjqAQDShzMqfmmPFNDGYZznDW/wn+pE4weB3QR/FsK 5wz6V5+ddJHAj5x0rvUF+6KkYffL3STjQSQPJXJKX+hWd/bYR9ZG6hcj1GDW3oaqA74Tcx UDORVHH68I2LoutSacMLWrHm/QTKyp64bZqHZNmvQ/qAQkarSnJt9w7lB/1/hGq4Nta2Gw aveDMY9Wf9kMFI+jptn2QSsYhCE25j4wTK5Ny1CZU1DFgrQBo3GZAPIab4dHiw9UWcGXu2 cgrfQWzlq9ce8/Mnc0+JUJSt/ZoGTFE4wZz2rqhew1HiAYSHLk9K43yFCHISxg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XRZnn6zvmz1BPp; Sun, 13 Oct 2024 22:30:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49DMUrt4040227; Sun, 13 Oct 2024 22:30:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49DMUriK040224; Sun, 13 Oct 2024 22:30:53 GMT (envelope-from git) Date: Sun, 13 Oct 2024 22:30:53 GMT Message-Id: <202410132230.49DMUriK040224@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: c9e22c749c0f - main - iommu: extract driver-independent ddb context and mapping reporting List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c9e22c749c0f3950b4526f630f6853ab104ab52f Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=c9e22c749c0f3950b4526f630f6853ab104ab52f commit c9e22c749c0f3950b4526f630f6853ab104ab52f Author: Konstantin Belousov AuthorDate: 2024-10-12 20:18:05 +0000 Commit: Konstantin Belousov 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