Merge tag 'sched_urgent_for_v5.15_rc1' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-microblaze.git] / drivers / vdpa / ifcvf / ifcvf_base.c
index 1a661ab..2808f1b 100644 (file)
@@ -133,6 +133,8 @@ int ifcvf_init_hw(struct ifcvf_hw *hw, struct pci_dev *pdev)
                                              &hw->notify_off_multiplier);
                        hw->notify_bar = cap.bar;
                        hw->notify_base = get_cap_addr(hw, &cap);
+                       hw->notify_base_pa = pci_resource_start(pdev, cap.bar) +
+                                       le32_to_cpu(cap.offset);
                        IFCVF_DBG(pdev, "hw->notify_base = %p\n",
                                  hw->notify_base);
                        break;
@@ -156,11 +158,15 @@ 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 +
                        notify_off * hw->notify_off_multiplier;
+               hw->vring[i].notify_pa = hw->notify_base_pa +
+                       notify_off * hw->notify_off_multiplier;
        }
 
        hw->lm_cfg = hw->base[IFCVF_LM_BAR];
@@ -300,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);
 
@@ -314,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);