Commit 1d46a7ce authored by Mostafa Saleh's avatar Mostafa Saleh Committed by Treehugger Robot
Browse files

ANDROID: iommu: Fix error path for deferred map_sg



When the core IOMMU code fails to __iommu_add_sg() an entry,
it will try to unmap the whole added entries, which might not be
mapped at this point.

This patch changes the fail path so the IOMMU code will consume
the list first the based on the mapped range it will unmap it.

There are 2 cases where __iommu_add_sg() can fail:
1) From the driver ops add_deferred_map_sg(), which for the SMMUv3
   driver can only fail if the list of out space and it tried to
   flush it but the map failed, so the list would be partially mapped.
   In that case the driver would unmap the partially mapped region,
   and set the ptr to 0, so when the consume is called it will just
   return any previously mapped memory so the core code can unmap.

2) Before calling add_deferred_map_sg() because of problems with
   alignment or domain type. In that case, the IOMMU code will
   consume the list and unmap it, this is slightly not optimal
   but given that these errors are very sever they should never
   happen.

Bug: 428939924
Change-Id: I91529fd9f043d37dde5d1ed2450dbba59d7857d1
Signed-off-by: default avatarMostafa Saleh <smostafa@google.com>
parent c3591bab
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment