From owner-svn-soc-all@FreeBSD.ORG Thu Sep 19 16:27:34 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6B347EAB for ; Thu, 19 Sep 2013 16:27:34 +0000 (UTC) (envelope-from zcore@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 57ED1296F for ; Thu, 19 Sep 2013 16:27:34 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r8JGRYXA066260 for ; Thu, 19 Sep 2013 16:27:34 GMT (envelope-from zcore@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r8JGRYL8066251 for svn-soc-all@FreeBSD.org; Thu, 19 Sep 2013 16:27:34 GMT (envelope-from zcore@FreeBSD.org) Date: Thu, 19 Sep 2013 16:27:34 GMT Message-Id: <201309191627.r8JGRYL8066251@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to zcore@FreeBSD.org using -f From: zcore@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r257501 - soc2013/zcore/head/usr.sbin/bhyve MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Sep 2013 16:27:34 -0000 Author: zcore Date: Thu Sep 19 16:27:34 2013 New Revision: 257501 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=257501 Log: remove max iovcnt limitation Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.h soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Modified: soc2013/zcore/head/usr.sbin/bhyve/block_if.h ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/block_if.h Thu Sep 19 14:41:10 2013 (r257500) +++ soc2013/zcore/head/usr.sbin/bhyve/block_if.h Thu Sep 19 16:27:34 2013 (r257501) @@ -32,9 +32,7 @@ #include #include -#include "ahci.h" - -#define BLOCKIF_IOV_MAX AHCI_SG_ENTRIES /* XXX */ +#define BLOCKIF_IOV_MAX 32 /* XXX */ struct blockif_req { struct iovec br_iov[BLOCKIF_IOV_MAX]; Modified: soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c ============================================================================== --- soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Sep 19 14:41:10 2013 (r257500) +++ soc2013/zcore/head/usr.sbin/bhyve/pci_ahci.c Thu Sep 19 16:27:34 2013 (r257501) @@ -105,6 +105,7 @@ uint8_t *cfis; uint32_t len; int slot; + int prdtl; }; struct ahci_port { @@ -371,9 +372,9 @@ } static void -handle_dma(struct ahci_port *p, int slot, uint8_t *cfis) +handle_dma(struct ahci_port *p, int slot, uint8_t *cfis, int seek) { - int i, err, ncq = 0, readop = 1; + int i, err, iovcnt, ncq = 0, readop = 1; uint64_t lba; uint32_t len; struct ahci_ioreq *aior; @@ -382,6 +383,7 @@ struct ahci_prdt_entry *prdt = (struct ahci_prdt_entry *)(cfis + 0x80); struct ahci_cmd_hdr *hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + prdt += seek; if (cfis[2] == ATA_WRITE_DMA || cfis[2] == ATA_WRITE_DMA48 || cfis[2] == ATA_WRITE_FPDMA_QUEUED) readop = 0; @@ -429,12 +431,18 @@ aior->len = len; breq = &aior->io_req; breq->br_offset = lba; - breq->br_iovcnt = hdr->prdtl; + iovcnt = hdr->prdtl - seek; + if (iovcnt > BLOCKIF_IOV_MAX) { + aior->prdtl = iovcnt - BLOCKIF_IOV_MAX; + iovcnt = BLOCKIF_IOV_MAX; + } else + aior->prdtl = 0; + breq->br_iovcnt = iovcnt; /* * Build up the iovec based on the prdt */ - for (i = 0; i < hdr->prdtl; i++) { + for (i = 0; i < iovcnt; i++) { 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; @@ -446,7 +454,7 @@ err = blockif_write(p->bctx, breq); assert(err == 0); - if (ncq) + if (!aior->prdtl && ncq) p->ci &= ~(1 << slot); } @@ -821,9 +829,9 @@ } static void -atapi_read(struct ahci_port *p, int slot, uint8_t *cfis) +atapi_read(struct ahci_port *p, int slot, uint8_t *cfis, int seek) { - int i, err; + int i, err, iovcnt; uint64_t lba; uint32_t len; struct ahci_ioreq *aior; @@ -833,6 +841,7 @@ struct ahci_prdt_entry *prdt = (struct ahci_prdt_entry *)(cfis + 0x80); struct ahci_cmd_hdr *hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + prdt += seek; lba = be32dec(acmd + 2); if (acmd[0] == READ_10) len = be16dec(acmd + 7); @@ -856,7 +865,13 @@ aior->len = len; breq = &aior->io_req; breq->br_offset = lba; - breq->br_iovcnt = hdr->prdtl; + iovcnt = hdr->prdtl - seek; + if (iovcnt > BLOCKIF_IOV_MAX) { + aior->prdtl = iovcnt - BLOCKIF_IOV_MAX; + iovcnt = BLOCKIF_IOV_MAX; + } else + aior->prdtl = 0; + breq->br_iovcnt = iovcnt; /* * Build up the iovec based on the prdt @@ -949,7 +964,7 @@ break; case READ_10: case READ_12: - atapi_read(p, slot, cfis); + atapi_read(p, slot, cfis, 0); break; case REQUEST_SENSE: atapi_request_sense(p, slot, cfis); @@ -1021,7 +1036,7 @@ case ATA_WRITE_DMA48: case ATA_READ_FPDMA_QUEUED: case ATA_WRITE_FPDMA_QUEUED: - handle_dma(p, slot, cfis); + handle_dma(p, slot, cfis, 0); break; case ATA_FLUSHCACHE: case ATA_FLUSHCACHE48: @@ -1130,20 +1145,34 @@ struct ahci_ioreq *aior; uint32_t tfd; struct ahci_cmd_hdr *hdr; - int ncq = 0; + int pending, slot, ncq = 0; + uint8_t *cfis; DPRINTF("%s %d\n", __func__, err); aior = br->br_param; p = aior->io_pr; + cfis = aior->cfis; + slot = aior->slot; + pending = aior->prdtl; sc = p->pr_sc; - hdr = p->cmd_lst + aior->slot * AHCI_CL_SIZE; - if (aior->cfis[2] == ATA_WRITE_FPDMA_QUEUED || - aior->cfis[2] == ATA_READ_FPDMA_QUEUED) + hdr = p->cmd_lst + slot * AHCI_CL_SIZE; + if (cfis[2] == ATA_WRITE_FPDMA_QUEUED || + cfis[2] == ATA_READ_FPDMA_QUEUED) ncq = 1; pthread_mutex_lock(&sc->mtx); + /* + * Move the blockif request back to the free list + */ + STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); + + if (pending && !err) { + handle_dma(p, slot, cfis, hdr->prdtl - pending); + goto out; + } + if (!err) { tfd = ATA_S_READY | ATA_S_DSC; if (ncq) @@ -1154,20 +1183,15 @@ tfd = (ATA_E_ABORT << 8) | ATA_S_READY | ATA_S_ERROR; hdr->prdbc = 0; if (ncq) - p->serr |= (1 << aior->slot); + p->serr |= (1 << slot); } if (ncq) { - p->sact &= ~(1 << aior->slot); - ahci_write_fis_sdb(p, aior->slot, tfd); + p->sact &= ~(1 << slot); + ahci_write_fis_sdb(p, slot, tfd); } else - ahci_write_fis_d2h(p, aior->slot, aior->cfis, tfd); - - /* - * Move the blockif request back to the free list - */ - STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); - + ahci_write_fis_d2h(p, slot, cfis, tfd); +out: pthread_mutex_unlock(&sc->mtx); DPRINTF("%s exit\n", __func__); } @@ -1181,16 +1205,30 @@ struct pci_ahci_softc *sc; struct ahci_ioreq *aior; struct ahci_cmd_hdr *hdr; + int pending, slot; DPRINTF("%s %d\n", __func__, err); aior = br->br_param; p = aior->io_pr; + cfis = aior->cfis; + slot = aior->slot; + pending = aior->prdtl; sc = p->pr_sc; hdr = p->cmd_lst + aior->slot * AHCI_CL_SIZE; pthread_mutex_lock(&sc->mtx); + /* + * Move the blockif request back to the free list + */ + STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); + + if (pending && !err) { + atapi_read(p, slot, cfis, hdr->prdtl - pending); + goto out; + } + if (!err) { tfd = ATA_S_READY | ATA_S_DSC; hdr->prdbc = aior->len; @@ -1201,18 +1239,12 @@ hdr->prdbc = 0; } - cfis = aior->cfis; cfis[4] = (cfis[4] & ~7) | ATA_I_CMD | ATA_I_IN; - ahci_write_fis_d2h(p, aior->slot, cfis, tfd); - - /* - * Move the blockif request back to the free list - */ - STAILQ_INSERT_TAIL(&p->iofhd, aior, io_list); + ahci_write_fis_d2h(p, slot, cfis, tfd); +out: pthread_mutex_unlock(&sc->mtx); DPRINTF("%s exit\n", __func__); - } static void