powerpc/powernv/pci: Fix m64 checks for SR-IOV and window alignment

Commit 5958d19a143e checks for prefetchable m64 BARs by comparing the
addresses instead of using resource flags. This broke SR-IOV as the m64
check in pnv_pci_ioda_fixup_iov_resources() fails.

The condition in pnv_pci_window_alignment() also changed to checking
only IORESOURCE_MEM_64 instead of both IORESOURCE_MEM_64 and
IORESOURCE_PREFETCH.

Revert these cases to the previous behaviour, adding a new helper function
to do so. This is named pnv_pci_is_m64_flags() to make it clear this
function is only looking at resource flags and should not be relied on for
non-SRIOV resources.

Fixes: 5958d19a143e ("Fix incorrect PE reservation attempt on some 64-bit BARs")
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Russell Currey <ruscur@russell.cc>
Tested-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by Russell Currey and committed by Michael Ellerman b79331a5 ed7d9a1d

+9 -2
+9 -2
arch/powerpc/platforms/powernv/pci-ioda.c
··· 124 124 r->start < (phb->ioda.m64_base + phb->ioda.m64_size)); 125 125 } 126 126 127 + static inline bool pnv_pci_is_m64_flags(unsigned long resource_flags) 128 + { 129 + unsigned long flags = (IORESOURCE_MEM_64 | IORESOURCE_PREFETCH); 130 + 131 + return (resource_flags & flags) == flags; 132 + } 133 + 127 134 static struct pnv_ioda_pe *pnv_ioda_init_pe(struct pnv_phb *phb, int pe_no) 128 135 { 129 136 phb->ioda.pe_array[pe_no].phb = phb; ··· 2878 2871 res = &pdev->resource[i + PCI_IOV_RESOURCES]; 2879 2872 if (!res->flags || res->parent) 2880 2873 continue; 2881 - if (!pnv_pci_is_m64(phb, res)) { 2874 + if (!pnv_pci_is_m64_flags(res->flags)) { 2882 2875 dev_warn(&pdev->dev, "Don't support SR-IOV with" 2883 2876 " non M64 VF BAR%d: %pR. \n", 2884 2877 i, res); ··· 3103 3096 * alignment for any 64-bit resource, PCIe doesn't care and 3104 3097 * bridges only do 64-bit prefetchable anyway. 3105 3098 */ 3106 - if (phb->ioda.m64_segsize && (type & IORESOURCE_MEM_64)) 3099 + if (phb->ioda.m64_segsize && pnv_pci_is_m64_flags(type)) 3107 3100 return phb->ioda.m64_segsize; 3108 3101 if (type & IORESOURCE_MEM) 3109 3102 return phb->ioda.m32_segsize;