powerpc/powernv/ioda2: Gracefully fail if too many TCE levels requested
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Wed, 22 Feb 2017 04:43:59 +0000 (15:43 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 16 Dec 2017 09:33:54 +0000 (10:33 +0100)
commitf1ff979f97bd5e1ee176112665db20c6114a6c45
tree744334bff77ddca891c28657dc7d9e7a6db3b4c7
parentd42ebf56380fb12b2699a07893beaf506c3a9c58
powerpc/powernv/ioda2: Gracefully fail if too many TCE levels requested

[ Upstream commit 7aafac11e308d37ed3c509829bb43d80c1811ac3 ]

The IODA2 specification says that a 64 DMA address cannot use top 4 bits
(3 are reserved and one is a "TVE select"); bottom page_shift bits
cannot be used for multilevel table addressing either.

The existing IODA2 table allocation code aligns the minimum TCE table
size to PAGE_SIZE so in the case of 64K system pages and 4K IOMMU pages,
we have 64-4-12=48 bits. Since 64K page stores 8192 TCEs, i.e. needs
13 bits, the maximum number of levels is 48/13 = 3 so we physically
cannot address more and EEH happens on DMA accesses.

This adds a check that too many levels were requested.

It is still possible to have 5 levels in the case of 4K system page size.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Acked-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/powerpc/platforms/powernv/pci-ioda.c