Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <Frank.Li@nxp.com>
Signed-off-by: Jon Mason <jdmason@kudzu.us>

authored by

Frank Li and committed by
Jon Mason
4284c88f a914fc52

+9 -1
+9 -1
drivers/pci/controller/dwc/pcie-designware-ep.c
··· 162 162 u32 free_win; 163 163 struct dw_pcie *pci = to_dw_pcie_from_ep(ep); 164 164 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 + 166 170 if (free_win >= pci->num_ib_windows) { 167 171 dev_err(pci->dev, "No free inbound window\n"); 168 172 return -EINVAL; ··· 220 216 dw_pcie_disable_atu(pci, atu_index, DW_PCIE_REGION_INBOUND); 221 217 clear_bit(atu_index, ep->ib_window_map); 222 218 ep->epf_bar[bar] = NULL; 219 + ep->bar_to_atu[bar] = 0; 223 220 } 224 221 225 222 static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no, ··· 249 244 epf_bar->phys_addr, as_type); 250 245 if (ret) 251 246 return ret; 247 + 248 + if (ep->epf_bar[bar]) 249 + return 0; 252 250 253 251 dw_pcie_dbi_ro_wr_en(pci); 254 252