Skip to content

Commit

Permalink
QEMU NVMe: cq doorbell write, interrupts
Browse files Browse the repository at this point in the history
Trigger an interrupt if the completion queue head is updated but there
are still completion entries to be processed.

Signed-off-by: Keith Busch <keith.busch@intel.com>

Conflicts:

	hw/nvme.c
  • Loading branch information
thokala committed Aug 13, 2012
1 parent df906b5 commit 9d1e69b
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -69,3 +69,4 @@ tags
TAGS
*~
linux-headers/asm
.project
17 changes: 17 additions & 0 deletions hw/nvme.c
Expand Up @@ -46,6 +46,7 @@ static void sq_processing_timer_cb(void *);
static int nvme_irqcq_empty(NVMEState *, uint32_t);
static void msix_clr_pending(PCIDevice *, uint32_t);


void enqueue_async_event(NVMEState *n, uint8_t event_type, uint8_t event_info,
uint8_t log_page)
{
Expand All @@ -61,6 +62,17 @@ void enqueue_async_event(NVMEState *n, uint8_t event_type, uint8_t event_info,
qemu_get_clock_ns(vm_clock) + 20000);
}

void isr_notify(NVMEState *n, NVMEIOCQueue *cq)
{
if (cq->irq_enabled) {
if (msix_enabled(&(n->dev))) {
msix_notify(&(n->dev), cq->vector);
} else {
qemu_irq_pulse(n->dev.irq[0]);
}
}
}

/*********************************************************************
Function : process_doorbell
Description : Processing Doorbell and SQ commands
Expand Down Expand Up @@ -117,6 +129,11 @@ static void process_doorbell(NVMEState *nvme_dev, target_phys_addr_t addr,
msix_clr_pending(&nvme_dev->dev, nvme_dev->cq[queue_id].vector);

}

if (nvme_dev->cq[queue_id].tail != nvme_dev->cq[queue_id].head) {
/* more completion entries, submit interrupt */
isr_notify(nvme_dev, &nvme_dev->cq[queue_id]);
}
} else {
/* SQ */
uint16_t new_tail = val & 0xffff;
Expand Down
1 change: 1 addition & 0 deletions hw/nvme.h
Expand Up @@ -1128,5 +1128,6 @@ void enqueue_async_event(NVMEState *n, uint8_t event_type, uint8_t event_info,
int random_chance(int chance);
void post_cq_entry(NVMEState *n, NVMEIOCQueue *cq, NVMECQE* cqe);
uint8_t is_cq_full(NVMEState *n, uint16_t qid);
void isr_notify(NVMEState *n, NVMEIOCQueue *cq);

#endif /* NVME_H_ */

0 comments on commit 9d1e69b

Please sign in to comment.