iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] iommu: io-pgtable: Drop WARN for empty PTEs on unmap
@ 2019-07-10 22:31 Rob Herring
  2019-07-11 10:23 ` Will Deacon
  0 siblings, 1 reply; 3+ messages in thread
From: Rob Herring @ 2019-07-10 22:31 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy; +Cc: iommu, linux-arm-kernel

If a region has been mapped sparsely (such as on page faults), the user
has to keep track of what was mapped or not in order to avoid warnings
when unmapping the entire region. Remove the WARN on empty PTEs to allow
unmapping sparsely mapped regions.

Cc: Will Deacon <will@kernel.org>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: linux-arm-kernel@lists.infradead.org
Cc: iommu@lists.linux-foundation.org
Signed-off-by: Rob Herring <robh@kernel.org>
---
This is needed for large (up to 1GB AIUI) scratch buffers on panfrost 
which are mapped on demand on GPU page faults and can be unmapped on 
memory pressure. Alternatively, I'd need to have a bitmap of mapped 
pages to track what is mapped or not. Dropping the WARN seems like a 
much simpler solution.

This will need to go thru the DRM tree once I've gotten the panfrost 
side finished, but wanted some early feedback.

Rob

 drivers/iommu/io-pgtable-arm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index 4e21efbc4459..43971638a5aa 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -611,7 +611,7 @@ static size_t __arm_lpae_unmap(struct arm_lpae_io_pgtable *data,
 
 	ptep += ARM_LPAE_LVL_IDX(iova, lvl, data);
 	pte = READ_ONCE(*ptep);
-	if (WARN_ON(!pte))
+	if (!pte)
 		return 0;
 
 	/* If the size matches this level, we're in the right place */
-- 
2.20.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] iommu: io-pgtable: Drop WARN for empty PTEs on unmap
  2019-07-10 22:31 [RFC PATCH] iommu: io-pgtable: Drop WARN for empty PTEs on unmap Rob Herring
@ 2019-07-11 10:23 ` Will Deacon
  2019-07-11 17:39   ` Rob Herring
  0 siblings, 1 reply; 3+ messages in thread
From: Will Deacon @ 2019-07-11 10:23 UTC (permalink / raw)
  To: Rob Herring; +Cc: Robin Murphy, iommu, linux-arm-kernel

On Wed, Jul 10, 2019 at 04:31:19PM -0600, Rob Herring wrote:
> If a region has been mapped sparsely (such as on page faults), the user
> has to keep track of what was mapped or not in order to avoid warnings
> when unmapping the entire region. Remove the WARN on empty PTEs to allow
> unmapping sparsely mapped regions.
> 
> Cc: Will Deacon <will@kernel.org>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Joerg Roedel <joro@8bytes.org>
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: iommu@lists.linux-foundation.org
> Signed-off-by: Rob Herring <robh@kernel.org>
> ---
> This is needed for large (up to 1GB AIUI) scratch buffers on panfrost 
> which are mapped on demand on GPU page faults and can be unmapped on 
> memory pressure. Alternatively, I'd need to have a bitmap of mapped 
> pages to track what is mapped or not. Dropping the WARN seems like a 
> much simpler solution.

I suppose an alternative would be to do an iova_to_phys() before you do the
unmap(). Would that be acceptable? The WARN_ON() indicates invalid usage by
the IOMMU API, so it would be a shame to lose it entirely and I'm hesitant
to continue adding quirks at the rate we're currently doing so!

Will
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC PATCH] iommu: io-pgtable: Drop WARN for empty PTEs on unmap
  2019-07-11 10:23 ` Will Deacon
@ 2019-07-11 17:39   ` Rob Herring
  0 siblings, 0 replies; 3+ messages in thread
From: Rob Herring @ 2019-07-11 17:39 UTC (permalink / raw)
  To: Will Deacon
  Cc: Robin Murphy, Linux IOMMU,
	moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE

On Thu, Jul 11, 2019 at 4:23 AM Will Deacon <will@kernel.org> wrote:
>
> On Wed, Jul 10, 2019 at 04:31:19PM -0600, Rob Herring wrote:
> > If a region has been mapped sparsely (such as on page faults), the user
> > has to keep track of what was mapped or not in order to avoid warnings
> > when unmapping the entire region. Remove the WARN on empty PTEs to allow
> > unmapping sparsely mapped regions.
> >
> > Cc: Will Deacon <will@kernel.org>
> > Cc: Robin Murphy <robin.murphy@arm.com>
> > Cc: Joerg Roedel <joro@8bytes.org>
> > Cc: linux-arm-kernel@lists.infradead.org
> > Cc: iommu@lists.linux-foundation.org
> > Signed-off-by: Rob Herring <robh@kernel.org>
> > ---
> > This is needed for large (up to 1GB AIUI) scratch buffers on panfrost
> > which are mapped on demand on GPU page faults and can be unmapped on
> > memory pressure. Alternatively, I'd need to have a bitmap of mapped
> > pages to track what is mapped or not. Dropping the WARN seems like a
> > much simpler solution.
>
> I suppose an alternative would be to do an iova_to_phys() before you do the
> unmap(). Would that be acceptable?

Yeah, that should work. Not that efficient, but I don't think
releasing the memory is hot path.

Thanks,
Rob

> The WARN_ON() indicates invalid usage by
> the IOMMU API, so it would be a shame to lose it entirely and I'm hesitant
> to continue adding quirks at the rate we're currently doing so!
>
> Will
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-07-11 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-10 22:31 [RFC PATCH] iommu: io-pgtable: Drop WARN for empty PTEs on unmap Rob Herring
2019-07-11 10:23 ` Will Deacon
2019-07-11 17:39   ` Rob Herring

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).