aboutsummaryrefslogtreecommitdiff
path: root/core/pci.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2017-06-06 08:59:20 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-06-06 20:49:05 +1000
commit5bbbb398544ae2869d1c1818280cd97f537d8cb9 (patch)
tree1c4110f1f39ddfb668aab86269fc210a10b8b760 /core/pci.c
parent94920c4946b5a9c33c063df22db0864fab2b5efa (diff)
downloadskiboot-5bbbb398544ae2869d1c1818280cd97f537d8cb9.zip
skiboot-5bbbb398544ae2869d1c1818280cd97f537d8cb9.tar.gz
skiboot-5bbbb398544ae2869d1c1818280cd97f537d8cb9.tar.bz2
pci: Make handling of config filters generic
Move phb3_pcicfg_filter() to pci.c, rename it to pci_handle_cfg_filters() Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'core/pci.c')
-rw-r--r--core/pci.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/core/pci.c b/core/pci.c
index 5671b69..c791ebd 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1768,11 +1768,33 @@ struct pci_cfg_reg_filter *pci_find_cfg_reg_filter(struct pci_device *pd,
return NULL;
}
-bool pci_device_has_cfg_reg_filters(struct phb *phb, uint16_t bdfn)
+static bool pci_device_has_cfg_reg_filters(struct phb *phb, uint16_t bdfn)
{
return bitmap_tst_bit(*phb->filter_map, bdfn);
}
+int64_t pci_handle_cfg_filters(struct phb *phb, uint32_t bdfn,
+ uint32_t offset, uint32_t len,
+ uint32_t *data, bool write)
+{
+ struct pci_device *pd;
+ struct pci_cfg_reg_filter *pcrf;
+ uint32_t flags;
+
+ if (!pci_device_has_cfg_reg_filters(phb, bdfn))
+ return OPAL_PARTIAL;
+ pd = pci_find_dev(phb, bdfn);
+ pcrf = pd ? pci_find_cfg_reg_filter(pd, offset, len) : NULL;
+ if (!pcrf || !pcrf->func)
+ return OPAL_PARTIAL;
+
+ flags = write ? PCI_REG_FLAG_WRITE : PCI_REG_FLAG_READ;
+ if ((pcrf->flags & flags) != flags)
+ return OPAL_PARTIAL;
+
+ return pcrf->func(pd, pcrf, offset, len, data, write);
+}
+
struct pci_cfg_reg_filter *pci_add_cfg_reg_filter(struct pci_device *pd,
uint32_t start, uint32_t len,
uint32_t flags,