summaryrefslogtreecommitdiff
path: root/sys/arch/amd64
diff options
context:
space:
mode:
authorMarco Peereboom <marco@cvs.openbsd.org>2005-09-29 21:30:43 +0000
committerMarco Peereboom <marco@cvs.openbsd.org>2005-09-29 21:30:43 +0000
commitbb12c089e70b86ad1fc937ec2da7e065bdc2ab0d (patch)
tree7b57ce515d281516b1e4468abb1772fe8bd0b00d /sys/arch/amd64
parent1a291f79aac038207f18b3e4a425118d8ffeb797 (diff)
Execute operations in the correct order. From jason@
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r--sys/arch/amd64/pci/iommu.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sys/arch/amd64/pci/iommu.c b/sys/arch/amd64/pci/iommu.c
index d493fd4550f..ea3e5ec94b9 100644
--- a/sys/arch/amd64/pci/iommu.c
+++ b/sys/arch/amd64/pci/iommu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iommu.c,v 1.15 2005/09/27 17:41:12 marco Exp $ */
+/* $OpenBSD: iommu.c,v 1.16 2005/09/29 21:30:42 marco Exp $ */
/*
* Copyright (c) 2005 Jason L. Wright (jason@thought.net)
@@ -429,7 +429,9 @@ amdgart_reload(struct extent *ex, bus_dmamap_t dmam)
err = amdgart_iommu_map(dmam, ex, opa, &npa, len);
if (err) {
for (j = 0; j < i - 1; j++)
- amdgart_iommu_unmap(ex, opa, len);
+ amdgart_iommu_unmap(ex,
+ dmam->dm_segs[j].ds_addr,
+ dmam->dm_segs[j].ds_len);
return (err);
}
dmam->dm_segs[i].ds_addr = npa;
@@ -482,19 +484,26 @@ amdgart_iommu_unmap(struct extent *ex, paddr_t pa, psize_t len)
base = trunc_page(pa);
end = roundup(pa + len, PAGE_SIZE);
alen = end - base;
+
+ /*
+ * order is significant here; invalidate the iommu page table
+ * entries, then mark them as freed in the extent.
+ */
+
+ for (idx = 0; idx < alen; idx += PAGE_SIZE) {
+ pgno = ((base - amdgart_softcs[0].g_pa) + idx) >> PGSHIFT;
+ amdgart_softcs[0].g_pte[pgno] = 0;
+ }
+
s = splhigh();
err = extent_free(ex, base, alen, EX_NOWAIT);
splx(s);
if (err) {
+ /* XXX Shouldn't happen, but if it does, I think we lose. */
printf("GART: extent_free %d\n", err);
return (err);
}
- for (idx = 0; idx < alen; idx += PAGE_SIZE) {
- pgno = ((base - amdgart_softcs[0].g_pa) + idx) >> PGSHIFT;
- amdgart_softcs[0].g_pte[pgno] = amdgart_softcs[0].g_scribpte;
- }
-
return (0);
}