Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/iommu/iommu_gas.c
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
struct iommu_map_entry *res; | struct iommu_map_entry *res; | ||||
KASSERT((flags & ~(IOMMU_PGF_WAITOK)) == 0, | KASSERT((flags & ~(IOMMU_PGF_WAITOK)) == 0, | ||||
("unsupported flags %x", flags)); | ("unsupported flags %x", flags)); | ||||
res = uma_zalloc(iommu_map_entry_zone, ((flags & IOMMU_PGF_WAITOK) != | res = uma_zalloc(iommu_map_entry_zone, ((flags & IOMMU_PGF_WAITOK) != | ||||
0 ? M_WAITOK : M_NOWAIT) | M_ZERO); | 0 ? M_WAITOK : M_NOWAIT) | M_ZERO); | ||||
if (res != NULL) { | if (res != NULL && domain != NULL) { | ||||
res->domain = domain; | res->domain = domain; | ||||
atomic_add_int(&domain->entries_cnt, 1); | atomic_add_int(&domain->entries_cnt, 1); | ||||
} | } | ||||
return (res); | return (res); | ||||
} | } | ||||
void | void | ||||
iommu_gas_free_entry(struct iommu_domain *domain, struct iommu_map_entry *entry) | iommu_gas_free_entry(struct iommu_domain *domain, struct iommu_map_entry *entry) | ||||
{ | { | ||||
KASSERT(domain == entry->domain, | KASSERT(domain == entry->domain, | ||||
("mismatched free domain %p entry %p entry->domain %p", domain, | ("mismatched free domain %p entry %p entry->domain %p", domain, | ||||
entry, entry->domain)); | entry, entry->domain)); | ||||
if (domain != NULL) | |||||
atomic_subtract_int(&domain->entries_cnt, 1); | atomic_subtract_int(&domain->entries_cnt, 1); | ||||
uma_zfree(iommu_map_entry_zone, entry); | uma_zfree(iommu_map_entry_zone, entry); | ||||
} | } | ||||
static int | static int | ||||
iommu_gas_cmp_entries(struct iommu_map_entry *a, struct iommu_map_entry *b) | iommu_gas_cmp_entries(struct iommu_map_entry *a, struct iommu_map_entry *b) | ||||
{ | { | ||||
/* Last entry have zero size, so <= */ | /* Last entry have zero size, so <= */ | ||||
▲ Show 20 Lines • Show All 746 Lines • Show Last 20 Lines |