iommu: io-pgtable: Drop WARN for empty PTEs on unmap
Subsystems (2)
RFC PATCH 1/1 iommu: io-pgtable: Drop WARN for empty PTEs on unmap
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.
---
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(-)
drivers/iommu/io-pgtable-arm.c +1 -1
@@ -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 */
Signature · 7 lines
2.20.1 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Will Deacon
maintainerQuoted 11 lines · Rob Herring
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 <[email protected]>Cc Robin Murphy <[email protected]>Cc Joerg Roedel <[email protected]>Signed-off-by Rob Herring <[email protected]>
Quoted 6 lines
---
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
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Quoted 20 lines · Will Deacon
Quoted 11 lines · Rob Herring
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 <[email protected]>Cc Robin Murphy <[email protected]>Cc Joerg Roedel <[email protected]>Signed-off-by Rob Herring <[email protected]>Quoted 6 lines
---
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.
Quoted 2 lines
I suppose an alternative would be to do an
iova_to_phys()before you do theunmap(). Would that be acceptable?
Yeah, that should work. Not that efficient, but I don't think releasing the memory is hot path.
Thanks,
Rob
Quoted 5 lines
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
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel