Move the rid variable to the generic iommu context.
It could be used in various IOMMU platforms, not only DMAR. Reviewed by: kib Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D26373
This commit is contained in:
parent
22a39a8912
commit
cb9050dd21
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=365577
@ -135,6 +135,7 @@ struct iommu_ctx {
|
|||||||
u_long loads; /* atomic updates, for stat only */
|
u_long loads; /* atomic updates, for stat only */
|
||||||
u_long unloads; /* same */
|
u_long unloads; /* same */
|
||||||
u_int flags; /* (u) */
|
u_int flags; /* (u) */
|
||||||
|
uint16_t rid; /* (c) pci RID */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* struct iommu_ctx flags */
|
/* struct iommu_ctx flags */
|
||||||
|
@ -118,9 +118,9 @@ dmar_map_ctx_entry(struct dmar_ctx *ctx, struct sf_buf **sfp)
|
|||||||
|
|
||||||
dmar = CTX2DMAR(ctx);
|
dmar = CTX2DMAR(ctx);
|
||||||
|
|
||||||
ctxp = dmar_map_pgtbl(dmar->ctx_obj, 1 +
|
ctxp = dmar_map_pgtbl(dmar->ctx_obj, 1 + PCI_RID2BUS(ctx->context.rid),
|
||||||
PCI_RID2BUS(ctx->rid), IOMMU_PGF_NOALLOC | IOMMU_PGF_WAITOK, sfp);
|
IOMMU_PGF_NOALLOC | IOMMU_PGF_WAITOK, sfp);
|
||||||
ctxp += ctx->rid & 0xff;
|
ctxp += ctx->context.rid & 0xff;
|
||||||
return (ctxp);
|
return (ctxp);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,7 +386,7 @@ dmar_ctx_alloc(struct dmar_domain *domain, uint16_t rid)
|
|||||||
ctx->context.domain = DOM2IODOM(domain);
|
ctx->context.domain = DOM2IODOM(domain);
|
||||||
ctx->context.tag = malloc(sizeof(struct bus_dma_tag_iommu),
|
ctx->context.tag = malloc(sizeof(struct bus_dma_tag_iommu),
|
||||||
M_DMAR_CTX, M_WAITOK | M_ZERO);
|
M_DMAR_CTX, M_WAITOK | M_ZERO);
|
||||||
ctx->rid = rid;
|
ctx->context.rid = rid;
|
||||||
ctx->refs = 1;
|
ctx->refs = 1;
|
||||||
return (ctx);
|
return (ctx);
|
||||||
}
|
}
|
||||||
@ -643,8 +643,9 @@ dmar_move_ctx_to_domain(struct dmar_domain *domain, struct dmar_ctx *ctx)
|
|||||||
error = dmar_flush_for_ctx_entry(dmar, true);
|
error = dmar_flush_for_ctx_entry(dmar, true);
|
||||||
/* If flush failed, rolling back would not work as well. */
|
/* If flush failed, rolling back would not work as well. */
|
||||||
printf("dmar%d rid %x domain %d->%d %s-mapped\n",
|
printf("dmar%d rid %x domain %d->%d %s-mapped\n",
|
||||||
dmar->iommu.unit, ctx->rid, old_domain->domain, domain->domain,
|
dmar->iommu.unit, ctx->context.rid, old_domain->domain,
|
||||||
(domain->iodom.flags & IOMMU_DOMAIN_IDMAP) != 0 ? "id" : "re");
|
domain->domain, (domain->iodom.flags & IOMMU_DOMAIN_IDMAP) != 0 ?
|
||||||
|
"id" : "re");
|
||||||
dmar_unref_domain_locked(dmar, old_domain);
|
dmar_unref_domain_locked(dmar, old_domain);
|
||||||
TD_PINNED_ASSERT;
|
TD_PINNED_ASSERT;
|
||||||
return (error);
|
return (error);
|
||||||
@ -776,7 +777,7 @@ dmar_find_ctx_locked(struct dmar_unit *dmar, uint16_t rid)
|
|||||||
|
|
||||||
LIST_FOREACH(domain, &dmar->domains, link) {
|
LIST_FOREACH(domain, &dmar->domains, link) {
|
||||||
LIST_FOREACH(ctx, &domain->contexts, link) {
|
LIST_FOREACH(ctx, &domain->contexts, link) {
|
||||||
if (ctx->rid == rid)
|
if (ctx->context.rid == rid)
|
||||||
return (ctx);
|
return (ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,6 @@ struct dmar_domain {
|
|||||||
|
|
||||||
struct dmar_ctx {
|
struct dmar_ctx {
|
||||||
struct iommu_ctx context;
|
struct iommu_ctx context;
|
||||||
uint16_t rid; /* (c) pci RID */
|
|
||||||
uint64_t last_fault_rec[2]; /* Last fault reported */
|
uint64_t last_fault_rec[2]; /* Last fault reported */
|
||||||
LIST_ENTRY(dmar_ctx) link; /* (u) Member in the domain list */
|
LIST_ENTRY(dmar_ctx) link; /* (u) Member in the domain list */
|
||||||
u_int refs; /* (u) References from tags */
|
u_int refs; /* (u) References from tags */
|
||||||
|
Loading…
Reference in New Issue
Block a user