Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/ioda: Use ibm, supported-tce-sizes for IOMMU page size mask

At the moment we assume that IODA2 and newer PHBs can always do 4K/64K/16M
IOMMU pages, however this is not the case for POWER9 and now skiboot
advertises the supported sizes via the device so we use that instead
of hard coding the mask.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Alexey Kardashevskiy and committed by
Michael Ellerman
7ef73cd3 8ccb442d

+29 -1
+29 -1
arch/powerpc/platforms/powernv/pci-ioda.c
··· 2910 2910 tbl->it_indirect_levels); 2911 2911 } 2912 2912 2913 + static unsigned long pnv_ioda_parse_tce_sizes(struct pnv_phb *phb) 2914 + { 2915 + struct pci_controller *hose = phb->hose; 2916 + struct device_node *dn = hose->dn; 2917 + unsigned long mask = 0; 2918 + int i, rc, count; 2919 + u32 val; 2920 + 2921 + count = of_property_count_u32_elems(dn, "ibm,supported-tce-sizes"); 2922 + if (count <= 0) { 2923 + mask = SZ_4K | SZ_64K; 2924 + /* Add 16M for POWER8 by default */ 2925 + if (cpu_has_feature(CPU_FTR_ARCH_207S) && 2926 + !cpu_has_feature(CPU_FTR_ARCH_300)) 2927 + mask |= SZ_16M; 2928 + return mask; 2929 + } 2930 + 2931 + for (i = 0; i < count; i++) { 2932 + rc = of_property_read_u32_index(dn, "ibm,supported-tce-sizes", 2933 + i, &val); 2934 + if (rc == 0) 2935 + mask |= 1ULL << val; 2936 + } 2937 + 2938 + return mask; 2939 + } 2940 + 2913 2941 static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb, 2914 2942 struct pnv_ioda_pe *pe) 2915 2943 { ··· 2962 2934 pe->table_group.max_dynamic_windows_supported = 2963 2935 IOMMU_TABLE_GROUP_MAX_TABLES; 2964 2936 pe->table_group.max_levels = POWERNV_IOMMU_MAX_LEVELS; 2965 - pe->table_group.pgsizes = SZ_4K | SZ_64K | SZ_16M; 2937 + pe->table_group.pgsizes = pnv_ioda_parse_tce_sizes(phb); 2966 2938 #ifdef CONFIG_IOMMU_API 2967 2939 pe->table_group.ops = &pnv_pci_ioda2_ops; 2968 2940 #endif