vfio/spapr: Fix indirect levels calculation
commit16107998761c1ce97d5c1d56a3e7092acb27d8d1
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Wed, 27 Feb 2019 08:51:45 +0000 (27 19:51 +1100)
committerDavid Gibson <david@gibson.dropbear.id.au>
Mon, 11 Mar 2019 23:50:59 +0000 (12 10:50 +1100)
tree9d40ef4049bcf7036fcab0e40855700438b65517
parent377b155bde451d5ac545fbdcdfbf6ca17a4228f5
vfio/spapr: Fix indirect levels calculation

The current code assumes that we can address more bits on a PCI bus
for DMA than we really can but there is no way knowing the actual limit.

This makes a better guess for the number of levels and if the kernel
fails to allocate that, this increases the level numbers till succeeded
or reached the 64bit limit.

This adds levels to the trace point.

This may cause the kernel to warn about failed allocation:
   [65122.837458] Failed to allocate a TCE memory, level shift=28
which might happen if MAX_ORDER is not large enough as it can vary:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/Kconfig?h=v5.0-rc2#n727

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Message-Id: <20190227085149.38596-3-aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/vfio/spapr.c
hw/vfio/trace-events