mirror of
https://github.com/torvalds/linux.git
synced 2024-11-15 00:21:59 +00:00
virtio/s390: DMA support for virtio-ccw
Currently virtio-ccw devices do not work if the device has VIRTIO_F_IOMMU_PLATFORM. In future we do want to support DMA API with virtio-ccw. Let us do the plumbing, so the feature VIRTIO_F_IOMMU_PLATFORM works with virtio-ccw. Let us also switch from legacy avail/used accessors to the DMA aware ones (even if it isn't strictly necessary), and remove the legacy accessors (we were the last users). Signed-off-by: Halil Pasic <pasic@linux.ibm.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cohuck@redhat.com>
This commit is contained in:
parent
3279beac54
commit
f35f54f11f
@ -66,6 +66,7 @@ struct virtio_ccw_device {
|
||||
bool device_lost;
|
||||
unsigned int config_ready;
|
||||
void *airq_info;
|
||||
u64 dma_mask;
|
||||
};
|
||||
|
||||
struct vq_info_block_legacy {
|
||||
@ -539,8 +540,8 @@ static struct virtqueue *virtio_ccw_setup_vq(struct virtio_device *vdev,
|
||||
info->info_block->s.desc = queue;
|
||||
info->info_block->s.index = i;
|
||||
info->info_block->s.num = info->num;
|
||||
info->info_block->s.avail = (__u64)virtqueue_get_avail(vq);
|
||||
info->info_block->s.used = (__u64)virtqueue_get_used(vq);
|
||||
info->info_block->s.avail = (__u64)virtqueue_get_avail_addr(vq);
|
||||
info->info_block->s.used = (__u64)virtqueue_get_used_addr(vq);
|
||||
ccw->count = sizeof(info->info_block->s);
|
||||
}
|
||||
ccw->cmd_code = CCW_CMD_SET_VQ;
|
||||
@ -772,10 +773,8 @@ out_free:
|
||||
static void ccw_transport_features(struct virtio_device *vdev)
|
||||
{
|
||||
/*
|
||||
* Packed ring isn't enabled on virtio_ccw for now,
|
||||
* because virtio_ccw uses some legacy accessors,
|
||||
* e.g. virtqueue_get_avail() and virtqueue_get_used()
|
||||
* which aren't available in packed ring currently.
|
||||
* There shouldn't be anything that precludes supporting packed.
|
||||
* TODO: Remove the limitation after having another look into this.
|
||||
*/
|
||||
__virtio_clear_bit(vdev, VIRTIO_F_RING_PACKED);
|
||||
}
|
||||
@ -1258,6 +1257,16 @@ static int virtio_ccw_online(struct ccw_device *cdev)
|
||||
ret = -ENOMEM;
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
vcdev->vdev.dev.parent = &cdev->dev;
|
||||
cdev->dev.dma_mask = &vcdev->dma_mask;
|
||||
/* we are fine with common virtio infrastructure using 64 bit DMA */
|
||||
ret = dma_set_mask_and_coherent(&cdev->dev, DMA_BIT_MASK(64));
|
||||
if (ret) {
|
||||
dev_warn(&cdev->dev, "Failed to enable 64-bit DMA.\n");
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
vcdev->config_block = kzalloc(sizeof(*vcdev->config_block),
|
||||
GFP_DMA | GFP_KERNEL);
|
||||
if (!vcdev->config_block) {
|
||||
@ -1272,7 +1281,6 @@ static int virtio_ccw_online(struct ccw_device *cdev)
|
||||
|
||||
vcdev->is_thinint = virtio_ccw_use_airq; /* at least try */
|
||||
|
||||
vcdev->vdev.dev.parent = &cdev->dev;
|
||||
vcdev->vdev.dev.release = virtio_ccw_release_dev;
|
||||
vcdev->vdev.config = &virtio_ccw_config_ops;
|
||||
vcdev->cdev = cdev;
|
||||
|
@ -90,23 +90,6 @@ dma_addr_t virtqueue_get_desc_addr(struct virtqueue *vq);
|
||||
dma_addr_t virtqueue_get_avail_addr(struct virtqueue *vq);
|
||||
dma_addr_t virtqueue_get_used_addr(struct virtqueue *vq);
|
||||
|
||||
/*
|
||||
* Legacy accessors -- in almost all cases, these are the wrong functions
|
||||
* to use.
|
||||
*/
|
||||
static inline void *virtqueue_get_desc(struct virtqueue *vq)
|
||||
{
|
||||
return virtqueue_get_vring(vq)->desc;
|
||||
}
|
||||
static inline void *virtqueue_get_avail(struct virtqueue *vq)
|
||||
{
|
||||
return virtqueue_get_vring(vq)->avail;
|
||||
}
|
||||
static inline void *virtqueue_get_used(struct virtqueue *vq)
|
||||
{
|
||||
return virtqueue_get_vring(vq)->used;
|
||||
}
|
||||
|
||||
/**
|
||||
* virtio_device - representation of a device using virtio
|
||||
* @index: unique position on the virtio bus
|
||||
|
Loading…
Reference in New Issue
Block a user