Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Sep 2013 02:25:04 GMT
From:      zcore@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r257525 - soc2013/zcore/head/usr.sbin/bhyve
Message-ID:  <201309200225.r8K2P4RJ048943@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zcore
Date: Fri Sep 20 02:25:04 2013
New Revision: 257525
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257525

Log:
  set br_offset accordingly

Modified:
  soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c

Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c
==============================================================================
--- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c	Fri Sep 20 01:55:37 2013	(r257524)
+++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c	Fri Sep 20 02:25:04 2013	(r257525)
@@ -111,6 +111,7 @@
 	STAILQ_ENTRY(ahci_ioreq) io_list;
 	uint8_t *cfis;
 	uint32_t len;
+	uint32_t done;
 	int slot;
 	int prdtl;
 };
@@ -379,7 +380,8 @@
 }
 
 static void
-handle_dma(struct ahci_port *p, int slot, uint8_t *cfis, int seek)
+handle_dma(struct ahci_port *p, int slot, uint8_t *cfis,
+		uint32_t done, int seek)
 {
 	int i, err, iovcnt, ncq = 0, readop = 1;
 	uint64_t lba;
@@ -436,8 +438,9 @@
 	aior->cfis = cfis;
 	aior->slot = slot;
 	aior->len = len;
+	aior->done = done;
 	breq = &aior->io_req;
-	breq->br_offset = lba;
+	breq->br_offset = lba + done;
 	iovcnt = hdr->prdtl - seek;
 	if (iovcnt > BLOCKIF_IOV_MAX) {
 		aior->prdtl = iovcnt - BLOCKIF_IOV_MAX;
@@ -453,6 +456,7 @@
 		breq->br_iov[i].iov_base = paddr_guest2host(ahci_ctx(sc),
 				prdt->dba, prdt->dbc + 1);
 		breq->br_iov[i].iov_len = prdt->dbc + 1;
+		aior->done += (prdt->dbc + 1);
 		prdt++;
 	}
 	if (readop)
@@ -836,7 +840,8 @@
 }
 
 static void
-atapi_read(struct ahci_port *p, int slot, uint8_t *cfis, int seek)
+atapi_read(struct ahci_port *p, int slot, uint8_t *cfis,
+		uint32_t done, int seek)
 {
 	int i, err, iovcnt;
 	uint64_t lba;
@@ -870,8 +875,9 @@
 	aior->cfis = cfis;
 	aior->slot = slot;
 	aior->len = len;
+	aior->done = done;
 	breq = &aior->io_req;
-	breq->br_offset = lba;
+	breq->br_offset = lba + done;
 	iovcnt = hdr->prdtl - seek;
 	if (iovcnt > BLOCKIF_IOV_MAX) {
 		aior->prdtl = iovcnt - BLOCKIF_IOV_MAX;
@@ -887,6 +893,7 @@
 		breq->br_iov[i].iov_base = paddr_guest2host(ahci_ctx(sc),
 				prdt->dba, prdt->dbc + 1);
 		breq->br_iov[i].iov_len = prdt->dbc + 1;
+		aior->done += (prdt->dbc + 1);
 		prdt++;
 	}
 	err = blockif_read(p->bctx, breq);
@@ -1075,7 +1082,7 @@
 		break;
 	case READ_10:
 	case READ_12:
-		atapi_read(p, slot, cfis, 0);
+		atapi_read(p, slot, cfis, 0, 0);
 		break;
 	case REQUEST_SENSE:
 		atapi_request_sense(p, slot, cfis);
@@ -1153,7 +1160,7 @@
 	case ATA_WRITE_DMA48:
 	case ATA_READ_FPDMA_QUEUED:
 	case ATA_WRITE_FPDMA_QUEUED:
-		handle_dma(p, slot, cfis, 0);
+		handle_dma(p, slot, cfis, 0, 0);
 		break;
 	case ATA_FLUSHCACHE:
 	case ATA_FLUSHCACHE48:
@@ -1286,11 +1293,11 @@
 	STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list);
 
 	if (pending && !err) {
-		handle_dma(p, slot, cfis, hdr->prdtl - pending);
+		handle_dma(p, slot, cfis, aior->done, hdr->prdtl - pending);
 		goto out;
 	}
 
-	if (!err) {
+	if (!err && aior->done == aior->len) {
 		tfd = ATA_S_READY | ATA_S_DSC;
 		if (ncq)
 			hdr->prdbc = 0;
@@ -1342,11 +1349,11 @@
 	STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list);
 
 	if (pending && !err) {
-		atapi_read(p, slot, cfis, hdr->prdtl - pending);
+		atapi_read(p, slot, cfis, aior->done, hdr->prdtl - pending);
 		goto out;
 	}
 
-	if (!err) {
+	if (!err && aior->done == aior->len) {
 		tfd = ATA_S_READY | ATA_S_DSC;
 		hdr->prdbc = aior->len;
 	} else {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309200225.r8K2P4RJ048943>