git: b3042e3a7c6f - main - x86 dmar: generalize dmar_domain_free_entry() into iommu_domain_free_entry()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 04 Sep 2024 21:50:49 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=b3042e3a7c6ffee3867d52b192c6a9f4f49faf4b
commit b3042e3a7c6ffee3867d52b192c6a9f4f49faf4b
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2024-07-07 03:22:00 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
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