From owner-svn-src-all@freebsd.org Sun Apr 12 19:21:44 2020 Return-Path: Delivered-To: svn-src-all@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 B3E872C674C; Sun, 12 Apr 2020 19:21:44 +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 490hSm4PH1z4XKZ; Sun, 12 Apr 2020 19:21:44 +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 9221968C0; Sun, 12 Apr 2020 19:21:44 +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 03CJLiot096382; Sun, 12 Apr 2020 19:21:44 GMT (envelope-from chuck@FreeBSD.org) Received: (from chuck@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03CJLiD5096381; Sun, 12 Apr 2020 19:21:44 GMT (envelope-from chuck@FreeBSD.org) Message-Id: <202004121921.03CJLiD5096381@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:21:44 +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: r359833 - 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: 359833 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Apr 2020 19:21:44 -0000 Author: chuck Date: Sun Apr 12 19:21:44 2020 New Revision: 359833 URL: https://svnweb.freebsd.org/changeset/base/359833 Log: MFC r359366 bhyve: fix NVMe emulation missed interrupts 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:18:26 2020 (r359832) +++ stable/12/usr.sbin/bhyve/pci_nvme.c Sun Apr 12 19:21:44 2020 (r359833) @@ -1082,12 +1082,12 @@ pci_nvme_handle_admin_cmd(struct pci_nvme_softc* sc, u struct nvme_command *cmd; struct nvme_submission_queue *sq; struct nvme_completion_queue *cq; - int do_intr = 0; uint16_t sqhead; DPRINTF(("%s index %u", __func__, (uint32_t)value)); sq = &sc->submit_queues[0]; + cq = &sc->compl_queues[0]; sqhead = atomic_load_acq_short(&sq->head); @@ -1106,44 +1106,44 @@ pci_nvme_handle_admin_cmd(struct pci_nvme_softc* sc, u switch (cmd->opc) { case NVME_OPC_DELETE_IO_SQ: DPRINTF(("%s command DELETE_IO_SQ", __func__)); - do_intr |= nvme_opc_delete_io_sq(sc, cmd, &compl); + nvme_opc_delete_io_sq(sc, cmd, &compl); break; case NVME_OPC_CREATE_IO_SQ: DPRINTF(("%s command CREATE_IO_SQ", __func__)); - do_intr |= nvme_opc_create_io_sq(sc, cmd, &compl); + nvme_opc_create_io_sq(sc, cmd, &compl); break; case NVME_OPC_DELETE_IO_CQ: DPRINTF(("%s command DELETE_IO_CQ", __func__)); - do_intr |= nvme_opc_delete_io_cq(sc, cmd, &compl); + nvme_opc_delete_io_cq(sc, cmd, &compl); break; case NVME_OPC_CREATE_IO_CQ: DPRINTF(("%s command CREATE_IO_CQ", __func__)); - do_intr |= nvme_opc_create_io_cq(sc, cmd, &compl); + nvme_opc_create_io_cq(sc, cmd, &compl); break; case NVME_OPC_GET_LOG_PAGE: DPRINTF(("%s command GET_LOG_PAGE", __func__)); - do_intr |= nvme_opc_get_log_page(sc, cmd, &compl); + nvme_opc_get_log_page(sc, cmd, &compl); break; case NVME_OPC_IDENTIFY: DPRINTF(("%s command IDENTIFY", __func__)); - do_intr |= nvme_opc_identify(sc, cmd, &compl); + nvme_opc_identify(sc, cmd, &compl); break; case NVME_OPC_ABORT: DPRINTF(("%s command ABORT", __func__)); - do_intr |= nvme_opc_abort(sc, cmd, &compl); + nvme_opc_abort(sc, cmd, &compl); break; case NVME_OPC_SET_FEATURES: DPRINTF(("%s command SET_FEATURES", __func__)); - do_intr |= nvme_opc_set_features(sc, cmd, &compl); + nvme_opc_set_features(sc, cmd, &compl); break; case NVME_OPC_GET_FEATURES: DPRINTF(("%s command GET_FEATURES", __func__)); - do_intr |= nvme_opc_get_features(sc, cmd, &compl); + nvme_opc_get_features(sc, cmd, &compl); break; case NVME_OPC_ASYNC_EVENT_REQUEST: DPRINTF(("%s command ASYNC_EVENT_REQ", __func__)); /* XXX dont care, unhandled for now - do_intr |= nvme_opc_async_event_req(sc, cmd, &compl); + nvme_opc_async_event_req(sc, cmd, &compl); */ compl.status = NVME_NO_STATUS; break; @@ -1151,15 +1151,12 @@ pci_nvme_handle_admin_cmd(struct pci_nvme_softc* sc, u WPRINTF(("0x%x command is not implemented", cmd->opc)); pci_nvme_status_genc(&compl.status, NVME_SC_INVALID_OPCODE); - do_intr |= 1; } if (NVME_COMPLETION_VALID(compl)) { struct nvme_completion *cp; int phase; - cq = &sc->compl_queues[0]; - cp = &(cq->qbase)[cq->tail]; cp->cdw0 = compl.cdw0; cp->sqid = 0; @@ -1179,7 +1176,7 @@ pci_nvme_handle_admin_cmd(struct pci_nvme_softc* sc, u atomic_store_short(&sq->head, sqhead); atomic_store_int(&sq->busy, 0); - if (do_intr) + if (cq->head != cq->tail) pci_generate_msix(sc->nsc_pi, 0); } @@ -1275,7 +1272,6 @@ pci_nvme_set_completion(struct pci_nvme_softc *sc, { struct nvme_completion_queue *cq = &sc->compl_queues[sq->cqid]; struct nvme_completion *compl; - int do_intr = 0; int phase; DPRINTF(("%s sqid %d cqid %u cid %u status: 0x%x 0x%x", @@ -1299,14 +1295,16 @@ pci_nvme_set_completion(struct pci_nvme_softc *sc, cq->tail = (cq->tail + 1) % cq->size; - if (cq->intr_en & NVME_CQ_INTEN) - do_intr = 1; - pthread_mutex_unlock(&cq->mtx); - if (ignore_busy || !atomic_load_acq_int(&sq->busy)) - if (do_intr) + if (cq->head != cq->tail) { + if (cq->intr_en & NVME_CQ_INTEN) { pci_generate_msix(sc->nsc_pi, cq->intr_vec); + } else { + DPRINTF(("%s: CQ%u interrupt disabled\n", + __func__, sq->cqid)); + } + } } static void