public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Suravee Suthikulpanit <suravee.suthikulpanit-5C7GfCeVMHo@public.gmane.org>
To: Alex Williamson
	<alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
	jroedel-l3A5Bk7waGM@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v3] vfio/type1: Adopt fast IOTLB flush interface when unmap IOVAs
Date: Wed, 24 Jan 2018 17:00:18 +0700	[thread overview]
Message-ID: <abb9f471-9a77-85f7-4afb-a46b86f4e11a@amd.com> (raw)
In-Reply-To: <20180123150452.03a42c53-DGNDKt5SQtizQB+pC5nmwQ@public.gmane.org>

Alex / Joerg,

On 1/24/18 5:04 AM, Alex Williamson wrote:
>> @@ -648,12 +685,40 @@ static int vfio_iommu_type1_unpin_pages(void *iommu_data,
>>   	return i > npage ? npage : (i > 0 ? i : -EINVAL);
>>   }
>>   
>> +static size_t try_unmap_unpin_fast(struct vfio_domain *domain, dma_addr_t iova,
>> +				   size_t len, phys_addr_t phys,
>> +				   struct list_head *unmapped_regions)
>> +{
>> +	struct vfio_regions *entry;
>> +	size_t unmapped;
>> +
>> +	entry = kzalloc(sizeof(*entry), GFP_KERNEL);
>> +	if (!entry)
>> +		return -ENOMEM;
>> +
>> +	unmapped = iommu_unmap_fast(domain->domain, iova, len);
>> +	if (WARN_ON(!unmapped)) {
>> +		kfree(entry);
>> +		return -EINVAL;
>> +	}
> Not sure about the handling of this, the zero check is just a
> consistency validation.  If there's nothing mapped where we think there
> should be something mapped, we warn and throw out the whole vfio_dma.
> After this patch, such an error gets warned twice, which doesn't
> really seem to be an improvement.
> 

Since iommu_unmap() and iommu_unmap_fast() can return errors, instead of just zero check,
we should also check for errors, warn, and bail out the whole vfio_dma.

Thanks,
Suravee

      parent reply	other threads:[~2018-01-24 10:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22  4:29 [PATCH v3] vfio/type1: Adopt fast IOTLB flush interface when unmap IOVAs Suravee Suthikulpanit
2018-01-23 22:04 ` Alex Williamson
2018-01-24  4:38   ` Suravee Suthikulpanit
     [not found]   ` <20180123150452.03a42c53-DGNDKt5SQtizQB+pC5nmwQ@public.gmane.org>
2018-01-24 10:00     ` Suravee Suthikulpanit [this message]

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=abb9f471-9a77-85f7-4afb-a46b86f4e11a@amd.com \
    --to=suravee.suthikulpanit-5c7gfcevmho@public.gmane.org \
    --cc=alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=jroedel-l3A5Bk7waGM@public.gmane.org \
    --cc=kvm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox