[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231220192427.1530460-1-Frank.Li@nxp.com>
Date: Wed, 20 Dec 2023 14:24:27 -0500
From: Frank Li <Frank.Li@....com>
To: mani@...nel.org
Cc: Frank.li@....com,
allenbh@...il.com,
bhelgaas@...gle.com,
dave.jiang@...el.com,
imx@...ts.linux.dev,
jdmason@...zu.us,
kishon@...nel.org,
kw@...ux.com,
linux-kernel@...r.kernel.org,
linux-pci@...r.kernel.org,
lpieralisi@...nel.org,
ntb@...ts.linux.dev
Subject: [PATCH v3 1/1] PCI: endpoint: pci-epf-vntb: Fix transfer failure for fixed size BARs
For the inbound MEM/IO TLPs, iATU on the endpoint expects the target
address to be aligned to the size of the BAR. For configurable BARs, there
is no issue because both host and endpoint will know the exact size of the
BAR region. But for fixed size BARs available in some controllers, if the
BAR size advertised by the endpoint is not same as of the actual BAR size
used in the controller, then the MEM/IO TLPs generated by the host will not
be translated properly by the endpoint iATU.
So if the fixed size BARs are available in endpoint controllers, always use
the actual BAR size.
Fixes: e35f56bb0330 ("PCI: endpoint: Support NTB transfer between RC and EP")
Cc: stable@...r.kernel.org
Signed-off-by: Frank Li <Frank.Li@....com>
---
Notes:
Change from v2 to v3
- rework commti message
- add fixes and cc stable
- return -ENOMEN when request size > fix bar size
Change from v1 to v2
- Remove unnessary set align when fix_bar_size.
drivers/pci/endpoint/functions/pci-epf-vntb.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c
index 3f60128560ed0..85120978fb8c9 100644
--- a/drivers/pci/endpoint/functions/pci-epf-vntb.c
+++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c
@@ -550,6 +550,14 @@ 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 -ENOMEM;
+ }
+ size = 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
Powered by blists - more mailing lists