[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250328-pci-ep-size-alignment-v1-1-ee5b78b15a9a@baylibre.com>
Date: Fri, 28 Mar 2025 15:53:42 +0100
From: Jerome Brunet <jbrunet@...libre.com>
To: Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
Krzysztof WilczyĆski <kw@...ux.com>,
Kishon Vijay Abraham I <kishon@...nel.org>,
Bjorn Helgaas <bhelgaas@...gle.com>,
Lorenzo Pieralisi <lpieralisi@...nel.org>, Jon Mason <jdmason@...zu.us>,
Dave Jiang <dave.jiang@...el.com>, Allen Hubbe <allenbh@...il.com>
Cc: Marek Vasut <marek.vasut+renesas@...il.com>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@...esas.com>,
Yuya Hamamachi <yuya.hamamachi.sx@...esas.com>, linux-pci@...r.kernel.org,
linux-kernel@...r.kernel.org, ntb@...ts.linux.dev,
Jerome Brunet <jbrunet@...libre.com>
Subject: [PATCH 1/2] PCI: endpoint: strictly apply bar fixed size to
allocate space
When trying to allocate space for an endpoint function on a BAR with a
fixed size, that size should be used regardless of the alignment.
Some controller may have specified an alignment, but do have a BAR with a
fixed size smaller that alignment. In such case, pci_epf_alloc_space()
tries to allocate a space that matches the alignment and it won't work.
When the BAR size is fixed, pci_epf_alloc_space() should not deviate
from this fixed size.
Fixes: 2a9a801620ef ("PCI: endpoint: Add support to specify alignment for buffers allocated to BARs")
Signed-off-by: Jerome Brunet <jbrunet@...libre.com>
---
drivers/pci/endpoint/pci-epf-core.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c
index 394395c7f8decfa2010469655a4bd58a002993fd..cb985b172ed041c6f319c083f412e51e25b0a157 100644
--- a/drivers/pci/endpoint/pci-epf-core.c
+++ b/drivers/pci/endpoint/pci-epf-core.c
@@ -285,12 +285,11 @@ void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar,
return NULL;
}
size = bar_fixed_size;
- }
-
- if (align)
+ } else if (align) {
size = ALIGN(size, align);
- else
+ } else {
size = roundup_pow_of_two(size);
+ }
if (type == PRIMARY_INTERFACE) {
epc = epf->epc;
--
2.47.2
Powered by blists - more mailing lists