From: Frank Li <Frank.Li@nxp.com>
To: frank.li@nxp.com
Cc: allenbh@gmail.com, bhelgaas@google.com, dave.jiang@intel.com,
imx@lists.linux.dev, jdmason@kudzu.us, kishon@kernel.org,
kw@linux.com, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org, lpieralisi@kernel.org,
mani@kernel.org, ntb@lists.linux.dev
Subject: [PATCH v2 1/1] PCI: endpoint: pci-epf-vntb: Fix transfer fail when BAR1 is fixed size
Date: Tue, 19 Dec 2023 09:24:03 -0500 [thread overview]
Message-ID: <20231219142403.1223873-1-Frank.Li@nxp.com> (raw)
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>
---
Notes:
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..ec3922f404efe 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 -EINVAL;
+ }
+ 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
next reply other threads:[~2023-12-19 14:24 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 14:24 Frank Li [this message]
2023-12-20 14:27 ` [PATCH v2 1/1] PCI: endpoint: pci-epf-vntb: Fix transfer fail when BAR1 is fixed size Manivannan Sadhasivam
2023-12-20 16:24 ` Frank Li
2023-12-20 17:41 ` Manivannan Sadhasivam
2023-12-20 18:55 ` Frank Li
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231219142403.1223873-1-Frank.Li@nxp.com \
--to=frank.li@nxp.com \
--cc=allenbh@gmail.com \
--cc=bhelgaas@google.com \
--cc=dave.jiang@intel.com \
--cc=imx@lists.linux.dev \
--cc=jdmason@kudzu.us \
--cc=kishon@kernel.org \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=mani@kernel.org \
--cc=ntb@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).