Re: [PATCH v2 04/23] virtio: Add get_shm_region method

From
Gurchetan Singh <>
Date
2020-09-03T00:00:42+00:00
ID
Thread
Re: [PATCH v2 04/23] virtio: Add get_shm_region method
On Wed, Sep 2, 2020 at 3:15 PM Vivek Goyal <> wrote:

Hi Gurchetan,

Now Miklos has queued, these tree virtio patches for shared memory

region in his tree as part of virtiofs dax patch series.

I am hoping this will get merged in 5.10 through his tree.

https://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse.git/log/?h=dax

Terrific ... ! Maybe we can queue the version Miklos has in drm-misc-next to avoid merge conflicts ?!?

There's a few checkpatch --strict fixes in the blob version, but I doubt anyone cares.

Thanks

Vivek

On Wed, Sep 02, 2020 at 02:08:28PM -0700, Gurchetan Singh wrote:

> From: Sebastien Boeuf <>

> 

> Virtio defines 'shared memory regions' that provide a continuously

> shared region between the host and guest.

> 

> Provide a method to find a particular region on a device.

> 

> Signed-off-by: Sebastien Boeuf <>

> Signed-off-by: Dr. David Alan Gilbert <>

> Acked-by: Michael S. Tsirkin <>

> Cc: 

> Cc: 

> Cc: "Michael S. Tsirkin" <>

> ---

>Â include/linux/virtio_config.h | 17 +++++++++++++++++

>Â 1 file changed, 17 insertions(+)

> 

> diff --git a/include/linux/virtio_config.h b/include/linux/virtio_config.h

> index 8fe857e27ef32..4b8e38c5c4d8c 100644

> --- a/include/linux/virtio_config.h

> +++ b/include/linux/virtio_config.h

> @@ -11,6 +11,11 @@

>Â 

>Â struct irq_affinity;

>Â 

> +struct virtio_shm_region {

> +Â Â Âu64 addr;

> +Â Â Âu64 len;

> +};

> +

>Â /**

>Â Â* virtio_config_ops - operations for configuring a virtio device

>Â Â* Note: Do not assume that a transport implements all of the operations

> @@ -66,6 +71,7 @@ struct irq_affinity;

>Â Â*Â Â Â the caller can then copy.

>Â Â* @set_vq_affinity: set the affinity for a virtqueue (optional).

>Â Â* @get_vq_affinity: get the affinity for a virtqueue (optional).

> + * @get_shm_region: get a shared memory region based on the index.

>Â Â*/

>Â typedef void vq_callback_t(struct virtqueue *);

>Â struct virtio_config_ops {

> @@ -89,6 +95,8 @@ struct virtio_config_ops {

>Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â const struct cpumask *cpu_mask);

>Â Â Â Âconst struct cpumask *(*get_vq_affinity)(struct virtio_device *vdev,

>Â Â Â Â Â Â Â Â Â Â Â Âint index);

> +Â Â Âbool (*get_shm_region)(struct virtio_device *vdev,

> +Â Â Â Â Â Â Â Â Â Â Â Â Â Â struct virtio_shm_region *region, u8 id);

>Â };

>Â 

>Â /* If driver didn't advertise the feature, it will never appear. */

> @@ -251,6 +259,15 @@ int virtqueue_set_affinity(struct virtqueue *vq, const struct cpumask *cpu_mask)

>Â Â Â Âreturn 0;

>Â }

>Â 

> +static inline

> +bool virtio_get_shm_region(struct virtio_device *vdev,

> +Â Â Â Â Â Â Â Â Â Â Â Â struct virtio_shm_region *region, u8 id)

> +{

> +Â Â Âif (!vdev->config->get_shm_region)

> +Â Â Â Â Â Â Âreturn false;

> +Â Â Âreturn vdev->config->get_shm_region(vdev, region, id);

> +}

> +

>Â static inline bool virtio_is_little_endian(struct virtio_device *vdev)

>Â {

>Â Â Â Âreturn virtio_has_feature(vdev, VIRTIO_F_VERSION_1) ||

> -- 

> 2.26.2

>