summaryrefslogtreecommitdiff
path: root/sys/dev/pv
diff options
context:
space:
mode:
authorMike Belopuhov <mikeb@cvs.openbsd.org>2016-09-12 17:22:46 +0000
committerMike Belopuhov <mikeb@cvs.openbsd.org>2016-09-12 17:22:46 +0000
commit10ad41a84270756dbaaf9166b79a68afe53db702 (patch)
tree97a0662c73ee6fa31b1e8788a5252f3c347cc441 /sys/dev/pv
parentacc0a766403f952db62eba9265b9edc727889876 (diff)
Bring back the code that cached DMA fragment offset.
It's required to handle mbuf fragments spanning multiple pages. Original commit message said: Memorize the DMA segment's data offset within the page Grant table references don't convey the information about an actual offset of the data within the page, however Xen needs to know it. We (ab)use bus_dma_segment's _ds_boundary member to store it and can get away with not restoring it's original value atm because neither i386 nor amd64 bus_dmamap_unload(9) code needs it.
Diffstat (limited to 'sys/dev/pv')
-rw-r--r--sys/dev/pv/xen.c6
-rw-r--r--sys/dev/pv/xenvar.h11
2 files changed, 15 insertions, 2 deletions
diff --git a/sys/dev/pv/xen.c b/sys/dev/pv/xen.c
index 6841c05a761..27759ffa982 100644
--- a/sys/dev/pv/xen.c
+++ b/sys/dev/pv/xen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xen.c,v 1.62 2016/08/17 17:18:38 mikeb Exp $ */
+/* $OpenBSD: xen.c,v 1.63 2016/09/12 17:22:45 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
@@ -1191,6 +1191,8 @@ xen_bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf,
xen_grant_table_enter(sc, gm[i].gm_ref, map->dm_segs[i].ds_addr,
domain, flags & BUS_DMA_WRITE ? GTF_readonly : 0);
gm[i].gm_paddr = map->dm_segs[i].ds_addr;
+ map->dm_segs[i].ds_offset = map->dm_segs[i].ds_addr &
+ PAGE_MASK;
map->dm_segs[i].ds_addr = gm[i].gm_ref;
}
return (0);
@@ -1212,6 +1214,8 @@ xen_bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0,
for (i = 0; i < map->dm_nsegs; i++) {
xen_grant_table_enter(sc, gm[i].gm_ref, map->dm_segs[i].ds_addr,
domain, flags & BUS_DMA_WRITE ? GTF_readonly : 0);
+ map->dm_segs[i].ds_offset = map->dm_segs[i].ds_addr &
+ PAGE_MASK;
gm[i].gm_paddr = map->dm_segs[i].ds_addr;
map->dm_segs[i].ds_addr = gm[i].gm_ref;
}
diff --git a/sys/dev/pv/xenvar.h b/sys/dev/pv/xenvar.h
index 980f5910b34..aae924c780c 100644
--- a/sys/dev/pv/xenvar.h
+++ b/sys/dev/pv/xenvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: xenvar.h,v 1.36 2016/08/17 17:18:38 mikeb Exp $ */
+/* $OpenBSD: xenvar.h,v 1.37 2016/09/12 17:22:45 mikeb Exp $ */
/*
* Copyright (c) 2015 Mike Belopuhov
@@ -94,6 +94,15 @@ struct xen_attach_args {
};
/*
+ * Grant table references don't convey the information about an actual
+ * offset of the data within the page, however Xen needs to know it.
+ * We (ab)use bus_dma_segment's _ds_boundary member to store it. Please
+ * note that we don't save or restore it's original value atm because
+ * neither i386 nor amd64 bus_dmamap_unload(9) code needs it.
+ */
+#define ds_offset _ds_boundary
+
+/*
* Hypercalls
*/
#define XC_MEMORY 12