dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Tony Krowiak <akrowiak@linux.ibm.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	David Airlie <airlied@linux.ie>,
	Alex Williamson <alex.williamson@redhat.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Cornelia Huck <cohuck@redhat.com>,
	Jonathan Corbet <corbet@lwn.net>, Daniel Vetter <daniel@ffwll.ch>,
	dri-devel@lists.freedesktop.org,
	Eric Farman <farman@linux.ibm.com>,
	Harald Freudenberger <freude@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	intel-gfx@lists.freedesktop.org,
	intel-gvt-dev@lists.freedesktop.org,
	Jani Nikula <jani.nikula@linux.intel.com>,
	Jason Herne <jjherne@linux.ibm.com>,
	Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
	kvm@vger.kernel.org, Kirti Wankhede <kwankhede@nvidia.com>,
	linux-doc@vger.kernel.org, linux-s390@vger.kernel.org,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Peter Oberparleiter <oberpar@linux.ibm.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	Rodrigo Vivi <rodrigo.vivi@intel.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
	Vineeth Vijayan <vneethv@linux.ibm.com>,
	Zhenyu Wang <zhenyuw@linux.intel.com>,
	Zhi Wang <zhi.a.wang@intel.com>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>, Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH 3/9] vfio/mdev: Pass in a struct vfio_device * to vfio_pin/unpin_pages()
Date: Mon, 18 Apr 2022 11:56:18 -0400	[thread overview]
Message-ID: <3231af63-4d36-f8bd-e8d7-426222a883d9@linux.ibm.com> (raw)
In-Reply-To: <3-v1-a8faf768d202+125dd-vfio_mdev_no_group_jgg@nvidia.com>



