]> www.infradead.org Git - qemu-nvme.git/commitdiff
hw/nvme: make nvme_sq_empty/nvme_cq_full inline bool
authorKlaus Jensen <k.jensen@samsung.com>
Tue, 7 Feb 2023 13:29:44 +0000 (14:29 +0100)
committerKlaus Jensen <k.jensen@samsung.com>
Thu, 8 Jun 2023 11:32:05 +0000 (13:32 +0200)
These functions returns booleans. Additionally, add an nvme_cq_empty
helper.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
hw/nvme/ctrl.c

index fd917fcda1f5ea054b21404619be1b25f2914195..983ca8afa9cb3fc14781a5f74830aba9d09b069d 100644 (file)
@@ -627,12 +627,17 @@ static void nvme_inc_sq_head(NvmeSQueue *sq)
     sq->head = (sq->head + 1) % sq->size;
 }
 
-static uint8_t nvme_cq_full(NvmeCQueue *cq)
+static inline bool nvme_cq_full(NvmeCQueue *cq)
 {
     return (cq->tail + 1) % cq->size == cq->head;
 }
 
-static uint8_t nvme_sq_empty(NvmeSQueue *sq)
+static inline bool nvme_cq_empty(NvmeCQueue *cq)
+{
+    return cq->head == cq->tail;
+}
+
+static inline bool nvme_sq_empty(NvmeSQueue *sq)
 {
     return sq->head == sq->tail;
 }
@@ -4469,7 +4474,7 @@ static void nvme_cq_notifier(EventNotifier *e)
 
     nvme_update_cq_head(cq);
 
-    if (cq->tail == cq->head) {
+    if (nvme_cq_empty(cq)) {
         if (cq->irq_enabled) {
             n->cq_pending--;
         }
@@ -7568,7 +7573,7 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
         /* Completion queue doorbell write */
 
         uint16_t new_head = val & 0xffff;
-        int start_sqs;
+        bool start_sqs;
         NvmeCQueue *cq;
 
         qid = (addr - (0x1000 + (1 << 2))) >> 3;
@@ -7619,7 +7624,7 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
 
         trace_pci_nvme_mmio_doorbell_cq(cq->cqid, new_head);
 
-        start_sqs = nvme_cq_full(cq) ? 1 : 0;
+        start_sqs = nvme_cq_full(cq);
         cq->head = new_head;
         if (!qid && n->dbbuf_enabled) {
             pci_dma_write(pci, cq->db_addr, &cq->head, sizeof(cq->head));
@@ -7632,7 +7637,7 @@ static void nvme_process_db(NvmeCtrl *n, hwaddr addr, int val)
             qemu_bh_schedule(cq->bh);
         }
 
-        if (cq->tail == cq->head) {
+        if (nvme_cq_empty(cq)) {
             if (cq->irq_enabled) {
                 n->cq_pending--;
             }