Skip to content

Commit

Permalink
PCI: designware-ep: Allow pcie_ep_set_bar change inbound map address
Browse files Browse the repository at this point in the history
ntb_transfer will set memory map windows after probe.
So the inbound map address need be updated dynamtically.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>
  • Loading branch information
Frank Li authored and Jon Mason committed Jun 20, 2022
1 parent d3b4b9c commit 991b4c2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/pci/controller/dwc/pcie-designware-ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, u8 func_no,
u32 free_win;
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);

free_win = find_first_zero_bit(ep->ib_window_map, pci->num_ib_windows);
if (!ep->bar_to_atu[bar])
free_win = find_first_zero_bit(ep->ib_window_map, pci->num_ib_windows);
else
free_win = ep->bar_to_atu[bar];

if (free_win >= pci->num_ib_windows) {
dev_err(pci->dev, "No free inbound window\n");
return -EINVAL;
Expand Down Expand Up @@ -216,6 +220,7 @@ static void dw_pcie_ep_clear_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
dw_pcie_disable_atu(pci, atu_index, DW_PCIE_REGION_INBOUND);
clear_bit(atu_index, ep->ib_window_map);
ep->epf_bar[bar] = NULL;
ep->bar_to_atu[bar] = 0;
}

static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
Expand Down Expand Up @@ -245,6 +250,9 @@ static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
if (ret)
return ret;

if (ep->epf_bar[bar])
return 0;

dw_pcie_dbi_ro_wr_en(pci);

dw_pcie_writel_dbi2(pci, reg, lower_32_bits(size - 1));
Expand Down

0 comments on commit 991b4c2

Please sign in to comment.