virtio: Add a new event queue allocate function.

Add a new event queue allocate function which will call a self-defined
event queue init callback. new queue init callback function can set
cache line align, which can reduce the snoop invalidate dcache line in
IPI AMP communication.

Signed-off-by: Minda Chen <minda.chen@starfivetech.com>
This commit is contained in:
Minda Chen
2024-05-13 16:49:27 +08:00
parent 454bd993b1
commit 62f6dc972e
2 changed files with 47 additions and 1 deletions

View File

@@ -2869,6 +2869,36 @@ struct virtqueue *vring_new_virtqueue(unsigned int index,
}
EXPORT_SYMBOL_GPL(vring_new_virtqueue);
#ifdef CONFIG_RISCV_AMP
struct virtqueue *vring_new_virtqueue_with_init(unsigned int index,
unsigned int num,
unsigned int vring_align,
struct virtio_device *vdev,
bool weak_barriers,
bool context,
void *pages,
bool (*notify)(struct virtqueue *vq),
void (*callback)(struct virtqueue *vq),
const char *name,
unsigned long (*init)(struct vring *vr,
unsigned int num,
void *p,
unsigned long align)
)
{
struct vring_virtqueue_split vring_split = {};
if (virtio_has_feature(vdev, VIRTIO_F_RING_PACKED))
return NULL;
init(&vring_split.vring, num, pages, vring_align);
return __vring_new_virtqueue(index, &vring_split, vdev, weak_barriers,
context, notify, callback, name,
vdev->dev.parent);
}
EXPORT_SYMBOL_GPL(vring_new_virtqueue_with_init);
#endif
static void vring_free(struct virtqueue *_vq)
{
struct vring_virtqueue *vq = to_vvq(_vq);

View File

@@ -107,7 +107,23 @@ struct virtqueue *vring_new_virtqueue(unsigned int index,
bool (*notify)(struct virtqueue *vq),
void (*callback)(struct virtqueue *vq),
const char *name);
#ifdef CONFIG_RISCV_AMP
struct virtqueue *vring_new_virtqueue_with_init(unsigned int index,
unsigned int num,
unsigned int vring_align,
struct virtio_device *vdev,
bool weak_barriers,
bool context,
void *pages,
bool (*notify)(struct virtqueue *vq),
void (*callback)(struct virtqueue *vq),
const char *name,
unsigned long (*init)(struct vring *vr,
unsigned int num,
void *p,
unsigned long align)
);
#endif
/*
* Destroys a virtqueue. If created with vring_create_virtqueue, this
* also frees the ring.