From nobody Wed Sep 04 21:50:49 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 4WzblY3fs3z5VRmT; Wed, 04 Sep 2024 21:50:49 +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 4WzblY26Dtz4hFS; Wed, 4 Sep 2024 21:50:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725486649; 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=MmRimT17N0Nb0TznJREFkc5z3XOgBd+zyykcZuCfBew=; b=YQeGWRbKgV7acXxIRTeuLg9aeX95t1XTvmfmH76iGeHhSOAQi53MSK4lMWDmLFjyPdW5qj 3S0V8ZJ+TZEXTTfLzKhmTlwYHN1/2VbPt+KpEdNsI9v8oWuZLfQOvKOVQoMKJQFw60yQdx tdXGWnExQH1Ht9plF2PgqLcxC5gAN6sBPlLcije3GO4tVnzEhb1tW0Bp0cNxuo5frQTm+k S/iyVdkd64Dv/ak+87PKgyTnRghEPwLaoltvVqZK149ZtKGo/S6hUOFPhgH1y/qwGwcJx3 BCu38Ol18KemkvyEgLCY8r/r97igSWjaKIXkgCc1nc2MUm3m/K4sziOfhe0SHQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725486649; a=rsa-sha256; cv=none; b=as/AI1wJQiyCINfch216LM+0m+Co57ENJpUuhQU/lbfdiiz90iRoMM7DVtAXadW8Cq45Ys Dw97y1gMAgr/yB2NagzQXK8ZddeuQ44e8P/pm34NF/9h5KWa+EYaPlAGFZAQZKEbLijDty o4Ga4311naOWTxjrjeltjWWsLkzws8FCV3teBIzwEaJ9r9V03ix24bsaCy3SU3CxAqIIom dawEwkkwr53OcxwDN2luCgOebWSjWumcay3TG/TC6yMmymNaVyF9y9A71IqFcvG4b8TmAR iPInaDlm5EgDxPzxQi1iyYgp7gaA0EuFZL0YCAg5i3c29oSxj3tI1GyzGuTSVQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725486649; 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=MmRimT17N0Nb0TznJREFkc5z3XOgBd+zyykcZuCfBew=; b=HTXBvT0luHMpNw1n4u1RSgOfiXyF097SMwcoCz8KPSBasxB34UA72MMXftWXt1AUuYIk8K PTVN6BD6OxIuW37zFqzsNHiwaxQvcoQfG1WR6BYoW5He9xrQtmqZRJSkfXzE+6wAhtR/zD RVFD71CRJ6UaSRQXG5EMjsSj3Xf2dxspHIhgk6K4DcyM2ggVfv/w4Zln+B53+bnCM7cSvM rhzZll2HOlUtLc2JUzcj0pQIYEKSJhMtTXVRolMMMuoh+snF7wuPDDWhWYxLyfLgWgmG0o i+I6lryVqaYIhwtbBbGaT77xOgR2OJ5CxFb8TGM55nH0mNTRM71ko+YXZmEtpA== 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 4WzblY1k1fzhL7; Wed, 4 Sep 2024 21:50:49 +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 484LonDD032844; Wed, 4 Sep 2024 21:50:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 484Lonvj032841; Wed, 4 Sep 2024 21:50:49 GMT (envelope-from git) Date: Wed, 4 Sep 2024 21:50:49 GMT Message-Id: <202409042150.484Lonvj032841@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: b3042e3a7c6f - main - x86 dmar: generalize dmar_domain_free_entry() into iommu_domain_free_entry() 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/main X-Git-Reftype: branch X-Git-Commit: b3042e3a7c6ffee3867d52b192c6a9f4f49faf4b Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=b3042e3a7c6ffee3867d52b192c6a9f4f49faf4b commit b3042e3a7c6ffee3867d52b192c6a9f4f49faf4b Author: Konstantin Belousov AuthorDate: 2024-07-07 03:22:00 +0000 Commit: Konstantin Belousov CommitDate: 2024-09-04 21:50:19 +0000 x86 dmar: generalize dmar_domain_free_entry() into iommu_domain_free_entry() Sponsored by: Advanced Micro Devices (AMD) Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/x86/iommu/intel_ctx.c | 19 +++---------------- sys/x86/iommu/intel_dmar.h | 1 - sys/x86/iommu/iommu_utils.c | 14 ++++++++++++++ sys/x86/iommu/x86_iommu.h | 2 ++ 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/sys/x86/iommu/intel_ctx.c b/sys/x86/iommu/intel_ctx.c index 12dd0f0a5259..9167bfd13589 100644 --- a/sys/x86/iommu/intel_ctx.c +++ b/sys/x86/iommu/intel_ctx.c @@ -833,19 +833,6 @@ dmar_find_ctx_locked(struct dmar_unit *dmar, uint16_t rid) return (NULL); } -void -dmar_domain_free_entry(struct iommu_map_entry *entry, bool free) -{ - if ((entry->flags & IOMMU_MAP_ENTRY_RMRR) != 0) - iommu_gas_free_region(entry); - else - iommu_gas_free_space(entry); - if (free) - iommu_gas_free_entry(entry); - else - entry->flags = 0; -} - /* * If the given value for "free" is true, then the caller must not be using * the entry's dmamap_link field. @@ -874,12 +861,12 @@ dmar_domain_unload_entry(struct iommu_map_entry *entry, bool free, } else { iommu_qi_invalidate_sync(&domain->iodom, entry->start, entry->end - entry->start, cansleep); - dmar_domain_free_entry(entry, false); + iommu_domain_free_entry(entry, false); } } else { domain_flush_iotlb_sync(domain, entry->start, entry->end - entry->start); - dmar_domain_free_entry(entry, free); + iommu_domain_free_entry(entry, free); } } @@ -915,7 +902,7 @@ dmar_domain_unload(struct iommu_domain *iodom, domain_flush_iotlb_sync(domain, entry->start, entry->end - entry->start); TAILQ_REMOVE(entries, entry, dmamap_link); - dmar_domain_free_entry(entry, true); + iommu_domain_free_entry(entry, true); } } if (TAILQ_EMPTY(entries)) diff --git a/sys/x86/iommu/intel_dmar.h b/sys/x86/iommu/intel_dmar.h index 0242e0cb954f..edb152f42fe7 100644 --- a/sys/x86/iommu/intel_dmar.h +++ b/sys/x86/iommu/intel_dmar.h @@ -243,7 +243,6 @@ 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); -void dmar_domain_free_entry(struct iommu_map_entry *entry, bool free); void dmar_domain_unload_entry(struct iommu_map_entry *entry, bool free, bool cansleep); void dmar_domain_unload(struct iommu_domain *iodom, diff --git a/sys/x86/iommu/iommu_utils.c b/sys/x86/iommu/iommu_utils.c index 20ca7890ce65..9c6cae5ff51f 100644 --- a/sys/x86/iommu/iommu_utils.c +++ b/sys/x86/iommu/iommu_utils.c @@ -605,3 +605,17 @@ iommu_device_tag_init(struct iommu_ctx *ctx, device_t dev) ctx->tag->ctx = ctx; ctx->tag->owner = dev; } + +void +iommu_domain_free_entry(struct iommu_map_entry *entry, bool free) +{ + if ((entry->flags & IOMMU_MAP_ENTRY_RMRR) != 0) + iommu_gas_free_region(entry); + else + iommu_gas_free_space(entry); + if (free) + iommu_gas_free_entry(entry); + else + entry->flags = 0; +} + diff --git a/sys/x86/iommu/x86_iommu.h b/sys/x86/iommu/x86_iommu.h index 5f56a2db74b5..9e3a82283729 100644 --- a/sys/x86/iommu/x86_iommu.h +++ b/sys/x86/iommu/x86_iommu.h @@ -167,6 +167,8 @@ struct x86_unit_common { struct iommu_msi_data intrs[IOMMU_MAX_MSI]; }; +void iommu_domain_free_entry(struct iommu_map_entry *entry, bool free); + void iommu_qi_emit_wait_seq(struct iommu_unit *unit, struct iommu_qi_genseq * pseq, bool emit_wait); void iommu_qi_wait_for_seq(struct iommu_unit *unit, const struct