lkml.org 
[lkml]   [2020]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 04/20] virtio: Implement get_shm_region for PCI transport
On Wed, Mar 04, 2020 at 11:58:29AM -0500, Vivek Goyal wrote:
> diff --git a/drivers/virtio/virtio_pci_modern.c b/drivers/virtio/virtio_pci_modern.c
> index 7abcc50838b8..52f179411015 100644
> --- a/drivers/virtio/virtio_pci_modern.c
> +++ b/drivers/virtio/virtio_pci_modern.c
> @@ -443,6 +443,111 @@ static void del_vq(struct virtio_pci_vq_info *info)
> vring_del_virtqueue(vq);
> }
>
> +static int virtio_pci_find_shm_cap(struct pci_dev *dev,
> + u8 required_id,
> + u8 *bar, u64 *offset, u64 *len)
> +{
> + int pos;
> +
> + for (pos = pci_find_capability(dev, PCI_CAP_ID_VNDR);

Please fix the mixed tabs vs space indentation in this patch.

> +static bool vp_get_shm_region(struct virtio_device *vdev,
> + struct virtio_shm_region *region, u8 id)
> +{
> + struct virtio_pci_device *vp_dev = to_vp_device(vdev);
> + struct pci_dev *pci_dev = vp_dev->pci_dev;
> + u8 bar;
> + u64 offset, len;
> + phys_addr_t phys_addr;
> + size_t bar_len;
> + int ret;
> +
> + if (!virtio_pci_find_shm_cap(pci_dev, id, &bar, &offset, &len)) {
> + return false;
> + }
> +
> + ret = pci_request_region(pci_dev, bar, "virtio-pci-shm");
> + if (ret < 0) {
> + dev_err(&pci_dev->dev, "%s: failed to request BAR\n",
> + __func__);
> + return false;
> + }
> +
> + phys_addr = pci_resource_start(pci_dev, bar);
> + bar_len = pci_resource_len(pci_dev, bar);
> +
> + if (offset + len > bar_len) {
> + dev_err(&pci_dev->dev,
> + "%s: bar shorter than cap offset+len\n",
> + __func__);
> + return false;
> + }
> +
> + region->len = len;
> + region->addr = (u64) phys_addr + offset;
> +
> + return true;
> +}

Missing pci_release_region()?
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-03-10 12:05    [W:0.542 / U:0.568 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site