OSDN Git Service

iommu/io-pgtable: Delegate page table memory management to drivers
authorMitchel Humpherys <mitchelh@codeaurora.org>
Thu, 30 Jul 2015 20:41:12 +0000 (13:41 -0700)
committerDavid Keitel <dkeitel@codeaurora.org>
Tue, 22 Mar 2016 18:13:46 +0000 (11:13 -0700)
commit52c8720e5cf479aae5dc8d0ac7d2c4afd261e446
tree34c9c2b8b9c185a556a243bb1a6659584ae7a0e5
parent3c60944373c71f82fdf234d3220720b781b4c67a
iommu/io-pgtable: Delegate page table memory management to drivers

Some IOMMU drivers (like arm-smmu) need to perform fixups to page table
memory when it's allocated and freed.  Some callbacks were added for
this purpose ({prepare,unprepare}_pgtable) that are called from the
io-pgtable code after each allocation and before each free.  However,
this approach is prone to bugs where new calls to allocate/free are
added without corresponding calls to the fixup callbacks.  Furthermore,
allocation and free is often done from atomic context, so if the driver
needs to do non-atomic fixups during free they are out of luck since the
memory will be freed back to the system by the time control is turned
back over to the driver.

Adding yet another callback for non-atomic fixups would start to get
tedious, and would only increase the chance of missing callbacks as new
allocations/frees are added.  Instead, fix this by allowing all page
table memory allocation and free to be delegated entirely to the driver.
Fall back to {alloc,free}_pages_exact by default if the driver doesn't
need any special handling of page table memory.

Change-Id: I0361bb81e25ff5ad4ef93a45330a35af47bc6013
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
drivers/iommu/arm-smmu.c
drivers/iommu/io-pgtable-arm.c
drivers/iommu/io-pgtable.c
drivers/iommu/io-pgtable.h