On 2020-04-20 3:39 pm, Maxime Ripard wrote:
Hi,
On Wed, Apr 08, 2020 at 04:06:49PM +0200, Joerg Roedel wrote:
On Wed, Apr 01, 2020 at 01:47:10PM +0200, Maxime Ripard wrote:
As far as I understand it, the page table can be accessed concurrently
since the framework doesn't seem to provide any serialization /
locking, shouldn't we have some locks to prevent concurrent access?
The dma-iommu code makes sure that there are no concurrent accesses to
the same address-range of the page-table, but there can (and will) be
concurrent accesses to the same page-table, just for different parts of
the address space.
Making this lock-less usually involves updating non-leaf page-table
entries using atomic compare-exchange instructions.
That makes sense, thanks!
I'm not sure what I should compare with though, do you want to compare with 0 to
check if there's already a page table assigned to that DTE? If so, then we
should also allocate the possible page table before the fact so that we have
something to swap with, and deallocate it if we already had one?
Indeed, for an example see arm_v7s_install_table() and how
__arm_v7s_map() calls it. The LPAE version in io-pgtable-arm.c does the
same too, but with some extra software-bit handshaking to track the
cache maintenance state as an optimisation, which you can probably do
without trying to make sense of ;)
Robin.