All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: linuxppc-dev@lists.ozlabs.org,
	David Gibson <david@gibson.dropbear.id.au>,
	kvm-ppc@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH kernel] vfio/spapr/nvlink2: Skip unpinning pages on error exit
Date: Fri, 10 Jan 2020 09:03:06 -0700	[thread overview]
Message-ID: <20200110090306.04683f3c@x1.home> (raw)
In-Reply-To: <20191223010927.79843-1-aik@ozlabs.ru>

On Mon, 23 Dec 2019 12:09:27 +1100
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:

> The nvlink2 subdriver for IBM Witherspoon machines preregisters
> GPU memory in the IOMMI API so KVM TCE code can map this memory
> for DMA as well. This is done by mm_iommu_newdev() called from
> vfio_pci_nvgpu_regops::mmap.
> 
> In an unlikely event of failure the data->mem remains NULL and
> since mm_iommu_put() (which unregisters the region and unpins memory
> if that was regular memory) does not expect mem==NULL, it should not be
> called.
> 
> This adds a check to only call mm_iommu_put() for a valid data->mem.
> 
> Fixes: 7f92891778df ("vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] subdriver")
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>  drivers/vfio/pci/vfio_pci_nvlink2.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
> index f2983f0f84be..3f5f8198a6bb 100644
> --- a/drivers/vfio/pci/vfio_pci_nvlink2.c
> +++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
> @@ -97,8 +97,10 @@ static void vfio_pci_nvgpu_release(struct vfio_pci_device *vdev,
>  
>  	/* If there were any mappings at all... */
>  	if (data->mm) {
> -		ret = mm_iommu_put(data->mm, data->mem);
> -		WARN_ON(ret);
> +		if (data->mem) {
> +			ret = mm_iommu_put(data->mm, data->mem);
> +			WARN_ON(ret);
> +		}
>  
>  		mmdrop(data->mm);
>  	}

Applied to vfio next branch for v5.6.  Thanks,

Alex


WARNING: multiple messages have this Message-ID
From: Alex Williamson <alex.williamson@redhat.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org,
	kvm-ppc@vger.kernel.org,
	David Gibson <david@gibson.dropbear.id.au>
Subject: Re: [PATCH kernel] vfio/spapr/nvlink2: Skip unpinning pages on error exit
Date: Fri, 10 Jan 2020 09:03:06 -0700	[thread overview]
Message-ID: <20200110090306.04683f3c@x1.home> (raw)
In-Reply-To: <20191223010927.79843-1-aik@ozlabs.ru>

On Mon, 23 Dec 2019 12:09:27 +1100
Alexey Kardashevskiy <aik@ozlabs.ru> wrote:

> The nvlink2 subdriver for IBM Witherspoon machines preregisters
> GPU memory in the IOMMI API so KVM TCE code can map this memory
> for DMA as well. This is done by mm_iommu_newdev() called from
> vfio_pci_nvgpu_regops::mmap.
> 
> In an unlikely event of failure the data->mem remains NULL and
> since mm_iommu_put() (which unregisters the region and unpins memory
> if that was regular memory) does not expect mem==NULL, it should not be
> called.
> 
> This adds a check to only call mm_iommu_put() for a valid data->mem.
> 
> Fixes: 7f92891778df ("vfio_pci: Add NVIDIA GV100GL [Tesla V100 SXM2] subdriver")
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> ---
>  drivers/vfio/pci/vfio_pci_nvlink2.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_nvlink2.c b/drivers/vfio/pci/vfio_pci_nvlink2.c
> index f2983f0f84be..3f5f8198a6bb 100644
> --- a/drivers/vfio/pci/vfio_pci_nvlink2.c
> +++ b/drivers/vfio/pci/vfio_pci_nvlink2.c
> @@ -97,8 +97,10 @@ static void vfio_pci_nvgpu_release(struct vfio_pci_device *vdev,
>  
>  	/* If there were any mappings at all... */
>  	if (data->mm) {
> -		ret = mm_iommu_put(data->mm, data->mem);
> -		WARN_ON(ret);
> +		if (data->mem) {
> +			ret = mm_iommu_put(data->mm, data->mem);
> +			WARN_ON(ret);
> +		}
>  
>  		mmdrop(data->mm);
>  	}

Applied to vfio next branch for v5.6.  Thanks,

Alex


  reply	other threads:[~2020-01-10 16:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-23  1:09 [PATCH kernel] vfio/spapr/nvlink2: Skip unpinning pages on error exit Alexey Kardashevskiy
2019-12-23  1:09 ` Alexey Kardashevskiy
2020-01-10 16:03 ` Alex Williamson [this message]
2020-01-10 16:03   ` Alex Williamson

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=20200110090306.04683f3c@x1.home \
    --to=alex.williamson@redhat.com \
    --cc=aik@ozlabs.ru \
    --cc=david@gibson.dropbear.id.au \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.