On 4/12/22 11:53 AM, Jason Gunthorpe wrote:
> Every caller has a readily available vfio_device pointer, use that instead
> of passing in a generic struct device. The struct vfio_device already
> contains the group we need so this avoids complexity, extra refcountings,
> and a confusing lifecycle model.
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
>   .../driver-api/vfio-mediated-device.rst       |  4 +-
>   drivers/s390/cio/vfio_ccw_cp.c                |  6 +--
>   drivers/s390/crypto/vfio_ap_ops.c             |  8 ++--
>   drivers/vfio/vfio.c                           | 40 ++++++-------------
>   include/linux/vfio.h                          |  4 +-
>   5 files changed, 24 insertions(+), 38 deletions(-)
>
> diff --git a/Documentation/driver-api/vfio-mediated-device.rst b/Documentation/driver-api/vfio-mediated-device.rst
> index 9f26079cacae35..6aeca741dc9be1 100644
> --- a/Documentation/driver-api/vfio-mediated-device.rst
> +++ b/Documentation/driver-api/vfio-mediated-device.rst
> @@ -279,10 +279,10 @@ Translation APIs for Mediated Devices
>   The following APIs are provided for translating user pfn to host pfn in a VFIO
>   driver::
>   
> -	extern int vfio_pin_pages(struct device *dev, unsigned long *user_pfn,
> +	extern int vfio_pin_pages(struct vfio_device *vdev, unsigned long *user_pfn,
>   				  int npage, int prot, unsigned long *phys_pfn);
>   
> -	extern int vfio_unpin_pages(struct device *dev, unsigned long *user_pfn,
> +	extern int vfio_unpin_pages(struct vfio_device *vdev, unsigned long *user_pfn,
>   				    int npage);
>   
>   These functions call back into the back-end IOMMU module by using the pin_pages
>
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index 69768061cd7bd9..a10b3369d76c41 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -124,7 +124,7 @@ static void vfio_ap_free_aqic_resources(struct vfio_ap_queue *q)
>   		q->saved_isc = VFIO_AP_ISC_INVALID;
>   	}
>   	if (q->saved_pfn && !WARN_ON(!q->matrix_mdev)) {
> -		vfio_unpin_pages(mdev_dev(q->matrix_mdev->mdev),
> +		vfio_unpin_pages(&q->matrix_mdev->vdev,
>   				 &q->saved_pfn, 1);
>   		q->saved_pfn = 0;
>   	}
> @@ -258,7 +258,7 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
>   		return status;
>   	}
>   
> -	ret = vfio_pin_pages(mdev_dev(q->matrix_mdev->mdev), &g_pfn, 1,
> +	ret = vfio_pin_pages(&q->matrix_mdev->vdev, &g_pfn, 1,
>   			     IOMMU_READ | IOMMU_WRITE, &h_pfn);
>   	switch (ret) {
>   	case 1:
> @@ -301,7 +301,7 @@ static struct ap_queue_status vfio_ap_irq_enable(struct vfio_ap_queue *q,
>   		break;
>   	case AP_RESPONSE_OTHERWISE_CHANGED:
>   		/* We could not modify IRQ setings: clear new configuration */
> -		vfio_unpin_pages(mdev_dev(q->matrix_mdev->mdev), &g_pfn, 1);
> +		vfio_unpin_pages(&q->matrix_mdev->vdev, &g_pfn, 1);
>   		kvm_s390_gisc_unregister(kvm, isc);
>   		break;
>   	default:
> @@ -1250,7 +1250,7 @@ static int vfio_ap_mdev_iommu_notifier(struct notifier_block *nb,
>   		struct vfio_iommu_type1_dma_unmap *unmap = data;
>   		unsigned long g_pfn = unmap->iova >> PAGE_SHIFT;
>   
> -		vfio_unpin_pages(mdev_dev(matrix_mdev->mdev), &g_pfn, 1);
> +		vfio_unpin_pages(&matrix_mdev->vdev, &g_pfn, 1);
>   		return NOTIFY_OK;
>   	}

The vfio_ap snippet:
Reviewed-by: Tony Krowiak <akrowiak@linux.ibm.com>

>   
>


  parent reply	other threads:[~2022-04-19  7:34 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 15:53 [PATCH 0/9] Make the rest of the VFIO driver interface use vfio_device Jason Gunthorpe
2022-04-12 15:53 ` [PATCH 1/9] vfio: Make vfio_(un)register_notifier accept a vfio_device Jason Gunthorpe
     [not found]   ` <20220413055524.GB32092@lst.de>
2022-04-13 11:39     ` Jason Gunthorpe
     [not found]       ` <20220413160601.GA29631@lst.de>
2022-04-13 16:18         ` Jason Gunthorpe
     [not found]           ` <20220413162946.GB31053@lst.de>
2022-04-13 17:37             ` Jason Gunthorpe
2022-04-13 19:17               ` Wang, Zhi A
2022-04-13 20:04                 ` Jason Gunthorpe
2022-04-13 21:08                   ` Wang, Zhi A
2022-04-13 23:12                     ` Jason Gunthorpe
2022-04-14  2:04                       ` Tian, Kevin
2022-04-14  2:15                     ` Tian, Kevin
2022-04-14 19:25   ` Eric Farman
2022-04-18 15:28   ` Tony Krowiak
2022-04-18 15:44     ` Jason Gunthorpe
2022-04-18 15:52       ` Tony Krowiak
2022-04-18 15:29   ` Jason J. Herne
2022-04-12 15:53 ` [PATCH 2/9] vfio/ccw: Remove mdev from struct channel_program Jason Gunthorpe
2022-04-14 19:25   ` Eric Farman
2022-04-12 15:53 ` [PATCH 3/9] vfio/mdev: Pass in a struct vfio_device * to vfio_pin/unpin_pages() Jason Gunthorpe
     [not found]   ` <20220413055717.GC32092@lst.de>
2022-04-13 11:40     ` Jason Gunthorpe
2022-04-14 19:26   ` Eric Farman
2022-04-18 15:25   ` Jason J. Herne
2022-04-19 17:00     ` Jason Gunthorpe
2022-04-18 15:56   ` Tony Krowiak [this message]
2022-04-12 15:53 ` [PATCH 4/9] drm/i915/gvt: Change from vfio_group_(un)pin_pages to vfio_(un)pin_pages Jason Gunthorpe
     [not found]   ` <20220413060110.GF32092@lst.de>
2022-04-13 13:39     ` Jason Gunthorpe
2022-04-12 15:53 ` [PATCH 5/9] vfio: Pass in a struct vfio_device * to vfio_dma_rw() Jason Gunthorpe
     [not found]   ` <20220413060008.GE32092@lst.de>
2022-04-13 13:39     ` Jason Gunthorpe
2022-04-12 15:53 ` [PATCH 6/9] drm/i915/gvt: Add missing module_put() in error unwind Jason Gunthorpe
2022-04-12 15:53 ` [PATCH 7/9] drm/i915/gvt: Delete kvmgt_vdev::vfio_group Jason Gunthorpe
2022-04-12 15:53 ` [PATCH 8/9] vfio: Remove dead code Jason Gunthorpe
2022-04-12 15:53 ` [PATCH 9/9] vfio: Remove calls to vfio_group_add_container_user() Jason Gunthorpe
     [not found]   ` <20220413061105.GA32701@lst.de>
2022-04-13 14:03     ` Jason Gunthorpe
2022-04-14 13:51   ` Matthew Rosato
2022-04-14 14:22     ` Jason Gunthorpe
2022-04-15  2:32       ` Tian, Kevin
2022-04-15 12:07         ` Jason Gunthorpe
2022-04-15 23:45           ` Tian, Kevin

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=3231af63-4d36-f8bd-e8d7-426222a883d9@linux.ibm.com \
    --to=akrowiak@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=airlied@linux.ie \
    --cc=alex.williamson@redhat.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=corbet@lwn.net \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=farman@linux.ibm.com \
    --cc=freude@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=hch@lst.de \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-gvt-dev@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=jgg@nvidia.com \
    --cc=jjherne@linux.ibm.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=oberpar@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=svens@linux.ibm.com \
    --cc=tvrtko.ursulin@linux.intel.com \
    --cc=vneethv@linux.ibm.com \
    --cc=yi.l.liu@intel.com \
    --cc=zhenyuw@linux.intel.com \
    --cc=zhi.a.wang@intel.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).