iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
From: isaacm@codeaurora.org
To: Lu Baolu <baolu.lu@linux.intel.com>
Cc: robin.murphy@arm.com, iommu@lists.linux-foundation.org,
	will@kernel.org, linux-arm-kernel@lists.infradead.org,
	pratikp@codeaurora.org
Subject: Re: [RFC PATCH 2/5] iommu: Add an unmap_pages() op for IOMMU drivers
Date: Tue, 30 Mar 2021 22:36:01 -0700	[thread overview]
Message-ID: <4c396e68a076f321ed3f406c2c875006@codeaurora.org> (raw)
In-Reply-To: <e1cadb9e-2ffa-8506-6790-2dab4733af25@linux.intel.com>

On 2021-03-30 21:47, Lu Baolu wrote:
> On 3/31/21 11:00 AM, Isaac J. Manjarres wrote:
>> Add a callback for IOMMU drivers to provide a path for the
>> IOMMU framework to call into an IOMMU driver, which can call
>> into the io-pgtable code, to unmap a virtually contiguous
>> range of pages of the same size.
>> 
>> For IOMMU drivers that do not specify an unmap_pages() callback,
>> the existing logic of unmapping memory one page block at a time
>> will be used.
>> 
>> Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
>> Suggested-by: Will Deacon <will@kernel.org>
>> ---
>>   include/linux/iommu.h | 4 ++++
>>   1 file changed, 4 insertions(+)
>> 
>> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
>> index 5e7fe519430a..9cf81242581a 100644
>> --- a/include/linux/iommu.h
>> +++ b/include/linux/iommu.h
>> @@ -193,6 +193,7 @@ struct iommu_iotlb_gather {
>>    * @detach_dev: detach device from an iommu domain
>>    * @map: map a physically contiguous memory region to an iommu 
>> domain
>>    * @unmap: unmap a physically contiguous memory region from an iommu 
>> domain
>> + * @unmap_pages: unmap a number of pages of the same size from an 
>> iommu domain
>>    * @flush_iotlb_all: Synchronously flush all hardware TLBs for this 
>> domain
>>    * @iotlb_sync_map: Sync mappings created recently using @map to the 
>> hardware
>>    * @iotlb_sync: Flush all queued ranges from the hardware TLBs and 
>> empty flush
>> @@ -245,6 +246,9 @@ struct iommu_ops {
>>   		   phys_addr_t paddr, size_t size, int prot, gfp_t gfp);
>>   	size_t (*unmap)(struct iommu_domain *domain, unsigned long iova,
>>   		     size_t size, struct iommu_iotlb_gather *iotlb_gather);
>> +	size_t (*unmap_pages)(struct iommu_domain *domain, unsigned long 
>> iova,
>> +			      size_t pgsize, size_t pgcount,
>> +			      struct iommu_iotlb_gather *iotlb_gather);
> 
> Is it possible to add an equivalent map_pages() callback?
Yes, map_pages() can be implemented and can leverage a lot of the 
implementation
of unmap_pages(). The problem is that if you map several pages in one 
call, and then
encounter an error and have to rollback, you should do TLB maintenance, 
as iommu_map
does when it encounters an error. However, we can't call iommu_unmap 
from io-pgtable-arm
for example. We can call arm_lpae_unmap_pages() from the later patches, 
but that doesn't
solve the TLB maintenance issue. Do you have any thoughts on how to 
address this?
> 
>>   	void (*flush_iotlb_all)(struct iommu_domain *domain);
>>   	void (*iotlb_sync_map)(struct iommu_domain *domain, unsigned long 
>> iova,
>>   			       size_t size);
>> 
> 
> Best regards,
> baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2021-03-31  5:36 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-31  3:00 [RFC PATCH 0/5] Optimization for unmapping iommu mapped buffers Isaac J. Manjarres
2021-03-31  3:00 ` [RFC PATCH 1/5] iommu/io-pgtable: Introduce unmap_pages() as a page table op Isaac J. Manjarres
2021-03-31  3:00 ` [RFC PATCH 2/5] iommu: Add an unmap_pages() op for IOMMU drivers Isaac J. Manjarres
2021-03-31  4:47   ` Lu Baolu
2021-03-31  5:36     ` isaacm [this message]
2021-03-31  5:39       ` Lu Baolu
2021-04-02 17:25         ` isaacm
2021-04-03  1:35           ` Lu Baolu
2021-03-31  3:00 ` [RFC PATCH 3/5] iommu: Add support for the unmap_pages IOMMU callback Isaac J. Manjarres
2021-04-01 15:34   ` Robin Murphy
2021-04-01 16:37     ` Will Deacon
2021-03-31  3:00 ` [RFC PATCH 4/5] iommu/io-pgtable-arm: Implement arm_lpae_unmap_pages() Isaac J. Manjarres
2021-04-01 17:19   ` Robin Murphy
2021-03-31  3:00 ` [RFC PATCH 5/5] iommu/arm-smmu: Implement the unmap_pages IOMMU driver callback Isaac J. Manjarres
2021-04-01  3:28 ` [RFC PATCH 0/5] Optimization for unmapping iommu mapped buffers chenxiang (M)
2021-04-01 15:33 ` Robin Murphy

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=4c396e68a076f321ed3f406c2c875006@codeaurora.org \
    --to=isaacm@codeaurora.org \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=pratikp@codeaurora.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.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;
as well as URLs for NNTP newsgroup(s).