summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2012-08-23 07:21:07 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2012-08-23 07:21:07 +0000
commitf12cfd0741501425174a54e5a303f740d4ce222b (patch)
treefcda6cce9fab2e7668d4e1a664c0e1355d2dfe1b /sys/dev
parentc691bc6880532fe0712399af1e255a746a884cb0 (diff)
turns out - is not commutative.
correctly determine the number of segments in the next chain, and also figure out the correct offset for the chain element at the end of the request frame.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/mfii.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/sys/dev/pci/mfii.c b/sys/dev/pci/mfii.c
index 607433ad061..e4467e39139 100644
--- a/sys/dev/pci/mfii.c
+++ b/sys/dev/pci/mfii.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mfii.c,v 1.8 2012/08/23 05:52:05 dlg Exp $ */
+/* $OpenBSD: mfii.c,v 1.9 2012/08/23 07:21:06 dlg Exp $ */
/*
* Copyright (c) 2012 David Gwynne <dlg@openbsd.org>
@@ -1286,15 +1286,16 @@ mfii_load_ccb(struct mfii_softc *sc, struct mfii_ccb *ccb, void *sglp,
space = (MFII_REQUEST_SIZE - ((u_int8_t *)nsge - (u_int8_t *)req)) /
sizeof(*nsge);
if (dmap->dm_nsegs > space) {
- ccb->ccb_sgl_len = (space - dmap->dm_nsegs) * sizeof(*sge);
+ space--;
+ ccb->ccb_sgl_len = (dmap->dm_nsegs - space) * sizeof(*sge);
- ce = nsge + space - 1;
+ ce = nsge + space;
ce->sg_addr = htole64(ccb->ccb_sgl_dva);
ce->sg_len = htole32(ccb->ccb_sgl_len);
ce->sg_flags = MFII_SGE_CHAIN_ELEMENT |
MFII_SGE_ADDR_IOCPLBNTA;
- req->chain_offset = ((u_int8_t *)req - (u_int8_t *)ce) / 4;
+ req->chain_offset = ((u_int8_t *)ce - (u_int8_t *)req) / 4;
}
for (i = 0; i < dmap->dm_nsegs; i++) {