OSDN Git Service

powerpc/powernv: Fix iommu table size calculation hook for small tables
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Thu, 13 Apr 2017 07:05:27 +0000 (17:05 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 28 Apr 2017 11:26:54 +0000 (21:26 +1000)
commite49a6a2173346d316c0e65d054a3cda89d57cb53
treee40d092f9292260039f1bf52231cf6e3a7550ad3
parent82eae1afbbdcaf2d716f88025736dc2d6f7afbf0
powerpc/powernv: Fix iommu table size calculation hook for small tables

When the userspace requests a small TCE table (which takes less than
the system page size) and more than 1 TCE level, the existing code
returns a single page size which is a bug as each additional TCE level
requires at least one page and this is what
pnv_pci_ioda2_table_alloc_pages() does. And we end up seeing
WARN_ON(!ret && ((*ptbl)->it_allocated_size != table_size))
in drivers/vfio/vfio_iommu_spapr_tce.c.

This replaces incorrect _ALIGN_UP() (which aligns zero up to zero) with
max_t() to fix the bug.

Besides removing WARN_ON(), there should be no other changes in
behaviour.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/platforms/powernv/pci-ioda.c