[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20201113134712.69744-10-sgarzare@redhat.com>
Date: Fri, 13 Nov 2020 14:47:09 +0100
From: Stefano Garzarella <sgarzare@...hat.com>
To: virtualization@...ts.linux-foundation.org
Cc: Stefan Hajnoczi <stefanha@...hat.com>,
Laurent Vivier <lvivier@...hat.com>,
linux-kernel@...r.kernel.org, Eli Cohen <elic@...dia.com>,
Jason Wang <jasowang@...hat.com>,
"Michael S. Tsirkin" <mst@...hat.com>,
Max Gurtovoy <mgurtovoy@...dia.com>
Subject: [PATCH RFC 09/12] vdpa_sim: make vdpasim->buffer size configurable
Allow each device to specify the size of the buffer allocated
in vdpa_sim.
Signed-off-by: Stefano Garzarella <sgarzare@...hat.com>
---
drivers/vdpa/vdpa_sim/vdpa_sim.h | 1 +
drivers/vdpa/vdpa_sim/vdpa_sim.c | 2 +-
drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 1 +
drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 1 +
4 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.h b/drivers/vdpa/vdpa_sim/vdpa_sim.h
index f7e1fe0a88d3..cc21e07aa2f7 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.h
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.h
@@ -49,6 +49,7 @@ struct vdpasim_device {
struct vdpasim_init_attr {
struct vdpasim_device device;
+ size_t buffer_size;
int batch_mapping;
work_func_t work_fn;
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index bd034fbf4683..3863d49e0d6d 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -223,7 +223,7 @@ struct vdpasim *vdpasim_create(struct vdpasim_init_attr *attr)
if (!vdpasim->iommu)
goto err_iommu;
- vdpasim->buffer = kvmalloc(PAGE_SIZE, GFP_KERNEL);
+ vdpasim->buffer = kvmalloc(attr->buffer_size, GFP_KERNEL);
if (!vdpasim->buffer)
goto err_iommu;
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
index f456a0e4e097..122a3c039507 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
@@ -100,6 +100,7 @@ static int __init vdpasim_blk_init(void)
attr.device.update_config = vdpasim_blk_update_config;
attr.work_fn = vdpasim_blk_work;
+ attr.buffer_size = PAGE_SIZE;
vdpasim_blk_dev = vdpasim_create(&attr);
if (IS_ERR(vdpasim_blk_dev)) {
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
index b9372fdf2415..d0a1403f64b2 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
@@ -124,6 +124,7 @@ static int __init vdpasim_net_init(void)
attr.work_fn = vdpasim_net_work;
attr.batch_mapping = batch_mapping;
+ attr.buffer_size = PAGE_SIZE;
vdpasim_net_dev = vdpasim_create(&attr);
if (IS_ERR(vdpasim_net_dev)) {
--
2.26.2
Powered by blists - more mailing lists