Skip to content

Commit

Permalink
virtqueue: Fix comment on shm_io and fix type
Browse files Browse the repository at this point in the history
This should hold a pointer to a metal_io_region, make that the type.

Also fix the comment above this variable. This region holds the address
of the message buffers, not the vring descriptor table nor available/used
ring data. It is only used for virt-to-phys/phys-to-vert translation on
the buffers pointed to by these descriptors.

This comment seems to have cause an issue in virtio_mmio_drv where
this region is used to translate the address of the vring descriptor
table. This may have worked if the vring descriptor table was part of
the same IO space as the buffers point to by those descriptors, but
this is not guaranteed to always be the case. Fix that here.

Signed-off-by: Andrew Davis <[email protected]>
  • Loading branch information
glneo committed Mar 16, 2024
1 parent 79b795e commit 58e04c9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/include/openamp/virtqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,10 @@ struct virtqueue {
uint16_t vq_queued_cnt;

/**
* Metal I/O region of the vrings and buffers.
* Metal I/O region of the buffers.
* This structure is used for conversion between virtual and physical addresses.
*/
void *shm_io;
struct metal_io_region *shm_io;

/**
* Head of the free chain in the descriptor table. If there are no free descriptors,
Expand Down
2 changes: 1 addition & 1 deletion lib/virtio_mmio/virtio_mmio_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ struct virtqueue *virtio_mmio_setup_virtqueue(struct virtio_device *vdev,
virtio_mmio_write32(vdev, VIRTIO_MMIO_QUEUE_NUM, vq->vq_nentries);
virtio_mmio_write32(vdev, VIRTIO_MMIO_QUEUE_ALIGN, 4096);
virtio_mmio_write32(vdev, VIRTIO_MMIO_QUEUE_PFN,
((uintptr_t)metal_io_virt_to_phys(vq->shm_io,
((uintptr_t)metal_io_virt_to_phys(vmdev->shm_io,
(char *)vq->vq_ring.desc)) / 4096);

vdev->vrings_info[vdev->vrings_num].vq = vq;
Expand Down

0 comments on commit 58e04c9

Please sign in to comment.