ntb.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] PCI: endpoint: pci-epf-vntb: Fix transfer fail when BAR1 is fixed size
@ 2023-12-19  6:17 Frank Li
  0 siblings, 0 replies; only message in thread
From: Frank Li @ 2023-12-19  6:17 UTC (permalink / raw)
  To: Jon Mason, Dave Jiang, Allen Hubbe, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam,
	Kishon Vijay Abraham I, Bjorn Helgaas, open list:NTB DRIVER CORE,
	open list:PCI ENDPOINT SUBSYSTEM, open list
  Cc: imx

ntb_netdev transfer is failing when epc controller's BAR1 is fix size, such
as 64K. Certain controller(like dwc) require memory address must be align
with the fixed bar size.

For example:
	If BAR1's fix size is 64K, and other size programmable BAR's
alignment is 4K.
	vntb call pci_epf_alloc_space() get 4K aligned address, like
0x104E31000. But root complex actually write to address 0x104E30000 when
write BAR1.

Adds bar_fixed_size check and sets correct alignment for fixed-size BAR.

Signed-off-by: Frank Li <Frank.Li@nxp.com>
---
 drivers/pci/endpoint/functions/pci-epf-vntb.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
index 3f60128560ed0..c24327a06d8ff 100644
--- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
@@ -550,6 +550,15 @@ static int epf_ntb_db_bar_init(struct epf_ntb *ntb)
 
 	barno = ntb->epf_ntb_bar[BAR_DB];
 
+	if (epc_features->bar_fixed_size[barno]) {
+		if (size > epc_features->bar_fixed_size[barno]) {
+			dev_err(dev, "Fixed BAR%d is too small for doorbell\n", barno);
+			return -EINVAL;
+		}
+		size = epc_features->bar_fixed_size[barno];
+		align = min_t(u32, align, epc_features->bar_fixed_size[barno]);
+	}
+
 	mw_addr = pci_epf_alloc_space(ntb->epf, size, barno, align, 0);
 	if (!mw_addr) {
 		dev_err(dev, "Failed to allocate OB address\n");
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-19  6:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-19  6:17 [PATCH 1/1] PCI: endpoint: pci-epf-vntb: Fix transfer fail when BAR1 is fixed size Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).