diff options
author | Kishon Vijay Abraham I <kishon@ti.com> | 2019-03-25 05:39:44 -0400 |
---|---|---|
committer | Lorenzo Pieralisi <lorenzo.pieralisi@arm.com> | 2019-05-01 10:50:13 -0400 |
commit | fc9a77040b04c05f036515f40aa7cf4b9c91defd (patch) | |
tree | 67e0f2cb014853584bdd062246c79ae02a7e6ff4 /drivers/pci/controller/dwc | |
parent | 23284ad677a94f26afc92017d540ccaf26c1a581 (diff) |
PCI: designware-ep: Configure Resizable BAR cap to advertise the smallest size
Configure the Resizable BAR capability to advertise the smallest size
(1MB) for a couple of reasons:
- Host side resource allocation of BAR fails for larger sizes
- Endpoint function driver does not allocate memory for all supported
sizes in the Resizable BAR capability.
If and when there is a usecase required to add more flexibility using
the Resizable BAR capability, this can be revisited.
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
[lorenzo.pieralisi@arm.com: updated commit log]
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Diffstat (limited to 'drivers/pci/controller/dwc')
-rw-r--r-- | drivers/pci/controller/dwc/pcie-designware-ep.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 74477ad7467f..0c208b9bda43 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c | |||
@@ -504,10 +504,32 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep) | |||
504 | pci_epc_mem_exit(epc); | 504 | pci_epc_mem_exit(epc); |
505 | } | 505 | } |
506 | 506 | ||
507 | static unsigned int dw_pcie_ep_find_ext_capability(struct dw_pcie *pci, int cap) | ||
508 | { | ||
509 | u32 header; | ||
510 | int pos = PCI_CFG_SPACE_SIZE; | ||
511 | |||
512 | while (pos) { | ||
513 | header = dw_pcie_readl_dbi(pci, pos); | ||
514 | if (PCI_EXT_CAP_ID(header) == cap) | ||
515 | return pos; | ||
516 | |||
517 | pos = PCI_EXT_CAP_NEXT(header); | ||
518 | if (!pos) | ||
519 | break; | ||
520 | } | ||
521 | |||
522 | return 0; | ||
523 | } | ||
524 | |||
507 | int dw_pcie_ep_init(struct dw_pcie_ep *ep) | 525 | int dw_pcie_ep_init(struct dw_pcie_ep *ep) |
508 | { | 526 | { |
527 | int i; | ||
509 | int ret; | 528 | int ret; |
529 | u32 reg; | ||
510 | void *addr; | 530 | void *addr; |
531 | unsigned int nbars; | ||
532 | unsigned int offset; | ||
511 | struct pci_epc *epc; | 533 | struct pci_epc *epc; |
512 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); | 534 | struct dw_pcie *pci = to_dw_pcie_from_ep(ep); |
513 | struct device *dev = pci->dev; | 535 | struct device *dev = pci->dev; |
@@ -591,6 +613,18 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) | |||
591 | 613 | ||
592 | ep->msix_cap = dw_pcie_ep_find_capability(pci, PCI_CAP_ID_MSIX); | 614 | ep->msix_cap = dw_pcie_ep_find_capability(pci, PCI_CAP_ID_MSIX); |
593 | 615 | ||
616 | offset = dw_pcie_ep_find_ext_capability(pci, PCI_EXT_CAP_ID_REBAR); | ||
617 | if (offset) { | ||
618 | reg = dw_pcie_readl_dbi(pci, offset + PCI_REBAR_CTRL); | ||
619 | nbars = (reg & PCI_REBAR_CTRL_NBAR_MASK) >> | ||
620 | PCI_REBAR_CTRL_NBAR_SHIFT; | ||
621 | |||
622 | dw_pcie_dbi_ro_wr_en(pci); | ||
623 | for (i = 0; i < nbars; i++, offset += PCI_REBAR_CTRL) | ||
624 | dw_pcie_writel_dbi(pci, offset + PCI_REBAR_CAP, 0x0); | ||
625 | dw_pcie_dbi_ro_wr_dis(pci); | ||
626 | } | ||
627 | |||
594 | dw_pcie_setup(pci); | 628 | dw_pcie_setup(pci); |
595 | 629 | ||
596 | return 0; | 630 | return 0; |