Skip to content

Commit 4284c88

Browse files
nxpfranklijonmason
authored andcommitted
PCI: designware-ep: Allow pci_epc_set_bar() update inbound map address
ntb_mw_set_trans() will set memory map window after endpoint function driver bind. The inbound map address need be updated dynamically when using NTB by PCIe Root Port and PCIe Endpoint connection. Checking if iatu already assigned to the BAR, if yes, using assigned iatu number to update inbound address map and skip set BAR's register. Signed-off-by: Frank Li <[email protected]> Signed-off-by: Jon Mason <[email protected]>
1 parent a914fc5 commit 4284c88

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/pci/controller/dwc/pcie-designware-ep.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,11 @@ static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, u8 func_no,
162162
u32 free_win;
163163
struct dw_pcie *pci = to_dw_pcie_from_ep(ep);
164164

165-
free_win = find_first_zero_bit(ep->ib_window_map, pci->num_ib_windows);
165+
if (!ep->bar_to_atu[bar])
166+
free_win = find_first_zero_bit(ep->ib_window_map, pci->num_ib_windows);
167+
else
168+
free_win = ep->bar_to_atu[bar];
169+
166170
if (free_win >= pci->num_ib_windows) {
167171
dev_err(pci->dev, "No free inbound window\n");
168172
return -EINVAL;
@@ -216,6 +220,7 @@ static void dw_pcie_ep_clear_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
216220
dw_pcie_disable_atu(pci, atu_index, DW_PCIE_REGION_INBOUND);
217221
clear_bit(atu_index, ep->ib_window_map);
218222
ep->epf_bar[bar] = NULL;
223+
ep->bar_to_atu[bar] = 0;
219224
}
220225

221226
static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
@@ -245,6 +250,9 @@ static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
245250
if (ret)
246251
return ret;
247252

253+
if (ep->epf_bar[bar])
254+
return 0;
255+
248256
dw_pcie_dbi_ro_wr_en(pci);
249257

250258
dw_pcie_writel_dbi2(pci, reg, lower_32_bits(size - 1));

0 commit comments

Comments
 (0)