From nobody Sat Nov 09 20:19:20 2024 X-Original-To: dev-commits-src-all@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 4Xm6bX5b9mz5ccl9; Sat, 09 Nov 2024 20:19:20 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xm6bX4VVTz4fMW; Sat, 9 Nov 2024 20:19:20 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731183560; 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=ptPGWG/BFNoDXzCTtDvUhE2rUQpXT9yK+S3RchObdtE=; b=EHLWs4eT/094QXxGQ5Fx3zq0kb0EFKYQ+mZASvCcYjL98Q2xG5seB4MLKGbYb8KP/06t3H OsCpNT1owjzA7UXsgmhR6X+BFs8Rv4VjbO7LLiFjp0YxPaaXcHWN3eimSPiwY0lADJvE+7 p2DlkM6bwaqLZ0mNrwOZiLqQoAlqBhKmvAP3zw4Fr3r9d60xZIkbg7VC6HGDisGYHTdOvC Dg8JiO6G/iY5AV6DDKq+c37QQKeJ99WU/FkR9f+CYxcHXjuZ4JOH18N9D6x4irOb+bMITb 96rovODc8e0C6LY/8eOsrJtGm7GQcRxG+V1BPV+RMxa3W9zYGfz2ya1lM4nU8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731183560; 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=ptPGWG/BFNoDXzCTtDvUhE2rUQpXT9yK+S3RchObdtE=; b=pWy724KwytKQIURlNFLDqB8jEu58vuod/rph2SQsFllVXq+6ATxH8FcwLuMRLLmFxS+xyg zjqjlSyDg6OxEYPixN4XB1/nggyjbtSNnDfLEI+Ama8QTCVWLSCmG6JixYt6Jjphawlay5 d56NuQm1mJHnUi84Lx9PiySuVb6Rf3W10pdCTx+wbjklri0puwh8jOItq9fIOIcupJ4pYv dT/eHo98AIIz4sBwj/jw1uGZFcg6e13qMtAhP48NX+rmEMjnnBWTAdFRCdGizalIMmXRbu 90IJP7CYUCoWGtURjV8zq9qJIJDHNTs7MWlGXDITheQsHv2DXay1ywg4tpmASw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731183560; a=rsa-sha256; cv=none; b=Y3a6rjAZiibI/SZcpTMcypjFDAIY9d163kxztiNMkA4PbrmSNaGs+/bPunjWLHiLK57S1N lXMfzGo20jQ5es2h3sjxSMaHTlRlBs82t3lsaRcd2eEt26QHlqUvQYpkBNl8cByG7Neze5 EFs1+M2MGc55fGVQ2o0pj7YJ+lWMVweC1t8naf37QgWQk5yTNIGQID0KQMdPLQgLZjEOWi lfCUdevL2QJzYOZ8yCktQrlRB8QchrLSulKesm5CSNN+b6tCjQTT5MMDzVCMVmRhy0Rajs Er3lv5QjOzZWr43CWyTfMrBv0ycwmR4LapxismBmYdNdfOaAjClGV0LlrSFtgg== 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 4Xm6bX2ZZ2z1RBZ; Sat, 9 Nov 2024 20:19:20 +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 4A9KJKdp033720; Sat, 9 Nov 2024 20:19:20 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A9KJKvt033716; Sat, 9 Nov 2024 20:19:20 GMT (envelope-from git) Date: Sat, 9 Nov 2024 20:19:20 GMT Message-Id: <202411092019.4A9KJKvt033716@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: ae81fb2db3df - stable/14 - iommu: eliminate iommu_free_ctx() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: ae81fb2db3df71e96fc154c72a1327dd3675f1a6 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=ae81fb2db3df71e96fc154c72a1327dd3675f1a6 commit ae81fb2db3df71e96fc154c72a1327dd3675f1a6 Author: Konstantin Belousov AuthorDate: 2024-11-03 14:50:01 +0000 Commit: Konstantin Belousov CommitDate: 2024-11-09 19:31:28 +0000 iommu: eliminate iommu_free_ctx() iommu_free_ctx_locked() alone is enough Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week (cherry picked from commit d97838b7c2a605932b6edf36f87abe7ccce74314) --- sys/arm64/iommu/iommu.c | 19 +++---------------- sys/dev/iommu/busdma_iommu.c | 10 ++++++++-- sys/x86/iommu/amd_ctx.c | 19 ------------------- sys/x86/iommu/amd_drv.c | 1 - sys/x86/iommu/amd_iommu.h | 1 - sys/x86/iommu/intel_ctx.c | 19 ------------------- sys/x86/iommu/intel_dmar.h | 1 - sys/x86/iommu/intel_drv.c | 1 - sys/x86/iommu/iommu_utils.c | 6 ------ sys/x86/iommu/x86_iommu.h | 1 - 10 files changed, 11 insertions(+), 67 deletions(-) diff --git a/sys/arm64/iommu/iommu.c b/sys/arm64/iommu/iommu.c index eb682a4a623f..afb5c7c5e152 100644 --- a/sys/arm64/iommu/iommu.c +++ b/sys/arm64/iommu/iommu.c @@ -375,32 +375,19 @@ void iommu_free_ctx_locked(struct iommu_unit *iommu, struct iommu_ctx *ioctx) { struct bus_dma_tag_iommu *tag; + int error; IOMMU_ASSERT_LOCKED(iommu); tag = ioctx->tag; IOMMU_CTX_FREE(iommu->dev, ioctx); + IOMMU_UNLOCK(iommu); free(tag, M_IOMMU); -} - -void -iommu_free_ctx(struct iommu_ctx *ioctx) -{ - struct iommu_unit *iommu; - struct iommu_domain *iodom; - int error; - - iodom = ioctx->domain; - iommu = iodom->iommu; - - IOMMU_LOCK(iommu); - iommu_free_ctx_locked(iommu, ioctx); - IOMMU_UNLOCK(iommu); /* Since we have a domain per each ctx, remove the domain too. */ - error = iommu_domain_free(iodom); + error = iommu_domain_free(ioctx->domain); if (error) device_printf(iommu->dev, "Could not free a domain\n"); } diff --git a/sys/dev/iommu/busdma_iommu.c b/sys/dev/iommu/busdma_iommu.c index dbd4ee0ef0f1..8c97965bcdf1 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -400,6 +400,8 @@ iommu_bus_dma_tag_destroy(bus_dma_tag_t dmat1) { struct bus_dma_tag_iommu *dmat, *parent; struct bus_dma_tag_iommu *dmat_copy __unused; + struct iommu_unit *iommu; + struct iommu_ctx *ctx; int error; error = 0; @@ -414,8 +416,12 @@ iommu_bus_dma_tag_destroy(bus_dma_tag_t dmat1) parent = (struct bus_dma_tag_iommu *)dmat->common.parent; if (atomic_fetchadd_int(&dmat->common.ref_count, -1) == 1) { - if (dmat == dmat->ctx->tag) - iommu_free_ctx(dmat->ctx); + ctx = dmat->ctx; + if (dmat == ctx->tag) { + iommu = ctx->domain->iommu; + IOMMU_LOCK(iommu); + iommu_free_ctx_locked(iommu, dmat->ctx); + } free(dmat->segments, M_IOMMU_DMAMAP); free(dmat, M_DEVBUF); dmat = parent; diff --git a/sys/x86/iommu/amd_ctx.c b/sys/x86/iommu/amd_ctx.c index 81e284373fc8..7f0e67f37eef 100644 --- a/sys/x86/iommu/amd_ctx.c +++ b/sys/x86/iommu/amd_ctx.c @@ -398,16 +398,6 @@ amdiommu_free_ctx_locked(struct amdiommu_unit *unit, struct amdiommu_ctx *ctx) amdiommu_unref_domain_locked(unit, domain); } -static void -amdiommu_free_ctx(struct amdiommu_ctx *ctx) -{ - struct amdiommu_unit *unit; - - unit = CTX2AMD(ctx); - AMDIOMMU_LOCK(unit); - amdiommu_free_ctx_locked(unit, ctx); -} - static void amdiommu_unref_domain_locked(struct amdiommu_unit *unit, struct amdiommu_domain *domain) @@ -628,12 +618,3 @@ amdiommu_free_ctx_locked_method(struct iommu_unit *iommu, ctx = IOCTX2CTX(context); amdiommu_free_ctx_locked(unit, ctx); } - -void -amdiommu_free_ctx_method(struct iommu_ctx *context) -{ - struct amdiommu_ctx *ctx; - - ctx = IOCTX2CTX(context); - amdiommu_free_ctx(ctx); -} diff --git a/sys/x86/iommu/amd_drv.c b/sys/x86/iommu/amd_drv.c index 513463f21292..2c544dfb60a6 100644 --- a/sys/x86/iommu/amd_drv.c +++ b/sys/x86/iommu/amd_drv.c @@ -1072,7 +1072,6 @@ static struct x86_iommu amd_x86_iommu = { .domain_unload = amdiommu_domain_unload, .get_ctx = amdiommu_get_ctx, .free_ctx_locked = amdiommu_free_ctx_locked_method, - .free_ctx = amdiommu_free_ctx_method, .alloc_msi_intr = amdiommu_alloc_msi_intr, .map_msi_intr = amdiommu_map_msi_intr, .unmap_msi_intr = amdiommu_unmap_msi_intr, diff --git a/sys/x86/iommu/amd_iommu.h b/sys/x86/iommu/amd_iommu.h index 2b0db4f8fe6d..64dd13db9745 100644 --- a/sys/x86/iommu/amd_iommu.h +++ b/sys/x86/iommu/amd_iommu.h @@ -222,7 +222,6 @@ struct amdiommu_ctx *amdiommu_find_ctx_locked(struct amdiommu_unit *unit, uint16_t rid); void amdiommu_free_ctx_locked_method(struct iommu_unit *iommu, struct iommu_ctx *context); -void amdiommu_free_ctx_method(struct iommu_ctx *context); struct amdiommu_domain *amdiommu_find_domain(struct amdiommu_unit *unit, uint16_t rid); diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c index c7c7012e94ea..ae74d0456b25 100644 --- a/sys/x86/iommu/intel_ctx.c +++ b/sys/x86/iommu/intel_ctx.c @@ -804,16 +804,6 @@ dmar_free_ctx_locked(struct dmar_unit *dmar, struct dmar_ctx *ctx) TD_PINNED_ASSERT; } -static void -dmar_free_ctx(struct dmar_ctx *ctx) -{ - struct dmar_unit *dmar; - - dmar = CTX2DMAR(ctx); - DMAR_LOCK(dmar); - dmar_free_ctx_locked(dmar, ctx); -} - /* * Returns with the domain locked. */ @@ -942,12 +932,3 @@ dmar_free_ctx_locked_method(struct iommu_unit *iommu, ctx = IOCTX2CTX(context); dmar_free_ctx_locked(dmar, ctx); } - -void -dmar_free_ctx_method(struct iommu_ctx *context) -{ - struct dmar_ctx *ctx; - - ctx = IOCTX2CTX(context); - dmar_free_ctx(ctx); -} diff --git a/sys/x86/iommu/intel_dmar.h b/sys/x86/iommu/intel_dmar.h index 1a9b5041975c..57a66aae69b2 100644 --- a/sys/x86/iommu/intel_dmar.h +++ b/sys/x86/iommu/intel_dmar.h @@ -237,7 +237,6 @@ struct dmar_ctx *dmar_get_ctx_for_devpath(struct dmar_unit *dmar, uint16_t rid, int dmar_move_ctx_to_domain(struct dmar_domain *domain, struct dmar_ctx *ctx); void dmar_free_ctx_locked_method(struct iommu_unit *dmar, struct iommu_ctx *ctx); -void dmar_free_ctx_method(struct iommu_ctx *ctx); struct dmar_ctx *dmar_find_ctx_locked(struct dmar_unit *dmar, uint16_t rid); struct iommu_ctx *dmar_get_ctx(struct iommu_unit *iommu, device_t dev, uint16_t rid, bool id_mapped, bool rmrr_init); diff --git a/sys/x86/iommu/intel_drv.c b/sys/x86/iommu/intel_drv.c index 22d04029f9ae..b21c8460e830 100644 --- a/sys/x86/iommu/intel_drv.c +++ b/sys/x86/iommu/intel_drv.c @@ -1317,7 +1317,6 @@ static struct x86_iommu dmar_x86_iommu = { .domain_unload = dmar_domain_unload, .get_ctx = dmar_get_ctx, .free_ctx_locked = dmar_free_ctx_locked_method, - .free_ctx = dmar_free_ctx_method, .find = dmar_find_method, .alloc_msi_intr = dmar_alloc_msi_intr, .map_msi_intr = dmar_map_msi_intr, diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c index 479e8637ee8e..2db02a98ca91 100644 --- a/sys/x86/iommu/iommu_utils.c +++ b/sys/x86/iommu/iommu_utils.c @@ -288,12 +288,6 @@ iommu_free_ctx_locked(struct iommu_unit *iommu, struct iommu_ctx *context) x86_iommu->free_ctx_locked(iommu, context); } -void -iommu_free_ctx(struct iommu_ctx *context) -{ - x86_iommu->free_ctx(context); -} - struct iommu_unit * iommu_find(device_t dev, bool verbose) { diff --git a/sys/x86/iommu/x86_iommu.h b/sys/x86/iommu/x86_iommu.h index 835a4623a95e..1c9ad6529d47 100644 --- a/sys/x86/iommu/x86_iommu.h +++ b/sys/x86/iommu/x86_iommu.h @@ -81,7 +81,6 @@ struct x86_iommu { device_t dev, uint16_t rid, bool id_mapped, bool rmrr_init); void (*free_ctx_locked)(struct iommu_unit *iommu, struct iommu_ctx *context); - void (*free_ctx)(struct iommu_ctx *context); struct iommu_unit *(*find)(device_t dev, bool verbose); int (*alloc_msi_intr)(device_t src, u_int *cookies, u_int count); int (*map_msi_intr)(device_t src, u_int cpu, u_int vector,