Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[linux-2.6-microblaze.git] / drivers / vdpa / ifcvf / ifcvf_base.c
index 6e197fe..2808f1b 100644 (file)
@@ -158,7 +158,9 @@ next:
                return -EIO;
        }
 
-       for (i = 0; i < IFCVF_MAX_QUEUE_PAIRS * 2; i++) {
+       hw->nr_vring = ifc_ioread16(&hw->common_cfg->num_queues);
+
+       for (i = 0; i < hw->nr_vring; i++) {
                ifc_iowrite16(i, &hw->common_cfg->queue_select);
                notify_off = ifc_ioread16(&hw->common_cfg->queue_notify_off);
                hw->vring[i].notify_addr = hw->notify_base +
@@ -304,7 +306,7 @@ u16 ifcvf_get_vq_state(struct ifcvf_hw *hw, u16 qid)
        u32 q_pair_id;
 
        ifcvf_lm = (struct ifcvf_lm_cfg __iomem *)hw->lm_cfg;
-       q_pair_id = qid / (IFCVF_MAX_QUEUE_PAIRS * 2);
+       q_pair_id = qid / hw->nr_vring;
        avail_idx_addr = &ifcvf_lm->vring_lm_cfg[q_pair_id].idx_addr[qid % 2];
        last_avail_idx = ifc_ioread16(avail_idx_addr);
 
@@ -318,7 +320,7 @@ int ifcvf_set_vq_state(struct ifcvf_hw *hw, u16 qid, u16 num)
        u32 q_pair_id;
 
        ifcvf_lm = (struct ifcvf_lm_cfg __iomem *)hw->lm_cfg;
-       q_pair_id = qid / (IFCVF_MAX_QUEUE_PAIRS * 2);
+       q_pair_id = qid / hw->nr_vring;
        avail_idx_addr = &ifcvf_lm->vring_lm_cfg[q_pair_id].idx_addr[qid % 2];
        hw->vring[qid].last_avail_idx = num;
        ifc_iowrite16(num, avail_idx_addr);