From d1943547d45a87eda0eaa80004f0117c5fd97f9a Mon Sep 17 00:00:00 2001 From: Mike Belopuhov Date: Tue, 5 Jan 2016 13:47:29 +0000 Subject: 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. --- sys/dev/pv/xen.c | 6 +++++- sys/dev/pv/xenvar.h | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'sys/dev/pv') diff --git a/sys/dev/pv/xen.c b/sys/dev/pv/xen.c index 436d6dda956..047c74c384a 100644 --- a/sys/dev/pv/xen.c +++ b/sys/dev/pv/xen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: xen.c,v 1.21 2016/01/04 16:07:52 mikeb Exp $ */ +/* $OpenBSD: xen.c,v 1.22 2016/01/05 13:47:28 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -1048,6 +1048,8 @@ xen_bus_dmamap_load(bus_dma_tag_t t, bus_dmamap_t map, void *buf, return (error); } 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); @@ -1073,6 +1075,8 @@ xen_bus_dmamap_load_mbuf(bus_dma_tag_t t, bus_dmamap_t map, struct mbuf *m0, return (error); } 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); diff --git a/sys/dev/pv/xenvar.h b/sys/dev/pv/xenvar.h index b1494c90f3e..3f03673d93d 100644 --- a/sys/dev/pv/xenvar.h +++ b/sys/dev/pv/xenvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: xenvar.h,v 1.18 2016/01/04 16:05:43 mikeb Exp $ */ +/* $OpenBSD: xenvar.h,v 1.19 2016/01/05 13:47:28 mikeb Exp $ */ /* * Copyright (c) 2015 Mike Belopuhov @@ -85,6 +85,15 @@ struct xen_attach_args { bus_dma_tag_t xa_dmat; }; +/* + * 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 */ -- cgit v1.2.3