From owner-svn-src-stable@freebsd.org Sun Apr 12 19:18:26 2020 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id DC2F62C64C8; Sun, 12 Apr 2020 19:18:26 +0000 (UTC) (envelope-from chuck@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 490hNy5WFBz4Wtn; Sun, 12 Apr 2020 19:18:26 +0000 (UTC) (envelope-from chuck@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B3BCE6844; Sun, 12 Apr 2020 19:18:26 +0000 (UTC) (envelope-from chuck@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 03CJIQM9092903; Sun, 12 Apr 2020 19:18:26 GMT (envelope-from chuck@FreeBSD.org) Received: (from chuck@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03CJIQVq092902; Sun, 12 Apr 2020 19:18:26 GMT (envelope-from chuck@FreeBSD.org) Message-Id: <202004121918.03CJIQVq092902@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: chuck set sender to chuck@FreeBSD.org using -f From: Chuck Tuffli Date: Sun, 12 Apr 2020 19:18:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r359832 - stable/12/usr.sbin/bhyve X-SVN-Group: stable-12 X-SVN-Commit-Author: chuck X-SVN-Commit-Paths: stable/12/usr.sbin/bhyve X-SVN-Commit-Revision: 359832 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2020 19:18:26 -0000 Author: chuck Date: Sun Apr 12 19:18:26 2020 New Revision: 359832 URL: https://svnweb.freebsd.org/changeset/base/359832 Log: MFC r359365 bhyve: use STAILQ in NVMe emulation Modified: stable/12/usr.sbin/bhyve/pci_nvme.c Directory Properties: stable/12/ (props changed) Modified: stable/12/usr.sbin/bhyve/pci_nvme.c ============================================================================== --- stable/12/usr.sbin/bhyve/pci_nvme.c Sun Apr 12 19:14:27 2020 (r359831) +++ stable/12/usr.sbin/bhyve/pci_nvme.c Sun Apr 12 19:18:26 2020 (r359832) @@ -185,7 +185,7 @@ struct pci_nvme_blockstore { struct pci_nvme_ioreq { struct pci_nvme_softc *sc; - struct pci_nvme_ioreq *next; + STAILQ_ENTRY(pci_nvme_ioreq) link; struct nvme_submission_queue *nvme_sq; uint16_t sqid; @@ -240,7 +240,7 @@ struct pci_nvme_softc { uint32_t num_squeues; struct pci_nvme_ioreq *ioreqs; - struct pci_nvme_ioreq *ioreqs_free; /* free list of ioreqs */ + STAILQ_HEAD(, pci_nvme_ioreq) ioreqs_free; /* free list of ioreqs */ uint32_t pending_ios; uint32_t ioslots; sem_t iosemlock; @@ -1318,8 +1318,7 @@ pci_nvme_release_ioreq(struct pci_nvme_softc *sc, stru pthread_mutex_lock(&sc->mtx); - req->next = sc->ioreqs_free; - sc->ioreqs_free = req; + STAILQ_INSERT_TAIL(&sc->ioreqs_free, req, link); sc->pending_ios--; /* when no more IO pending, can set to ready if device reset/enabled */ @@ -1340,12 +1339,10 @@ pci_nvme_get_ioreq(struct pci_nvme_softc *sc) sem_wait(&sc->iosemlock); pthread_mutex_lock(&sc->mtx); - req = sc->ioreqs_free; + req = STAILQ_FIRST(&sc->ioreqs_free); assert(req != NULL); + STAILQ_REMOVE_HEAD(&sc->ioreqs_free, link); - sc->ioreqs_free = req->next; - - req->next = NULL; req->sc = sc; sc->pending_ios++; @@ -2150,14 +2147,13 @@ pci_nvme_init(struct vmctx *ctx, struct pci_devinst *p else error = 0; + STAILQ_INIT(&sc->ioreqs_free); sc->ioreqs = calloc(sc->ioslots, sizeof(struct pci_nvme_ioreq)); for (int i = 0; i < sc->ioslots; i++) { - if (i < (sc->ioslots-1)) - sc->ioreqs[i].next = &sc->ioreqs[i+1]; + STAILQ_INSERT_TAIL(&sc->ioreqs_free, &sc->ioreqs[i], link); pthread_mutex_init(&sc->ioreqs[i].mtx, NULL); pthread_cond_init(&sc->ioreqs[i].cv, NULL); } - sc->ioreqs_free = sc->ioreqs; sc->intr_coales_aggr_thresh = 1; pci_set_cfgdata16(pi, PCIR_DEVICE, 0x0A0A);