From nobody Sun Nov 03 19:47:46 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 4XhQ9t5Xqkz5cjDH; Sun, 03 Nov 2024 19:47:46 +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 4XhQ9t431Tz4yxh; Sun, 3 Nov 2024 19:47:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730663266; 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=1JoRzX9GMEpDCevUHCEbLKk1c5dE9VKI9HDlHiZ3OY8=; b=nJDWeUUSx0N6nLSvetiswMSwTXP79g2NfsfpuEDfdcgkyPzFynYF0n0KmFVFsPDYF7pU0Z h5dth9M4sbFbgyRUPPikN4+DiP0+zZQ86Cltryd15QndEuhSZITIzMS6RJLDv027tPFwnB 9AHw44r1bVCV4LSa84Fus0b3x/4xdWHJS9xytRiAagiufipQjxKb0WQ+YH3dPC+m+LqLsI znyoL9doAbEwYcBBRRAh4XF4FMDLfYJkv33hg/w4kolC3hmXbfiYByt2KPPkJf/IqdP60x FrRnGutDOxQiJXl4r89Daxz4W9hmHRDM8f52KdmW0F0JKU9mFlSK3WJY8vO3Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730663266; 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=1JoRzX9GMEpDCevUHCEbLKk1c5dE9VKI9HDlHiZ3OY8=; b=QmfkD16cHUnSzUm2PPB28oVJjGJkJonVPmvJ0xco5YuNn2AfkkEL8I2lZXdaq2sHlGS56N /GkBMFriAneQTVtebfI9/BI2W2Z+vAWI8WMVQozLFEjgVst0hdaxdca1XV+ps1PfmQVBla JiKPBZNe+9gfKxgrt7lmPdxF5JKEmzX5U/gSjezZt58n7DWbSkskGd8VI63N7ykXOA0VTH kzMC7aZL6GGIk/n70Lm9bRU+McfvNt7eUDGM2pDfdGrxxppgaly6V28cfr433SalrJMrSP 43PPc3wKYUWTh68yJNalaCMDwD7D6dmvyya3x/vPijaXsMVh4LVS2wwBPNPqpw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730663266; a=rsa-sha256; cv=none; b=a5D5Tjl3b52X39x+ll3NCqJcxOmBXnKq65OrzTYFEEtb+Jx9Ch7J92W469CZ/LnTU4vej6 qKw17GGkOXllhY85UXyi935euhF8ZWHxdyhk313pIxEHlOTFumcCeb6jMGr08MqprUp8eO MoEafRMzHgPCgVsfPvtm8LwxMpAhL1vg9m/VTWjOLJOhzGaXXS4BBuSobz7+3zzgz+46Gj Z65qgJRCshNazXiEHPu2ZdcJSzLUhm05cSVM8k80Qf1pcdlZRmQ2b09cdEAaOQsagFHIby Hh5Ty+IlKvz4lySQ198nVsNY12dkC88gG+NirdNHWUN00YefLbLCjl/s7SfARw== 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 4XhQ9t3K03z12PZ; Sun, 3 Nov 2024 19:47:46 +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 4A3JlkbQ027819; Sun, 3 Nov 2024 19:47:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A3Jlk1W027813; Sun, 3 Nov 2024 19:47:46 GMT (envelope-from git) Date: Sun, 3 Nov 2024 19:47:46 GMT Message-Id: <202411031947.4A3Jlk1W027813@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: d97838b7c2a6 - main - iommu: eliminate iommu_free_ctx() 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: d97838b7c2a605932b6edf36f87abe7ccce74314 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d97838b7c2a605932b6edf36f87abe7ccce74314 commit d97838b7c2a605932b6edf36f87abe7ccce74314 Author: Konstantin Belousov AuthorDate: 2024-11-03 14:50:01 +0000 Commit: Konstantin Belousov CommitDate: 2024-11-03 19:38:19 +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 --- 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 0fe59c5d10b6..5db48b3bc276 100644 --- a/sys/arm64/iommu/iommu.c +++ b/sys/arm64/iommu/iommu.c @@ -373,32 +373,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 4d295ed7c6b2..6856b0551dde 100644 --- a/sys/dev/iommu/busdma_iommu.c +++ b/sys/dev/iommu/busdma_iommu.c @@ -397,6 +397,8 @@ static int iommu_bus_dma_tag_destroy(bus_dma_tag_t dmat1) { struct bus_dma_tag_iommu *dmat; + struct iommu_unit *iommu; + struct iommu_ctx *ctx; int error; error = 0; @@ -407,8 +409,12 @@ iommu_bus_dma_tag_destroy(bus_dma_tag_t dmat1) error = EBUSY; goto out; } - 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); } diff --git a/sys/x86/iommu/amd_ctx.c b/sys/x86/iommu/amd_ctx.c index b3e85350a995..7e41ecf2dc04 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 395cefc65caa..62315902fcd9 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 c2371d4d9c4f..2bc5f8a9d361 100644 --- a/sys/x86/iommu/intel_ctx.c +++ b/sys/x86/iommu/intel_ctx.c @@ -803,16 +803,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. */ @@ -941,12 +931,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 eb4a9907a5d6..431228512fd8 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,