]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc/powernv/ioda: Fix race in TCE level allocation
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Thu, 18 Jul 2019 05:11:36 +0000 (15:11 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 19 Aug 2019 03:20:23 +0000 (13:20 +1000)
commitf6db3f46883dc5412622d10fea7bcb8d7581274e
treee28bf46263ab7b6f0a9dd4fb6a40c0b0959be343
parent0523040fb5e8aa5082c0218d428064edb046f95a
powerpc/powernv/ioda: Fix race in TCE level allocation

pnv_tce() returns a pointer to a TCE entry and originally a TCE table
would be pre-allocated. For the default case of 2GB window the table
needs only a single level and that is fine. However if more levels are
requested, it is possible to get a race when 2 threads want a pointer
to a TCE entry from the same page of TCEs.

This adds cmpxchg to handle the race. Note that once TCE is non-zero,
it cannot become zero again.

Fixes: 8955863ac170 ("powerpc/powernv/ioda: Allocate indirect TCE levels on demand")
CC: stable@vger.kernel.org # v4.19+
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190718051139.74787-2-aik@ozlabs.ru
arch/powerpc/platforms/powernv/pci-ioda-tce.c