Skip to content

Commit 7712832

Browse files
Zhu Lingshanmstsirkin
authored andcommitted
vDPA/ifcvf: dynamic allocate vq data stores
This commit dynamically allocates the data stores for the virtqueues based on virtio_pci_common_cfg.num_queues. Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com> Message-Id: <20230612151420.1019504-2-lingshan.zhu@intel.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent bc9a2b3 commit 7712832

3 files changed

Lines changed: 6 additions & 1 deletion

File tree

drivers/vdpa/ifcvf/ifcvf_base.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ int ifcvf_init_hw(struct ifcvf_hw *hw, struct pci_dev *pdev)
134134
}
135135

136136
hw->nr_vring = vp_ioread16(&hw->common_cfg->num_queues);
137+
hw->vring = kzalloc(sizeof(struct vring_info) * hw->nr_vring, GFP_KERNEL);
138+
if (!hw->vring)
139+
return -ENOMEM;
137140

138141
for (i = 0; i < hw->nr_vring; i++) {
139142
vp_iowrite16(i, &hw->common_cfg->queue_select);

drivers/vdpa/ifcvf/ifcvf_base.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct ifcvf_hw {
7474
u64 dev_features;
7575
struct virtio_pci_common_cfg __iomem *common_cfg;
7676
void __iomem *dev_cfg;
77-
struct vring_info vring[IFCVF_MAX_QUEUES];
77+
struct vring_info *vring;
7878
void __iomem * const *base;
7979
char config_msix_name[256];
8080
struct vdpa_callback config_cb;

drivers/vdpa/ifcvf/ifcvf_main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,7 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
830830
return 0;
831831

832832
err:
833+
kfree(ifcvf_mgmt_dev->vf.vring);
833834
kfree(ifcvf_mgmt_dev);
834835
return ret;
835836
}
@@ -840,6 +841,7 @@ static void ifcvf_remove(struct pci_dev *pdev)
840841

841842
ifcvf_mgmt_dev = pci_get_drvdata(pdev);
842843
vdpa_mgmtdev_unregister(&ifcvf_mgmt_dev->mdev);
844+
kfree(ifcvf_mgmt_dev->vf.vring);
843845
kfree(ifcvf_mgmt_dev);
844846
}
845847

0 commit comments

Comments
 (0)