Commit ca1f46fa authored by Stefano Garzarella's avatar Stefano Garzarella Committed by Pengyuan Zhao
Browse files

vdpa_sim: make vdpasim->buffer size configurable

stable inclusion
from stable-v5.11
commit da7af696
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I5WXCZ
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=da7af6967c6e9815f8da60a8db1d0fe35b8e97b9



----------------------------------------------------------------------

Allow each device to specify the size of the buffer allocated
in vdpa_sim.

Acked-by: default avatarJason Wang <jasowang@redhat.com>
Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
Link: https://lore.kernel.org/r/20201215144256.155342-17-sgarzare@redhat.com


Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Signed-off-by: default avatarPengyuan Zhao <zhaopengyuan@hisilicon.com>
parent e9fa014b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ struct vdpasim *vdpasim_create(struct vdpasim_dev_attr *dev_attr)
	if (!vdpasim->iommu)
		goto err_iommu;

	vdpasim->buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
	vdpasim->buffer = kvmalloc(dev_attr->buffer_size, GFP_KERNEL);
	if (!vdpasim->buffer)
		goto err_iommu;

+1 −0
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ struct vdpasim_virtqueue {
struct vdpasim_dev_attr {
	u64 supported_features;
	size_t config_size;
	size_t buffer_size;
	int nvqs;
	u32 id;

+1 −0
Original line number Diff line number Diff line
@@ -109,6 +109,7 @@ static int __init vdpasim_blk_init(void)
	dev_attr.config_size = sizeof(struct virtio_blk_config);
	dev_attr.get_config = vdpasim_blk_get_config;
	dev_attr.work_fn = vdpasim_blk_work;
	dev_attr.buffer_size = PAGE_SIZE;

	vdpasim_blk_dev = vdpasim_create(&dev_attr);
	if (IS_ERR(vdpasim_blk_dev)) {
+1 −0
Original line number Diff line number Diff line
@@ -141,6 +141,7 @@ static int __init vdpasim_net_init(void)
	dev_attr.config_size = sizeof(struct virtio_net_config);
	dev_attr.get_config = vdpasim_net_get_config;
	dev_attr.work_fn = vdpasim_net_work;
	dev_attr.buffer_size = PAGE_SIZE;

	vdpasim_net_dev = vdpasim_create(&dev_attr);
	if (IS_ERR(vdpasim_net_dev)) {