From e0bfc429895c7f0b49dea2f4f5794b8f295edf9a Mon Sep 17 00:00:00 2001 From: Minghuan Lian Date: Tue, 8 Oct 2013 17:34:41 +0800 Subject: fsl_pci_ep: fix checking PCI register size For T4240, the first PCI controller whose register size is 0x10000, has two physical functions and each physical function register size is 0x2000. But for some older platform PCI controller size is 0x1000 less than 0x2000. The original checking of PCI register size is mistaken. The patch is to fix this issue. Signed-off-by: Minghuan Lian Change-Id: I089adfb5f31f09f57ea1c2ee29572ac3c68992f4 Reviewed-on: http://git.am.freescale.net:8181/9601 Tested-by: Review Code-CDREVIEW Reviewed-by: Tiefei Zang Reviewed-by: Jose Rivera diff --git a/drivers/vfio/fsl_pci_ep/fsl_pci_ep.c b/drivers/vfio/fsl_pci_ep/fsl_pci_ep.c index a09950f..18fc5b7 100644 --- a/drivers/vfio/fsl_pci_ep/fsl_pci_ep.c +++ b/drivers/vfio/fsl_pci_ep/fsl_pci_ep.c @@ -772,14 +772,14 @@ int fsl_pci_pf_setup(struct pci_bus *bus, int pf_num) return -ENOMEM; } - if (resource_size(&rsrc) < (PCI_EP_PF_OFFSET * pf_num)) - return -EINVAL; - if (pf_num > 1) regs_size = PCI_EP_PF_OFFSET; else regs_size = resource_size(&rsrc); + if (resource_size(&rsrc) < (regs_size * pf_num)) + return -EINVAL; + for (pf_idx = 0; pf_idx < pf_num; pf_idx++) { pdev = alloc_pci_dev(); if (!pdev) -- cgit v0.10.2