aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorRay Jui <ray.jui@broadcom.com>2016-10-31 20:38:33 -0400
committerBjorn Helgaas <bhelgaas@google.com>2016-11-14 17:07:37 -0500
commit538928fd6ce8e0342d98a203a1d16caf2ce33f2b (patch)
tree48746af68701a77695bf3deed88707565fdf477b /drivers/pci
parent404349c5c806d56de2b41f48a99402c3c7573af5 (diff)
PCI: iproc: Fix exception with multi-function devices
During enumeration with multi-function EP devices, access to the configuration space of a non-existent function results in an unsupported request being returned as expected. By default the PAXB-based iProc PCIe controller forwards this as an APB error to the host system and that causes an exception, which is undesired. Disable this undesired behaviour and let the kernel PCI stack deal with an access to the non-existent function, in which case a vendor ID of 0xffff is returned and handled gracefully. Reported-by: JD Zheng <jiandong.zheng@broadcom.com> Signed-off-by: Ray Jui <ray.jui@broadcom.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: JD Zheng <jiandong.zheng@broadcom.com> Reviewed-by: Oza Oza <oza.oza@broadcom.com> Reviewed-by: Scott Branden <scott.branden@broadcom.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/host/pcie-iproc.c58
-rw-r--r--drivers/pci/host/pcie-iproc.h3
2 files changed, 59 insertions, 2 deletions
diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c
index 912a1cbe561e..15aafbfec7f1 100644
--- a/drivers/pci/host/pcie-iproc.c
+++ b/drivers/pci/host/pcie-iproc.c
@@ -58,6 +58,9 @@
58#define PCIE_DL_ACTIVE_SHIFT 2 58#define PCIE_DL_ACTIVE_SHIFT 2
59#define PCIE_DL_ACTIVE BIT(PCIE_DL_ACTIVE_SHIFT) 59#define PCIE_DL_ACTIVE BIT(PCIE_DL_ACTIVE_SHIFT)
60 60
61#define APB_ERR_EN_SHIFT 0
62#define APB_ERR_EN BIT(APB_ERR_EN_SHIFT)
63
61#define OARR_VALID_SHIFT 0 64#define OARR_VALID_SHIFT 0
62#define OARR_VALID BIT(OARR_VALID_SHIFT) 65#define OARR_VALID BIT(OARR_VALID_SHIFT)
63#define OARR_SIZE_CFG_SHIFT 1 66#define OARR_SIZE_CFG_SHIFT 1
@@ -96,6 +99,9 @@ enum iproc_pcie_reg {
96 /* link status */ 99 /* link status */
97 IPROC_PCIE_LINK_STATUS, 100 IPROC_PCIE_LINK_STATUS,
98 101
102 /* enable APB error for unsupported requests */
103 IPROC_PCIE_APB_ERR_EN,
104
99 /* total number of core registers */ 105 /* total number of core registers */
100 IPROC_PCIE_MAX_NUM_REG, 106 IPROC_PCIE_MAX_NUM_REG,
101}; 107};
@@ -124,6 +130,7 @@ static const u16 iproc_pcie_reg_paxb[] = {
124 [IPROC_PCIE_OMAP_LO] = 0xd40, 130 [IPROC_PCIE_OMAP_LO] = 0xd40,
125 [IPROC_PCIE_OMAP_HI] = 0xd44, 131 [IPROC_PCIE_OMAP_HI] = 0xd44,
126 [IPROC_PCIE_LINK_STATUS] = 0xf0c, 132 [IPROC_PCIE_LINK_STATUS] = 0xf0c,
133 [IPROC_PCIE_APB_ERR_EN] = 0xf40,
127}; 134};
128 135
129/* iProc PCIe PAXC v1 registers */ 136/* iProc PCIe PAXC v1 registers */
@@ -181,6 +188,28 @@ static inline void iproc_pcie_write_reg(struct iproc_pcie *pcie,
181 writel(val, pcie->base + offset); 188 writel(val, pcie->base + offset);
182} 189}
183 190
191/**
192 * APB error forwarding can be disabled during access of configuration
193 * registers of the endpoint device, to prevent unsupported requests
194 * (typically seen during enumeration with multi-function devices) from
195 * triggering a system exception.
196 */
197static inline void iproc_pcie_apb_err_disable(struct pci_bus *bus,
198 bool disable)
199{
200 struct iproc_pcie *pcie = iproc_data(bus);
201 u32 val;
202
203 if (bus->number && pcie->has_apb_err_disable) {
204 val = iproc_pcie_read_reg(pcie, IPROC_PCIE_APB_ERR_EN);
205 if (disable)
206 val &= ~APB_ERR_EN;
207 else
208 val |= APB_ERR_EN;
209 iproc_pcie_write_reg(pcie, IPROC_PCIE_APB_ERR_EN, val);
210 }
211}
212
184static inline void iproc_pcie_ob_write(struct iproc_pcie *pcie, 213static inline void iproc_pcie_ob_write(struct iproc_pcie *pcie,
185 enum iproc_pcie_reg reg, 214 enum iproc_pcie_reg reg,
186 unsigned window, u32 val) 215 unsigned window, u32 val)
@@ -244,10 +273,34 @@ static void __iomem *iproc_pcie_map_cfg_bus(struct pci_bus *bus,
244 return (pcie->base + offset); 273 return (pcie->base + offset);
245} 274}
246 275
276static int iproc_pcie_config_read32(struct pci_bus *bus, unsigned int devfn,
277 int where, int size, u32 *val)
278{
279 int ret;
280
281 iproc_pcie_apb_err_disable(bus, true);
282 ret = pci_generic_config_read32(bus, devfn, where, size, val);
283 iproc_pcie_apb_err_disable(bus, false);
284
285 return ret;
286}
287
288static int iproc_pcie_config_write32(struct pci_bus *bus, unsigned int devfn,
289 int where, int size, u32 val)
290{
291 int ret;
292
293 iproc_pcie_apb_err_disable(bus, true);
294 ret = pci_generic_config_write32(bus, devfn, where, size, val);
295 iproc_pcie_apb_err_disable(bus, false);
296
297 return ret;
298}
299
247static struct pci_ops iproc_pcie_ops = { 300static struct pci_ops iproc_pcie_ops = {
248 .map_bus = iproc_pcie_map_cfg_bus, 301 .map_bus = iproc_pcie_map_cfg_bus,
249 .read = pci_generic_config_read32, 302 .read = iproc_pcie_config_read32,
250 .write = pci_generic_config_write32, 303 .write = iproc_pcie_config_write32,
251}; 304};
252 305
253static void iproc_pcie_reset(struct iproc_pcie *pcie) 306static void iproc_pcie_reset(struct iproc_pcie *pcie)
@@ -485,6 +538,7 @@ static int iproc_pcie_rev_init(struct iproc_pcie *pcie)
485 break; 538 break;
486 case IPROC_PCIE_PAXB: 539 case IPROC_PCIE_PAXB:
487 regs = iproc_pcie_reg_paxb; 540 regs = iproc_pcie_reg_paxb;
541 pcie->has_apb_err_disable = true;
488 break; 542 break;
489 case IPROC_PCIE_PAXC: 543 case IPROC_PCIE_PAXC:
490 regs = iproc_pcie_reg_paxc; 544 regs = iproc_pcie_reg_paxc;
diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h
index 768be05cf496..711dd3a5f55b 100644
--- a/drivers/pci/host/pcie-iproc.h
+++ b/drivers/pci/host/pcie-iproc.h
@@ -57,6 +57,8 @@ struct iproc_msi;
57 * @phy: optional PHY device that controls the Serdes 57 * @phy: optional PHY device that controls the Serdes
58 * @map_irq: function callback to map interrupts 58 * @map_irq: function callback to map interrupts
59 * @ep_is_internal: indicates an internal emulated endpoint device is connected 59 * @ep_is_internal: indicates an internal emulated endpoint device is connected
60 * @has_apb_err_disable: indicates the controller can be configured to prevent
61 * unsupported request from being forwarded as an APB bus error
60 * @need_ob_cfg: indicates SW needs to configure the outbound mapping window 62 * @need_ob_cfg: indicates SW needs to configure the outbound mapping window
61 * @ob: outbound mapping parameters 63 * @ob: outbound mapping parameters
62 * @msi: MSI data 64 * @msi: MSI data
@@ -74,6 +76,7 @@ struct iproc_pcie {
74 struct phy *phy; 76 struct phy *phy;
75 int (*map_irq)(const struct pci_dev *, u8, u8); 77 int (*map_irq)(const struct pci_dev *, u8, u8);
76 bool ep_is_internal; 78 bool ep_is_internal;
79 bool has_apb_err_disable;
77 bool need_ob_cfg; 80 bool need_ob_cfg;
78 struct iproc_pcie_ob ob; 81 struct iproc_pcie_ob ob;
79 struct iproc_msi *msi; 82 struct iproc_msi *msi;