busdma_iommu: indirect dmar-specific method calls in iommu_get_dev_ctx()

Sponsored by:	Advanced Micro Devices (AMD)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2024-07-27 19:28:01 +03:00
parent 22bf8cf32f
commit ba33e74c7d
6 changed files with 22 additions and 5 deletions

View file

@ -501,6 +501,11 @@ iommu_find(device_t dev, bool verbose)
return (NULL);
}
void
iommu_unit_pre_instantiate_ctx(struct iommu_unit *unit)
{
}
void
iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free,
bool cansleep __unused)

View file

@ -278,11 +278,7 @@ iommu_get_dev_ctx(device_t dev)
if (!unit->dma_enabled)
return (NULL);
#if defined(__amd64__) || defined(__i386__)
dmar_quirks_pre_use(unit);
dmar_instantiate_rmrr_ctxs(unit);
#endif
iommu_unit_pre_instantiate_ctx(unit);
return (iommu_instantiate_ctx(unit, dev, false));
}

View file

@ -158,6 +158,7 @@ void iommu_domain_unload_entry(struct iommu_map_entry *entry, bool free,
void iommu_domain_unload(struct iommu_domain *domain,
struct iommu_map_entries_tailq *entries, bool cansleep);
void iommu_unit_pre_instantiate_ctx(struct iommu_unit *iommu);
struct iommu_ctx *iommu_instantiate_ctx(struct iommu_unit *iommu,
device_t dev, bool rmrr);
device_t iommu_get_requester(device_t dev, uint16_t *rid);

View file

@ -1310,8 +1310,16 @@ dmar_get_x86_common(struct iommu_unit *unit)
return (&dmar->x86c);
}
static void
dmar_unit_pre_instantiate_ctx(struct iommu_unit *unit)
{
dmar_quirks_pre_use(unit);
dmar_instantiate_rmrr_ctxs(unit);
}
static struct x86_iommu dmar_x86_iommu = {
.get_x86_common = dmar_get_x86_common,
.unit_pre_instantiate_ctx = dmar_unit_pre_instantiate_ctx,
.domain_unload_entry = dmar_domain_unload_entry,
.domain_unload = dmar_domain_unload,
.get_ctx = dmar_get_ctx,

View file

@ -278,6 +278,12 @@ iommu_unmap_ioapic_intr(u_int ioapic_id, u_int *cookie)
return (x86_iommu->unmap_ioapic_intr(ioapic_id, cookie));
}
void
iommu_unit_pre_instantiate_ctx(struct iommu_unit *unit)
{
x86_iommu->unit_pre_instantiate_ctx(unit);
}
#define IOMMU2X86C(iommu) (x86_iommu->get_x86_common(iommu))
static bool

View file

@ -64,6 +64,7 @@ struct x86_unit_common;
struct x86_iommu {
struct x86_unit_common *(*get_x86_common)(struct
iommu_unit *iommu);
void (*unit_pre_instantiate_ctx)(struct iommu_unit *iommu);
void (*qi_ensure)(struct iommu_unit *unit, int descr_count);
void (*qi_emit_wait_descr)(struct iommu_unit *unit, uint32_t seq,
bool, bool, bool);