#include <../drivers/ata/ahci.h>
 #include <linux/export.h>
 #include <linux/debugfs.h>
+#include <linux/prefetch.h>
 #include "mtip32xx.h"
 
 #define HW_CMD_SLOT_SZ         (MTIP_MAX_COMMAND_SLOTS * 32)
        /* Map the scatter list for DMA access */
        nents = dma_map_sg(&dd->pdev->dev, command->sg, nents, dma_dir);
 
+       prefetch(&port->flags);
+
        command->scatter_ents = nents;
 
        /*
        fis = command->command;
        fis->type        = 0x27;
        fis->opts        = 1 << 7;
-       if (rq_data_dir(rq) == READ)
+       if (dma_dir == DMA_FROM_DEVICE)
                fis->command = ATA_CMD_FPDMA_READ;
        else
                fis->command = ATA_CMD_FPDMA_WRITE;
        fis->res3        = 0;
        fill_command_sg(dd, command, nents);
 
-       if (command->unaligned)
+       if (unlikely(command->unaligned))
                fis->device |= 1 << 7;
 
        /* Populate the command header */
         * To prevent this command from being issued
         * if an internal command is in progress or error handling is active.
         */
-       if (port->flags & MTIP_PF_PAUSE_IO) {
+       if (unlikely(port->flags & MTIP_PF_PAUSE_IO)) {
                set_bit(rq->tag, port->cmds_to_issue);
                set_bit(MTIP_PF_ISSUE_CMDS_BIT, &port->flags);
                return;
        struct driver_data *dd = hctx->queue->queuedata;
        struct mtip_cmd *cmd = blk_mq_rq_to_pdu(rq);
 
-       if (!dd->unal_qdepth || rq_data_dir(rq) == READ)
+       if (rq_data_dir(rq) == READ || !dd->unal_qdepth)
                return false;
 
        /*
 {
        int ret;
 
-       if (mtip_check_unal_depth(hctx, rq))
+       if (unlikely(mtip_check_unal_depth(hctx, rq)))
                return BLK_MQ_RQ_QUEUE_BUSY;
 
        ret = mtip_submit_request(hctx, rq);
-       if (!ret)
+       if (likely(!ret))
                return BLK_MQ_RQ_QUEUE_OK;
 
        rq->errors = ret;
 
 
        struct workqueue_struct *isr_workq;
 
-       struct mtip_work work[MTIP_MAX_SLOT_GROUPS];
-
        atomic_t irq_workers_active;
 
+       struct mtip_work work[MTIP_MAX_SLOT_GROUPS];
+
        int isr_binding;
 
        struct block_device *bdev;
 
-       int unal_qdepth; /* qdepth of unaligned IO queue */
-
        struct list_head online_list; /* linkage for online list */
 
        struct list_head remove_list; /* linkage for removing list */
+
+       int unal_qdepth; /* qdepth of unaligned IO queue */
 };
 
 #endif