ANDROID: drivers/arm-smmu-v3-kvm: Re-use CD table when possible
At the moment, the CD table is allocated for each SID, which wastes
memory for SIDs belonging to the same domain device (domain).
Previously, the lifetime for a CD was allocated only once when the
device was attached and it never got freed, and the CD would be reused
for the next attach(s).
As EL2 doesn't know which SIDs are part of the same device, it can use
the domain as an indication to share the CD table between SIDs which makes
the CD table ownership part of the domain. However that only works
for devices that doesn't use pasid.
The CD table lifecycles is as follows:
For attach:
- PASID != 0, the CD is read from the STE as PASID = 0 must be
attached first, and it would allocate the CD table before.
- PASID = 0 and PASID_BITs > 0: Devices that support pasids,
allocate a new CD table as they can't be shared.
- PASID_BITS = 0: Share the CDptr inside the domain if existing,
otherwise allocate it.
For detach:
- PASID != 0: invalidate that the CD entry.
- PASID = 0 and PASID_BITs > 0: Devices that support pasids, free the
CD table and invalidate the STE
- PASID_BITS = 0: invalidate the STE, the cd table is per domain would
be freed at free_domain.
Bug: 366562658
Bug: 277989609
Bug: 278749606
Change-Id: Iffcd448e1802924917c19947d9d3f2abc942975b
Signed-off-by:
Mostafa Saleh <smostafa@google.com>
Loading
Please sign in to comment