diff mbox series

[RFC,1/4] PCI: designware-ep: Allow pcie_ep_set_bar change inbound map address

Message ID 20220215053844.7119-2-Frank.Li@nxp.com (mailing list archive)
State Superseded
Headers show
Series NTB function for PCIe RC to EP connection | expand

Commit Message

Frank Li Feb. 15, 2022, 5:38 a.m. UTC
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>
---
 drivers/pci/controller/dwc/pcie-designware-ep.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Bjorn Helgaas Feb. 17, 2022, 9:53 p.m. UTC | #1
In the subject, "pcie_ep_set_bar" looks like *part* of a function
name.  Please include the entire function name and add "()" after it.

On Mon, Feb 14, 2022 at 11:38:41PM -0600, Frank Li wrote:
> ntb_transfer will set memory map windows after probe.
> So the inbound map address need be updated dynamtically.

I don't see "ntb_transfer" in the tree.  If it's a function, please
add "()" after the name.  Otherwise, please say more about what
"ntb_transfer" is.

s/dynamtically/dynamically/

Please make the commit log say what the patch *does*, not just what
needs to happen.

Bjorn
Zhi Li Feb. 17, 2022, 10:13 p.m. UTC | #2
On Thu, Feb 17, 2022 at 3:54 PM Bjorn Helgaas <helgaas@kernel.org> wrote:
>
> In the subject, "pcie_ep_set_bar" looks like *part* of a function
> name.  Please include the entire function name and add "()" after it.

Okay

>
> On Mon, Feb 14, 2022 at 11:38:41PM -0600, Frank Li wrote:
> > ntb_transfer will set memory map windows after probe.
> > So the inbound map address need be updated dynamtically.
>
> I don't see "ntb_transfer" in the tree.  If it's a function, please
> add "()" after the name.  Otherwise, please say more about what
> "ntb_transfer" is.

Thanks.  That's ntb_mw_set_trans() at drivers/ntb/ntb_transport.c.

>
> s/dynamtically/dynamically/
>
> Please make the commit log say what the patch *does*, not just what
> needs to happen.

Okay,  this patch allows changing PCI BAR's address.  For example,
previous BAR0 map to physical address to 0xF1000000, now can change
to new physical address 0xF2000000 by call function pci_epc_set_bar()

The patch 3/4 is totally new method to make NTB work at RC and EP system,
I hope the basic structure is acceptable.

>
> Bjorn
diff mbox series

Patch

diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c
index 998b698f40858..cad5d9ea7cc6c 100644
--- a/drivers/pci/controller/dwc/pcie-designware-ep.c
+++ b/drivers/pci/controller/dwc/pcie-designware-ep.c
@@ -161,7 +161,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;
@@ -215,6 +219,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,
@@ -244,6 +249,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));