From: Alex Williamson <alex.williamson@redhat.com>
To: Yishai Hadas <yishaih@nvidia.com>
Cc: <mst@redhat.com>, <jasowang@redhat.com>, <jgg@nvidia.com>,
<kvm@vger.kernel.org>,
<virtualization@lists.linux-foundation.org>, <parav@nvidia.com>,
<feliu@nvidia.com>, <jiri@nvidia.com>, <kevin.tian@intel.com>,
<joao.m.martins@oracle.com>, <si-wei.liu@oracle.com>,
<leonro@nvidia.com>, <maorg@nvidia.com>
Subject: Re: [PATCH V5 vfio 8/9] vfio/pci: Expose vfio_pci_core_iowrite/read##size()
Date: Tue, 5 Dec 2023 15:51:53 -0700 [thread overview]
Message-ID: <20231205155153.2d5aceab.alex.williamson@redhat.com> (raw)
In-Reply-To: <20231205170623.197877-9-yishaih@nvidia.com>
On Tue, 5 Dec 2023 19:06:22 +0200
Yishai Hadas <yishaih@nvidia.com> wrote:
> Expose vfio_pci_core_iowrite/read##size() to let it be used by drivers.
>
> This functionality is needed to enable direct access to some physical
> BAR of the device with the proper locks/checks in place.
>
> The next patches from this series will use this functionality on a data
> path flow when a direct access to the BAR is needed.
>
> Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
> ---
> drivers/vfio/pci/vfio_pci_rdwr.c | 46 +++++++++++++++++---------------
> include/linux/vfio_pci_core.h | 19 +++++++++++++
> 2 files changed, 43 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c
> index a9887fd6de46..448ee90a3bb1 100644
> --- a/drivers/vfio/pci/vfio_pci_rdwr.c
> +++ b/drivers/vfio/pci/vfio_pci_rdwr.c
> @@ -38,7 +38,7 @@
> #define vfio_iowrite8 iowrite8
>
> #define VFIO_IOWRITE(size) \
> -static int vfio_pci_iowrite##size(struct vfio_pci_core_device *vdev, \
> +int vfio_pci_core_iowrite##size(struct vfio_pci_core_device *vdev, \
> bool test_mem, u##size val, void __iomem *io) \
> { \
> if (test_mem) { \
> @@ -55,7 +55,8 @@ static int vfio_pci_iowrite##size(struct vfio_pci_core_device *vdev, \
> up_read(&vdev->memory_lock); \
> \
> return 0; \
> -}
> +} \
> +EXPORT_SYMBOL_GPL(vfio_pci_core_iowrite##size);
>
> VFIO_IOWRITE(8)
> VFIO_IOWRITE(16)
> @@ -65,7 +66,7 @@ VFIO_IOWRITE(64)
> #endif
>
> #define VFIO_IOREAD(size) \
> -static int vfio_pci_ioread##size(struct vfio_pci_core_device *vdev, \
> +int vfio_pci_core_ioread##size(struct vfio_pci_core_device *vdev, \
> bool test_mem, u##size *val, void __iomem *io) \
> { \
> if (test_mem) { \
> @@ -82,7 +83,8 @@ static int vfio_pci_ioread##size(struct vfio_pci_core_device *vdev, \
> up_read(&vdev->memory_lock); \
> \
> return 0; \
> -}
> +} \
> +EXPORT_SYMBOL_GPL(vfio_pci_core_ioread##size);
>
> VFIO_IOREAD(8)
> VFIO_IOREAD(16)
> @@ -119,13 +121,13 @@ static ssize_t do_io_rw(struct vfio_pci_core_device *vdev, bool test_mem,
> if (copy_from_user(&val, buf, 4))
> return -EFAULT;
>
> - ret = vfio_pci_iowrite32(vdev, test_mem,
> - val, io + off);
> + ret = vfio_pci_core_iowrite32(vdev, test_mem,
> + val, io + off);
> if (ret)
> return ret;
> } else {
> - ret = vfio_pci_ioread32(vdev, test_mem,
> - &val, io + off);
> + ret = vfio_pci_core_ioread32(vdev, test_mem,
> + &val, io + off);
> if (ret)
> return ret;
>
> @@ -141,13 +143,13 @@ static ssize_t do_io_rw(struct vfio_pci_core_device *vdev, bool test_mem,
> if (copy_from_user(&val, buf, 2))
> return -EFAULT;
>
> - ret = vfio_pci_iowrite16(vdev, test_mem,
> - val, io + off);
> + ret = vfio_pci_core_iowrite16(vdev, test_mem,
> + val, io + off);
> if (ret)
> return ret;
> } else {
> - ret = vfio_pci_ioread16(vdev, test_mem,
> - &val, io + off);
> + ret = vfio_pci_core_ioread16(vdev, test_mem,
> + &val, io + off);
> if (ret)
> return ret;
>
> @@ -163,13 +165,13 @@ static ssize_t do_io_rw(struct vfio_pci_core_device *vdev, bool test_mem,
> if (copy_from_user(&val, buf, 1))
> return -EFAULT;
>
> - ret = vfio_pci_iowrite8(vdev, test_mem,
> - val, io + off);
> + ret = vfio_pci_core_iowrite8(vdev, test_mem,
> + val, io + off);
> if (ret)
> return ret;
> } else {
> - ret = vfio_pci_ioread8(vdev, test_mem,
> - &val, io + off);
> + ret = vfio_pci_core_ioread8(vdev, test_mem,
> + &val, io + off);
> if (ret)
> return ret;
>
> @@ -364,16 +366,16 @@ static void vfio_pci_ioeventfd_do_write(struct vfio_pci_ioeventfd *ioeventfd,
> {
> switch (ioeventfd->count) {
> case 1:
> - vfio_pci_iowrite8(ioeventfd->vdev, test_mem,
> - ioeventfd->data, ioeventfd->addr);
> + vfio_pci_core_iowrite8(ioeventfd->vdev, test_mem,
> + ioeventfd->data, ioeventfd->addr);
> break;
> case 2:
> - vfio_pci_iowrite16(ioeventfd->vdev, test_mem,
> - ioeventfd->data, ioeventfd->addr);
> + vfio_pci_core_iowrite16(ioeventfd->vdev, test_mem,
> + ioeventfd->data, ioeventfd->addr);
> break;
> case 4:
> - vfio_pci_iowrite32(ioeventfd->vdev, test_mem,
> - ioeventfd->data, ioeventfd->addr);
> + vfio_pci_core_iowrite32(ioeventfd->vdev, test_mem,
> + ioeventfd->data, ioeventfd->addr);
> break;
> #ifdef iowrite64
> case 8:
There's a vfio_pci_iowrite64() call just below here that was missed.
Otherwise the vfio parts of the series looks ok to me. We still need
to recruit another reviewer though.
My preferred merge approach would be that virtio maintainers take
patches 1-6 and provide a branch or tag I can merge to bring 7-9 in
through the vfio tree. Thanks,
Alex
> diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h
> index 67ac58e20e1d..85e84b92751b 100644
> --- a/include/linux/vfio_pci_core.h
> +++ b/include/linux/vfio_pci_core.h
> @@ -131,4 +131,23 @@ int vfio_pci_core_setup_barmap(struct vfio_pci_core_device *vdev, int bar);
> pci_ers_result_t vfio_pci_core_aer_err_detected(struct pci_dev *pdev,
> pci_channel_state_t state);
>
> +#define VFIO_IOWRITE_DECLATION(size) \
> +int vfio_pci_core_iowrite##size(struct vfio_pci_core_device *vdev, \
> + bool test_mem, u##size val, void __iomem *io);
> +
> +VFIO_IOWRITE_DECLATION(8)
> +VFIO_IOWRITE_DECLATION(16)
> +VFIO_IOWRITE_DECLATION(32)
> +#ifdef iowrite64
> +VFIO_IOWRITE_DECLATION(64)
> +#endif
> +
> +#define VFIO_IOREAD_DECLATION(size) \
> +int vfio_pci_core_ioread##size(struct vfio_pci_core_device *vdev, \
> + bool test_mem, u##size *val, void __iomem *io);
> +
> +VFIO_IOREAD_DECLATION(8)
> +VFIO_IOREAD_DECLATION(16)
> +VFIO_IOREAD_DECLATION(32)
> +
> #endif /* VFIO_PCI_CORE_H */
next prev parent reply other threads:[~2023-12-05 22:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-05 17:06 [PATCH V5 vfio 0/9] Introduce a vfio driver over virtio devices Yishai Hadas
2023-12-05 17:06 ` [PATCH V5 vfio 1/9] virtio: Define feature bit for administration virtqueue Yishai Hadas
2023-12-05 17:06 ` [PATCH V5 vfio 2/9] virtio-pci: Introduce admin virtqueue Yishai Hadas
2023-12-05 17:06 ` [PATCH V5 vfio 3/9] virtio-pci: Introduce admin command sending function Yishai Hadas
2023-12-05 17:06 ` [PATCH V5 vfio 4/9] virtio-pci: Introduce admin commands Yishai Hadas
2023-12-05 17:06 ` [PATCH V5 vfio 5/9] virtio-pci: Initialize the supported " Yishai Hadas
2023-12-05 17:06 ` [PATCH V5 vfio 6/9] virtio-pci: Introduce APIs to execute legacy IO " Yishai Hadas
2023-12-05 17:06 ` [PATCH V5 vfio 7/9] vfio/pci: Expose vfio_pci_core_setup_barmap() Yishai Hadas
2023-12-05 17:06 ` [PATCH V5 vfio 8/9] vfio/pci: Expose vfio_pci_core_iowrite/read##size() Yishai Hadas
2023-12-05 22:51 ` Alex Williamson [this message]
2023-12-05 17:06 ` [PATCH V5 vfio 9/9] vfio/virtio: Introduce a vfio driver over virtio devices Yishai Hadas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231205155153.2d5aceab.alex.williamson@redhat.com \
--to=alex.williamson@redhat.com \
--cc=feliu@nvidia.com \
--cc=jasowang@redhat.com \
--cc=jgg@nvidia.com \
--cc=jiri@nvidia.com \
--cc=joao.m.martins@oracle.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=leonro@nvidia.com \
--cc=maorg@nvidia.com \
--cc=mst@redhat.com \
--cc=parav@nvidia.com \
--cc=si-wei.liu@oracle.com \
--cc=virtualization@lists.linux-foundation.org \
--cc=yishaih@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).