[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 3/7] virtio: Add shared memory capability
From: |
Dr. David Alan Gilbert |
Subject: |
Re: [PATCH 3/7] virtio: Add shared memory capability |
Date: |
Wed, 28 Jul 2021 14:21:29 +0100 |
User-agent: |
Mutt/2.0.7 (2021-05-04) |
* Antonio Caggiano (antonio.caggiano@collabora.com) wrote:
> From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
>
> Define a new capability type 'VIRTIO_PCI_CAP_SHARED_MEMORY_CFG'.
> They allow defining shared memory regions with sizes and offsets
> of 2^32 and more.
> Multiple instances of the capability are allowed and distinguished
> by a device-specific 'id'.
> Use VIRTIO_GPU_SHM_ID_HOST_VISIBLE as id for virtio-gpu.
>
> Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
> Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com>
> (cherry picked from commit a5d628a3a3c5e60b98b15ffff197c36a77056115)
Could you please separate this off, so that you have my original
virtio-pci patch, adn then the gpu parts in a separate patch please.
Dave
> ---
> hw/display/virtio-gpu-pci.c | 2 +-
> hw/display/virtio-vga.c | 2 +-
> hw/virtio/virtio-pci.c | 19 +++++++++++++++++++
> hw/virtio/virtio-pci.h | 5 +++++
> 4 files changed, 26 insertions(+), 2 deletions(-)
>
> diff --git a/hw/display/virtio-gpu-pci.c b/hw/display/virtio-gpu-pci.c
> index 9808663d05..a79bd751b2 100644
> --- a/hw/display/virtio-gpu-pci.c
> +++ b/hw/display/virtio-gpu-pci.c
> @@ -43,7 +43,7 @@ static void virtio_gpu_pci_base_realize(VirtIOPCIProxy
> *vpci_dev, Error **errp)
> PCI_BASE_ADDRESS_MEM_PREFETCH |
> PCI_BASE_ADDRESS_MEM_TYPE_64,
> &g->hostmem);
> - virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, 0);
> + virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem,
> VIRTIO_GPU_SHM_ID_HOST_VISIBLE);
> }
>
> qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus), errp);
> diff --git a/hw/display/virtio-vga.c b/hw/display/virtio-vga.c
> index 61993dd3f2..ca841a0799 100644
> --- a/hw/display/virtio-vga.c
> +++ b/hw/display/virtio-vga.c
> @@ -147,7 +147,7 @@ static void virtio_vga_base_realize(VirtIOPCIProxy
> *vpci_dev, Error **errp)
> PCI_BASE_ADDRESS_MEM_PREFETCH |
> PCI_BASE_ADDRESS_MEM_TYPE_64,
> &g->hostmem);
> - virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem, 0);
> + virtio_pci_add_shm_cap(vpci_dev, 4, 0, g->conf.hostmem,
> VIRTIO_GPU_SHM_ID_HOST_VISIBLE);
> }
>
> if (!(vpci_dev->flags & VIRTIO_PCI_FLAG_PAGE_PER_VQ)) {
> diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
> index 433060ac02..37a50b4658 100644
> --- a/hw/virtio/virtio-pci.c
> +++ b/hw/virtio/virtio-pci.c
> @@ -1149,6 +1149,25 @@ static int virtio_pci_add_mem_cap(VirtIOPCIProxy
> *proxy,
> return offset;
> }
>
> +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy,
> + uint8_t bar, uint64_t offset, uint64_t length,
> + uint8_t id)
> +{
> + struct virtio_pci_cap64 cap = {
> + .cap.cap_len = sizeof cap,
> + .cap.cfg_type = VIRTIO_PCI_CAP_SHARED_MEMORY_CFG,
> + };
> + uint32_t mask32 = ~0;
> +
> + cap.cap.bar = bar;
> + cap.cap.length = cpu_to_le32(length & mask32);
> + cap.length_hi = cpu_to_le32((length >> 32) & mask32);
> + cap.cap.offset = cpu_to_le32(offset & mask32);
> + cap.offset_hi = cpu_to_le32((offset >> 32) & mask32);
> + cap.cap.id = id;
> + return virtio_pci_add_mem_cap(proxy, &cap.cap);
> +}
> +
> static uint64_t virtio_pci_common_read(void *opaque, hwaddr addr,
> unsigned size)
> {
> diff --git a/hw/virtio/virtio-pci.h b/hw/virtio/virtio-pci.h
> index 2446dcd9ae..25c4b7a32d 100644
> --- a/hw/virtio/virtio-pci.h
> +++ b/hw/virtio/virtio-pci.h
> @@ -252,4 +252,9 @@ void virtio_pci_types_register(const
> VirtioPCIDeviceTypeInfo *t);
> */
> unsigned virtio_pci_optimal_num_queues(unsigned fixed_queues);
>
> +/* Add shared memory capability */
> +int virtio_pci_add_shm_cap(VirtIOPCIProxy *proxy,
> + uint8_t bar, uint64_t offset, uint64_t length,
> + uint8_t id);
> +
> #endif
> --
> 2.30.2
>
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK
- [PATCH 0/7] virtio-gpu: Support Venus Vulkan driver, Antonio Caggiano, 2021/07/27
- [PATCH 1/7] virtio-gpu: CONTEXT_INIT feature, Antonio Caggiano, 2021/07/27
- [PATCH 4/7] virtio-gpu: Resource UUID, Antonio Caggiano, 2021/07/27
- [PATCH 6/7] virtio-gpu: Initialize Venus, Antonio Caggiano, 2021/07/27
- [PATCH 7/7] virtio-gpu: Handle resource blob commands, Antonio Caggiano, 2021/07/27
- [PATCH 3/7] virtio: Add shared memory capability, Antonio Caggiano, 2021/07/27
- Re: [PATCH 3/7] virtio: Add shared memory capability,
Dr. David Alan Gilbert <=
- [PATCH 2/7] virtio-gpu: hostmem [wip], Antonio Caggiano, 2021/07/27
- [PATCH 5/7] virtio-gpu: Support Venus capset, Antonio Caggiano, 2021/07/27