On Sep 23 15:20, Markku Ahvenjärvi wrote: > cq_pending counts interrupt-enabled completion queues with unconsumed > entries. nvme_cq_notifier() and nvme_process_db() decrement it whenever > a CQ becomes empty, but they may also process a notification or doorbell > write for a CQ that was already empty. > > Decrement cq_pending only when the CQ contained pending completions > before its head update. Otherwise cq_pending may underflow and > prevent legacy INTx from being deasserted. > > Signed-off-by: Markku Ahvenjärvi <[email protected]>
Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/4753 > --- > hw/nvme/ctrl.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c > index c641226e27ad..2be4bab7eb5a 100644 > --- a/hw/nvme/ctrl.c > +++ b/hw/nvme/ctrl.c > @@ -4782,6 +4782,7 @@ static void nvme_cq_notifier(EventNotifier *e) > { > NvmeCQueue *cq = container_of(e, NvmeCQueue, notifier); > NvmeCtrl *n = cq->ctrl; > + bool pending = cq->tail != cq->head; > > if (!event_notifier_test_and_clear(e)) { > return; > @@ -4790,7 +4791,7 @@ static void nvme_cq_notifier(EventNotifier *e) > nvme_update_cq_head(cq); > > if (cq->tail == cq->head) { > - if (cq->irq_enabled) { > + if (cq->irq_enabled && pending) { > n->cq_pending--; > } > > @@ -8555,6 +8556,7 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, > int val) > > uint16_t new_head = val & 0xffff; > NvmeCQueue *cq; > + bool pending; > > qid = (addr - (0x1000 + (1 << 2))) >> 3; > if (unlikely(nvme_check_cqid(n, qid))) { > @@ -8609,13 +8611,14 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, > int val) > qemu_bh_schedule(cq->bh); > } > > + pending = cq->tail != cq->head; > cq->head = new_head; > if (!qid && n->dbbuf_enabled) { > stl_le_pci_dma(pci, cq->db_addr, cq->head, > MEMTXATTRS_UNSPECIFIED); > } > > if (cq->tail == cq->head) { > - if (cq->irq_enabled) { > + if (cq->irq_enabled && pending) { > n->cq_pending--; > } > > > -- > 2.55.0 > >
signature.asc
Description: PGP signature
